author | Christian Urban <urbanc@in.tum.de> |
Sun, 08 Aug 2010 10:12:38 +0800 | |
changeset 2392 | 9294d7cec5e2 |
parent 2337 | b151399bd2c3 |
child 2424 | 621ebd8b13c4 |
permissions | -rw-r--r-- |
1795 | 1 |
theory TypeSchemes |
2040
94e24da9ae75
Move TypeSchemes to NewParser
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1933
diff
changeset
|
2 |
imports "../NewParser" |
1795 | 3 |
begin |
4 |
||
5 |
section {*** Type Schemes ***} |
|
6 |
||
7 |
atom_decl name |
|
2337
b151399bd2c3
fixed according to changes in quotient
Christian Urban <urbanc@in.tum.de>
parents:
2308
diff
changeset
|
8 |
|
b151399bd2c3
fixed according to changes in quotient
Christian Urban <urbanc@in.tum.de>
parents:
2308
diff
changeset
|
9 |
declare [[STEPS = 15]] |
1795 | 10 |
|
11 |
nominal_datatype ty = |
|
12 |
Var "name" |
|
13 |
| Fun "ty" "ty" |
|
14 |
and tys = |
|
2040
94e24da9ae75
Move TypeSchemes to NewParser
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1933
diff
changeset
|
15 |
All xs::"name fset" ty::"ty" bind_res xs in ty |
1795 | 16 |
|
2308
387fcbd33820
fixed problem with bn_info
Christian Urban <urbanc@in.tum.de>
parents:
2181
diff
changeset
|
17 |
nominal_datatype ty2 = |
387fcbd33820
fixed problem with bn_info
Christian Urban <urbanc@in.tum.de>
parents:
2181
diff
changeset
|
18 |
Var2 "name" |
387fcbd33820
fixed problem with bn_info
Christian Urban <urbanc@in.tum.de>
parents:
2181
diff
changeset
|
19 |
| Fun2 "ty2" "ty2" |
387fcbd33820
fixed problem with bn_info
Christian Urban <urbanc@in.tum.de>
parents:
2181
diff
changeset
|
20 |
|
2337
b151399bd2c3
fixed according to changes in quotient
Christian Urban <urbanc@in.tum.de>
parents:
2308
diff
changeset
|
21 |
instance ty2 :: pt sorry |
b151399bd2c3
fixed according to changes in quotient
Christian Urban <urbanc@in.tum.de>
parents:
2308
diff
changeset
|
22 |
|
2308
387fcbd33820
fixed problem with bn_info
Christian Urban <urbanc@in.tum.de>
parents:
2181
diff
changeset
|
23 |
nominal_datatype tys2 = |
387fcbd33820
fixed problem with bn_info
Christian Urban <urbanc@in.tum.de>
parents:
2181
diff
changeset
|
24 |
All2 xs::"name fset" ty::"ty2" bind_res xs in ty |
2337
b151399bd2c3
fixed according to changes in quotient
Christian Urban <urbanc@in.tum.de>
parents:
2308
diff
changeset
|
25 |
|
2308
387fcbd33820
fixed problem with bn_info
Christian Urban <urbanc@in.tum.de>
parents:
2181
diff
changeset
|
26 |
|
1795 | 27 |
lemmas ty_tys_supp = ty_tys.fv[simplified ty_tys.supp] |
28 |
||
2082
0854af516f14
cleaned up a bit the examples; added equivariance to all examples
Christian Urban <urbanc@in.tum.de>
parents:
2040
diff
changeset
|
29 |
|
0854af516f14
cleaned up a bit the examples; added equivariance to all examples
Christian Urban <urbanc@in.tum.de>
parents:
2040
diff
changeset
|
30 |
|
1795 | 31 |
(* below we define manually the function for size *) |
32 |
||
33 |
lemma size_eqvt_raw: |
|
34 |
"size (pi \<bullet> t :: ty_raw) = size t" |
|
35 |
"size (pi \<bullet> ts :: tys_raw) = size ts" |
|
36 |
apply (induct rule: ty_raw_tys_raw.inducts) |
|
37 |
apply simp_all |
|
38 |
done |
|
39 |
||
40 |
instantiation ty and tys :: size |
|
41 |
begin |
|
42 |
||
43 |
quotient_definition |
|
44 |
"size_ty :: ty \<Rightarrow> nat" |
|
45 |
is |
|
46 |
"size :: ty_raw \<Rightarrow> nat" |
|
47 |
||
48 |
quotient_definition |
|
49 |
"size_tys :: tys \<Rightarrow> nat" |
|
50 |
is |
|
51 |
"size :: tys_raw \<Rightarrow> nat" |
|
52 |
||
53 |
lemma size_rsp: |
|
54 |
"alpha_ty_raw x y \<Longrightarrow> size x = size y" |
|
55 |
"alpha_tys_raw a b \<Longrightarrow> size a = size b" |
|
56 |
apply (induct rule: alpha_ty_raw_alpha_tys_raw.inducts) |
|
57 |
apply (simp_all only: ty_raw_tys_raw.size) |
|
58 |
apply (simp_all only: alphas) |
|
59 |
apply clarify |
|
60 |
apply (simp_all only: size_eqvt_raw) |
|
61 |
done |
|
62 |
||
63 |
lemma [quot_respect]: |
|
64 |
"(alpha_ty_raw ===> op =) size size" |
|
65 |
"(alpha_tys_raw ===> op =) size size" |
|
66 |
by (simp_all add: size_rsp) |
|
67 |
||
68 |
lemma [quot_preserve]: |
|
69 |
"(rep_ty ---> id) size = size" |
|
70 |
"(rep_tys ---> id) size = size" |
|
71 |
by (simp_all add: size_ty_def size_tys_def) |
|
72 |
||
73 |
instance |
|
74 |
by default |
|
75 |
||
76 |
end |
|
77 |
||
78 |
thm ty_raw_tys_raw.size(4)[quot_lifted] |
|
79 |
thm ty_raw_tys_raw.size(5)[quot_lifted] |
|
80 |
thm ty_raw_tys_raw.size(6)[quot_lifted] |
|
81 |
||
82 |
||
83 |
thm ty_tys.fv |
|
84 |
thm ty_tys.eq_iff |
|
85 |
thm ty_tys.bn |
|
86 |
thm ty_tys.perm |
|
87 |
thm ty_tys.inducts |
|
88 |
thm ty_tys.distinct |
|
89 |
||
90 |
ML {* Sign.of_sort @{theory} (@{typ ty}, @{sort fs}) *} |
|
91 |
||
92 |
lemma strong_induct: |
|
93 |
assumes a1: "\<And>name b. P b (Var name)" |
|
94 |
and a2: "\<And>t1 t2 b. \<lbrakk>\<And>c. P c t1; \<And>c. P c t2\<rbrakk> \<Longrightarrow> P b (Fun t1 t2)" |
|
95 |
and a3: "\<And>fset t b. \<lbrakk>\<And>c. P c t; fset_to_set (fmap atom fset) \<sharp>* b\<rbrakk> \<Longrightarrow> P' b (All fset t)" |
|
96 |
shows "P (a :: 'a :: pt) t \<and> P' (d :: 'b :: {fs}) ts " |
|
97 |
proof - |
|
98 |
have " (\<forall>p a. P a (p \<bullet> t)) \<and> (\<forall>p d. P' d (p \<bullet> ts))" |
|
99 |
apply (rule ty_tys.induct) |
|
100 |
apply (simp add: a1) |
|
101 |
apply (simp) |
|
102 |
apply (rule allI)+ |
|
103 |
apply (rule a2) |
|
104 |
apply simp |
|
105 |
apply simp |
|
106 |
apply (rule allI) |
|
107 |
apply (rule allI) |
|
108 |
apply(subgoal_tac "\<exists>pa. ((pa \<bullet> (fset_to_set (fmap atom (p \<bullet> fset)))) \<sharp>* d \<and> supp (p \<bullet> All fset ty) \<sharp>* pa)") |
|
109 |
apply clarify |
|
110 |
apply(rule_tac t="p \<bullet> All fset ty" and |
|
111 |
s="pa \<bullet> (p \<bullet> All fset ty)" in subst) |
|
112 |
apply (rule supp_perm_eq) |
|
113 |
apply assumption |
|
114 |
apply (simp only: ty_tys.perm) |
|
115 |
apply (rule a3) |
|
116 |
apply(erule_tac x="(pa + p)" in allE) |
|
117 |
apply simp |
|
118 |
apply (simp add: eqvts eqvts_raw) |
|
119 |
apply (rule at_set_avoiding2) |
|
120 |
apply (simp add: fin_fset_to_set) |
|
121 |
apply (simp add: finite_supp) |
|
122 |
apply (simp add: eqvts finite_supp) |
|
1933
9eab1dfc14d2
moved lemmas from FSet.thy to do with atom to Nominal2_Base, and to do with 'a::at set to Nominal2_Atoms; moved Nominal2_Eqvt.thy one up to be loaded before Nominal2_Atoms
Christian Urban <urbanc@in.tum.de>
parents:
1795
diff
changeset
|
123 |
apply (rule_tac p=" -p" in permute_boolE) |
9eab1dfc14d2
moved lemmas from FSet.thy to do with atom to Nominal2_Base, and to do with 'a::at set to Nominal2_Atoms; moved Nominal2_Eqvt.thy one up to be loaded before Nominal2_Atoms
Christian Urban <urbanc@in.tum.de>
parents:
1795
diff
changeset
|
124 |
apply(simp add: eqvts) |
9eab1dfc14d2
moved lemmas from FSet.thy to do with atom to Nominal2_Base, and to do with 'a::at set to Nominal2_Atoms; moved Nominal2_Eqvt.thy one up to be loaded before Nominal2_Atoms
Christian Urban <urbanc@in.tum.de>
parents:
1795
diff
changeset
|
125 |
apply(simp add: permute_fun_def atom_eqvt) |
1795 | 126 |
apply (simp add: fresh_star_def) |
127 |
apply clarify |
|
128 |
apply (simp add: fresh_def) |
|
129 |
apply (simp add: ty_tys_supp) |
|
130 |
done |
|
131 |
then have "P a (0 \<bullet> t) \<and> P' d (0 \<bullet> ts)" by blast |
|
132 |
then show ?thesis by simp |
|
133 |
qed |
|
134 |
||
135 |
lemma |
|
136 |
shows "All {|a, b|} (Fun (Var a) (Var b)) = All {|b, a|} (Fun (Var a) (Var b))" |
|
137 |
apply(simp add: ty_tys.eq_iff) |
|
138 |
apply(rule_tac x="0::perm" in exI) |
|
139 |
apply(simp add: alphas) |
|
2040
94e24da9ae75
Move TypeSchemes to NewParser
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1933
diff
changeset
|
140 |
apply(simp add: fresh_star_def fresh_zero_perm supp_at_base) |
1795 | 141 |
done |
142 |
||
143 |
lemma |
|
144 |
shows "All {|a, b|} (Fun (Var a) (Var b)) = All {|a, b|} (Fun (Var b) (Var a))" |
|
145 |
apply(simp add: ty_tys.eq_iff) |
|
146 |
apply(rule_tac x="(atom a \<rightleftharpoons> atom b)" in exI) |
|
2040
94e24da9ae75
Move TypeSchemes to NewParser
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1933
diff
changeset
|
147 |
apply(simp add: alphas fresh_star_def eqvts supp_at_base) |
1795 | 148 |
done |
149 |
||
150 |
lemma |
|
151 |
shows "All {|a, b, c|} (Fun (Var a) (Var b)) = All {|a, b|} (Fun (Var a) (Var b))" |
|
152 |
apply(simp add: ty_tys.eq_iff) |
|
153 |
apply(rule_tac x="0::perm" in exI) |
|
2040
94e24da9ae75
Move TypeSchemes to NewParser
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1933
diff
changeset
|
154 |
apply(simp add: alphas fresh_star_def eqvts ty_tys.eq_iff supp_at_base) |
1795 | 155 |
done |
156 |
||
157 |
lemma |
|
158 |
assumes a: "a \<noteq> b" |
|
159 |
shows "\<not>(All {|a, b|} (Fun (Var a) (Var b)) = All {|c|} (Fun (Var c) (Var c)))" |
|
160 |
using a |
|
161 |
apply(simp add: ty_tys.eq_iff) |
|
162 |
apply(clarify) |
|
2040
94e24da9ae75
Move TypeSchemes to NewParser
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1933
diff
changeset
|
163 |
apply(simp add: alphas fresh_star_def eqvts ty_tys.eq_iff supp_at_base) |
1795 | 164 |
apply auto |
165 |
done |
|
166 |
||
2179
7687f97eca53
A lemma about substitution in TypeSchemes.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
2120
diff
changeset
|
167 |
fun |
7687f97eca53
A lemma about substitution in TypeSchemes.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
2120
diff
changeset
|
168 |
lookup :: "(name \<times> ty) list \<Rightarrow> name \<Rightarrow> ty" |
7687f97eca53
A lemma about substitution in TypeSchemes.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
2120
diff
changeset
|
169 |
where |
7687f97eca53
A lemma about substitution in TypeSchemes.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
2120
diff
changeset
|
170 |
"lookup [] n = Var n" |
7687f97eca53
A lemma about substitution in TypeSchemes.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
2120
diff
changeset
|
171 |
| "lookup ((p, s) # t) n = (if p = n then s else lookup t n)" |
7687f97eca53
A lemma about substitution in TypeSchemes.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
2120
diff
changeset
|
172 |
|
7687f97eca53
A lemma about substitution in TypeSchemes.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
2120
diff
changeset
|
173 |
locale subst_loc = |
7687f97eca53
A lemma about substitution in TypeSchemes.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
2120
diff
changeset
|
174 |
fixes |
7687f97eca53
A lemma about substitution in TypeSchemes.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
2120
diff
changeset
|
175 |
subst :: "(name \<times> ty) list \<Rightarrow> ty \<Rightarrow> ty" |
7687f97eca53
A lemma about substitution in TypeSchemes.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
2120
diff
changeset
|
176 |
and substs :: "(name \<times> ty) list \<Rightarrow> tys \<Rightarrow> tys" |
7687f97eca53
A lemma about substitution in TypeSchemes.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
2120
diff
changeset
|
177 |
assumes |
7687f97eca53
A lemma about substitution in TypeSchemes.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
2120
diff
changeset
|
178 |
s1: "subst \<theta> (Var n) = lookup \<theta> n" |
7687f97eca53
A lemma about substitution in TypeSchemes.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
2120
diff
changeset
|
179 |
and s2: "subst \<theta> (Fun l r) = Fun (subst \<theta> l) (subst \<theta> r)" |
7687f97eca53
A lemma about substitution in TypeSchemes.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
2120
diff
changeset
|
180 |
and s3: "fset_to_set (fmap atom xs) \<sharp>* \<theta> \<Longrightarrow> substs \<theta> (All xs t) = All xs (subst \<theta> t)" |
7687f97eca53
A lemma about substitution in TypeSchemes.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
2120
diff
changeset
|
181 |
begin |
7687f97eca53
A lemma about substitution in TypeSchemes.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
2120
diff
changeset
|
182 |
|
7687f97eca53
A lemma about substitution in TypeSchemes.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
2120
diff
changeset
|
183 |
lemma subst_ty: |
7687f97eca53
A lemma about substitution in TypeSchemes.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
2120
diff
changeset
|
184 |
assumes x: "atom x \<sharp> t" |
7687f97eca53
A lemma about substitution in TypeSchemes.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
2120
diff
changeset
|
185 |
shows "subst [(x, S)] t = t" |
7687f97eca53
A lemma about substitution in TypeSchemes.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
2120
diff
changeset
|
186 |
using x |
7687f97eca53
A lemma about substitution in TypeSchemes.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
2120
diff
changeset
|
187 |
apply (induct t rule: ty_tys.induct[of _ "\<lambda>t. True" _ , simplified]) |
7687f97eca53
A lemma about substitution in TypeSchemes.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
2120
diff
changeset
|
188 |
by (simp_all add: s1 s2 fresh_def ty_tys.fv[simplified ty_tys.supp] supp_at_base) |
7687f97eca53
A lemma about substitution in TypeSchemes.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
2120
diff
changeset
|
189 |
|
7687f97eca53
A lemma about substitution in TypeSchemes.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
2120
diff
changeset
|
190 |
lemma subst_tyS: |
7687f97eca53
A lemma about substitution in TypeSchemes.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
2120
diff
changeset
|
191 |
shows "atom x \<sharp> T \<longrightarrow> substs [(x, S)] T = T" |
7687f97eca53
A lemma about substitution in TypeSchemes.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
2120
diff
changeset
|
192 |
apply (rule strong_induct[of |
2180 | 193 |
"\<lambda>a t. True" "\<lambda>(x, S) T. (atom x \<sharp> T \<longrightarrow> substs [(x, S)] T = T)" _ "t" "(x, S)", simplified]) |
194 |
apply clarify |
|
2179
7687f97eca53
A lemma about substitution in TypeSchemes.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
2120
diff
changeset
|
195 |
apply (subst s3) |
7687f97eca53
A lemma about substitution in TypeSchemes.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
2120
diff
changeset
|
196 |
apply (simp add: fresh_star_def fresh_Cons fresh_Nil) |
7687f97eca53
A lemma about substitution in TypeSchemes.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
2120
diff
changeset
|
197 |
apply (subst subst_ty) |
2180 | 198 |
apply (simp_all add: fresh_star_prod_elim) |
2179
7687f97eca53
A lemma about substitution in TypeSchemes.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
2120
diff
changeset
|
199 |
apply (drule fresh_star_atom) |
2180 | 200 |
apply (simp add: fresh_def ty_tys.fv[simplified ty_tys.supp]) |
201 |
apply (subgoal_tac "atom a \<notin> fset_to_set (fmap atom fset)") |
|
2179
7687f97eca53
A lemma about substitution in TypeSchemes.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
2120
diff
changeset
|
202 |
apply blast |
7687f97eca53
A lemma about substitution in TypeSchemes.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
2120
diff
changeset
|
203 |
apply (metis supp_finite_atom_set finite_fset) |
7687f97eca53
A lemma about substitution in TypeSchemes.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
2120
diff
changeset
|
204 |
done |
7687f97eca53
A lemma about substitution in TypeSchemes.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
2120
diff
changeset
|
205 |
|
2181
b997c22805ae
Substitution Lemma for TypeSchemes.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
2180
diff
changeset
|
206 |
lemma subst_lemma_pre: |
b997c22805ae
Substitution Lemma for TypeSchemes.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
2180
diff
changeset
|
207 |
"z \<sharp> (N,L) \<longrightarrow> z \<sharp> (subst [(y, L)] N)" |
b997c22805ae
Substitution Lemma for TypeSchemes.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
2180
diff
changeset
|
208 |
apply (induct N rule: ty_tys.induct[of _ "\<lambda>t. True" _ , simplified]) |
b997c22805ae
Substitution Lemma for TypeSchemes.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
2180
diff
changeset
|
209 |
apply (simp add: s1) |
b997c22805ae
Substitution Lemma for TypeSchemes.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
2180
diff
changeset
|
210 |
apply (auto simp add: fresh_Pair) |
b997c22805ae
Substitution Lemma for TypeSchemes.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
2180
diff
changeset
|
211 |
apply (auto simp add: fresh_def ty_tys.fv[simplified ty_tys.supp])[3] |
b997c22805ae
Substitution Lemma for TypeSchemes.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
2180
diff
changeset
|
212 |
apply (simp add: s2) |
b997c22805ae
Substitution Lemma for TypeSchemes.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
2180
diff
changeset
|
213 |
apply (auto simp add: fresh_def ty_tys.fv[simplified ty_tys.supp]) |
b997c22805ae
Substitution Lemma for TypeSchemes.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
2180
diff
changeset
|
214 |
done |
b997c22805ae
Substitution Lemma for TypeSchemes.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
2180
diff
changeset
|
215 |
|
b997c22805ae
Substitution Lemma for TypeSchemes.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
2180
diff
changeset
|
216 |
lemma substs_lemma_pre: |
b997c22805ae
Substitution Lemma for TypeSchemes.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
2180
diff
changeset
|
217 |
"atom z \<sharp> (N,L) \<longrightarrow> atom z \<sharp> (substs [(y, L)] N)" |
b997c22805ae
Substitution Lemma for TypeSchemes.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
2180
diff
changeset
|
218 |
apply (rule strong_induct[of |
b997c22805ae
Substitution Lemma for TypeSchemes.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
2180
diff
changeset
|
219 |
"\<lambda>a t. True" "\<lambda>(z, y, L) N. (atom z \<sharp> (N, L) \<longrightarrow> atom z \<sharp> (substs [(y, L)] N))" _ _ "(z, y, L)", simplified]) |
b997c22805ae
Substitution Lemma for TypeSchemes.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
2180
diff
changeset
|
220 |
apply clarify |
b997c22805ae
Substitution Lemma for TypeSchemes.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
2180
diff
changeset
|
221 |
apply (subst s3) |
b997c22805ae
Substitution Lemma for TypeSchemes.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
2180
diff
changeset
|
222 |
apply (simp add: fresh_star_def fresh_Cons fresh_Nil fresh_Pair) |
b997c22805ae
Substitution Lemma for TypeSchemes.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
2180
diff
changeset
|
223 |
apply (simp_all add: fresh_star_prod_elim fresh_Pair) |
b997c22805ae
Substitution Lemma for TypeSchemes.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
2180
diff
changeset
|
224 |
apply clarify |
b997c22805ae
Substitution Lemma for TypeSchemes.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
2180
diff
changeset
|
225 |
apply (drule fresh_star_atom) |
b997c22805ae
Substitution Lemma for TypeSchemes.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
2180
diff
changeset
|
226 |
apply (drule fresh_star_atom) |
b997c22805ae
Substitution Lemma for TypeSchemes.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
2180
diff
changeset
|
227 |
apply (simp add: fresh_def) |
b997c22805ae
Substitution Lemma for TypeSchemes.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
2180
diff
changeset
|
228 |
apply (simp only: ty_tys.fv[simplified ty_tys.supp]) |
b997c22805ae
Substitution Lemma for TypeSchemes.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
2180
diff
changeset
|
229 |
apply (subgoal_tac "atom a \<notin> supp (subst [(aa, b)] t)") |
b997c22805ae
Substitution Lemma for TypeSchemes.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
2180
diff
changeset
|
230 |
apply blast |
b997c22805ae
Substitution Lemma for TypeSchemes.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
2180
diff
changeset
|
231 |
apply (subgoal_tac "atom a \<notin> supp t") |
b997c22805ae
Substitution Lemma for TypeSchemes.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
2180
diff
changeset
|
232 |
apply (fold fresh_def)[1] |
b997c22805ae
Substitution Lemma for TypeSchemes.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
2180
diff
changeset
|
233 |
apply (rule mp[OF subst_lemma_pre]) |
b997c22805ae
Substitution Lemma for TypeSchemes.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
2180
diff
changeset
|
234 |
apply (simp add: fresh_Pair) |
b997c22805ae
Substitution Lemma for TypeSchemes.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
2180
diff
changeset
|
235 |
apply (subgoal_tac "atom a \<notin> (fset_to_set (fmap atom fset))") |
b997c22805ae
Substitution Lemma for TypeSchemes.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
2180
diff
changeset
|
236 |
apply blast |
b997c22805ae
Substitution Lemma for TypeSchemes.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
2180
diff
changeset
|
237 |
apply (metis supp_finite_atom_set finite_fset) |
b997c22805ae
Substitution Lemma for TypeSchemes.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
2180
diff
changeset
|
238 |
done |
b997c22805ae
Substitution Lemma for TypeSchemes.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
2180
diff
changeset
|
239 |
|
b997c22805ae
Substitution Lemma for TypeSchemes.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
2180
diff
changeset
|
240 |
lemma subst_lemma: |
b997c22805ae
Substitution Lemma for TypeSchemes.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
2180
diff
changeset
|
241 |
shows "x \<noteq> y \<and> atom x \<sharp> L \<longrightarrow> |
b997c22805ae
Substitution Lemma for TypeSchemes.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
2180
diff
changeset
|
242 |
subst [(y, L)] (subst [(x, N)] M) = |
b997c22805ae
Substitution Lemma for TypeSchemes.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
2180
diff
changeset
|
243 |
subst [(x, (subst [(y, L)] N))] (subst [(y, L)] M)" |
b997c22805ae
Substitution Lemma for TypeSchemes.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
2180
diff
changeset
|
244 |
apply (induct M rule: ty_tys.induct[of _ "\<lambda>t. True" _ , simplified]) |
b997c22805ae
Substitution Lemma for TypeSchemes.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
2180
diff
changeset
|
245 |
apply (simp_all add: s1 s2) |
b997c22805ae
Substitution Lemma for TypeSchemes.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
2180
diff
changeset
|
246 |
apply clarify |
b997c22805ae
Substitution Lemma for TypeSchemes.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
2180
diff
changeset
|
247 |
apply (subst (2) subst_ty) |
b997c22805ae
Substitution Lemma for TypeSchemes.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
2180
diff
changeset
|
248 |
apply simp_all |
b997c22805ae
Substitution Lemma for TypeSchemes.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
2180
diff
changeset
|
249 |
done |
b997c22805ae
Substitution Lemma for TypeSchemes.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
2180
diff
changeset
|
250 |
|
b997c22805ae
Substitution Lemma for TypeSchemes.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
2180
diff
changeset
|
251 |
lemma substs_lemma: |
b997c22805ae
Substitution Lemma for TypeSchemes.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
2180
diff
changeset
|
252 |
shows "x \<noteq> y \<and> atom x \<sharp> L \<longrightarrow> |
b997c22805ae
Substitution Lemma for TypeSchemes.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
2180
diff
changeset
|
253 |
substs [(y, L)] (substs [(x, N)] M) = |
b997c22805ae
Substitution Lemma for TypeSchemes.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
2180
diff
changeset
|
254 |
substs [(x, (subst [(y, L)] N))] (substs [(y, L)] M)" |
b997c22805ae
Substitution Lemma for TypeSchemes.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
2180
diff
changeset
|
255 |
apply (rule strong_induct[of |
b997c22805ae
Substitution Lemma for TypeSchemes.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
2180
diff
changeset
|
256 |
"\<lambda>a t. True" "\<lambda>(x, y, N, L) M. x \<noteq> y \<and> atom x \<sharp> L \<longrightarrow> |
b997c22805ae
Substitution Lemma for TypeSchemes.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
2180
diff
changeset
|
257 |
substs [(y, L)] (substs [(x, N)] M) = |
b997c22805ae
Substitution Lemma for TypeSchemes.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
2180
diff
changeset
|
258 |
substs [(x, (subst [(y, L)] N))] (substs [(y, L)] M)" _ _ "(x, y, N, L)", simplified]) |
b997c22805ae
Substitution Lemma for TypeSchemes.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
2180
diff
changeset
|
259 |
apply clarify |
b997c22805ae
Substitution Lemma for TypeSchemes.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
2180
diff
changeset
|
260 |
apply (simp_all add: fresh_star_prod_elim fresh_Pair) |
b997c22805ae
Substitution Lemma for TypeSchemes.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
2180
diff
changeset
|
261 |
apply (subst s3) |
b997c22805ae
Substitution Lemma for TypeSchemes.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
2180
diff
changeset
|
262 |
apply (unfold fresh_star_def)[1] |
b997c22805ae
Substitution Lemma for TypeSchemes.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
2180
diff
changeset
|
263 |
apply (simp add: fresh_Cons fresh_Nil fresh_Pair) |
b997c22805ae
Substitution Lemma for TypeSchemes.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
2180
diff
changeset
|
264 |
apply (subst s3) |
b997c22805ae
Substitution Lemma for TypeSchemes.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
2180
diff
changeset
|
265 |
apply (unfold fresh_star_def)[1] |
b997c22805ae
Substitution Lemma for TypeSchemes.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
2180
diff
changeset
|
266 |
apply (simp add: fresh_Cons fresh_Nil fresh_Pair) |
b997c22805ae
Substitution Lemma for TypeSchemes.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
2180
diff
changeset
|
267 |
apply (subst s3) |
b997c22805ae
Substitution Lemma for TypeSchemes.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
2180
diff
changeset
|
268 |
apply (unfold fresh_star_def)[1] |
b997c22805ae
Substitution Lemma for TypeSchemes.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
2180
diff
changeset
|
269 |
apply (simp add: fresh_Cons fresh_Nil fresh_Pair) |
b997c22805ae
Substitution Lemma for TypeSchemes.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
2180
diff
changeset
|
270 |
apply (subst s3) |
b997c22805ae
Substitution Lemma for TypeSchemes.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
2180
diff
changeset
|
271 |
apply (unfold fresh_star_def)[1] |
b997c22805ae
Substitution Lemma for TypeSchemes.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
2180
diff
changeset
|
272 |
apply (simp add: fresh_Cons fresh_Nil fresh_Pair) |
b997c22805ae
Substitution Lemma for TypeSchemes.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
2180
diff
changeset
|
273 |
apply (rule ballI) |
b997c22805ae
Substitution Lemma for TypeSchemes.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
2180
diff
changeset
|
274 |
apply (rule mp[OF subst_lemma_pre]) |
b997c22805ae
Substitution Lemma for TypeSchemes.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
2180
diff
changeset
|
275 |
apply (simp add: fresh_Pair) |
b997c22805ae
Substitution Lemma for TypeSchemes.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
2180
diff
changeset
|
276 |
apply (subst subst_lemma) |
b997c22805ae
Substitution Lemma for TypeSchemes.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
2180
diff
changeset
|
277 |
apply simp_all |
b997c22805ae
Substitution Lemma for TypeSchemes.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
2180
diff
changeset
|
278 |
done |
b997c22805ae
Substitution Lemma for TypeSchemes.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
2180
diff
changeset
|
279 |
|
2179
7687f97eca53
A lemma about substitution in TypeSchemes.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
2120
diff
changeset
|
280 |
end |
7687f97eca53
A lemma about substitution in TypeSchemes.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
2120
diff
changeset
|
281 |
|
1795 | 282 |
(* PROBLEM: |
283 |
Type schemes with separate datatypes |
|
284 |
||
285 |
nominal_datatype T = |
|
286 |
TVar "name" |
|
287 |
| TFun "T" "T" |
|
288 |
nominal_datatype TyS = |
|
289 |
TAll xs::"name list" ty::"T" bind xs in ty |
|
290 |
||
291 |
*** exception Datatype raised |
|
292 |
*** (line 218 of "/usr/local/src/Isabelle_16-Mar-2010/src/HOL/Tools/Datatype/datatype_aux.ML") |
|
293 |
*** At command "nominal_datatype". |
|
294 |
*) |
|
295 |
||
296 |
||
297 |
end |