author | Christian Urban <urbanc@in.tum.de> |
Thu, 27 Jan 2011 20:19:13 +0100 | |
changeset 2709 | eb4a2f4078ae |
parent 2707 | 747ebf2f066d |
child 2710 | 7eebe0d5d298 |
permissions | -rw-r--r-- |
1795 | 1 |
theory TypeSchemes |
2454
9ffee4eb1ae1
renamed NewParser to Nominal2
Christian Urban <urbanc@in.tum.de>
parents:
2451
diff
changeset
|
2 |
imports "../Nominal2" |
1795 | 3 |
begin |
4 |
||
5 |
section {*** Type Schemes ***} |
|
6 |
||
2709 | 7 |
nominal_datatype |
8 |
A = Aa bool | Ab B |
|
9 |
and |
|
10 |
B = Ba bool | Bb A |
|
11 |
||
12 |
lemma |
|
13 |
"(p \<bullet> (Sum_Type.Projl (f (Inl x)))) = Sum_Type.Projl ((p \<bullet> f) (Inl (p \<bullet> x)))" |
|
14 |
apply(perm_simp) |
|
15 |
apply(subst permute_fun_def) |
|
16 |
sorry |
|
17 |
||
18 |
||
19 |
nominal_primrec |
|
20 |
even :: "nat \<Rightarrow> A" |
|
21 |
and odd :: "nat \<Rightarrow> B" |
|
22 |
where |
|
23 |
"even 0 = Aa True" |
|
24 |
| "even (Suc n) = Ab (odd n)" |
|
25 |
| "odd 0 = Ba False" |
|
26 |
| "odd (Suc n) = Bb (even n)" |
|
27 |
thm even_odd_graph.intros even_odd_sumC_def |
|
28 |
thm sum.cases Product_Type.split |
|
29 |
thm even_odd_graph_def |
|
30 |
term Inr |
|
31 |
term Sum_Type.Projr |
|
32 |
term even_odd_sumC |
|
33 |
thm even_odd_sumC_def |
|
34 |
unfolding even_odd_sumC_def |
|
35 |
sorry |
|
36 |
||
37 |
ML {* the *} |
|
38 |
||
39 |
thm even.psimps odd.psimps |
|
40 |
||
41 |
||
42 |
||
2556
8ed62410236e
added a test about subtyping; disabled two tests, because of problem with function package
Christian Urban <urbanc@in.tum.de>
parents:
2524
diff
changeset
|
43 |
atom_decl name |
8ed62410236e
added a test about subtyping; disabled two tests, because of problem with function package
Christian Urban <urbanc@in.tum.de>
parents:
2524
diff
changeset
|
44 |
|
2486
b4ea19604b0b
cleaned up two examples
Christian Urban <urbanc@in.tum.de>
parents:
2480
diff
changeset
|
45 |
(* defined as a single nominal datatype *) |
1795 | 46 |
|
47 |
nominal_datatype ty = |
|
48 |
Var "name" |
|
49 |
| Fun "ty" "ty" |
|
50 |
and tys = |
|
2634
3ce1089cdbf3
changed res keyword to set+ for restrictions; comment by a referee
Christian Urban <urbanc@in.tum.de>
parents:
2630
diff
changeset
|
51 |
All xs::"name fset" ty::"ty" bind (set+) xs in ty |
2434 | 52 |
|
2468 | 53 |
thm ty_tys.distinct |
54 |
thm ty_tys.induct |
|
2617
e44551d067e6
properly exported strong exhaust theorem; cleaned up some examples
Christian Urban <urbanc@in.tum.de>
parents:
2611
diff
changeset
|
55 |
thm ty_tys.inducts |
e44551d067e6
properly exported strong exhaust theorem; cleaned up some examples
Christian Urban <urbanc@in.tum.de>
parents:
2611
diff
changeset
|
56 |
thm ty_tys.exhaust ty_tys.strong_exhaust |
2468 | 57 |
thm ty_tys.fv_defs |
58 |
thm ty_tys.bn_defs |
|
59 |
thm ty_tys.perm_simps |
|
60 |
thm ty_tys.eq_iff |
|
61 |
thm ty_tys.fv_bn_eqvt |
|
62 |
thm ty_tys.size_eqvt |
|
63 |
thm ty_tys.supports |
|
2493
2e174807c891
added postprocessed fresh-lemmas for constructors
Christian Urban <urbanc@in.tum.de>
parents:
2486
diff
changeset
|
64 |
thm ty_tys.supp |
2494
11133eb76f61
added Foo1 to explore a contrived example
Christian Urban <urbanc@in.tum.de>
parents:
2493
diff
changeset
|
65 |
thm ty_tys.fresh |
1795 | 66 |
|
2707
747ebf2f066d
made eqvt-proof explicit in the function definitions
Christian Urban <urbanc@in.tum.de>
parents:
2676
diff
changeset
|
67 |
fun |
747ebf2f066d
made eqvt-proof explicit in the function definitions
Christian Urban <urbanc@in.tum.de>
parents:
2676
diff
changeset
|
68 |
lookup :: "(name \<times> ty) list \<Rightarrow> name \<Rightarrow> ty" |
747ebf2f066d
made eqvt-proof explicit in the function definitions
Christian Urban <urbanc@in.tum.de>
parents:
2676
diff
changeset
|
69 |
where |
747ebf2f066d
made eqvt-proof explicit in the function definitions
Christian Urban <urbanc@in.tum.de>
parents:
2676
diff
changeset
|
70 |
"lookup [] Y = Var Y" |
747ebf2f066d
made eqvt-proof explicit in the function definitions
Christian Urban <urbanc@in.tum.de>
parents:
2676
diff
changeset
|
71 |
| "lookup ((X, T) # Ts) Y = (if X = Y then T else lookup Ts Y)" |
747ebf2f066d
made eqvt-proof explicit in the function definitions
Christian Urban <urbanc@in.tum.de>
parents:
2676
diff
changeset
|
72 |
|
747ebf2f066d
made eqvt-proof explicit in the function definitions
Christian Urban <urbanc@in.tum.de>
parents:
2676
diff
changeset
|
73 |
lemma lookup_eqvt[eqvt]: |
747ebf2f066d
made eqvt-proof explicit in the function definitions
Christian Urban <urbanc@in.tum.de>
parents:
2676
diff
changeset
|
74 |
shows "(p \<bullet> lookup Ts T) = lookup (p \<bullet> Ts) (p \<bullet> T)" |
747ebf2f066d
made eqvt-proof explicit in the function definitions
Christian Urban <urbanc@in.tum.de>
parents:
2676
diff
changeset
|
75 |
apply(induct Ts T rule: lookup.induct) |
747ebf2f066d
made eqvt-proof explicit in the function definitions
Christian Urban <urbanc@in.tum.de>
parents:
2676
diff
changeset
|
76 |
apply(simp_all) |
747ebf2f066d
made eqvt-proof explicit in the function definitions
Christian Urban <urbanc@in.tum.de>
parents:
2676
diff
changeset
|
77 |
done |
747ebf2f066d
made eqvt-proof explicit in the function definitions
Christian Urban <urbanc@in.tum.de>
parents:
2676
diff
changeset
|
78 |
|
2709 | 79 |
lemma test: |
80 |
assumes a: "f x = Inl y" |
|
81 |
shows "(p \<bullet> (Sum_Type.Projl (f x))) = Sum_Type.Projl ((p \<bullet> f) (p \<bullet> x))" |
|
82 |
using a |
|
83 |
apply(frule_tac p="p" in permute_boolI) |
|
84 |
apply(simp (no_asm_use) only: eqvts) |
|
85 |
apply(subst (asm) permute_fun_app_eq) |
|
86 |
back |
|
87 |
apply(simp) |
|
88 |
done |
|
89 |
||
90 |
lemma |
|
91 |
"(p \<bullet> (Sum_Type.Projl x)) = Sum_Type.Projl (p \<bullet> x)" |
|
92 |
apply(case_tac x) |
|
93 |
apply(simp) |
|
94 |
apply(simp) |
|
95 |
||
96 |
||
2707
747ebf2f066d
made eqvt-proof explicit in the function definitions
Christian Urban <urbanc@in.tum.de>
parents:
2676
diff
changeset
|
97 |
nominal_primrec |
747ebf2f066d
made eqvt-proof explicit in the function definitions
Christian Urban <urbanc@in.tum.de>
parents:
2676
diff
changeset
|
98 |
subst :: "(name \<times> ty) list \<Rightarrow> ty \<Rightarrow> ty" |
747ebf2f066d
made eqvt-proof explicit in the function definitions
Christian Urban <urbanc@in.tum.de>
parents:
2676
diff
changeset
|
99 |
and substs :: "(name \<times> ty) list \<Rightarrow> tys \<Rightarrow> tys" |
747ebf2f066d
made eqvt-proof explicit in the function definitions
Christian Urban <urbanc@in.tum.de>
parents:
2676
diff
changeset
|
100 |
where |
747ebf2f066d
made eqvt-proof explicit in the function definitions
Christian Urban <urbanc@in.tum.de>
parents:
2676
diff
changeset
|
101 |
"subst \<theta> (Var X) = lookup \<theta> X" |
747ebf2f066d
made eqvt-proof explicit in the function definitions
Christian Urban <urbanc@in.tum.de>
parents:
2676
diff
changeset
|
102 |
| "subst \<theta> (Fun T1 T2) = Fun (subst \<theta> T1) (subst \<theta> T2)" |
747ebf2f066d
made eqvt-proof explicit in the function definitions
Christian Urban <urbanc@in.tum.de>
parents:
2676
diff
changeset
|
103 |
| "fset (map_fset atom xs) \<sharp>* \<theta> \<Longrightarrow> substs \<theta> (All xs T) = All xs (subst \<theta> T)" |
2709 | 104 |
|
2707
747ebf2f066d
made eqvt-proof explicit in the function definitions
Christian Urban <urbanc@in.tum.de>
parents:
2676
diff
changeset
|
105 |
term subst_substs_sumC |
2709 | 106 |
thm subst_substs_sumC_def |
2707
747ebf2f066d
made eqvt-proof explicit in the function definitions
Christian Urban <urbanc@in.tum.de>
parents:
2676
diff
changeset
|
107 |
term Inl |
747ebf2f066d
made eqvt-proof explicit in the function definitions
Christian Urban <urbanc@in.tum.de>
parents:
2676
diff
changeset
|
108 |
thm subst_substs_graph.induct |
747ebf2f066d
made eqvt-proof explicit in the function definitions
Christian Urban <urbanc@in.tum.de>
parents:
2676
diff
changeset
|
109 |
thm subst_substs_graph.intros |
747ebf2f066d
made eqvt-proof explicit in the function definitions
Christian Urban <urbanc@in.tum.de>
parents:
2676
diff
changeset
|
110 |
thm Projl.simps |
747ebf2f066d
made eqvt-proof explicit in the function definitions
Christian Urban <urbanc@in.tum.de>
parents:
2676
diff
changeset
|
111 |
apply(subgoal_tac "\<And>p x r. subst_substs_graph x r \<Longrightarrow> subst_substs_graph (p \<bullet> x) (p \<bullet> r)") |
747ebf2f066d
made eqvt-proof explicit in the function definitions
Christian Urban <urbanc@in.tum.de>
parents:
2676
diff
changeset
|
112 |
apply(simp add: eqvt_def) |
747ebf2f066d
made eqvt-proof explicit in the function definitions
Christian Urban <urbanc@in.tum.de>
parents:
2676
diff
changeset
|
113 |
apply(rule allI) |
747ebf2f066d
made eqvt-proof explicit in the function definitions
Christian Urban <urbanc@in.tum.de>
parents:
2676
diff
changeset
|
114 |
apply(simp add: permute_fun_def permute_bool_def) |
747ebf2f066d
made eqvt-proof explicit in the function definitions
Christian Urban <urbanc@in.tum.de>
parents:
2676
diff
changeset
|
115 |
apply(rule ext) |
747ebf2f066d
made eqvt-proof explicit in the function definitions
Christian Urban <urbanc@in.tum.de>
parents:
2676
diff
changeset
|
116 |
apply(rule ext) |
747ebf2f066d
made eqvt-proof explicit in the function definitions
Christian Urban <urbanc@in.tum.de>
parents:
2676
diff
changeset
|
117 |
apply(rule iffI) |
747ebf2f066d
made eqvt-proof explicit in the function definitions
Christian Urban <urbanc@in.tum.de>
parents:
2676
diff
changeset
|
118 |
apply(drule_tac x="p" in meta_spec) |
747ebf2f066d
made eqvt-proof explicit in the function definitions
Christian Urban <urbanc@in.tum.de>
parents:
2676
diff
changeset
|
119 |
apply(drule_tac x="- p \<bullet> x" in meta_spec) |
747ebf2f066d
made eqvt-proof explicit in the function definitions
Christian Urban <urbanc@in.tum.de>
parents:
2676
diff
changeset
|
120 |
apply(drule_tac x="- p \<bullet> xa" in meta_spec) |
747ebf2f066d
made eqvt-proof explicit in the function definitions
Christian Urban <urbanc@in.tum.de>
parents:
2676
diff
changeset
|
121 |
apply(simp) |
747ebf2f066d
made eqvt-proof explicit in the function definitions
Christian Urban <urbanc@in.tum.de>
parents:
2676
diff
changeset
|
122 |
apply(drule_tac x="-p" in meta_spec) |
747ebf2f066d
made eqvt-proof explicit in the function definitions
Christian Urban <urbanc@in.tum.de>
parents:
2676
diff
changeset
|
123 |
apply(drule_tac x="x" in meta_spec) |
747ebf2f066d
made eqvt-proof explicit in the function definitions
Christian Urban <urbanc@in.tum.de>
parents:
2676
diff
changeset
|
124 |
apply(drule_tac x="xa" in meta_spec) |
747ebf2f066d
made eqvt-proof explicit in the function definitions
Christian Urban <urbanc@in.tum.de>
parents:
2676
diff
changeset
|
125 |
apply(simp) |
747ebf2f066d
made eqvt-proof explicit in the function definitions
Christian Urban <urbanc@in.tum.de>
parents:
2676
diff
changeset
|
126 |
thm subst_substs_graph.induct |
747ebf2f066d
made eqvt-proof explicit in the function definitions
Christian Urban <urbanc@in.tum.de>
parents:
2676
diff
changeset
|
127 |
thm subst_substs_graph.intros |
747ebf2f066d
made eqvt-proof explicit in the function definitions
Christian Urban <urbanc@in.tum.de>
parents:
2676
diff
changeset
|
128 |
thm Projl.simps |
747ebf2f066d
made eqvt-proof explicit in the function definitions
Christian Urban <urbanc@in.tum.de>
parents:
2676
diff
changeset
|
129 |
apply(erule subst_substs_graph.induct) |
747ebf2f066d
made eqvt-proof explicit in the function definitions
Christian Urban <urbanc@in.tum.de>
parents:
2676
diff
changeset
|
130 |
apply(perm_simp) |
747ebf2f066d
made eqvt-proof explicit in the function definitions
Christian Urban <urbanc@in.tum.de>
parents:
2676
diff
changeset
|
131 |
apply(rule subst_substs_graph.intros) |
2709 | 132 |
thm subst_substs_graph.cases |
133 |
apply(erule subst_substs_graph.cases) |
|
134 |
apply(simp (no_asm_use) only: eqvts) |
|
135 |
apply(subst test) |
|
136 |
back |
|
137 |
apply(assumption) |
|
138 |
apply(rotate_tac 1) |
|
139 |
apply(erule subst_substs_graph.cases) |
|
140 |
apply(subst test) |
|
141 |
back |
|
142 |
apply(assumption) |
|
143 |
apply(perm_simp) |
|
144 |
apply(rule subst_substs_graph.intros) |
|
145 |
apply(assumption) |
|
146 |
apply(assumption) |
|
147 |
apply(subst test) |
|
148 |
back |
|
149 |
apply(assumption) |
|
150 |
apply(perm_simp) |
|
151 |
apply(rule subst_substs_graph.intros) |
|
152 |
apply(assumption) |
|
153 |
apply(assumption) |
|
154 |
apply(simp) |
|
155 |
--"A" |
|
156 |
apply(simp (no_asm_use) only: eqvts) |
|
157 |
apply(subst test) |
|
158 |
back |
|
159 |
apply(assumption) |
|
160 |
apply(rotate_tac 1) |
|
161 |
apply(erule subst_substs_graph.cases) |
|
162 |
apply(subst test) |
|
163 |
back |
|
164 |
apply(assumption) |
|
165 |
apply(perm_simp) |
|
166 |
apply(rule subst_substs_graph.intros) |
|
167 |
apply(assumption) |
|
168 |
apply(assumption) |
|
169 |
apply(subst test) |
|
170 |
back |
|
171 |
apply(assumption) |
|
172 |
apply(perm_simp) |
|
173 |
apply(rule subst_substs_graph.intros) |
|
174 |
apply(assumption) |
|
175 |
apply(assumption) |
|
176 |
apply(simp) |
|
177 |
--"A" |
|
178 |
apply(simp) |
|
179 |
apply(erule subst_substs_graph.cases) |
|
180 |
apply(simp (no_asm_use) only: eqvts) |
|
181 |
apply(subst test) |
|
182 |
back |
|
183 |
back |
|
184 |
apply(assumption) |
|
185 |
apply(rule subst_substs_graph.intros) |
|
186 |
defer |
|
187 |
apply(perm_simp) |
|
188 |
apply(assumption) |
|
189 |
apply(simp (no_asm_use) only: eqvts) |
|
190 |
apply(subst test) |
|
191 |
back |
|
192 |
back |
|
193 |
apply(assumption) |
|
194 |
apply(rule subst_substs_graph.intros) |
|
195 |
defer |
|
196 |
apply(perm_simp) |
|
197 |
apply(assumption) |
|
198 |
apply(simp) |
|
199 |
apply(simp_all add: ty_tys.distinct) |
|
200 |
defer |
|
201 |
apply(simp add: ty_tys.eq_iff) |
|
202 |
apply(simp add: ty_tys.eq_iff) |
|
203 |
apply(erule conjE)+ |
|
204 |
apply(simp add: ty_tys.eq_iff) |
|
205 |
apply(subst (asm) Abs_eq_iff2) |
|
206 |
apply(erule exE) |
|
207 |
apply(simp add: alphas) |
|
208 |
apply(clarify) |
|
209 |
thm subst_def |
|
210 |
||
211 |
||
212 |
apply(assumption) |
|
213 |
apply(subst test) |
|
214 |
back |
|
215 |
apply(assumption) |
|
216 |
apply(perm_simp) |
|
217 |
apply(rule subst_substs_graph.intros) |
|
218 |
apply(assumption) |
|
219 |
apply(assumption) |
|
220 |
apply(subst test) |
|
221 |
back |
|
222 |
apply(assumption) |
|
223 |
apply(perm_simp) |
|
224 |
apply(rule subst_substs_graph.intros) |
|
225 |
apply(assumption) |
|
226 |
apply(assumption) |
|
227 |
apply(simp) |
|
228 |
||
229 |
||
230 |
apply(rotate_tac 1) |
|
231 |
apply(erule subst_substs_graph.cases) |
|
232 |
apply(subst test) |
|
233 |
back |
|
234 |
apply(assumption) |
|
235 |
||
236 |
||
237 |
apply(auto)[4] |
|
238 |
thm subst_substs_graph.cases |
|
239 |
thm subst_substs_graph.intros |
|
240 |
thm subst_substs_graph.intros(2)[THEN permute_boolI] |
|
241 |
term subst_substs_graph |
|
2707
747ebf2f066d
made eqvt-proof explicit in the function definitions
Christian Urban <urbanc@in.tum.de>
parents:
2676
diff
changeset
|
242 |
apply(simp only: eqvts) |
747ebf2f066d
made eqvt-proof explicit in the function definitions
Christian Urban <urbanc@in.tum.de>
parents:
2676
diff
changeset
|
243 |
thm Projl.simps |
747ebf2f066d
made eqvt-proof explicit in the function definitions
Christian Urban <urbanc@in.tum.de>
parents:
2676
diff
changeset
|
244 |
term Inl |
747ebf2f066d
made eqvt-proof explicit in the function definitions
Christian Urban <urbanc@in.tum.de>
parents:
2676
diff
changeset
|
245 |
term Inr |
747ebf2f066d
made eqvt-proof explicit in the function definitions
Christian Urban <urbanc@in.tum.de>
parents:
2676
diff
changeset
|
246 |
apply(perm_simp) |
747ebf2f066d
made eqvt-proof explicit in the function definitions
Christian Urban <urbanc@in.tum.de>
parents:
2676
diff
changeset
|
247 |
thm subst_substs_graph.intros |
2709 | 248 |
apply(simp add: permute_fun_def) |
2707
747ebf2f066d
made eqvt-proof explicit in the function definitions
Christian Urban <urbanc@in.tum.de>
parents:
2676
diff
changeset
|
249 |
thm Projl.simps |
747ebf2f066d
made eqvt-proof explicit in the function definitions
Christian Urban <urbanc@in.tum.de>
parents:
2676
diff
changeset
|
250 |
oops |
747ebf2f066d
made eqvt-proof explicit in the function definitions
Christian Urban <urbanc@in.tum.de>
parents:
2676
diff
changeset
|
251 |
|
2676
028d5511c15f
some tryes about substitution over type-schemes
Christian Urban <urbanc@in.tum.de>
parents:
2634
diff
changeset
|
252 |
|
028d5511c15f
some tryes about substitution over type-schemes
Christian Urban <urbanc@in.tum.de>
parents:
2634
diff
changeset
|
253 |
section {* defined as two separate nominal datatypes *} |
2486
b4ea19604b0b
cleaned up two examples
Christian Urban <urbanc@in.tum.de>
parents:
2480
diff
changeset
|
254 |
|
2308
387fcbd33820
fixed problem with bn_info
Christian Urban <urbanc@in.tum.de>
parents:
2181
diff
changeset
|
255 |
nominal_datatype ty2 = |
387fcbd33820
fixed problem with bn_info
Christian Urban <urbanc@in.tum.de>
parents:
2181
diff
changeset
|
256 |
Var2 "name" |
387fcbd33820
fixed problem with bn_info
Christian Urban <urbanc@in.tum.de>
parents:
2181
diff
changeset
|
257 |
| Fun2 "ty2" "ty2" |
387fcbd33820
fixed problem with bn_info
Christian Urban <urbanc@in.tum.de>
parents:
2181
diff
changeset
|
258 |
|
387fcbd33820
fixed problem with bn_info
Christian Urban <urbanc@in.tum.de>
parents:
2181
diff
changeset
|
259 |
nominal_datatype tys2 = |
2634
3ce1089cdbf3
changed res keyword to set+ for restrictions; comment by a referee
Christian Urban <urbanc@in.tum.de>
parents:
2630
diff
changeset
|
260 |
All2 xs::"name fset" ty::"ty2" bind (set+) xs in ty |
2337
b151399bd2c3
fixed according to changes in quotient
Christian Urban <urbanc@in.tum.de>
parents:
2308
diff
changeset
|
261 |
|
2468 | 262 |
thm tys2.distinct |
2630
8268b277d240
automated all strong induction lemmas
Christian Urban <urbanc@in.tum.de>
parents:
2622
diff
changeset
|
263 |
thm tys2.induct tys2.strong_induct |
2617
e44551d067e6
properly exported strong exhaust theorem; cleaned up some examples
Christian Urban <urbanc@in.tum.de>
parents:
2611
diff
changeset
|
264 |
thm tys2.exhaust tys2.strong_exhaust |
2468 | 265 |
thm tys2.fv_defs |
266 |
thm tys2.bn_defs |
|
267 |
thm tys2.perm_simps |
|
268 |
thm tys2.eq_iff |
|
269 |
thm tys2.fv_bn_eqvt |
|
270 |
thm tys2.size_eqvt |
|
271 |
thm tys2.supports |
|
2493
2e174807c891
added postprocessed fresh-lemmas for constructors
Christian Urban <urbanc@in.tum.de>
parents:
2486
diff
changeset
|
272 |
thm tys2.supp |
2494
11133eb76f61
added Foo1 to explore a contrived example
Christian Urban <urbanc@in.tum.de>
parents:
2493
diff
changeset
|
273 |
thm tys2.fresh |
2468 | 274 |
|
2676
028d5511c15f
some tryes about substitution over type-schemes
Christian Urban <urbanc@in.tum.de>
parents:
2634
diff
changeset
|
275 |
fun |
2707
747ebf2f066d
made eqvt-proof explicit in the function definitions
Christian Urban <urbanc@in.tum.de>
parents:
2676
diff
changeset
|
276 |
lookup2 :: "(name \<times> ty2) list \<Rightarrow> name \<Rightarrow> ty2" |
2676
028d5511c15f
some tryes about substitution over type-schemes
Christian Urban <urbanc@in.tum.de>
parents:
2634
diff
changeset
|
277 |
where |
2707
747ebf2f066d
made eqvt-proof explicit in the function definitions
Christian Urban <urbanc@in.tum.de>
parents:
2676
diff
changeset
|
278 |
"lookup2 [] Y = Var2 Y" |
747ebf2f066d
made eqvt-proof explicit in the function definitions
Christian Urban <urbanc@in.tum.de>
parents:
2676
diff
changeset
|
279 |
| "lookup2 ((X, T) # Ts) Y = (if X = Y then T else lookup2 Ts Y)" |
2556
8ed62410236e
added a test about subtyping; disabled two tests, because of problem with function package
Christian Urban <urbanc@in.tum.de>
parents:
2524
diff
changeset
|
280 |
|
2707
747ebf2f066d
made eqvt-proof explicit in the function definitions
Christian Urban <urbanc@in.tum.de>
parents:
2676
diff
changeset
|
281 |
lemma lookup2_eqvt[eqvt]: |
747ebf2f066d
made eqvt-proof explicit in the function definitions
Christian Urban <urbanc@in.tum.de>
parents:
2676
diff
changeset
|
282 |
shows "(p \<bullet> lookup2 Ts T) = lookup2 (p \<bullet> Ts) (p \<bullet> T)" |
747ebf2f066d
made eqvt-proof explicit in the function definitions
Christian Urban <urbanc@in.tum.de>
parents:
2676
diff
changeset
|
283 |
apply(induct Ts T rule: lookup2.induct) |
2676
028d5511c15f
some tryes about substitution over type-schemes
Christian Urban <urbanc@in.tum.de>
parents:
2634
diff
changeset
|
284 |
apply(simp_all) |
028d5511c15f
some tryes about substitution over type-schemes
Christian Urban <urbanc@in.tum.de>
parents:
2634
diff
changeset
|
285 |
done |
028d5511c15f
some tryes about substitution over type-schemes
Christian Urban <urbanc@in.tum.de>
parents:
2634
diff
changeset
|
286 |
|
2707
747ebf2f066d
made eqvt-proof explicit in the function definitions
Christian Urban <urbanc@in.tum.de>
parents:
2676
diff
changeset
|
287 |
nominal_primrec |
2676
028d5511c15f
some tryes about substitution over type-schemes
Christian Urban <urbanc@in.tum.de>
parents:
2634
diff
changeset
|
288 |
subst :: "(name \<times> ty2) list \<Rightarrow> ty2 \<Rightarrow> ty2" |
028d5511c15f
some tryes about substitution over type-schemes
Christian Urban <urbanc@in.tum.de>
parents:
2634
diff
changeset
|
289 |
where |
2707
747ebf2f066d
made eqvt-proof explicit in the function definitions
Christian Urban <urbanc@in.tum.de>
parents:
2676
diff
changeset
|
290 |
"subst \<theta> (Var2 X) = lookup2 \<theta> X" |
2676
028d5511c15f
some tryes about substitution over type-schemes
Christian Urban <urbanc@in.tum.de>
parents:
2634
diff
changeset
|
291 |
| "subst \<theta> (Fun2 T1 T2) = Fun2 (subst \<theta> T1) (subst \<theta> T2)" |
2707
747ebf2f066d
made eqvt-proof explicit in the function definitions
Christian Urban <urbanc@in.tum.de>
parents:
2676
diff
changeset
|
292 |
defer |
2676
028d5511c15f
some tryes about substitution over type-schemes
Christian Urban <urbanc@in.tum.de>
parents:
2634
diff
changeset
|
293 |
apply(case_tac x) |
028d5511c15f
some tryes about substitution over type-schemes
Christian Urban <urbanc@in.tum.de>
parents:
2634
diff
changeset
|
294 |
apply(simp) |
028d5511c15f
some tryes about substitution over type-schemes
Christian Urban <urbanc@in.tum.de>
parents:
2634
diff
changeset
|
295 |
apply(rule_tac y="b" in ty2.exhaust) |
028d5511c15f
some tryes about substitution over type-schemes
Christian Urban <urbanc@in.tum.de>
parents:
2634
diff
changeset
|
296 |
apply(blast) |
028d5511c15f
some tryes about substitution over type-schemes
Christian Urban <urbanc@in.tum.de>
parents:
2634
diff
changeset
|
297 |
apply(blast) |
028d5511c15f
some tryes about substitution over type-schemes
Christian Urban <urbanc@in.tum.de>
parents:
2634
diff
changeset
|
298 |
apply(simp_all add: ty2.distinct) |
028d5511c15f
some tryes about substitution over type-schemes
Christian Urban <urbanc@in.tum.de>
parents:
2634
diff
changeset
|
299 |
apply(simp add: ty2.eq_iff) |
028d5511c15f
some tryes about substitution over type-schemes
Christian Urban <urbanc@in.tum.de>
parents:
2634
diff
changeset
|
300 |
apply(simp add: ty2.eq_iff) |
2707
747ebf2f066d
made eqvt-proof explicit in the function definitions
Christian Urban <urbanc@in.tum.de>
parents:
2676
diff
changeset
|
301 |
apply(subgoal_tac "\<And>p x r. subst_graph x r \<Longrightarrow> subst_graph (p \<bullet> x) (p \<bullet> r)") |
747ebf2f066d
made eqvt-proof explicit in the function definitions
Christian Urban <urbanc@in.tum.de>
parents:
2676
diff
changeset
|
302 |
apply(simp add: eqvt_def) |
747ebf2f066d
made eqvt-proof explicit in the function definitions
Christian Urban <urbanc@in.tum.de>
parents:
2676
diff
changeset
|
303 |
apply(rule allI) |
747ebf2f066d
made eqvt-proof explicit in the function definitions
Christian Urban <urbanc@in.tum.de>
parents:
2676
diff
changeset
|
304 |
apply(simp add: permute_fun_def permute_bool_def) |
747ebf2f066d
made eqvt-proof explicit in the function definitions
Christian Urban <urbanc@in.tum.de>
parents:
2676
diff
changeset
|
305 |
apply(rule ext) |
747ebf2f066d
made eqvt-proof explicit in the function definitions
Christian Urban <urbanc@in.tum.de>
parents:
2676
diff
changeset
|
306 |
apply(rule ext) |
747ebf2f066d
made eqvt-proof explicit in the function definitions
Christian Urban <urbanc@in.tum.de>
parents:
2676
diff
changeset
|
307 |
apply(rule iffI) |
747ebf2f066d
made eqvt-proof explicit in the function definitions
Christian Urban <urbanc@in.tum.de>
parents:
2676
diff
changeset
|
308 |
apply(drule_tac x="p" in meta_spec) |
747ebf2f066d
made eqvt-proof explicit in the function definitions
Christian Urban <urbanc@in.tum.de>
parents:
2676
diff
changeset
|
309 |
apply(drule_tac x="- p \<bullet> x" in meta_spec) |
747ebf2f066d
made eqvt-proof explicit in the function definitions
Christian Urban <urbanc@in.tum.de>
parents:
2676
diff
changeset
|
310 |
apply(drule_tac x="- p \<bullet> xa" in meta_spec) |
747ebf2f066d
made eqvt-proof explicit in the function definitions
Christian Urban <urbanc@in.tum.de>
parents:
2676
diff
changeset
|
311 |
apply(simp) |
747ebf2f066d
made eqvt-proof explicit in the function definitions
Christian Urban <urbanc@in.tum.de>
parents:
2676
diff
changeset
|
312 |
apply(drule_tac x="-p" in meta_spec) |
747ebf2f066d
made eqvt-proof explicit in the function definitions
Christian Urban <urbanc@in.tum.de>
parents:
2676
diff
changeset
|
313 |
apply(drule_tac x="x" in meta_spec) |
747ebf2f066d
made eqvt-proof explicit in the function definitions
Christian Urban <urbanc@in.tum.de>
parents:
2676
diff
changeset
|
314 |
apply(drule_tac x="xa" in meta_spec) |
747ebf2f066d
made eqvt-proof explicit in the function definitions
Christian Urban <urbanc@in.tum.de>
parents:
2676
diff
changeset
|
315 |
apply(simp) |
747ebf2f066d
made eqvt-proof explicit in the function definitions
Christian Urban <urbanc@in.tum.de>
parents:
2676
diff
changeset
|
316 |
apply(erule subst_graph.induct) |
747ebf2f066d
made eqvt-proof explicit in the function definitions
Christian Urban <urbanc@in.tum.de>
parents:
2676
diff
changeset
|
317 |
apply(perm_simp) |
747ebf2f066d
made eqvt-proof explicit in the function definitions
Christian Urban <urbanc@in.tum.de>
parents:
2676
diff
changeset
|
318 |
apply(rule subst_graph.intros) |
747ebf2f066d
made eqvt-proof explicit in the function definitions
Christian Urban <urbanc@in.tum.de>
parents:
2676
diff
changeset
|
319 |
apply(perm_simp) |
747ebf2f066d
made eqvt-proof explicit in the function definitions
Christian Urban <urbanc@in.tum.de>
parents:
2676
diff
changeset
|
320 |
apply(rule subst_graph.intros) |
747ebf2f066d
made eqvt-proof explicit in the function definitions
Christian Urban <urbanc@in.tum.de>
parents:
2676
diff
changeset
|
321 |
apply(assumption) |
747ebf2f066d
made eqvt-proof explicit in the function definitions
Christian Urban <urbanc@in.tum.de>
parents:
2676
diff
changeset
|
322 |
apply(assumption) |
2676
028d5511c15f
some tryes about substitution over type-schemes
Christian Urban <urbanc@in.tum.de>
parents:
2634
diff
changeset
|
323 |
done |
028d5511c15f
some tryes about substitution over type-schemes
Christian Urban <urbanc@in.tum.de>
parents:
2634
diff
changeset
|
324 |
|
028d5511c15f
some tryes about substitution over type-schemes
Christian Urban <urbanc@in.tum.de>
parents:
2634
diff
changeset
|
325 |
termination |
028d5511c15f
some tryes about substitution over type-schemes
Christian Urban <urbanc@in.tum.de>
parents:
2634
diff
changeset
|
326 |
apply(relation "measure (size o snd)") |
028d5511c15f
some tryes about substitution over type-schemes
Christian Urban <urbanc@in.tum.de>
parents:
2634
diff
changeset
|
327 |
apply(simp_all add: ty2.size) |
028d5511c15f
some tryes about substitution over type-schemes
Christian Urban <urbanc@in.tum.de>
parents:
2634
diff
changeset
|
328 |
done |
028d5511c15f
some tryes about substitution over type-schemes
Christian Urban <urbanc@in.tum.de>
parents:
2634
diff
changeset
|
329 |
|
028d5511c15f
some tryes about substitution over type-schemes
Christian Urban <urbanc@in.tum.de>
parents:
2634
diff
changeset
|
330 |
lemma subst_eqvt[eqvt]: |
028d5511c15f
some tryes about substitution over type-schemes
Christian Urban <urbanc@in.tum.de>
parents:
2634
diff
changeset
|
331 |
shows "(p \<bullet> subst \<theta> T) = subst (p \<bullet> \<theta>) (p \<bullet> T)" |
028d5511c15f
some tryes about substitution over type-schemes
Christian Urban <urbanc@in.tum.de>
parents:
2634
diff
changeset
|
332 |
apply(induct \<theta> T rule: subst.induct) |
2707
747ebf2f066d
made eqvt-proof explicit in the function definitions
Christian Urban <urbanc@in.tum.de>
parents:
2676
diff
changeset
|
333 |
apply(simp_all add: lookup2_eqvt) |
2676
028d5511c15f
some tryes about substitution over type-schemes
Christian Urban <urbanc@in.tum.de>
parents:
2634
diff
changeset
|
334 |
done |
028d5511c15f
some tryes about substitution over type-schemes
Christian Urban <urbanc@in.tum.de>
parents:
2634
diff
changeset
|
335 |
|
028d5511c15f
some tryes about substitution over type-schemes
Christian Urban <urbanc@in.tum.de>
parents:
2634
diff
changeset
|
336 |
lemma j: |
028d5511c15f
some tryes about substitution over type-schemes
Christian Urban <urbanc@in.tum.de>
parents:
2634
diff
changeset
|
337 |
assumes "a \<sharp> Ts" " a \<sharp> X" |
2707
747ebf2f066d
made eqvt-proof explicit in the function definitions
Christian Urban <urbanc@in.tum.de>
parents:
2676
diff
changeset
|
338 |
shows "a \<sharp> lookup2 Ts X" |
2676
028d5511c15f
some tryes about substitution over type-schemes
Christian Urban <urbanc@in.tum.de>
parents:
2634
diff
changeset
|
339 |
using assms |
2707
747ebf2f066d
made eqvt-proof explicit in the function definitions
Christian Urban <urbanc@in.tum.de>
parents:
2676
diff
changeset
|
340 |
apply(induct Ts X rule: lookup2.induct) |
2676
028d5511c15f
some tryes about substitution over type-schemes
Christian Urban <urbanc@in.tum.de>
parents:
2634
diff
changeset
|
341 |
apply(auto simp add: ty2.fresh fresh_Cons fresh_Pair) |
028d5511c15f
some tryes about substitution over type-schemes
Christian Urban <urbanc@in.tum.de>
parents:
2634
diff
changeset
|
342 |
done |
028d5511c15f
some tryes about substitution over type-schemes
Christian Urban <urbanc@in.tum.de>
parents:
2634
diff
changeset
|
343 |
|
028d5511c15f
some tryes about substitution over type-schemes
Christian Urban <urbanc@in.tum.de>
parents:
2634
diff
changeset
|
344 |
lemma i: |
028d5511c15f
some tryes about substitution over type-schemes
Christian Urban <urbanc@in.tum.de>
parents:
2634
diff
changeset
|
345 |
assumes "a \<sharp> t" " a \<sharp> \<theta>" |
028d5511c15f
some tryes about substitution over type-schemes
Christian Urban <urbanc@in.tum.de>
parents:
2634
diff
changeset
|
346 |
shows "a \<sharp> subst \<theta> t" |
028d5511c15f
some tryes about substitution over type-schemes
Christian Urban <urbanc@in.tum.de>
parents:
2634
diff
changeset
|
347 |
using assms |
028d5511c15f
some tryes about substitution over type-schemes
Christian Urban <urbanc@in.tum.de>
parents:
2634
diff
changeset
|
348 |
apply(induct \<theta> t rule: subst.induct) |
028d5511c15f
some tryes about substitution over type-schemes
Christian Urban <urbanc@in.tum.de>
parents:
2634
diff
changeset
|
349 |
apply(auto simp add: ty2.fresh j) |
028d5511c15f
some tryes about substitution over type-schemes
Christian Urban <urbanc@in.tum.de>
parents:
2634
diff
changeset
|
350 |
done |
028d5511c15f
some tryes about substitution over type-schemes
Christian Urban <urbanc@in.tum.de>
parents:
2634
diff
changeset
|
351 |
|
028d5511c15f
some tryes about substitution over type-schemes
Christian Urban <urbanc@in.tum.de>
parents:
2634
diff
changeset
|
352 |
lemma k: |
028d5511c15f
some tryes about substitution over type-schemes
Christian Urban <urbanc@in.tum.de>
parents:
2634
diff
changeset
|
353 |
assumes "as \<sharp>* t" " as \<sharp>* \<theta>" |
028d5511c15f
some tryes about substitution over type-schemes
Christian Urban <urbanc@in.tum.de>
parents:
2634
diff
changeset
|
354 |
shows "as \<sharp>* subst \<theta> t" |
028d5511c15f
some tryes about substitution over type-schemes
Christian Urban <urbanc@in.tum.de>
parents:
2634
diff
changeset
|
355 |
using assms |
028d5511c15f
some tryes about substitution over type-schemes
Christian Urban <urbanc@in.tum.de>
parents:
2634
diff
changeset
|
356 |
by (simp add: fresh_star_def i) |
028d5511c15f
some tryes about substitution over type-schemes
Christian Urban <urbanc@in.tum.de>
parents:
2634
diff
changeset
|
357 |
|
028d5511c15f
some tryes about substitution over type-schemes
Christian Urban <urbanc@in.tum.de>
parents:
2634
diff
changeset
|
358 |
lemma h: |
028d5511c15f
some tryes about substitution over type-schemes
Christian Urban <urbanc@in.tum.de>
parents:
2634
diff
changeset
|
359 |
assumes "as \<subseteq> bs \<union> cs" |
028d5511c15f
some tryes about substitution over type-schemes
Christian Urban <urbanc@in.tum.de>
parents:
2634
diff
changeset
|
360 |
and " cs \<sharp>* x" |
028d5511c15f
some tryes about substitution over type-schemes
Christian Urban <urbanc@in.tum.de>
parents:
2634
diff
changeset
|
361 |
shows "(as - bs) \<sharp>* x" |
028d5511c15f
some tryes about substitution over type-schemes
Christian Urban <urbanc@in.tum.de>
parents:
2634
diff
changeset
|
362 |
using assms |
028d5511c15f
some tryes about substitution over type-schemes
Christian Urban <urbanc@in.tum.de>
parents:
2634
diff
changeset
|
363 |
by (auto simp add: fresh_star_def) |
028d5511c15f
some tryes about substitution over type-schemes
Christian Urban <urbanc@in.tum.de>
parents:
2634
diff
changeset
|
364 |
|
028d5511c15f
some tryes about substitution over type-schemes
Christian Urban <urbanc@in.tum.de>
parents:
2634
diff
changeset
|
365 |
nominal_primrec |
028d5511c15f
some tryes about substitution over type-schemes
Christian Urban <urbanc@in.tum.de>
parents:
2634
diff
changeset
|
366 |
substs :: "(name \<times> ty2) list \<Rightarrow> tys2 \<Rightarrow> tys2" |
028d5511c15f
some tryes about substitution over type-schemes
Christian Urban <urbanc@in.tum.de>
parents:
2634
diff
changeset
|
367 |
where |
028d5511c15f
some tryes about substitution over type-schemes
Christian Urban <urbanc@in.tum.de>
parents:
2634
diff
changeset
|
368 |
"fset (map_fset atom xs) \<sharp>* \<theta> \<Longrightarrow> substs \<theta> (All2 xs t) = All2 xs (subst \<theta> t)" |
028d5511c15f
some tryes about substitution over type-schemes
Christian Urban <urbanc@in.tum.de>
parents:
2634
diff
changeset
|
369 |
oops |
028d5511c15f
some tryes about substitution over type-schemes
Christian Urban <urbanc@in.tum.de>
parents:
2634
diff
changeset
|
370 |
|
028d5511c15f
some tryes about substitution over type-schemes
Christian Urban <urbanc@in.tum.de>
parents:
2634
diff
changeset
|
371 |
|
028d5511c15f
some tryes about substitution over type-schemes
Christian Urban <urbanc@in.tum.de>
parents:
2634
diff
changeset
|
372 |
text {* Some Tests about Alpha-Equality *} |
1795 | 373 |
|
374 |
lemma |
|
375 |
shows "All {|a, b|} (Fun (Var a) (Var b)) = All {|b, a|} (Fun (Var a) (Var b))" |
|
2676
028d5511c15f
some tryes about substitution over type-schemes
Christian Urban <urbanc@in.tum.de>
parents:
2634
diff
changeset
|
376 |
apply(simp add: ty_tys.eq_iff Abs_eq_iff) |
1795 | 377 |
apply(rule_tac x="0::perm" in exI) |
2676
028d5511c15f
some tryes about substitution over type-schemes
Christian Urban <urbanc@in.tum.de>
parents:
2634
diff
changeset
|
378 |
apply(simp add: alphas fresh_star_def ty_tys.supp supp_at_base) |
1795 | 379 |
done |
380 |
||
381 |
lemma |
|
382 |
shows "All {|a, b|} (Fun (Var a) (Var b)) = All {|a, b|} (Fun (Var b) (Var a))" |
|
2566
a59d8e1e3a17
moved rest of the lemmas from Nominal2_FSet to the TypeScheme example
Christian Urban <urbanc@in.tum.de>
parents:
2556
diff
changeset
|
383 |
apply(simp add: ty_tys.eq_iff Abs_eq_iff) |
1795 | 384 |
apply(rule_tac x="(atom a \<rightleftharpoons> atom b)" in exI) |
2566
a59d8e1e3a17
moved rest of the lemmas from Nominal2_FSet to the TypeScheme example
Christian Urban <urbanc@in.tum.de>
parents:
2556
diff
changeset
|
385 |
apply(simp add: alphas fresh_star_def supp_at_base ty_tys.supp) |
1795 | 386 |
done |
387 |
||
388 |
lemma |
|
389 |
shows "All {|a, b, c|} (Fun (Var a) (Var b)) = All {|a, b|} (Fun (Var a) (Var b))" |
|
2566
a59d8e1e3a17
moved rest of the lemmas from Nominal2_FSet to the TypeScheme example
Christian Urban <urbanc@in.tum.de>
parents:
2556
diff
changeset
|
390 |
apply(simp add: ty_tys.eq_iff Abs_eq_iff) |
1795 | 391 |
apply(rule_tac x="0::perm" in exI) |
2566
a59d8e1e3a17
moved rest of the lemmas from Nominal2_FSet to the TypeScheme example
Christian Urban <urbanc@in.tum.de>
parents:
2556
diff
changeset
|
392 |
apply(simp add: alphas fresh_star_def ty_tys.supp supp_at_base) |
1795 | 393 |
done |
394 |
||
395 |
lemma |
|
396 |
assumes a: "a \<noteq> b" |
|
397 |
shows "\<not>(All {|a, b|} (Fun (Var a) (Var b)) = All {|c|} (Fun (Var c) (Var c)))" |
|
398 |
using a |
|
2566
a59d8e1e3a17
moved rest of the lemmas from Nominal2_FSet to the TypeScheme example
Christian Urban <urbanc@in.tum.de>
parents:
2556
diff
changeset
|
399 |
apply(simp add: ty_tys.eq_iff Abs_eq_iff) |
1795 | 400 |
apply(clarify) |
2566
a59d8e1e3a17
moved rest of the lemmas from Nominal2_FSet to the TypeScheme example
Christian Urban <urbanc@in.tum.de>
parents:
2556
diff
changeset
|
401 |
apply(simp add: alphas fresh_star_def ty_tys.eq_iff ty_tys.supp supp_at_base) |
1795 | 402 |
apply auto |
403 |
done |
|
404 |
||
2566
a59d8e1e3a17
moved rest of the lemmas from Nominal2_FSet to the TypeScheme example
Christian Urban <urbanc@in.tum.de>
parents:
2556
diff
changeset
|
405 |
|
1795 | 406 |
|
407 |
||
408 |
end |