5 *) |
5 *) |
6 |
6 |
7 Addsimps [mgu_eq,mgu_mg,mgu_free]; |
7 Addsimps [mgu_eq,mgu_mg,mgu_free]; |
8 |
8 |
9 (* mgu does not introduce new type variables *) |
9 (* mgu does not introduce new type variables *) |
10 goalw thy [new_tv_def] |
10 Goalw [new_tv_def] |
11 "!! n. [|mgu t1 t2 = Ok u; new_tv n t1; new_tv n t2|] ==> \ |
11 "!! n. [|mgu t1 t2 = Ok u; new_tv n t1; new_tv n t2|] ==> \ |
12 \ new_tv n u"; |
12 \ new_tv n u"; |
13 by (fast_tac (set_cs addDs [mgu_free]) 1); |
13 by (fast_tac (set_cs addDs [mgu_free]) 1); |
14 qed "mgu_new"; |
14 qed "mgu_new"; |
15 |
15 |
16 (* application of id_subst does not change type expression *) |
16 (* application of id_subst does not change type expression *) |
17 goalw thy [id_subst_def] |
17 Goalw [id_subst_def] |
18 "$ id_subst = (%t::typ. t)"; |
18 "$ id_subst = (%t::typ. t)"; |
19 by (rtac ext 1); |
19 by (rtac ext 1); |
20 by (typ.induct_tac "t" 1); |
20 by (typ.induct_tac "t" 1); |
21 by (ALLGOALS Asm_simp_tac); |
21 by (ALLGOALS Asm_simp_tac); |
22 qed "app_subst_id_te"; |
22 qed "app_subst_id_te"; |
23 Addsimps [app_subst_id_te]; |
23 Addsimps [app_subst_id_te]; |
24 |
24 |
25 (* application of id_subst does not change list of type expressions *) |
25 (* application of id_subst does not change list of type expressions *) |
26 goalw thy [app_subst_list] |
26 Goalw [app_subst_list] |
27 "$ id_subst = (%ts::typ list. ts)"; |
27 "$ id_subst = (%ts::typ list. ts)"; |
28 by (rtac ext 1); |
28 by (rtac ext 1); |
29 by (list.induct_tac "ts" 1); |
29 by (list.induct_tac "ts" 1); |
30 by (ALLGOALS Asm_simp_tac); |
30 by (ALLGOALS Asm_simp_tac); |
31 qed "app_subst_id_tel"; |
31 qed "app_subst_id_tel"; |
32 Addsimps [app_subst_id_tel]; |
32 Addsimps [app_subst_id_tel]; |
33 |
33 |
34 goalw Type.thy [id_subst_def,o_def] "$s o id_subst = s"; |
34 Goalw [id_subst_def,o_def] "$s o id_subst = s"; |
35 by (rtac ext 1); |
35 by (rtac ext 1); |
36 by (Simp_tac 1); |
36 by (Simp_tac 1); |
37 qed "o_id_subst"; |
37 qed "o_id_subst"; |
38 Addsimps[o_id_subst]; |
38 Addsimps[o_id_subst]; |
39 |
39 |
40 goalw thy [dom_def,id_subst_def,empty_def] |
40 Goalw [dom_def,id_subst_def,empty_def] |
41 "dom id_subst = {}"; |
41 "dom id_subst = {}"; |
42 by (Simp_tac 1); |
42 by (Simp_tac 1); |
43 qed "dom_id_subst"; |
43 qed "dom_id_subst"; |
44 Addsimps [dom_id_subst]; |
44 Addsimps [dom_id_subst]; |
45 |
45 |
46 goalw thy [cod_def] |
46 Goalw [cod_def] |
47 "cod id_subst = {}"; |
47 "cod id_subst = {}"; |
48 by (Simp_tac 1); |
48 by (Simp_tac 1); |
49 qed "cod_id_subst"; |
49 qed "cod_id_subst"; |
50 Addsimps [cod_id_subst]; |
50 Addsimps [cod_id_subst]; |
51 |
51 |
52 goalw thy [free_tv_subst] |
52 Goalw [free_tv_subst] |
53 "free_tv id_subst = {}"; |
53 "free_tv id_subst = {}"; |
54 by (Simp_tac 1); |
54 by (Simp_tac 1); |
55 qed "free_tv_id_subst"; |
55 qed "free_tv_id_subst"; |
56 Addsimps [free_tv_id_subst]; |
56 Addsimps [free_tv_id_subst]; |
57 |
57 |
58 goalw thy [dom_def,cod_def,UNION_def,Bex_def] |
58 Goalw [dom_def,cod_def,UNION_def,Bex_def] |
59 "!!v. [| v : free_tv(s n); v~=n |] ==> v : cod s"; |
59 "!!v. [| v : free_tv(s n); v~=n |] ==> v : cod s"; |
60 by (Simp_tac 1); |
60 by (Simp_tac 1); |
61 by (safe_tac (empty_cs addSIs [exI,conjI,notI])); |
61 by (safe_tac (empty_cs addSIs [exI,conjI,notI])); |
62 by (assume_tac 2); |
62 by (assume_tac 2); |
63 by (rotate_tac 1 1); |
63 by (rotate_tac 1 1); |
65 qed "cod_app_subst"; |
65 qed "cod_app_subst"; |
66 Addsimps [cod_app_subst]; |
66 Addsimps [cod_app_subst]; |
67 |
67 |
68 |
68 |
69 (* composition of substitutions *) |
69 (* composition of substitutions *) |
70 goal thy |
70 Goal |
71 "$ g ($ f t::typ) = $ (%x. $ g (f x) ) t"; |
71 "$ g ($ f t::typ) = $ (%x. $ g (f x) ) t"; |
72 by (typ.induct_tac "t" 1); |
72 by (typ.induct_tac "t" 1); |
73 by (ALLGOALS Asm_simp_tac); |
73 by (ALLGOALS Asm_simp_tac); |
74 qed "subst_comp_te"; |
74 qed "subst_comp_te"; |
75 |
75 |
76 goalw thy [app_subst_list] |
76 Goalw [app_subst_list] |
77 "$ g ($ f ts::typ list) = $ (%x. $ g (f x)) ts"; |
77 "$ g ($ f ts::typ list) = $ (%x. $ g (f x)) ts"; |
78 by (list.induct_tac "ts" 1); |
78 by (list.induct_tac "ts" 1); |
79 (* case [] *) |
79 (* case [] *) |
80 by (Simp_tac 1); |
80 by (Simp_tac 1); |
81 (* case x#xl *) |
81 (* case x#xl *) |
82 by (asm_full_simp_tac (simpset() addsimps [subst_comp_te]) 1); |
82 by (asm_full_simp_tac (simpset() addsimps [subst_comp_te]) 1); |
83 qed "subst_comp_tel"; |
83 qed "subst_comp_tel"; |
84 |
84 |
85 |
85 |
86 (* constructor laws for app_subst *) |
86 (* constructor laws for app_subst *) |
87 goalw thy [app_subst_list] |
87 Goalw [app_subst_list] |
88 "$ s [] = []"; |
88 "$ s [] = []"; |
89 by (Simp_tac 1); |
89 by (Simp_tac 1); |
90 qed "app_subst_Nil"; |
90 qed "app_subst_Nil"; |
91 |
91 |
92 goalw thy [app_subst_list] |
92 Goalw [app_subst_list] |
93 "$ s (t#ts) = ($ s t)#($ s ts)"; |
93 "$ s (t#ts) = ($ s t)#($ s ts)"; |
94 by (Simp_tac 1); |
94 by (Simp_tac 1); |
95 qed "app_subst_Cons"; |
95 qed "app_subst_Cons"; |
96 |
96 |
97 Addsimps [app_subst_Nil,app_subst_Cons]; |
97 Addsimps [app_subst_Nil,app_subst_Cons]; |
98 |
98 |
99 (* constructor laws for new_tv *) |
99 (* constructor laws for new_tv *) |
100 goalw thy [new_tv_def] |
100 Goalw [new_tv_def] |
101 "new_tv n (TVar m) = (m<n)"; |
101 "new_tv n (TVar m) = (m<n)"; |
102 by (fast_tac (HOL_cs addss simpset()) 1); |
102 by (fast_tac (HOL_cs addss simpset()) 1); |
103 qed "new_tv_TVar"; |
103 qed "new_tv_TVar"; |
104 |
104 |
105 goalw thy [new_tv_def] |
105 Goalw [new_tv_def] |
106 "new_tv n (t1 -> t2) = (new_tv n t1 & new_tv n t2)"; |
106 "new_tv n (t1 -> t2) = (new_tv n t1 & new_tv n t2)"; |
107 by (fast_tac (HOL_cs addss simpset()) 1); |
107 by (fast_tac (HOL_cs addss simpset()) 1); |
108 qed "new_tv_Fun"; |
108 qed "new_tv_Fun"; |
109 |
109 |
110 goalw thy [new_tv_def] |
110 Goalw [new_tv_def] |
111 "new_tv n []"; |
111 "new_tv n []"; |
112 by (Simp_tac 1); |
112 by (Simp_tac 1); |
113 qed "new_tv_Nil"; |
113 qed "new_tv_Nil"; |
114 |
114 |
115 goalw thy [new_tv_def] |
115 Goalw [new_tv_def] |
116 "new_tv n (t#ts) = (new_tv n t & new_tv n ts)"; |
116 "new_tv n (t#ts) = (new_tv n t & new_tv n ts)"; |
117 by (fast_tac (HOL_cs addss simpset()) 1); |
117 by (fast_tac (HOL_cs addss simpset()) 1); |
118 qed "new_tv_Cons"; |
118 qed "new_tv_Cons"; |
119 |
119 |
120 Addsimps [new_tv_TVar,new_tv_Fun,new_tv_Nil,new_tv_Cons]; |
120 Addsimps [new_tv_TVar,new_tv_Fun,new_tv_Nil,new_tv_Cons]; |
121 |
121 |
122 goalw Type.thy [id_subst_def,new_tv_def,free_tv_subst,dom_def,cod_def] |
122 Goalw [id_subst_def,new_tv_def,free_tv_subst,dom_def,cod_def] |
123 "new_tv n id_subst"; |
123 "new_tv n id_subst"; |
124 by (Simp_tac 1); |
124 by (Simp_tac 1); |
125 qed "new_tv_id_subst"; |
125 qed "new_tv_id_subst"; |
126 Addsimps[new_tv_id_subst]; |
126 Addsimps[new_tv_id_subst]; |
127 |
127 |
128 goalw thy [new_tv_def] |
128 Goalw [new_tv_def] |
129 "new_tv n s = ((!m. n <= m --> (s m = TVar m)) & \ |
129 "new_tv n s = ((!m. n <= m --> (s m = TVar m)) & \ |
130 \ (! l. l < n --> new_tv n (s l) ))"; |
130 \ (! l. l < n --> new_tv n (s l) ))"; |
131 by (safe_tac HOL_cs ); |
131 by (safe_tac HOL_cs ); |
132 (* ==> *) |
132 (* ==> *) |
133 by (fast_tac (HOL_cs addDs [leD] addss (simpset() addsimps [free_tv_subst,dom_def])) 1); |
133 by (fast_tac (HOL_cs addDs [leD] addss (simpset() addsimps [free_tv_subst,dom_def])) 1); |
144 by (fast_tac (HOL_cs addSIs [less_or_eq_imp_le]) 1); |
144 by (fast_tac (HOL_cs addSIs [less_or_eq_imp_le]) 1); |
145 by (cut_inst_tac [("m","ma"),("n","n")] less_linear 1); |
145 by (cut_inst_tac [("m","ma"),("n","n")] less_linear 1); |
146 by (fast_tac (HOL_cs addSIs [less_or_eq_imp_le]) 1); |
146 by (fast_tac (HOL_cs addSIs [less_or_eq_imp_le]) 1); |
147 qed "new_tv_subst"; |
147 qed "new_tv_subst"; |
148 |
148 |
149 goal thy |
149 Goal |
150 "new_tv n = list_all (new_tv n)"; |
150 "new_tv n = list_all (new_tv n)"; |
151 by (rtac ext 1); |
151 by (rtac ext 1); |
152 by (list.induct_tac "x" 1); |
152 by (list.induct_tac "x" 1); |
153 by (ALLGOALS Asm_simp_tac); |
153 by (ALLGOALS Asm_simp_tac); |
154 qed "new_tv_list"; |
154 qed "new_tv_list"; |
155 |
155 |
156 (* substitution affects only variables occurring freely *) |
156 (* substitution affects only variables occurring freely *) |
157 goal thy |
157 Goal |
158 "new_tv n (t::typ) --> $(%x. if x=n then t' else s x) t = $s t"; |
158 "new_tv n (t::typ) --> $(%x. if x=n then t' else s x) t = $s t"; |
159 by (typ.induct_tac "t" 1); |
159 by (typ.induct_tac "t" 1); |
160 by (ALLGOALS Asm_simp_tac); |
160 by (ALLGOALS Asm_simp_tac); |
161 qed "subst_te_new_tv"; |
161 qed "subst_te_new_tv"; |
162 Addsimps [subst_te_new_tv]; |
162 Addsimps [subst_te_new_tv]; |
163 |
163 |
164 goal thy |
164 Goal |
165 "new_tv n (ts::typ list) --> $(%x. if x=n then t else s x) ts = $s ts"; |
165 "new_tv n (ts::typ list) --> $(%x. if x=n then t else s x) ts = $s ts"; |
166 by (list.induct_tac "ts" 1); |
166 by (list.induct_tac "ts" 1); |
167 by (ALLGOALS Asm_full_simp_tac); |
167 by (ALLGOALS Asm_full_simp_tac); |
168 qed "subst_tel_new_tv"; |
168 qed "subst_tel_new_tv"; |
169 Addsimps [subst_tel_new_tv]; |
169 Addsimps [subst_tel_new_tv]; |
170 |
170 |
171 (* all greater variables are also new *) |
171 (* all greater variables are also new *) |
172 goal thy |
172 Goal |
173 "n<=m --> new_tv n (t::typ) --> new_tv m t"; |
173 "n<=m --> new_tv n (t::typ) --> new_tv m t"; |
174 by (typ.induct_tac "t" 1); |
174 by (typ.induct_tac "t" 1); |
175 (* case TVar n *) |
175 (* case TVar n *) |
176 by (fast_tac (HOL_cs addIs [less_le_trans] addss simpset()) 1); |
176 by (fast_tac (HOL_cs addIs [less_le_trans] addss simpset()) 1); |
177 (* case Fun t1 t2 *) |
177 (* case Fun t1 t2 *) |
178 by (Asm_simp_tac 1); |
178 by (Asm_simp_tac 1); |
179 qed_spec_mp "new_tv_le"; |
179 qed_spec_mp "new_tv_le"; |
180 Addsimps [lessI RS less_imp_le RS new_tv_le]; |
180 Addsimps [lessI RS less_imp_le RS new_tv_le]; |
181 |
181 |
182 goal thy |
182 Goal |
183 "n<=m --> new_tv n (ts::typ list) --> new_tv m ts"; |
183 "n<=m --> new_tv n (ts::typ list) --> new_tv m ts"; |
184 by (list.induct_tac "ts" 1); |
184 by (list.induct_tac "ts" 1); |
185 (* case [] *) |
185 (* case [] *) |
186 by (Simp_tac 1); |
186 by (Simp_tac 1); |
187 (* case a#al *) |
187 (* case a#al *) |
188 by (fast_tac (HOL_cs addIs [new_tv_le] addss simpset()) 1); |
188 by (fast_tac (HOL_cs addIs [new_tv_le] addss simpset()) 1); |
189 qed_spec_mp "new_tv_list_le"; |
189 qed_spec_mp "new_tv_list_le"; |
190 Addsimps [lessI RS less_imp_le RS new_tv_list_le]; |
190 Addsimps [lessI RS less_imp_le RS new_tv_list_le]; |
191 |
191 |
192 goal thy |
192 Goal |
193 "!! n. [| n<=m; new_tv n (s::subst) |] ==> new_tv m s"; |
193 "!! n. [| n<=m; new_tv n (s::subst) |] ==> new_tv m s"; |
194 by (asm_full_simp_tac (simpset() addsimps [new_tv_subst]) 1); |
194 by (asm_full_simp_tac (simpset() addsimps [new_tv_subst]) 1); |
195 by (rtac conjI 1); |
195 by (rtac conjI 1); |
196 by (slow_tac (HOL_cs addIs [le_trans]) 1); |
196 by (slow_tac (HOL_cs addIs [le_trans]) 1); |
197 by (safe_tac HOL_cs ); |
197 by (safe_tac HOL_cs ); |
200 by (ALLGOALS (asm_full_simp_tac (simpset() addsimps [new_tv_le])) ); |
200 by (ALLGOALS (asm_full_simp_tac (simpset() addsimps [new_tv_le])) ); |
201 qed "new_tv_subst_le"; |
201 qed "new_tv_subst_le"; |
202 Addsimps [lessI RS less_imp_le RS new_tv_subst_le]; |
202 Addsimps [lessI RS less_imp_le RS new_tv_subst_le]; |
203 |
203 |
204 (* new_tv property remains if a substitution is applied *) |
204 (* new_tv property remains if a substitution is applied *) |
205 goal thy |
205 Goal |
206 "!!n. [| n<m; new_tv m (s::subst) |] ==> new_tv m (s n)"; |
206 "!!n. [| n<m; new_tv m (s::subst) |] ==> new_tv m (s n)"; |
207 by (asm_full_simp_tac (simpset() addsimps [new_tv_subst]) 1); |
207 by (asm_full_simp_tac (simpset() addsimps [new_tv_subst]) 1); |
208 qed "new_tv_subst_var"; |
208 qed "new_tv_subst_var"; |
209 |
209 |
210 goal thy |
210 Goal |
211 "new_tv n s --> new_tv n (t::typ) --> new_tv n ($ s t)"; |
211 "new_tv n s --> new_tv n (t::typ) --> new_tv n ($ s t)"; |
212 by (typ.induct_tac "t" 1); |
212 by (typ.induct_tac "t" 1); |
213 by (ALLGOALS(fast_tac (HOL_cs addss (simpset() addsimps [new_tv_subst])))); |
213 by (ALLGOALS(fast_tac (HOL_cs addss (simpset() addsimps [new_tv_subst])))); |
214 qed_spec_mp "new_tv_subst_te"; |
214 qed_spec_mp "new_tv_subst_te"; |
215 Addsimps [new_tv_subst_te]; |
215 Addsimps [new_tv_subst_te]; |
216 |
216 |
217 goal thy |
217 Goal |
218 "new_tv n s --> new_tv n (ts::typ list) --> new_tv n ($ s ts)"; |
218 "new_tv n s --> new_tv n (ts::typ list) --> new_tv n ($ s ts)"; |
219 by (simp_tac (simpset() addsimps [new_tv_list]) 1); |
219 by (simp_tac (simpset() addsimps [new_tv_list]) 1); |
220 by (list.induct_tac "ts" 1); |
220 by (list.induct_tac "ts" 1); |
221 by (ALLGOALS(fast_tac (HOL_cs addss (simpset() addsimps [new_tv_subst])))); |
221 by (ALLGOALS(fast_tac (HOL_cs addss (simpset() addsimps [new_tv_subst])))); |
222 qed_spec_mp "new_tv_subst_tel"; |
222 qed_spec_mp "new_tv_subst_tel"; |
223 Addsimps [new_tv_subst_tel]; |
223 Addsimps [new_tv_subst_tel]; |
224 |
224 |
225 (* auxilliary lemma *) |
225 (* auxilliary lemma *) |
226 goal thy |
226 Goal |
227 "new_tv n ts --> new_tv (Suc n) ((TVar n)#ts)"; |
227 "new_tv n ts --> new_tv (Suc n) ((TVar n)#ts)"; |
228 by (simp_tac (simpset() addsimps [new_tv_list]) 1); |
228 by (simp_tac (simpset() addsimps [new_tv_list]) 1); |
229 by (list.induct_tac "ts" 1); |
229 by (list.induct_tac "ts" 1); |
230 by (ALLGOALS Asm_full_simp_tac); |
230 by (ALLGOALS Asm_full_simp_tac); |
231 qed "new_tv_Suc_list"; |
231 qed "new_tv_Suc_list"; |
232 |
232 |
233 |
233 |
234 (* composition of substitutions preserves new_tv proposition *) |
234 (* composition of substitutions preserves new_tv proposition *) |
235 goal thy |
235 Goal |
236 "!! n. [| new_tv n (s::subst); new_tv n r |] ==> \ |
236 "!! n. [| new_tv n (s::subst); new_tv n r |] ==> \ |
237 \ new_tv n (($ r) o s)"; |
237 \ new_tv n (($ r) o s)"; |
238 by (asm_full_simp_tac (simpset() addsimps [new_tv_subst]) 1); |
238 by (asm_full_simp_tac (simpset() addsimps [new_tv_subst]) 1); |
239 qed "new_tv_subst_comp_1"; |
239 qed "new_tv_subst_comp_1"; |
240 |
240 |
241 goal thy |
241 Goal |
242 "!! n. [| new_tv n (s::subst); new_tv n r |] ==> \ |
242 "!! n. [| new_tv n (s::subst); new_tv n r |] ==> \ |
243 \ new_tv n (%v.$ r (s v))"; |
243 \ new_tv n (%v.$ r (s v))"; |
244 by (asm_full_simp_tac (simpset() addsimps [new_tv_subst]) 1); |
244 by (asm_full_simp_tac (simpset() addsimps [new_tv_subst]) 1); |
245 qed "new_tv_subst_comp_2"; |
245 qed "new_tv_subst_comp_2"; |
246 |
246 |
247 Addsimps [new_tv_subst_comp_1,new_tv_subst_comp_2]; |
247 Addsimps [new_tv_subst_comp_1,new_tv_subst_comp_2]; |
248 |
248 |
249 (* new type variables do not occur freely in a type structure *) |
249 (* new type variables do not occur freely in a type structure *) |
250 goalw thy [new_tv_def] |
250 Goalw [new_tv_def] |
251 "!!n. new_tv n ts ==> n~:(free_tv ts)"; |
251 "!!n. new_tv n ts ==> n~:(free_tv ts)"; |
252 by (fast_tac (HOL_cs addEs [less_irrefl]) 1); |
252 by (fast_tac (HOL_cs addEs [less_irrefl]) 1); |
253 qed "new_tv_not_free_tv"; |
253 qed "new_tv_not_free_tv"; |
254 Addsimps [new_tv_not_free_tv]; |
254 Addsimps [new_tv_not_free_tv]; |
255 |
255 |
256 goal thy |
256 Goal |
257 "(t::typ) mem ts --> free_tv t <= free_tv ts"; |
257 "(t::typ) mem ts --> free_tv t <= free_tv ts"; |
258 by (list.induct_tac "ts" 1); |
258 by (list.induct_tac "ts" 1); |
259 (* case [] *) |
259 (* case [] *) |
260 by (Simp_tac 1); |
260 by (Simp_tac 1); |
261 (* case x#xl *) |
261 (* case x#xl *) |
265 |
265 |
266 |
266 |
267 (* if two substitutions yield the same result if applied to a type |
267 (* if two substitutions yield the same result if applied to a type |
268 structure the substitutions coincide on the free type variables |
268 structure the substitutions coincide on the free type variables |
269 occurring in the type structure *) |
269 occurring in the type structure *) |
270 goal thy |
270 Goal |
271 "$ s1 (t::typ) = $ s2 t --> n:(free_tv t) --> s1 n = s2 n"; |
271 "$ s1 (t::typ) = $ s2 t --> n:(free_tv t) --> s1 n = s2 n"; |
272 by (typ.induct_tac "t" 1); |
272 by (typ.induct_tac "t" 1); |
273 (* case TVar n *) |
273 (* case TVar n *) |
274 by (fast_tac (HOL_cs addss simpset()) 1); |
274 by (fast_tac (HOL_cs addss simpset()) 1); |
275 (* case Fun t1 t2 *) |
275 (* case Fun t1 t2 *) |
276 by (fast_tac (HOL_cs addss simpset()) 1); |
276 by (fast_tac (HOL_cs addss simpset()) 1); |
277 qed_spec_mp "eq_subst_te_eq_free"; |
277 qed_spec_mp "eq_subst_te_eq_free"; |
278 |
278 |
279 goal thy |
279 Goal |
280 "(!n. n:(free_tv t) --> s1 n = s2 n) --> $ s1 (t::typ) = $ s2 t"; |
280 "(!n. n:(free_tv t) --> s1 n = s2 n) --> $ s1 (t::typ) = $ s2 t"; |
281 by (typ.induct_tac "t" 1); |
281 by (typ.induct_tac "t" 1); |
282 (* case TVar n *) |
282 (* case TVar n *) |
283 by (fast_tac (HOL_cs addss simpset()) 1); |
283 by (fast_tac (HOL_cs addss simpset()) 1); |
284 (* case Fun t1 t2 *) |
284 (* case Fun t1 t2 *) |
285 by (fast_tac (HOL_cs addss simpset()) 1); |
285 by (fast_tac (HOL_cs addss simpset()) 1); |
286 qed_spec_mp "eq_free_eq_subst_te"; |
286 qed_spec_mp "eq_free_eq_subst_te"; |
287 |
287 |
288 goal thy |
288 Goal |
289 "$s1 (ts::typ list) = $s2 ts --> n:(free_tv ts) --> s1 n = s2 n"; |
289 "$s1 (ts::typ list) = $s2 ts --> n:(free_tv ts) --> s1 n = s2 n"; |
290 by (list.induct_tac "ts" 1); |
290 by (list.induct_tac "ts" 1); |
291 (* case [] *) |
291 (* case [] *) |
292 by (fast_tac (HOL_cs addss simpset()) 1); |
292 by (fast_tac (HOL_cs addss simpset()) 1); |
293 (* case x#xl *) |
293 (* case x#xl *) |
294 by (fast_tac (HOL_cs addIs [eq_subst_te_eq_free] addss (simpset())) 1); |
294 by (fast_tac (HOL_cs addIs [eq_subst_te_eq_free] addss (simpset())) 1); |
295 qed_spec_mp "eq_subst_tel_eq_free"; |
295 qed_spec_mp "eq_subst_tel_eq_free"; |
296 |
296 |
297 goal thy |
297 Goal |
298 "(!n. n:(free_tv ts) --> s1 n = s2 n) --> $s1 (ts::typ list) = $s2 ts"; |
298 "(!n. n:(free_tv ts) --> s1 n = s2 n) --> $s1 (ts::typ list) = $s2 ts"; |
299 by (list.induct_tac "ts" 1); |
299 by (list.induct_tac "ts" 1); |
300 (* case [] *) |
300 (* case [] *) |
301 by (fast_tac (HOL_cs addss simpset()) 1); |
301 by (fast_tac (HOL_cs addss simpset()) 1); |
302 (* case x#xl *) |
302 (* case x#xl *) |
303 by (fast_tac (HOL_cs addIs [eq_free_eq_subst_te] addss (simpset())) 1); |
303 by (fast_tac (HOL_cs addIs [eq_free_eq_subst_te] addss (simpset())) 1); |
304 qed_spec_mp "eq_free_eq_subst_tel"; |
304 qed_spec_mp "eq_free_eq_subst_tel"; |
305 |
305 |
306 (* some useful theorems *) |
306 (* some useful theorems *) |
307 goalw thy [free_tv_subst] |
307 Goalw [free_tv_subst] |
308 "!!v. v : cod s ==> v : free_tv s"; |
308 "!!v. v : cod s ==> v : free_tv s"; |
309 by (fast_tac set_cs 1); |
309 by (fast_tac set_cs 1); |
310 qed "codD"; |
310 qed "codD"; |
311 |
311 |
312 goalw thy [free_tv_subst,dom_def] |
312 Goalw [free_tv_subst,dom_def] |
313 "!! x. x ~: free_tv s ==> s x = TVar x"; |
313 "!! x. x ~: free_tv s ==> s x = TVar x"; |
314 by (fast_tac set_cs 1); |
314 by (fast_tac set_cs 1); |
315 qed "not_free_impl_id"; |
315 qed "not_free_impl_id"; |
316 |
316 |
317 goalw thy [new_tv_def] |
317 Goalw [new_tv_def] |
318 "!! n. [| new_tv n t; m:free_tv t |] ==> m<n"; |
318 "!! n. [| new_tv n t; m:free_tv t |] ==> m<n"; |
319 by (fast_tac HOL_cs 1 ); |
319 by (fast_tac HOL_cs 1 ); |
320 qed "free_tv_le_new_tv"; |
320 qed "free_tv_le_new_tv"; |
321 |
321 |
322 goal thy |
322 Goal |
323 "free_tv (s (v::nat)) <= insert v (cod s)"; |
323 "free_tv (s (v::nat)) <= insert v (cod s)"; |
324 by (expand_case_tac "v:dom s" 1); |
324 by (expand_case_tac "v:dom s" 1); |
325 by (fast_tac (set_cs addss (simpset() addsimps [cod_def])) 1); |
325 by (fast_tac (set_cs addss (simpset() addsimps [cod_def])) 1); |
326 by (fast_tac (set_cs addss (simpset() addsimps [dom_def])) 1); |
326 by (fast_tac (set_cs addss (simpset() addsimps [dom_def])) 1); |
327 qed "free_tv_subst_var"; |
327 qed "free_tv_subst_var"; |
328 |
328 |
329 goal thy |
329 Goal |
330 "free_tv ($ s (t::typ)) <= cod s Un free_tv t"; |
330 "free_tv ($ s (t::typ)) <= cod s Un free_tv t"; |
331 by (typ.induct_tac "t" 1); |
331 by (typ.induct_tac "t" 1); |
332 (* case TVar n *) |
332 (* case TVar n *) |
333 by (simp_tac (simpset() addsimps [free_tv_subst_var]) 1); |
333 by (simp_tac (simpset() addsimps [free_tv_subst_var]) 1); |
334 (* case Fun t1 t2 *) |
334 (* case Fun t1 t2 *) |
335 by (fast_tac (set_cs addss simpset()) 1); |
335 by (fast_tac (set_cs addss simpset()) 1); |
336 qed "free_tv_app_subst_te"; |
336 qed "free_tv_app_subst_te"; |
337 |
337 |
338 goal thy |
338 Goal |
339 "free_tv ($ s (ts::typ list)) <= cod s Un free_tv ts"; |
339 "free_tv ($ s (ts::typ list)) <= cod s Un free_tv ts"; |
340 by (list.induct_tac "ts" 1); |
340 by (list.induct_tac "ts" 1); |
341 (* case [] *) |
341 (* case [] *) |
342 by (Simp_tac 1); |
342 by (Simp_tac 1); |
343 (* case a#al *) |
343 (* case a#al *) |
344 by (cut_facts_tac [free_tv_app_subst_te] 1); |
344 by (cut_facts_tac [free_tv_app_subst_te] 1); |
345 by (fast_tac (set_cs addss simpset()) 1); |
345 by (fast_tac (set_cs addss simpset()) 1); |
346 qed "free_tv_app_subst_tel"; |
346 qed "free_tv_app_subst_tel"; |
347 |
347 |
348 goalw thy [free_tv_subst,dom_def] |
348 Goalw [free_tv_subst,dom_def] |
349 "free_tv (%u::nat. $ s1 (s2 u) :: typ) <= \ |
349 "free_tv (%u::nat. $ s1 (s2 u) :: typ) <= \ |
350 \ free_tv s1 Un free_tv s2"; |
350 \ free_tv s1 Un free_tv s2"; |
351 by (fast_tac (set_cs addSDs [free_tv_app_subst_te RS subsetD, |
351 by (fast_tac (set_cs addSDs [free_tv_app_subst_te RS subsetD, |
352 free_tv_subst_var RS subsetD] |
352 free_tv_subst_var RS subsetD] |
353 addss (simpset() delsimps bex_simps |
353 addss (simpset() delsimps bex_simps |