author | wenzelm |
Fri, 19 Oct 2007 23:21:08 +0200 | |
changeset 25107 | dbf09ca6a80e |
parent 24231 | 85fb973a8207 |
child 26647 | 147c920ed5f7 |
permissions | -rw-r--r-- |
22073 | 1 |
(* "$Id$" *) |
2 |
(* *) |
|
22082 | 3 |
(* Formalisation of the chapter on Logical Relations *) |
4 |
(* and a Case Study in Equivalence Checking *) |
|
5 |
(* by Karl Crary from the book on Advanced Topics in *) |
|
6 |
(* Types and Programming Languages, MIT Press 2005 *) |
|
7 |
||
8 |
(* The formalisation was done by Julien Narboux and *) |
|
22594
33a690455f88
add a few details in the Fst and Snd cases of unicity proof
narboux
parents:
22542
diff
changeset
|
9 |
(* Christian Urban. *) |
22073 | 10 |
|
11 |
theory Crary |
|
22418
49e2d9744ae1
major update of the nominal package; there is now an infrastructure
urbanc
parents:
22231
diff
changeset
|
12 |
imports "../Nominal" |
22073 | 13 |
begin |
14 |
||
15 |
atom_decl name |
|
16 |
||
22829
f1db55c7534d
tuned some proofs and changed variable names in some definitions of Nominal.thy
urbanc
parents:
22730
diff
changeset
|
17 |
nominal_datatype ty = |
f1db55c7534d
tuned some proofs and changed variable names in some definitions of Nominal.thy
urbanc
parents:
22730
diff
changeset
|
18 |
TBase |
f1db55c7534d
tuned some proofs and changed variable names in some definitions of Nominal.thy
urbanc
parents:
22730
diff
changeset
|
19 |
| TUnit |
f1db55c7534d
tuned some proofs and changed variable names in some definitions of Nominal.thy
urbanc
parents:
22730
diff
changeset
|
20 |
| Arrow "ty" "ty" ("_\<rightarrow>_" [100,100] 100) |
22073 | 21 |
|
22829
f1db55c7534d
tuned some proofs and changed variable names in some definitions of Nominal.thy
urbanc
parents:
22730
diff
changeset
|
22 |
nominal_datatype trm = |
f1db55c7534d
tuned some proofs and changed variable names in some definitions of Nominal.thy
urbanc
parents:
22730
diff
changeset
|
23 |
Unit |
24070 | 24 |
| Var "name" ("Var _" [100] 100) |
22829
f1db55c7534d
tuned some proofs and changed variable names in some definitions of Nominal.thy
urbanc
parents:
22730
diff
changeset
|
25 |
| Lam "\<guillemotleft>name\<guillemotright>trm" ("Lam [_]._" [100,100] 100) |
24070 | 26 |
| App "trm" "trm" ("App _ _" [110,110] 100) |
22829
f1db55c7534d
tuned some proofs and changed variable names in some definitions of Nominal.thy
urbanc
parents:
22730
diff
changeset
|
27 |
| Const "nat" |
22073 | 28 |
|
22494 | 29 |
types Ctxt = "(name\<times>ty) list" |
30 |
types Subst = "(name\<times>trm) list" |
|
31 |
||
22073 | 32 |
|
33 |
lemma perm_ty[simp]: |
|
34 |
fixes T::"ty" |
|
35 |
and pi::"name prm" |
|
36 |
shows "pi\<bullet>T = T" |
|
22542 | 37 |
by (induct T rule: ty.weak_induct) (simp_all) |
22073 | 38 |
|
39 |
lemma fresh_ty[simp]: |
|
40 |
fixes x::"name" |
|
41 |
and T::"ty" |
|
42 |
shows "x\<sharp>T" |
|
43 |
by (simp add: fresh_def supp_def) |
|
44 |
||
45 |
lemma ty_cases: |
|
46 |
fixes T::ty |
|
22418
49e2d9744ae1
major update of the nominal package; there is now an infrastructure
urbanc
parents:
22231
diff
changeset
|
47 |
shows "(\<exists> T\<^isub>1 T\<^isub>2. T=T\<^isub>1\<rightarrow>T\<^isub>2) \<or> T=TUnit \<or> T=TBase" |
22542 | 48 |
by (induct T rule:ty.weak_induct) (auto) |
22073 | 49 |
|
50 |
instance ty :: size .. |
|
51 |
||
52 |
nominal_primrec |
|
53 |
"size (TBase) = 1" |
|
54 |
"size (TUnit) = 1" |
|
22418
49e2d9744ae1
major update of the nominal package; there is now an infrastructure
urbanc
parents:
22231
diff
changeset
|
55 |
"size (T\<^isub>1\<rightarrow>T\<^isub>2) = size T\<^isub>1 + size T\<^isub>2" |
22073 | 56 |
by (rule TrueI)+ |
57 |
||
58 |
lemma ty_size_greater_zero[simp]: |
|
59 |
fixes T::"ty" |
|
60 |
shows "size T > 0" |
|
61 |
by (nominal_induct rule:ty.induct) (simp_all) |
|
62 |
||
22494 | 63 |
section {* Substitutions *} |
64 |
||
65 |
fun |
|
66 |
lookup :: "Subst \<Rightarrow> name \<Rightarrow> trm" |
|
67 |
where |
|
68 |
"lookup [] x = Var x" |
|
22501 | 69 |
| "lookup ((y,T)#\<theta>) x = (if x=y then T else lookup \<theta> x)" |
22494 | 70 |
|
71 |
lemma lookup_eqvt[eqvt]: |
|
72 |
fixes pi::"name prm" |
|
73 |
shows "pi\<bullet>(lookup \<theta> x) = lookup (pi\<bullet>\<theta>) (pi\<bullet>x)" |
|
74 |
by (induct \<theta>) (auto simp add: perm_bij) |
|
75 |
||
76 |
lemma lookup_fresh: |
|
77 |
fixes z::"name" |
|
78 |
assumes a: "z\<sharp>\<theta>" "z\<sharp>x" |
|
79 |
shows "z\<sharp> lookup \<theta> x" |
|
80 |
using a |
|
81 |
by (induct rule: lookup.induct) |
|
82 |
(auto simp add: fresh_list_cons) |
|
83 |
||
84 |
lemma lookup_fresh': |
|
85 |
assumes a: "z\<sharp>\<theta>" |
|
86 |
shows "lookup \<theta> z = Var z" |
|
87 |
using a |
|
88 |
by (induct rule: lookup.induct) |
|
89 |
(auto simp add: fresh_list_cons fresh_prod fresh_atm) |
|
90 |
||
91 |
consts |
|
24070 | 92 |
psubst :: "Subst \<Rightarrow> trm \<Rightarrow> trm" ("_<_>" [100,100] 130) |
22494 | 93 |
|
94 |
nominal_primrec |
|
95 |
"\<theta><(Var x)> = (lookup \<theta> x)" |
|
24070 | 96 |
"\<theta><(App t\<^isub>1 t\<^isub>2)> = App \<theta><t\<^isub>1> \<theta><t\<^isub>2>" |
22494 | 97 |
"x\<sharp>\<theta> \<Longrightarrow> \<theta><(Lam [x].t)> = Lam [x].(\<theta><t>)" |
98 |
"\<theta><(Const n)> = Const n" |
|
99 |
"\<theta><(Unit)> = Unit" |
|
100 |
apply(finite_guess)+ |
|
101 |
apply(rule TrueI)+ |
|
102 |
apply(simp add: abs_fresh)+ |
|
103 |
apply(fresh_guess)+ |
|
104 |
done |
|
22418
49e2d9744ae1
major update of the nominal package; there is now an infrastructure
urbanc
parents:
22231
diff
changeset
|
105 |
|
22494 | 106 |
abbreviation |
107 |
subst :: "trm \<Rightarrow> name \<Rightarrow> trm \<Rightarrow> trm" ("_[_::=_]" [100,100,100] 100) |
|
108 |
where |
|
109 |
"t[x::=t'] \<equiv> ([(x,t')])<t>" |
|
110 |
||
111 |
lemma subst[simp]: |
|
112 |
shows "(Var x)[y::=t'] = (if x=y then t' else (Var x))" |
|
113 |
and "(App t\<^isub>1 t\<^isub>2)[y::=t'] = App (t\<^isub>1[y::=t']) (t\<^isub>2[y::=t'])" |
|
114 |
and "x\<sharp>(y,t') \<Longrightarrow> (Lam [x].t)[y::=t'] = Lam [x].(t[y::=t'])" |
|
115 |
and "Const n[y::=t'] = Const n" |
|
116 |
and "Unit [y::=t'] = Unit" |
|
117 |
by (simp_all add: fresh_list_cons fresh_list_nil) |
|
118 |
||
119 |
lemma subst_eqvt[eqvt]: |
|
120 |
fixes pi::"name prm" |
|
121 |
shows "pi\<bullet>(t[x::=t']) = (pi\<bullet>t)[(pi\<bullet>x)::=(pi\<bullet>t')]" |
|
122 |
by (nominal_induct t avoiding: x t' rule: trm.induct) |
|
123 |
(perm_simp add: fresh_bij)+ |
|
22418
49e2d9744ae1
major update of the nominal package; there is now an infrastructure
urbanc
parents:
22231
diff
changeset
|
124 |
|
22494 | 125 |
lemma subst_rename: |
126 |
fixes c::"name" |
|
127 |
assumes a: "c\<sharp>t\<^isub>1" |
|
128 |
shows "t\<^isub>1[a::=t\<^isub>2] = ([(c,a)]\<bullet>t\<^isub>1)[c::=t\<^isub>2]" |
|
129 |
using a |
|
130 |
apply(nominal_induct t\<^isub>1 avoiding: a c t\<^isub>2 rule: trm.induct) |
|
131 |
apply(simp add: trm.inject calc_atm fresh_atm abs_fresh perm_nat_def)+ |
|
132 |
done |
|
133 |
||
134 |
lemma fresh_psubst: |
|
135 |
fixes z::"name" |
|
136 |
assumes a: "z\<sharp>t" "z\<sharp>\<theta>" |
|
137 |
shows "z\<sharp>(\<theta><t>)" |
|
138 |
using a |
|
139 |
by (nominal_induct t avoiding: z \<theta> t rule: trm.induct) |
|
140 |
(auto simp add: abs_fresh lookup_fresh) |
|
141 |
||
142 |
lemma fresh_subst'': |
|
143 |
fixes z::"name" |
|
144 |
assumes "z\<sharp>t\<^isub>2" |
|
145 |
shows "z\<sharp>t\<^isub>1[z::=t\<^isub>2]" |
|
146 |
using assms |
|
147 |
by (nominal_induct t\<^isub>1 avoiding: t\<^isub>2 z rule: trm.induct) |
|
148 |
(auto simp add: abs_fresh fresh_nat fresh_atm) |
|
149 |
||
150 |
lemma fresh_subst': |
|
151 |
fixes z::"name" |
|
152 |
assumes "z\<sharp>[y].t\<^isub>1" "z\<sharp>t\<^isub>2" |
|
153 |
shows "z\<sharp>t\<^isub>1[y::=t\<^isub>2]" |
|
154 |
using assms |
|
155 |
by (nominal_induct t\<^isub>1 avoiding: y t\<^isub>2 z rule: trm.induct) |
|
156 |
(auto simp add: abs_fresh fresh_nat fresh_atm) |
|
22073 | 157 |
|
22494 | 158 |
lemma fresh_subst: |
159 |
fixes z::"name" |
|
160 |
assumes a: "z\<sharp>t\<^isub>1" "z\<sharp>t\<^isub>2" |
|
161 |
shows "z\<sharp>t\<^isub>1[y::=t\<^isub>2]" |
|
162 |
using a |
|
163 |
by (auto simp add: fresh_subst' abs_fresh) |
|
164 |
||
165 |
lemma fresh_psubst_simp: |
|
166 |
assumes "x\<sharp>t" |
|
24070 | 167 |
shows "((x,u)#\<theta>)<t> = \<theta><t>" |
22494 | 168 |
using assms |
169 |
proof (nominal_induct t avoiding: x u \<theta> rule: trm.induct) |
|
170 |
case (Lam y t x u) |
|
25107 | 171 |
have fs: "y\<sharp>\<theta>" "y\<sharp>x" "y\<sharp>u" by fact+ |
22494 | 172 |
moreover have "x\<sharp> Lam [y].t" by fact |
173 |
ultimately have "x\<sharp>t" by (simp add: abs_fresh fresh_atm) |
|
174 |
moreover have ih:"\<And>n T. n\<sharp>t \<Longrightarrow> ((n,T)#\<theta>)<t> = \<theta><t>" by fact |
|
24070 | 175 |
ultimately have "((x,u)#\<theta>)<t> = \<theta><t>" by auto |
176 |
moreover have "((x,u)#\<theta>)<Lam [y].t> = Lam [y].(((x,u)#\<theta>)<t>)" using fs |
|
22494 | 177 |
by (simp add: fresh_list_cons fresh_prod) |
178 |
moreover have " \<theta><Lam [y].t> = Lam [y]. (\<theta><t>)" using fs by simp |
|
24070 | 179 |
ultimately show "((x,u)#\<theta>)<Lam [y].t> = \<theta><Lam [y].t>" by auto |
22494 | 180 |
qed (auto simp add: fresh_atm abs_fresh) |
22418
49e2d9744ae1
major update of the nominal package; there is now an infrastructure
urbanc
parents:
22231
diff
changeset
|
181 |
|
22494 | 182 |
lemma forget: |
183 |
fixes x::"name" |
|
184 |
assumes a: "x\<sharp>t" |
|
185 |
shows "t[x::=t'] = t" |
|
186 |
using a |
|
187 |
by (nominal_induct t avoiding: x t' rule: trm.induct) |
|
188 |
(auto simp add: fresh_atm abs_fresh) |
|
189 |
||
190 |
lemma subst_fun_eq: |
|
191 |
fixes u::trm |
|
192 |
assumes h:"[x].t\<^isub>1 = [y].t\<^isub>2" |
|
193 |
shows "t\<^isub>1[x::=u] = t\<^isub>2[y::=u]" |
|
194 |
proof - |
|
195 |
{ |
|
196 |
assume "x=y" and "t\<^isub>1=t\<^isub>2" |
|
197 |
then have ?thesis using h by simp |
|
198 |
} |
|
199 |
moreover |
|
200 |
{ |
|
201 |
assume h1:"x \<noteq> y" and h2:"t\<^isub>1=[(x,y)] \<bullet> t\<^isub>2" and h3:"x \<sharp> t\<^isub>2" |
|
202 |
then have "([(x,y)] \<bullet> t\<^isub>2)[x::=u] = t\<^isub>2[y::=u]" by (simp add: subst_rename) |
|
203 |
then have ?thesis using h2 by simp |
|
204 |
} |
|
205 |
ultimately show ?thesis using alpha h by blast |
|
206 |
qed |
|
22418
49e2d9744ae1
major update of the nominal package; there is now an infrastructure
urbanc
parents:
22231
diff
changeset
|
207 |
|
22494 | 208 |
lemma psubst_empty[simp]: |
209 |
shows "[]<t> = t" |
|
210 |
by (nominal_induct t rule: trm.induct) |
|
211 |
(auto simp add: fresh_list_nil) |
|
212 |
||
213 |
lemma psubst_subst_psubst: |
|
214 |
assumes h:"c\<sharp>\<theta>" |
|
24070 | 215 |
shows "\<theta><t>[c::=s] = ((c,s)#\<theta>)<t>" |
22494 | 216 |
using h |
217 |
by (nominal_induct t avoiding: \<theta> c s rule: trm.induct) |
|
218 |
(auto simp add: fresh_list_cons fresh_atm forget lookup_fresh lookup_fresh' fresh_psubst) |
|
219 |
||
220 |
lemma subst_fresh_simp: |
|
221 |
assumes a: "x\<sharp>\<theta>" |
|
222 |
shows "\<theta><Var x> = Var x" |
|
223 |
using a |
|
224 |
by (induct \<theta> arbitrary: x, auto simp add:fresh_list_cons fresh_prod fresh_atm) |
|
22418
49e2d9744ae1
major update of the nominal package; there is now an infrastructure
urbanc
parents:
22231
diff
changeset
|
225 |
|
22494 | 226 |
lemma psubst_subst_propagate: |
227 |
assumes "x\<sharp>\<theta>" |
|
228 |
shows "\<theta><t[x::=u]> = \<theta><t>[x::=\<theta><u>]" |
|
229 |
using assms |
|
230 |
proof (nominal_induct t avoiding: x u \<theta> rule: trm.induct) |
|
231 |
case (Var n x u \<theta>) |
|
232 |
{ assume "x=n" |
|
233 |
moreover have "x\<sharp>\<theta>" by fact |
|
234 |
ultimately have "\<theta><Var n[x::=u]> = \<theta><Var n>[x::=\<theta><u>]" using subst_fresh_simp by auto |
|
235 |
} |
|
236 |
moreover |
|
237 |
{ assume h:"x\<noteq>n" |
|
238 |
then have "x\<sharp>Var n" by (auto simp add: fresh_atm) |
|
239 |
moreover have "x\<sharp>\<theta>" by fact |
|
240 |
ultimately have "x\<sharp>\<theta><Var n>" using fresh_psubst by blast |
|
241 |
then have " \<theta><Var n>[x::=\<theta><u>] = \<theta><Var n>" using forget by auto |
|
242 |
then have "\<theta><Var n[x::=u]> = \<theta><Var n>[x::=\<theta><u>]" using h by auto |
|
243 |
} |
|
244 |
ultimately show ?case by auto |
|
245 |
next |
|
246 |
case (Lam n t x u \<theta>) |
|
25107 | 247 |
have fs:"n\<sharp>x" "n\<sharp>u" "n\<sharp>\<theta>" "x\<sharp>\<theta>" by fact+ |
22494 | 248 |
have ih:"\<And> y s \<theta>. y\<sharp>\<theta> \<Longrightarrow> ((\<theta><(t[y::=s])>) = ((\<theta><t>)[y::=(\<theta><s>)]))" by fact |
249 |
have "\<theta> <(Lam [n].t)[x::=u]> = \<theta><Lam [n]. (t [x::=u])>" using fs by auto |
|
250 |
then have "\<theta> <(Lam [n].t)[x::=u]> = Lam [n]. \<theta><t [x::=u]>" using fs by auto |
|
251 |
moreover have "\<theta><t[x::=u]> = \<theta><t>[x::=\<theta><u>]" using ih fs by blast |
|
252 |
ultimately have "\<theta> <(Lam [n].t)[x::=u]> = Lam [n].(\<theta><t>[x::=\<theta><u>])" by auto |
|
253 |
moreover have "Lam [n].(\<theta><t>[x::=\<theta><u>]) = (Lam [n].\<theta><t>)[x::=\<theta><u>]" using fs fresh_psubst by auto |
|
254 |
ultimately have "\<theta><(Lam [n].t)[x::=u]> = (Lam [n].\<theta><t>)[x::=\<theta><u>]" using fs by auto |
|
255 |
then show "\<theta><(Lam [n].t)[x::=u]> = \<theta><Lam [n].t>[x::=\<theta><u>]" using fs by auto |
|
256 |
qed (auto) |
|
257 |
||
258 |
section {* Typing *} |
|
259 |
||
23760 | 260 |
inductive |
22494 | 261 |
valid :: "Ctxt \<Rightarrow> bool" |
22073 | 262 |
where |
22494 | 263 |
v_nil[intro]: "valid []" |
264 |
| v_cons[intro]: "\<lbrakk>valid \<Gamma>;a\<sharp>\<Gamma>\<rbrakk> \<Longrightarrow> valid ((a,T)#\<Gamma>)" |
|
22418
49e2d9744ae1
major update of the nominal package; there is now an infrastructure
urbanc
parents:
22231
diff
changeset
|
265 |
|
22538
3ccb92dfb5e9
tuned proofs (taking full advantage of nominal_inductive)
urbanc
parents:
22531
diff
changeset
|
266 |
equivariance valid |
22418
49e2d9744ae1
major update of the nominal package; there is now an infrastructure
urbanc
parents:
22231
diff
changeset
|
267 |
|
24070 | 268 |
inductive_cases |
22073 | 269 |
valid_cons_elim_auto[elim]:"valid ((x,T)#\<Gamma>)" |
270 |
||
22494 | 271 |
abbreviation |
22650
0c5b22076fb3
tuned the proof of lemma pt_list_set_fresh (as suggested by Randy Pollack) and tuned the syntax for sub_contexts
urbanc
parents:
22609
diff
changeset
|
272 |
"sub_context" :: "Ctxt \<Rightarrow> Ctxt \<Rightarrow> bool" (" _ \<subseteq> _ " [55,55] 55) |
22494 | 273 |
where |
22650
0c5b22076fb3
tuned the proof of lemma pt_list_set_fresh (as suggested by Randy Pollack) and tuned the syntax for sub_contexts
urbanc
parents:
22609
diff
changeset
|
274 |
"\<Gamma>\<^isub>1 \<subseteq> \<Gamma>\<^isub>2 \<equiv> \<forall>a T. (a,T)\<in>set \<Gamma>\<^isub>1 \<longrightarrow> (a,T)\<in>set \<Gamma>\<^isub>2" |
22418
49e2d9744ae1
major update of the nominal package; there is now an infrastructure
urbanc
parents:
22231
diff
changeset
|
275 |
|
22494 | 276 |
lemma valid_monotonicity[elim]: |
24231
85fb973a8207
added type constraints to resolve syntax ambiguities;
wenzelm
parents:
24088
diff
changeset
|
277 |
fixes \<Gamma> \<Gamma>' :: Ctxt |
22650
0c5b22076fb3
tuned the proof of lemma pt_list_set_fresh (as suggested by Randy Pollack) and tuned the syntax for sub_contexts
urbanc
parents:
22609
diff
changeset
|
278 |
assumes a: "\<Gamma> \<subseteq> \<Gamma>'" |
22494 | 279 |
and b: "x\<sharp>\<Gamma>'" |
22650
0c5b22076fb3
tuned the proof of lemma pt_list_set_fresh (as suggested by Randy Pollack) and tuned the syntax for sub_contexts
urbanc
parents:
22609
diff
changeset
|
280 |
shows "(x,T\<^isub>1)#\<Gamma> \<subseteq> (x,T\<^isub>1)#\<Gamma>'" |
22494 | 281 |
using a b by auto |
22418
49e2d9744ae1
major update of the nominal package; there is now an infrastructure
urbanc
parents:
22231
diff
changeset
|
282 |
|
49e2d9744ae1
major update of the nominal package; there is now an infrastructure
urbanc
parents:
22231
diff
changeset
|
283 |
lemma fresh_context: |
22494 | 284 |
fixes \<Gamma> :: "Ctxt" |
22418
49e2d9744ae1
major update of the nominal package; there is now an infrastructure
urbanc
parents:
22231
diff
changeset
|
285 |
and a :: "name" |
49e2d9744ae1
major update of the nominal package; there is now an infrastructure
urbanc
parents:
22231
diff
changeset
|
286 |
assumes "a\<sharp>\<Gamma>" |
49e2d9744ae1
major update of the nominal package; there is now an infrastructure
urbanc
parents:
22231
diff
changeset
|
287 |
shows "\<not>(\<exists>\<tau>::ty. (a,\<tau>)\<in>set \<Gamma>)" |
22494 | 288 |
using assms |
289 |
by (induct \<Gamma>) |
|
290 |
(auto simp add: fresh_prod fresh_list_cons fresh_atm) |
|
22418
49e2d9744ae1
major update of the nominal package; there is now an infrastructure
urbanc
parents:
22231
diff
changeset
|
291 |
|
49e2d9744ae1
major update of the nominal package; there is now an infrastructure
urbanc
parents:
22231
diff
changeset
|
292 |
lemma type_unicity_in_context: |
22494 | 293 |
assumes a: "valid \<Gamma>" |
294 |
and b: "(x,T\<^isub>1) \<in> set \<Gamma>" |
|
295 |
and c: "(x,T\<^isub>2) \<in> set \<Gamma>" |
|
22418
49e2d9744ae1
major update of the nominal package; there is now an infrastructure
urbanc
parents:
22231
diff
changeset
|
296 |
shows "T\<^isub>1=T\<^isub>2" |
22494 | 297 |
using a b c |
298 |
by (induct \<Gamma>) |
|
299 |
(auto dest!: fresh_context) |
|
22073 | 300 |
|
23760 | 301 |
inductive |
22494 | 302 |
typing :: "Ctxt\<Rightarrow>trm\<Rightarrow>ty\<Rightarrow>bool" (" _ \<turnstile> _ : _ " [60,60,60] 60) |
22073 | 303 |
where |
24070 | 304 |
T_Var[intro]: "\<lbrakk>valid \<Gamma>; (x,T)\<in>set \<Gamma>\<rbrakk> \<Longrightarrow> \<Gamma> \<turnstile> Var x : T" |
305 |
| T_App[intro]: "\<lbrakk>\<Gamma> \<turnstile> e\<^isub>1 : T\<^isub>1\<rightarrow>T\<^isub>2; \<Gamma> \<turnstile> e\<^isub>2 : T\<^isub>1\<rbrakk> \<Longrightarrow> \<Gamma> \<turnstile> App e\<^isub>1 e\<^isub>2 : T\<^isub>2" |
|
306 |
| T_Lam[intro]: "\<lbrakk>x\<sharp>\<Gamma>; (x,T\<^isub>1)#\<Gamma> \<turnstile> t : T\<^isub>2\<rbrakk> \<Longrightarrow> \<Gamma> \<turnstile> Lam [x].t : T\<^isub>1\<rightarrow>T\<^isub>2" |
|
307 |
| T_Const[intro]: "valid \<Gamma> \<Longrightarrow> \<Gamma> \<turnstile> Const n : TBase" |
|
308 |
| T_Unit[intro]: "valid \<Gamma> \<Longrightarrow> \<Gamma> \<turnstile> Unit : TUnit" |
|
22418
49e2d9744ae1
major update of the nominal package; there is now an infrastructure
urbanc
parents:
22231
diff
changeset
|
309 |
|
22730
8bcc8809ed3b
nominal_inductive no longer proves equivariance.
berghofe
parents:
22650
diff
changeset
|
310 |
equivariance typing |
8bcc8809ed3b
nominal_inductive no longer proves equivariance.
berghofe
parents:
22650
diff
changeset
|
311 |
|
22418
49e2d9744ae1
major update of the nominal package; there is now an infrastructure
urbanc
parents:
22231
diff
changeset
|
312 |
nominal_inductive typing |
22531 | 313 |
by (simp_all add: abs_fresh) |
22073 | 314 |
|
22494 | 315 |
lemma typing_implies_valid: |
316 |
assumes a: "\<Gamma> \<turnstile> t : T" |
|
317 |
shows "valid \<Gamma>" |
|
318 |
using a by (induct) (auto) |
|
22073 | 319 |
|
320 |
declare trm.inject [simp add] |
|
321 |
declare ty.inject [simp add] |
|
322 |
||
24088
c2d8270e53a5
undo a change in last commit : give a single name to the inversion lemmas for the same inductive type
narboux
parents:
24070
diff
changeset
|
323 |
inductive_cases typing_inv_auto[elim]: |
c2d8270e53a5
undo a change in last commit : give a single name to the inversion lemmas for the same inductive type
narboux
parents:
24070
diff
changeset
|
324 |
"\<Gamma> \<turnstile> Lam [x].t : T" |
c2d8270e53a5
undo a change in last commit : give a single name to the inversion lemmas for the same inductive type
narboux
parents:
24070
diff
changeset
|
325 |
"\<Gamma> \<turnstile> Var x : T" |
c2d8270e53a5
undo a change in last commit : give a single name to the inversion lemmas for the same inductive type
narboux
parents:
24070
diff
changeset
|
326 |
"\<Gamma> \<turnstile> App x y : T" |
c2d8270e53a5
undo a change in last commit : give a single name to the inversion lemmas for the same inductive type
narboux
parents:
24070
diff
changeset
|
327 |
"\<Gamma> \<turnstile> Const n : T" |
c2d8270e53a5
undo a change in last commit : give a single name to the inversion lemmas for the same inductive type
narboux
parents:
24070
diff
changeset
|
328 |
"\<Gamma> \<turnstile> Unit : TUnit" |
c2d8270e53a5
undo a change in last commit : give a single name to the inversion lemmas for the same inductive type
narboux
parents:
24070
diff
changeset
|
329 |
"\<Gamma> \<turnstile> s : TUnit" |
22073 | 330 |
|
331 |
declare trm.inject [simp del] |
|
332 |
declare ty.inject [simp del] |
|
24088
c2d8270e53a5
undo a change in last commit : give a single name to the inversion lemmas for the same inductive type
narboux
parents:
24070
diff
changeset
|
333 |
|
22073 | 334 |
|
22494 | 335 |
section {* Definitional Equivalence *} |
22073 | 336 |
|
23760 | 337 |
inductive |
22494 | 338 |
def_equiv :: "Ctxt\<Rightarrow>trm\<Rightarrow>trm\<Rightarrow>ty\<Rightarrow>bool" ("_ \<turnstile> _ \<equiv> _ : _" [60,60] 60) |
22418
49e2d9744ae1
major update of the nominal package; there is now an infrastructure
urbanc
parents:
22231
diff
changeset
|
339 |
where |
49e2d9744ae1
major update of the nominal package; there is now an infrastructure
urbanc
parents:
22231
diff
changeset
|
340 |
Q_Refl[intro]: "\<Gamma> \<turnstile> t : T \<Longrightarrow> \<Gamma> \<turnstile> t \<equiv> t : T" |
49e2d9744ae1
major update of the nominal package; there is now an infrastructure
urbanc
parents:
22231
diff
changeset
|
341 |
| Q_Symm[intro]: "\<Gamma> \<turnstile> t \<equiv> s : T \<Longrightarrow> \<Gamma> \<turnstile> s \<equiv> t : T" |
49e2d9744ae1
major update of the nominal package; there is now an infrastructure
urbanc
parents:
22231
diff
changeset
|
342 |
| Q_Trans[intro]: "\<lbrakk>\<Gamma> \<turnstile> s \<equiv> t : T; \<Gamma> \<turnstile> t \<equiv> u : T\<rbrakk> \<Longrightarrow> \<Gamma> \<turnstile> s \<equiv> u : T" |
49e2d9744ae1
major update of the nominal package; there is now an infrastructure
urbanc
parents:
22231
diff
changeset
|
343 |
| Q_Abs[intro]: "\<lbrakk>x\<sharp>\<Gamma>; (x,T\<^isub>1)#\<Gamma> \<turnstile> s\<^isub>2 \<equiv> t\<^isub>2 : T\<^isub>2\<rbrakk> \<Longrightarrow> \<Gamma> \<turnstile> Lam [x]. s\<^isub>2 \<equiv> Lam [x]. t\<^isub>2 : T\<^isub>1 \<rightarrow> T\<^isub>2" |
49e2d9744ae1
major update of the nominal package; there is now an infrastructure
urbanc
parents:
22231
diff
changeset
|
344 |
| Q_App[intro]: "\<lbrakk>\<Gamma> \<turnstile> s\<^isub>1 \<equiv> t\<^isub>1 : T\<^isub>1 \<rightarrow> T\<^isub>2 ; \<Gamma> \<turnstile> s\<^isub>2 \<equiv> t\<^isub>2 : T\<^isub>1\<rbrakk> \<Longrightarrow> \<Gamma> \<turnstile> App s\<^isub>1 s\<^isub>2 \<equiv> App t\<^isub>1 t\<^isub>2 : T\<^isub>2" |
22494 | 345 |
| Q_Beta[intro]: "\<lbrakk>x\<sharp>(\<Gamma>,s\<^isub>2,t\<^isub>2); (x,T\<^isub>1)#\<Gamma> \<turnstile> s\<^isub>1 \<equiv> t\<^isub>1 : T\<^isub>2 ; \<Gamma> \<turnstile> s\<^isub>2 \<equiv> t\<^isub>2 : T\<^isub>1\<rbrakk> |
346 |
\<Longrightarrow> \<Gamma> \<turnstile> App (Lam [x]. s\<^isub>1) s\<^isub>2 \<equiv> t\<^isub>1[x::=t\<^isub>2] : T\<^isub>2" |
|
22418
49e2d9744ae1
major update of the nominal package; there is now an infrastructure
urbanc
parents:
22231
diff
changeset
|
347 |
| Q_Ext[intro]: "\<lbrakk>x\<sharp>(\<Gamma>,s,t); (x,T\<^isub>1)#\<Gamma> \<turnstile> App s (Var x) \<equiv> App t (Var x) : T\<^isub>2\<rbrakk> |
49e2d9744ae1
major update of the nominal package; there is now an infrastructure
urbanc
parents:
22231
diff
changeset
|
348 |
\<Longrightarrow> \<Gamma> \<turnstile> s \<equiv> t : T\<^isub>1 \<rightarrow> T\<^isub>2" |
23370
513a8ee192f1
added the Q_Unit rule (was missing) and adjusted the proof accordingly
urbanc
parents:
22829
diff
changeset
|
349 |
| Q_Unit[intro]: "\<lbrakk>\<Gamma> \<turnstile> s : TUnit; \<Gamma> \<turnstile> t: TUnit\<rbrakk> \<Longrightarrow> \<Gamma> \<turnstile> s \<equiv> t : TUnit" |
22418
49e2d9744ae1
major update of the nominal package; there is now an infrastructure
urbanc
parents:
22231
diff
changeset
|
350 |
|
22730
8bcc8809ed3b
nominal_inductive no longer proves equivariance.
berghofe
parents:
22650
diff
changeset
|
351 |
equivariance def_equiv |
8bcc8809ed3b
nominal_inductive no longer proves equivariance.
berghofe
parents:
22650
diff
changeset
|
352 |
|
22494 | 353 |
nominal_inductive def_equiv |
22531 | 354 |
by (simp_all add: abs_fresh fresh_subst'') |
22418
49e2d9744ae1
major update of the nominal package; there is now an infrastructure
urbanc
parents:
22231
diff
changeset
|
355 |
|
22494 | 356 |
lemma def_equiv_implies_valid: |
357 |
assumes a: "\<Gamma> \<turnstile> t \<equiv> s : T" |
|
22418
49e2d9744ae1
major update of the nominal package; there is now an infrastructure
urbanc
parents:
22231
diff
changeset
|
358 |
shows "valid \<Gamma>" |
22494 | 359 |
using a by (induct) (auto elim: typing_implies_valid) |
22418
49e2d9744ae1
major update of the nominal package; there is now an infrastructure
urbanc
parents:
22231
diff
changeset
|
360 |
|
24070 | 361 |
lemma test30: |
362 |
fixes x::"name" |
|
363 |
assumes a: "(x,T) \<in> set \<Gamma>" |
|
364 |
shows "x\<in>supp \<Gamma>" |
|
365 |
using a |
|
366 |
apply(induct \<Gamma>) |
|
367 |
apply(auto simp add: supp_list_cons supp_prod supp_atm) |
|
368 |
done |
|
369 |
||
370 |
lemma supp_ty[simp]: |
|
371 |
fixes T::"ty" |
|
372 |
shows "(supp T) = ({}::name set)" |
|
373 |
apply(simp add: supp_def) |
|
374 |
done |
|
375 |
||
376 |
lemma test3a: |
|
24231
85fb973a8207
added type constraints to resolve syntax ambiguities;
wenzelm
parents:
24088
diff
changeset
|
377 |
fixes \<Gamma> :: Ctxt and t :: trm |
24070 | 378 |
assumes a: "\<Gamma> \<turnstile> t : T" |
379 |
shows "(supp t) \<subseteq> ((supp \<Gamma>)::name set)" |
|
380 |
using a |
|
381 |
apply(induct) |
|
382 |
apply(auto simp add: trm.supp supp_atm supp_list_cons abs_supp supp_prod) |
|
383 |
apply(simp add: test30) |
|
384 |
apply(simp add: supp_def perm_nat_def) |
|
385 |
done |
|
386 |
||
387 |
lemma test3b: |
|
388 |
shows "supp (t\<^isub>1[x::=t\<^isub>2]) \<subseteq> ((supp ([x].t\<^isub>1,t\<^isub>2))::name set)" |
|
389 |
apply(nominal_induct t\<^isub>1 avoiding: x t\<^isub>2 rule: trm.induct) |
|
390 |
apply(auto simp add: trm.supp supp_prod abs_supp supp_atm) |
|
391 |
apply(blast) |
|
392 |
apply(blast) |
|
393 |
apply(simp add: supp_def perm_nat_def) |
|
394 |
done |
|
395 |
||
396 |
lemma test3: |
|
24231
85fb973a8207
added type constraints to resolve syntax ambiguities;
wenzelm
parents:
24088
diff
changeset
|
397 |
fixes \<Gamma> :: Ctxt and s t :: trm |
24070 | 398 |
assumes a: "\<Gamma> \<turnstile> s \<equiv> t : T" |
399 |
shows "(supp (s,t)) \<subseteq> ((supp \<Gamma>)::name set)" |
|
400 |
using a |
|
401 |
apply(induct) |
|
402 |
apply(auto simp add: supp_prod supp_list_cons trm.supp abs_supp supp_atm) |
|
403 |
apply(drule test3a) |
|
404 |
apply(blast) |
|
405 |
apply(subgoal_tac "supp (t\<^isub>1[x::=t\<^isub>2]) \<subseteq> ((supp ([x].t\<^isub>1,t\<^isub>2))::name set)") |
|
406 |
apply(auto simp add: supp_prod abs_supp)[1] |
|
407 |
apply(rule test3b) |
|
408 |
apply(case_tac "x=xa") |
|
409 |
apply(simp add: fresh_def supp_prod) |
|
410 |
apply(blast) |
|
411 |
apply(case_tac "x=xa") |
|
412 |
apply(simp add: fresh_def supp_prod) |
|
413 |
apply(blast) |
|
414 |
apply(drule test3a) |
|
415 |
apply(blast) |
|
416 |
apply(drule test3a)+ |
|
417 |
apply(blast) |
|
418 |
done |
|
419 |
||
420 |
lemma test0: |
|
421 |
assumes a: "(x,T\<^isub>1)#\<Gamma> \<turnstile> s\<^isub>1 \<equiv> t\<^isub>1 : T\<^isub>2" |
|
422 |
and b: "\<Gamma> \<turnstile> s\<^isub>2 \<equiv> t\<^isub>2 : T\<^isub>1" |
|
423 |
shows "\<Gamma> \<turnstile> App (Lam [x]. s\<^isub>1) s\<^isub>2 \<equiv> t\<^isub>1[x::=t\<^isub>2] : T\<^isub>2" |
|
424 |
using a b |
|
425 |
apply(rule_tac Q_Beta) |
|
426 |
apply(auto) |
|
427 |
apply(drule def_equiv_implies_valid) |
|
428 |
apply(drule valid.cases) |
|
429 |
apply(auto) |
|
430 |
apply(drule test3) |
|
431 |
apply(auto simp add: fresh_def supp_prod) |
|
432 |
done |
|
433 |
||
434 |
lemma test1: |
|
435 |
assumes a: "\<forall>x. x\<sharp>\<Gamma> \<longrightarrow> (x,T\<^isub>1)#\<Gamma> \<turnstile> App s (Var x) \<equiv> App t (Var x) : T\<^isub>2" |
|
436 |
shows "\<Gamma> \<turnstile> s \<equiv> t : T\<^isub>1 \<rightarrow> T\<^isub>2" |
|
437 |
using a |
|
438 |
apply - |
|
439 |
apply(generate_fresh "name") |
|
440 |
apply(rule_tac x="c" in Q_Ext) |
|
441 |
apply(simp) |
|
442 |
apply(simp add: fresh_prod) |
|
443 |
done |
|
444 |
||
445 |
lemma test2: |
|
446 |
assumes a: "x\<sharp>(\<Gamma>,s,t) \<and> (x,T\<^isub>1)#\<Gamma> \<turnstile> App s (Var x) \<equiv> App t (Var x) : T\<^isub>2" |
|
447 |
shows "\<forall>x. x\<sharp>(\<Gamma>,s,t) \<longrightarrow> (x,T\<^isub>1)#\<Gamma> \<turnstile> App s (Var x) \<equiv> App t (Var x) : T\<^isub>2" |
|
448 |
using a |
|
449 |
apply - |
|
450 |
apply(rule allI) |
|
451 |
apply(case_tac "xa=x") |
|
452 |
apply(simp) |
|
453 |
apply(rule impI) |
|
454 |
apply(erule conjE) |
|
455 |
apply(drule_tac pi="[(x,xa)]" in def_equiv.eqvt) |
|
456 |
apply(simp add: eqvts) |
|
457 |
apply(simp add: calc_atm) |
|
458 |
apply(perm_simp) |
|
459 |
done |
|
460 |
||
461 |
lemma test2: |
|
462 |
assumes a: "x\<sharp>(\<Gamma>,s,t) \<and> (x,T\<^isub>1)#\<Gamma> \<turnstile> App s (Var x) \<equiv> App t (Var x) : T\<^isub>2" |
|
463 |
shows "\<forall>x. x\<sharp>\<Gamma> \<longrightarrow> (x,T\<^isub>1)#\<Gamma> \<turnstile> App s (Var x) \<equiv> App t (Var x) : T\<^isub>2" |
|
464 |
using a |
|
465 |
apply - |
|
466 |
apply(rule allI) |
|
467 |
apply(case_tac "xa=x") |
|
468 |
apply(simp) |
|
469 |
apply(rule impI) |
|
470 |
apply(erule conjE) |
|
471 |
apply(frule test3) |
|
472 |
apply(simp add: supp_prod supp_list_cons supp_atm trm.supp) |
|
473 |
apply(subgoal_tac "xa\<sharp>(s,t)") |
|
474 |
apply(drule_tac pi="[(x,xa)]" in def_equiv.eqvt) |
|
475 |
apply(simp add: eqvts) |
|
476 |
apply(simp add: calc_atm) |
|
477 |
apply(perm_simp) |
|
478 |
apply(simp add: fresh_def supp_prod) |
|
479 |
apply(auto) |
|
480 |
done |
|
481 |
||
482 |
||
22494 | 483 |
section {* Weak Head Reduction *} |
22418
49e2d9744ae1
major update of the nominal package; there is now an infrastructure
urbanc
parents:
22231
diff
changeset
|
484 |
|
23760 | 485 |
inductive |
22418
49e2d9744ae1
major update of the nominal package; there is now an infrastructure
urbanc
parents:
22231
diff
changeset
|
486 |
whr_def :: "trm\<Rightarrow>trm\<Rightarrow>bool" ("_ \<leadsto> _" [80,80] 80) |
49e2d9744ae1
major update of the nominal package; there is now an infrastructure
urbanc
parents:
22231
diff
changeset
|
487 |
where |
22494 | 488 |
QAR_Beta[intro]: "App (Lam [x]. t\<^isub>1) t\<^isub>2 \<leadsto> t\<^isub>1[x::=t\<^isub>2]" |
489 |
| QAR_App[intro]: "t\<^isub>1 \<leadsto> t\<^isub>1' \<Longrightarrow> App t\<^isub>1 t\<^isub>2 \<leadsto> App t\<^isub>1' t\<^isub>2" |
|
22418
49e2d9744ae1
major update of the nominal package; there is now an infrastructure
urbanc
parents:
22231
diff
changeset
|
490 |
|
49e2d9744ae1
major update of the nominal package; there is now an infrastructure
urbanc
parents:
22231
diff
changeset
|
491 |
declare trm.inject [simp add] |
49e2d9744ae1
major update of the nominal package; there is now an infrastructure
urbanc
parents:
22231
diff
changeset
|
492 |
declare ty.inject [simp add] |
49e2d9744ae1
major update of the nominal package; there is now an infrastructure
urbanc
parents:
22231
diff
changeset
|
493 |
|
24088
c2d8270e53a5
undo a change in last commit : give a single name to the inversion lemmas for the same inductive type
narboux
parents:
24070
diff
changeset
|
494 |
inductive_cases whr_inv_auto[elim]: |
c2d8270e53a5
undo a change in last commit : give a single name to the inversion lemmas for the same inductive type
narboux
parents:
24070
diff
changeset
|
495 |
"t \<leadsto> t'" |
c2d8270e53a5
undo a change in last commit : give a single name to the inversion lemmas for the same inductive type
narboux
parents:
24070
diff
changeset
|
496 |
"Lam [x].t \<leadsto> t'" |
c2d8270e53a5
undo a change in last commit : give a single name to the inversion lemmas for the same inductive type
narboux
parents:
24070
diff
changeset
|
497 |
"App (Lam [x].t12) t2 \<leadsto> t" |
c2d8270e53a5
undo a change in last commit : give a single name to the inversion lemmas for the same inductive type
narboux
parents:
24070
diff
changeset
|
498 |
"Var x \<leadsto> t" |
c2d8270e53a5
undo a change in last commit : give a single name to the inversion lemmas for the same inductive type
narboux
parents:
24070
diff
changeset
|
499 |
"Const n \<leadsto> t" |
c2d8270e53a5
undo a change in last commit : give a single name to the inversion lemmas for the same inductive type
narboux
parents:
24070
diff
changeset
|
500 |
"App p q \<leadsto> t" |
c2d8270e53a5
undo a change in last commit : give a single name to the inversion lemmas for the same inductive type
narboux
parents:
24070
diff
changeset
|
501 |
"t \<leadsto> Const n" |
c2d8270e53a5
undo a change in last commit : give a single name to the inversion lemmas for the same inductive type
narboux
parents:
24070
diff
changeset
|
502 |
"t \<leadsto> Var x" |
c2d8270e53a5
undo a change in last commit : give a single name to the inversion lemmas for the same inductive type
narboux
parents:
24070
diff
changeset
|
503 |
"t \<leadsto> App p q" |
22418
49e2d9744ae1
major update of the nominal package; there is now an infrastructure
urbanc
parents:
22231
diff
changeset
|
504 |
|
49e2d9744ae1
major update of the nominal package; there is now an infrastructure
urbanc
parents:
22231
diff
changeset
|
505 |
declare trm.inject [simp del] |
49e2d9744ae1
major update of the nominal package; there is now an infrastructure
urbanc
parents:
22231
diff
changeset
|
506 |
declare ty.inject [simp del] |
49e2d9744ae1
major update of the nominal package; there is now an infrastructure
urbanc
parents:
22231
diff
changeset
|
507 |
|
22531 | 508 |
equivariance whr_def |
22418
49e2d9744ae1
major update of the nominal package; there is now an infrastructure
urbanc
parents:
22231
diff
changeset
|
509 |
|
22494 | 510 |
section {* Weak Head Normalisation *} |
22418
49e2d9744ae1
major update of the nominal package; there is now an infrastructure
urbanc
parents:
22231
diff
changeset
|
511 |
|
49e2d9744ae1
major update of the nominal package; there is now an infrastructure
urbanc
parents:
22231
diff
changeset
|
512 |
abbreviation |
49e2d9744ae1
major update of the nominal package; there is now an infrastructure
urbanc
parents:
22231
diff
changeset
|
513 |
nf :: "trm \<Rightarrow> bool" ("_ \<leadsto>|" [100] 100) |
49e2d9744ae1
major update of the nominal package; there is now an infrastructure
urbanc
parents:
22231
diff
changeset
|
514 |
where |
49e2d9744ae1
major update of the nominal package; there is now an infrastructure
urbanc
parents:
22231
diff
changeset
|
515 |
"t\<leadsto>| \<equiv> \<not>(\<exists> u. t \<leadsto> u)" |
49e2d9744ae1
major update of the nominal package; there is now an infrastructure
urbanc
parents:
22231
diff
changeset
|
516 |
|
23760 | 517 |
inductive |
22418
49e2d9744ae1
major update of the nominal package; there is now an infrastructure
urbanc
parents:
22231
diff
changeset
|
518 |
whn_def :: "trm\<Rightarrow>trm\<Rightarrow>bool" ("_ \<Down> _" [80,80] 80) |
49e2d9744ae1
major update of the nominal package; there is now an infrastructure
urbanc
parents:
22231
diff
changeset
|
519 |
where |
49e2d9744ae1
major update of the nominal package; there is now an infrastructure
urbanc
parents:
22231
diff
changeset
|
520 |
QAN_Reduce[intro]: "\<lbrakk>s \<leadsto> t; t \<Down> u\<rbrakk> \<Longrightarrow> s \<Down> u" |
49e2d9744ae1
major update of the nominal package; there is now an infrastructure
urbanc
parents:
22231
diff
changeset
|
521 |
| QAN_Normal[intro]: "t\<leadsto>| \<Longrightarrow> t \<Down> t" |
49e2d9744ae1
major update of the nominal package; there is now an infrastructure
urbanc
parents:
22231
diff
changeset
|
522 |
|
22494 | 523 |
declare trm.inject[simp] |
22418
49e2d9744ae1
major update of the nominal package; there is now an infrastructure
urbanc
parents:
22231
diff
changeset
|
524 |
|
23760 | 525 |
inductive_cases whn_inv_auto[elim]: "t \<Down> t'" |
22494 | 526 |
|
527 |
declare trm.inject[simp del] |
|
22418
49e2d9744ae1
major update of the nominal package; there is now an infrastructure
urbanc
parents:
22231
diff
changeset
|
528 |
|
49e2d9744ae1
major update of the nominal package; there is now an infrastructure
urbanc
parents:
22231
diff
changeset
|
529 |
lemma whn_eqvt[eqvt]: |
49e2d9744ae1
major update of the nominal package; there is now an infrastructure
urbanc
parents:
22231
diff
changeset
|
530 |
fixes pi::"name prm" |
49e2d9744ae1
major update of the nominal package; there is now an infrastructure
urbanc
parents:
22231
diff
changeset
|
531 |
assumes a: "t \<Down> t'" |
49e2d9744ae1
major update of the nominal package; there is now an infrastructure
urbanc
parents:
22231
diff
changeset
|
532 |
shows "(pi\<bullet>t) \<Down> (pi\<bullet>t')" |
49e2d9744ae1
major update of the nominal package; there is now an infrastructure
urbanc
parents:
22231
diff
changeset
|
533 |
using a |
49e2d9744ae1
major update of the nominal package; there is now an infrastructure
urbanc
parents:
22231
diff
changeset
|
534 |
apply(induct) |
49e2d9744ae1
major update of the nominal package; there is now an infrastructure
urbanc
parents:
22231
diff
changeset
|
535 |
apply(rule QAN_Reduce) |
22542 | 536 |
apply(rule whr_def.eqvt) |
22418
49e2d9744ae1
major update of the nominal package; there is now an infrastructure
urbanc
parents:
22231
diff
changeset
|
537 |
apply(assumption)+ |
49e2d9744ae1
major update of the nominal package; there is now an infrastructure
urbanc
parents:
22231
diff
changeset
|
538 |
apply(rule QAN_Normal) |
49e2d9744ae1
major update of the nominal package; there is now an infrastructure
urbanc
parents:
22231
diff
changeset
|
539 |
apply(auto) |
22542 | 540 |
apply(drule_tac pi="rev pi" in whr_def.eqvt) |
22418
49e2d9744ae1
major update of the nominal package; there is now an infrastructure
urbanc
parents:
22231
diff
changeset
|
541 |
apply(perm_simp) |
49e2d9744ae1
major update of the nominal package; there is now an infrastructure
urbanc
parents:
22231
diff
changeset
|
542 |
done |
49e2d9744ae1
major update of the nominal package; there is now an infrastructure
urbanc
parents:
22231
diff
changeset
|
543 |
|
22494 | 544 |
lemma red_unicity : |
545 |
assumes a: "x \<leadsto> a" |
|
546 |
and b: "x \<leadsto> b" |
|
547 |
shows "a=b" |
|
548 |
using a b |
|
549 |
apply (induct arbitrary: b) |
|
24088
c2d8270e53a5
undo a change in last commit : give a single name to the inversion lemmas for the same inductive type
narboux
parents:
24070
diff
changeset
|
550 |
apply (erule whr_inv_auto(3)) |
22494 | 551 |
apply (clarify) |
552 |
apply (rule subst_fun_eq) |
|
553 |
apply (simp) |
|
554 |
apply (force) |
|
24088
c2d8270e53a5
undo a change in last commit : give a single name to the inversion lemmas for the same inductive type
narboux
parents:
24070
diff
changeset
|
555 |
apply (erule whr_inv_auto(6)) |
22494 | 556 |
apply (blast)+ |
557 |
done |
|
22418
49e2d9744ae1
major update of the nominal package; there is now an infrastructure
urbanc
parents:
22231
diff
changeset
|
558 |
|
22494 | 559 |
lemma nf_unicity : |
560 |
assumes "x \<Down> a" and "x \<Down> b" |
|
561 |
shows "a=b" |
|
562 |
using assms |
|
563 |
proof (induct arbitrary: b) |
|
564 |
case (QAN_Reduce x t a b) |
|
25107 | 565 |
have h:"x \<leadsto> t" "t \<Down> a" by fact+ |
22494 | 566 |
have ih:"\<And>b. t \<Down> b \<Longrightarrow> a = b" by fact |
567 |
have "x \<Down> b" by fact |
|
568 |
then obtain t' where "x \<leadsto> t'" and hl:"t' \<Down> b" using h by auto |
|
569 |
then have "t=t'" using h red_unicity by auto |
|
570 |
then show "a=b" using ih hl by auto |
|
571 |
qed (auto) |
|
572 |
||
24070 | 573 |
lemma test4a: |
574 |
shows "s \<leadsto> t \<Longrightarrow> (supp t) \<subseteq> ((supp s)::name set)" |
|
575 |
apply(induct s t rule: whr_def.induct) |
|
576 |
apply(insert test3b) |
|
577 |
apply(simp add: trm.supp supp_prod abs_supp) |
|
578 |
apply(auto simp add: trm.supp) |
|
579 |
done |
|
580 |
||
581 |
lemma test4b: |
|
582 |
shows "s \<Down> t \<Longrightarrow> (supp t) \<subseteq> ((supp s)::name set)" |
|
583 |
apply(induct s t rule: whn_def.induct) |
|
584 |
apply(auto dest: test4a) |
|
585 |
done |
|
586 |
||
22494 | 587 |
section {* Algorithmic Term Equivalence and Algorithmic Path Equivalence *} |
588 |
||
23760 | 589 |
inductive |
22650
0c5b22076fb3
tuned the proof of lemma pt_list_set_fresh (as suggested by Randy Pollack) and tuned the syntax for sub_contexts
urbanc
parents:
22609
diff
changeset
|
590 |
alg_equiv :: "Ctxt\<Rightarrow>trm\<Rightarrow>trm\<Rightarrow>ty\<Rightarrow>bool" ("_ \<turnstile> _ \<Leftrightarrow> _ : _" [60,60,60,60] 60) |
22418
49e2d9744ae1
major update of the nominal package; there is now an infrastructure
urbanc
parents:
22231
diff
changeset
|
591 |
and |
22650
0c5b22076fb3
tuned the proof of lemma pt_list_set_fresh (as suggested by Randy Pollack) and tuned the syntax for sub_contexts
urbanc
parents:
22609
diff
changeset
|
592 |
alg_path_equiv :: "Ctxt\<Rightarrow>trm\<Rightarrow>trm\<Rightarrow>ty\<Rightarrow>bool" ("_ \<turnstile> _ \<leftrightarrow> _ : _" [60,60,60,60] 60) |
22418
49e2d9744ae1
major update of the nominal package; there is now an infrastructure
urbanc
parents:
22231
diff
changeset
|
593 |
where |
22650
0c5b22076fb3
tuned the proof of lemma pt_list_set_fresh (as suggested by Randy Pollack) and tuned the syntax for sub_contexts
urbanc
parents:
22609
diff
changeset
|
594 |
QAT_Base[intro]: "\<lbrakk>s \<Down> p; t \<Down> q; \<Gamma> \<turnstile> p \<leftrightarrow> q : TBase\<rbrakk> \<Longrightarrow> \<Gamma> \<turnstile> s \<Leftrightarrow> t : TBase" |
22494 | 595 |
| QAT_Arrow[intro]: "\<lbrakk>x\<sharp>(\<Gamma>,s,t); (x,T\<^isub>1)#\<Gamma> \<turnstile> App s (Var x) \<Leftrightarrow> App t (Var x) : T\<^isub>2\<rbrakk> |
22418
49e2d9744ae1
major update of the nominal package; there is now an infrastructure
urbanc
parents:
22231
diff
changeset
|
596 |
\<Longrightarrow> \<Gamma> \<turnstile> s \<Leftrightarrow> t : T\<^isub>1 \<rightarrow> T\<^isub>2" |
49e2d9744ae1
major update of the nominal package; there is now an infrastructure
urbanc
parents:
22231
diff
changeset
|
597 |
| QAT_One[intro]: "valid \<Gamma> \<Longrightarrow> \<Gamma> \<turnstile> s \<Leftrightarrow> t : TUnit" |
49e2d9744ae1
major update of the nominal package; there is now an infrastructure
urbanc
parents:
22231
diff
changeset
|
598 |
| QAP_Var[intro]: "\<lbrakk>valid \<Gamma>;(x,T) \<in> set \<Gamma>\<rbrakk> \<Longrightarrow> \<Gamma> \<turnstile> Var x \<leftrightarrow> Var x : T" |
22650
0c5b22076fb3
tuned the proof of lemma pt_list_set_fresh (as suggested by Randy Pollack) and tuned the syntax for sub_contexts
urbanc
parents:
22609
diff
changeset
|
599 |
| QAP_App[intro]: "\<lbrakk>\<Gamma> \<turnstile> p \<leftrightarrow> q : T\<^isub>1 \<rightarrow> T\<^isub>2; \<Gamma> \<turnstile> s \<Leftrightarrow> t : T\<^isub>1\<rbrakk> \<Longrightarrow> \<Gamma> \<turnstile> App p s \<leftrightarrow> App q t : T\<^isub>2" |
22418
49e2d9744ae1
major update of the nominal package; there is now an infrastructure
urbanc
parents:
22231
diff
changeset
|
600 |
| QAP_Const[intro]: "valid \<Gamma> \<Longrightarrow> \<Gamma> \<turnstile> Const n \<leftrightarrow> Const n : TBase" |
49e2d9744ae1
major update of the nominal package; there is now an infrastructure
urbanc
parents:
22231
diff
changeset
|
601 |
|
22730
8bcc8809ed3b
nominal_inductive no longer proves equivariance.
berghofe
parents:
22650
diff
changeset
|
602 |
equivariance alg_equiv |
8bcc8809ed3b
nominal_inductive no longer proves equivariance.
berghofe
parents:
22650
diff
changeset
|
603 |
|
22531 | 604 |
nominal_inductive alg_equiv |
605 |
avoids QAT_Arrow: x |
|
606 |
by simp_all |
|
22418
49e2d9744ae1
major update of the nominal package; there is now an infrastructure
urbanc
parents:
22231
diff
changeset
|
607 |
|
22494 | 608 |
declare trm.inject [simp add] |
22418
49e2d9744ae1
major update of the nominal package; there is now an infrastructure
urbanc
parents:
22231
diff
changeset
|
609 |
declare ty.inject [simp add] |
49e2d9744ae1
major update of the nominal package; there is now an infrastructure
urbanc
parents:
22231
diff
changeset
|
610 |
|
24088
c2d8270e53a5
undo a change in last commit : give a single name to the inversion lemmas for the same inductive type
narboux
parents:
24070
diff
changeset
|
611 |
inductive_cases alg_equiv_inv_auto[elim]: |
c2d8270e53a5
undo a change in last commit : give a single name to the inversion lemmas for the same inductive type
narboux
parents:
24070
diff
changeset
|
612 |
"\<Gamma> \<turnstile> s\<Leftrightarrow>t : TBase" |
c2d8270e53a5
undo a change in last commit : give a single name to the inversion lemmas for the same inductive type
narboux
parents:
24070
diff
changeset
|
613 |
"\<Gamma> \<turnstile> s\<Leftrightarrow>t : T\<^isub>1 \<rightarrow> T\<^isub>2" |
c2d8270e53a5
undo a change in last commit : give a single name to the inversion lemmas for the same inductive type
narboux
parents:
24070
diff
changeset
|
614 |
"\<Gamma> \<turnstile> s\<leftrightarrow>t : TBase" |
c2d8270e53a5
undo a change in last commit : give a single name to the inversion lemmas for the same inductive type
narboux
parents:
24070
diff
changeset
|
615 |
"\<Gamma> \<turnstile> s\<leftrightarrow>t : TUnit" |
c2d8270e53a5
undo a change in last commit : give a single name to the inversion lemmas for the same inductive type
narboux
parents:
24070
diff
changeset
|
616 |
"\<Gamma> \<turnstile> s\<leftrightarrow>t : T\<^isub>1 \<rightarrow> T\<^isub>2" |
22418
49e2d9744ae1
major update of the nominal package; there is now an infrastructure
urbanc
parents:
22231
diff
changeset
|
617 |
|
24088
c2d8270e53a5
undo a change in last commit : give a single name to the inversion lemmas for the same inductive type
narboux
parents:
24070
diff
changeset
|
618 |
"\<Gamma> \<turnstile> Var x \<leftrightarrow> t : T" |
c2d8270e53a5
undo a change in last commit : give a single name to the inversion lemmas for the same inductive type
narboux
parents:
24070
diff
changeset
|
619 |
"\<Gamma> \<turnstile> Var x \<leftrightarrow> t : T'" |
c2d8270e53a5
undo a change in last commit : give a single name to the inversion lemmas for the same inductive type
narboux
parents:
24070
diff
changeset
|
620 |
"\<Gamma> \<turnstile> s \<leftrightarrow> Var x : T" |
c2d8270e53a5
undo a change in last commit : give a single name to the inversion lemmas for the same inductive type
narboux
parents:
24070
diff
changeset
|
621 |
"\<Gamma> \<turnstile> s \<leftrightarrow> Var x : T'" |
c2d8270e53a5
undo a change in last commit : give a single name to the inversion lemmas for the same inductive type
narboux
parents:
24070
diff
changeset
|
622 |
"\<Gamma> \<turnstile> Const n \<leftrightarrow> t : T" |
c2d8270e53a5
undo a change in last commit : give a single name to the inversion lemmas for the same inductive type
narboux
parents:
24070
diff
changeset
|
623 |
"\<Gamma> \<turnstile> s \<leftrightarrow> Const n : T" |
c2d8270e53a5
undo a change in last commit : give a single name to the inversion lemmas for the same inductive type
narboux
parents:
24070
diff
changeset
|
624 |
"\<Gamma> \<turnstile> App p s \<leftrightarrow> t : T" |
c2d8270e53a5
undo a change in last commit : give a single name to the inversion lemmas for the same inductive type
narboux
parents:
24070
diff
changeset
|
625 |
"\<Gamma> \<turnstile> s \<leftrightarrow> App q t : T" |
c2d8270e53a5
undo a change in last commit : give a single name to the inversion lemmas for the same inductive type
narboux
parents:
24070
diff
changeset
|
626 |
"\<Gamma> \<turnstile> Lam[x].s \<leftrightarrow> t : T" |
c2d8270e53a5
undo a change in last commit : give a single name to the inversion lemmas for the same inductive type
narboux
parents:
24070
diff
changeset
|
627 |
"\<Gamma> \<turnstile> t \<leftrightarrow> Lam[x].s : T" |
22418
49e2d9744ae1
major update of the nominal package; there is now an infrastructure
urbanc
parents:
22231
diff
changeset
|
628 |
|
49e2d9744ae1
major update of the nominal package; there is now an infrastructure
urbanc
parents:
22231
diff
changeset
|
629 |
declare trm.inject [simp del] |
49e2d9744ae1
major update of the nominal package; there is now an infrastructure
urbanc
parents:
22231
diff
changeset
|
630 |
declare ty.inject [simp del] |
49e2d9744ae1
major update of the nominal package; there is now an infrastructure
urbanc
parents:
22231
diff
changeset
|
631 |
|
22073 | 632 |
lemma Q_Arrow_strong_inversion: |
22494 | 633 |
assumes fs: "x\<sharp>\<Gamma>" "x\<sharp>t" "x\<sharp>u" |
634 |
and h: "\<Gamma> \<turnstile> t \<Leftrightarrow> u : T\<^isub>1\<rightarrow>T\<^isub>2" |
|
22418
49e2d9744ae1
major update of the nominal package; there is now an infrastructure
urbanc
parents:
22231
diff
changeset
|
635 |
shows "(x,T\<^isub>1)#\<Gamma> \<turnstile> App t (Var x) \<Leftrightarrow> App u (Var x) : T\<^isub>2" |
22073 | 636 |
proof - |
22494 | 637 |
obtain y where fs2: "y\<sharp>(\<Gamma>,t,u)" and "(y,T\<^isub>1)#\<Gamma> \<turnstile> App t (Var y) \<Leftrightarrow> App u (Var y) : T\<^isub>2" |
22082 | 638 |
using h by auto |
22418
49e2d9744ae1
major update of the nominal package; there is now an infrastructure
urbanc
parents:
22231
diff
changeset
|
639 |
then have "([(x,y)]\<bullet>((y,T\<^isub>1)#\<Gamma>)) \<turnstile> [(x,y)]\<bullet> App t (Var y) \<Leftrightarrow> [(x,y)]\<bullet> App u (Var y) : T\<^isub>2" |
22542 | 640 |
using alg_equiv.eqvt[simplified] by blast |
22082 | 641 |
then show ?thesis using fs fs2 by (perm_simp) |
22073 | 642 |
qed |
643 |
||
22418
49e2d9744ae1
major update of the nominal package; there is now an infrastructure
urbanc
parents:
22231
diff
changeset
|
644 |
(* |
22594
33a690455f88
add a few details in the Fst and Snd cases of unicity proof
narboux
parents:
22542
diff
changeset
|
645 |
Warning this lemma is false: |
33a690455f88
add a few details in the Fst and Snd cases of unicity proof
narboux
parents:
22542
diff
changeset
|
646 |
|
22073 | 647 |
lemma algorithmic_type_unicity: |
22418
49e2d9744ae1
major update of the nominal package; there is now an infrastructure
urbanc
parents:
22231
diff
changeset
|
648 |
shows "\<lbrakk> \<Gamma> \<turnstile> s \<Leftrightarrow> t : T ; \<Gamma> \<turnstile> s \<Leftrightarrow> u : T' \<rbrakk> \<Longrightarrow> T = T'" |
22073 | 649 |
and "\<lbrakk> \<Gamma> \<turnstile> s \<leftrightarrow> t : T ; \<Gamma> \<turnstile> s \<leftrightarrow> u : T' \<rbrakk> \<Longrightarrow> T = T'" |
650 |
||
651 |
Here is the counter example : |
|
22418
49e2d9744ae1
major update of the nominal package; there is now an infrastructure
urbanc
parents:
22231
diff
changeset
|
652 |
\<Gamma> \<turnstile> Const n \<Leftrightarrow> Const n : Tbase and \<Gamma> \<turnstile> Const n \<Leftrightarrow> Const n : TUnit |
22073 | 653 |
*) |
654 |
||
655 |
lemma algorithmic_path_type_unicity: |
|
22494 | 656 |
shows "\<Gamma> \<turnstile> s \<leftrightarrow> t : T \<Longrightarrow> \<Gamma> \<turnstile> s \<leftrightarrow> u : T' \<Longrightarrow> T = T'" |
22082 | 657 |
proof (induct arbitrary: u T' |
658 |
rule: alg_equiv_alg_path_equiv.inducts(2) [of _ _ _ _ _ "%a b c d . True" ]) |
|
22073 | 659 |
case (QAP_Var \<Gamma> x T u T') |
660 |
have "\<Gamma> \<turnstile> Var x \<leftrightarrow> u : T'" by fact |
|
661 |
then have "u=Var x" and "(x,T') \<in> set \<Gamma>" by auto |
|
25107 | 662 |
moreover have "valid \<Gamma>" "(x,T) \<in> set \<Gamma>" by fact+ |
22073 | 663 |
ultimately show "T=T'" using type_unicity_in_context by auto |
664 |
next |
|
22418
49e2d9744ae1
major update of the nominal package; there is now an infrastructure
urbanc
parents:
22231
diff
changeset
|
665 |
case (QAP_App \<Gamma> p q T\<^isub>1 T\<^isub>2 s t u T\<^isub>2') |
24070 | 666 |
have ih:"\<And>u T. \<Gamma> \<turnstile> p \<leftrightarrow> u : T \<Longrightarrow> T\<^isub>1\<rightarrow>T\<^isub>2 = T" by fact |
22418
49e2d9744ae1
major update of the nominal package; there is now an infrastructure
urbanc
parents:
22231
diff
changeset
|
667 |
have "\<Gamma> \<turnstile> App p s \<leftrightarrow> u : T\<^isub>2'" by fact |
49e2d9744ae1
major update of the nominal package; there is now an infrastructure
urbanc
parents:
22231
diff
changeset
|
668 |
then obtain r t T\<^isub>1' where "u = App r t" "\<Gamma> \<turnstile> p \<leftrightarrow> r : T\<^isub>1' \<rightarrow> T\<^isub>2'" by auto |
25107 | 669 |
with ih have "T\<^isub>1\<rightarrow>T\<^isub>2 = T\<^isub>1' \<rightarrow> T\<^isub>2'" by auto |
22418
49e2d9744ae1
major update of the nominal package; there is now an infrastructure
urbanc
parents:
22231
diff
changeset
|
670 |
then show "T\<^isub>2=T\<^isub>2'" using ty.inject by auto |
22073 | 671 |
qed (auto) |
672 |
||
22494 | 673 |
lemma alg_path_equiv_implies_valid: |
674 |
shows "\<Gamma> \<turnstile> s \<Leftrightarrow> t : T \<Longrightarrow> valid \<Gamma>" |
|
675 |
and "\<Gamma> \<turnstile> s \<leftrightarrow> t : T \<Longrightarrow> valid \<Gamma>" |
|
676 |
by (induct rule : alg_equiv_alg_path_equiv.inducts, auto) |
|
677 |
||
678 |
lemma algorithmic_symmetry: |
|
679 |
shows "\<Gamma> \<turnstile> s \<Leftrightarrow> t : T \<Longrightarrow> \<Gamma> \<turnstile> t \<Leftrightarrow> s : T" |
|
680 |
and "\<Gamma> \<turnstile> s \<leftrightarrow> t : T \<Longrightarrow> \<Gamma> \<turnstile> t \<leftrightarrow> s : T" |
|
681 |
by (induct rule: alg_equiv_alg_path_equiv.inducts) |
|
682 |
(auto simp add: fresh_prod) |
|
683 |
||
22073 | 684 |
lemma algorithmic_transitivity: |
22494 | 685 |
shows "\<Gamma> \<turnstile> s \<Leftrightarrow> t : T \<Longrightarrow> \<Gamma> \<turnstile> t \<Leftrightarrow> u : T \<Longrightarrow> \<Gamma> \<turnstile> s \<Leftrightarrow> u : T" |
686 |
and "\<Gamma> \<turnstile> s \<leftrightarrow> t : T \<Longrightarrow> \<Gamma> \<turnstile> t \<leftrightarrow> u : T \<Longrightarrow> \<Gamma> \<turnstile> s \<leftrightarrow> u : T" |
|
22531 | 687 |
proof (nominal_induct \<Gamma> s t T and \<Gamma> s t T avoiding: u rule: alg_equiv_alg_path_equiv.strong_inducts) |
22073 | 688 |
case (QAT_Base s p t q \<Gamma> u) |
22418
49e2d9744ae1
major update of the nominal package; there is now an infrastructure
urbanc
parents:
22231
diff
changeset
|
689 |
have "\<Gamma> \<turnstile> t \<Leftrightarrow> u : TBase" by fact |
22494 | 690 |
then obtain r' q' where b1: "t \<Down> q'" and b2: "u \<Down> r'" and b3: "\<Gamma> \<turnstile> q' \<leftrightarrow> r' : TBase" by auto |
691 |
have ih: "\<Gamma> \<turnstile> q \<leftrightarrow> r' : TBase \<Longrightarrow> \<Gamma> \<turnstile> p \<leftrightarrow> r' : TBase" by fact |
|
692 |
have "t \<Down> q" by fact |
|
693 |
with b1 have eq: "q=q'" by (simp add: nf_unicity) |
|
694 |
with ih b3 have "\<Gamma> \<turnstile> p \<leftrightarrow> r' : TBase" by simp |
|
695 |
moreover |
|
696 |
have "s \<Down> p" by fact |
|
697 |
ultimately show "\<Gamma> \<turnstile> s \<Leftrightarrow> u : TBase" using b2 by auto |
|
22073 | 698 |
next |
22418
49e2d9744ae1
major update of the nominal package; there is now an infrastructure
urbanc
parents:
22231
diff
changeset
|
699 |
case (QAT_Arrow x \<Gamma> s t T\<^isub>1 T\<^isub>2 u) |
22494 | 700 |
have ih:"(x,T\<^isub>1)#\<Gamma> \<turnstile> App t (Var x) \<Leftrightarrow> App u (Var x) : T\<^isub>2 |
701 |
\<Longrightarrow> (x,T\<^isub>1)#\<Gamma> \<turnstile> App s (Var x) \<Leftrightarrow> App u (Var x) : T\<^isub>2" by fact |
|
25107 | 702 |
have fs: "x\<sharp>\<Gamma>" "x\<sharp>s" "x\<sharp>t" "x\<sharp>u" by fact+ |
22494 | 703 |
have "\<Gamma> \<turnstile> t \<Leftrightarrow> u : T\<^isub>1\<rightarrow>T\<^isub>2" by fact |
704 |
then have "(x,T\<^isub>1)#\<Gamma> \<turnstile> App t (Var x) \<Leftrightarrow> App u (Var x) : T\<^isub>2" using fs |
|
705 |
by (simp add: Q_Arrow_strong_inversion) |
|
706 |
with ih have "(x,T\<^isub>1)#\<Gamma> \<turnstile> App s (Var x) \<Leftrightarrow> App u (Var x) : T\<^isub>2" by simp |
|
707 |
then show "\<Gamma> \<turnstile> s \<Leftrightarrow> u : T\<^isub>1\<rightarrow>T\<^isub>2" using fs by (auto simp add: fresh_prod) |
|
22073 | 708 |
next |
22418
49e2d9744ae1
major update of the nominal package; there is now an infrastructure
urbanc
parents:
22231
diff
changeset
|
709 |
case (QAP_App \<Gamma> p q T\<^isub>1 T\<^isub>2 s t u) |
49e2d9744ae1
major update of the nominal package; there is now an infrastructure
urbanc
parents:
22231
diff
changeset
|
710 |
have "\<Gamma> \<turnstile> App q t \<leftrightarrow> u : T\<^isub>2" by fact |
22494 | 711 |
then obtain r T\<^isub>1' v where ha: "\<Gamma> \<turnstile> q \<leftrightarrow> r : T\<^isub>1'\<rightarrow>T\<^isub>2" and hb: "\<Gamma> \<turnstile> t \<Leftrightarrow> v : T\<^isub>1'" and eq: "u = App r v" |
22082 | 712 |
by auto |
22494 | 713 |
have ih1: "\<Gamma> \<turnstile> q \<leftrightarrow> r : T\<^isub>1\<rightarrow>T\<^isub>2 \<Longrightarrow> \<Gamma> \<turnstile> p \<leftrightarrow> r : T\<^isub>1\<rightarrow>T\<^isub>2" by fact |
714 |
have ih2:"\<Gamma> \<turnstile> t \<Leftrightarrow> v : T\<^isub>1 \<Longrightarrow> \<Gamma> \<turnstile> s \<Leftrightarrow> v : T\<^isub>1" by fact |
|
715 |
have "\<Gamma> \<turnstile> p \<leftrightarrow> q : T\<^isub>1\<rightarrow>T\<^isub>2" by fact |
|
716 |
then have "\<Gamma> \<turnstile> q \<leftrightarrow> p : T\<^isub>1\<rightarrow>T\<^isub>2" by (simp add: algorithmic_symmetry) |
|
717 |
with ha have "T\<^isub>1'\<rightarrow>T\<^isub>2 = T\<^isub>1\<rightarrow>T\<^isub>2" using algorithmic_path_type_unicity by simp |
|
718 |
then have "T\<^isub>1' = T\<^isub>1" by (simp add: ty.inject) |
|
22418
49e2d9744ae1
major update of the nominal package; there is now an infrastructure
urbanc
parents:
22231
diff
changeset
|
719 |
then have "\<Gamma> \<turnstile> s \<Leftrightarrow> v : T\<^isub>1" "\<Gamma> \<turnstile> p \<leftrightarrow> r : T\<^isub>1\<rightarrow>T\<^isub>2" using ih1 ih2 ha hb by auto |
49e2d9744ae1
major update of the nominal package; there is now an infrastructure
urbanc
parents:
22231
diff
changeset
|
720 |
then show "\<Gamma> \<turnstile> App p s \<leftrightarrow> u : T\<^isub>2" using eq by auto |
22073 | 721 |
qed (auto) |
722 |
||
723 |
lemma algorithmic_weak_head_closure: |
|
22494 | 724 |
shows "\<Gamma> \<turnstile> s \<Leftrightarrow> t : T \<Longrightarrow> s' \<leadsto> s \<Longrightarrow> t' \<leadsto> t \<Longrightarrow> \<Gamma> \<turnstile> s' \<Leftrightarrow> t' : T" |
725 |
apply (nominal_induct \<Gamma> s t T avoiding: s' t' |
|
22531 | 726 |
rule: alg_equiv_alg_path_equiv.strong_inducts(1) [of _ _ _ _ "%a b c d e. True"]) |
22494 | 727 |
apply(auto intro!: QAT_Arrow) |
728 |
done |
|
729 |
||
730 |
lemma algorithmic_monotonicity: |
|
22650
0c5b22076fb3
tuned the proof of lemma pt_list_set_fresh (as suggested by Randy Pollack) and tuned the syntax for sub_contexts
urbanc
parents:
22609
diff
changeset
|
731 |
shows "\<Gamma> \<turnstile> s \<Leftrightarrow> t : T \<Longrightarrow> \<Gamma> \<subseteq> \<Gamma>' \<Longrightarrow> valid \<Gamma>' \<Longrightarrow> \<Gamma>' \<turnstile> s \<Leftrightarrow> t : T" |
0c5b22076fb3
tuned the proof of lemma pt_list_set_fresh (as suggested by Randy Pollack) and tuned the syntax for sub_contexts
urbanc
parents:
22609
diff
changeset
|
732 |
and "\<Gamma> \<turnstile> s \<leftrightarrow> t : T \<Longrightarrow> \<Gamma> \<subseteq> \<Gamma>' \<Longrightarrow> valid \<Gamma>' \<Longrightarrow> \<Gamma>' \<turnstile> s \<leftrightarrow> t : T" |
22531 | 733 |
proof (nominal_induct \<Gamma> s t T and \<Gamma> s t T avoiding: \<Gamma>' rule: alg_equiv_alg_path_equiv.strong_inducts) |
22494 | 734 |
case (QAT_Arrow x \<Gamma> s t T\<^isub>1 T\<^isub>2 \<Gamma>') |
25107 | 735 |
have fs:"x\<sharp>\<Gamma>" "x\<sharp>s" "x\<sharp>t" "x\<sharp>\<Gamma>'" by fact+ |
22650
0c5b22076fb3
tuned the proof of lemma pt_list_set_fresh (as suggested by Randy Pollack) and tuned the syntax for sub_contexts
urbanc
parents:
22609
diff
changeset
|
736 |
have h2:"\<Gamma> \<subseteq> \<Gamma>'" by fact |
0c5b22076fb3
tuned the proof of lemma pt_list_set_fresh (as suggested by Randy Pollack) and tuned the syntax for sub_contexts
urbanc
parents:
22609
diff
changeset
|
737 |
have ih:"\<And>\<Gamma>'. \<lbrakk>(x,T\<^isub>1)#\<Gamma> \<subseteq> \<Gamma>'; valid \<Gamma>'\<rbrakk> \<Longrightarrow> \<Gamma>' \<turnstile> App s (Var x) \<Leftrightarrow> App t (Var x) : T\<^isub>2" by fact |
22494 | 738 |
have "valid \<Gamma>'" by fact |
739 |
then have "valid ((x,T\<^isub>1)#\<Gamma>')" using fs by auto |
|
740 |
moreover |
|
22650
0c5b22076fb3
tuned the proof of lemma pt_list_set_fresh (as suggested by Randy Pollack) and tuned the syntax for sub_contexts
urbanc
parents:
22609
diff
changeset
|
741 |
have sub: "(x,T\<^isub>1)#\<Gamma> \<subseteq> (x,T\<^isub>1)#\<Gamma>'" using h2 by auto |
22494 | 742 |
ultimately have "(x,T\<^isub>1)#\<Gamma>' \<turnstile> App s (Var x) \<Leftrightarrow> App t (Var x) : T\<^isub>2" using ih by simp |
743 |
then show "\<Gamma>' \<turnstile> s \<Leftrightarrow> t : T\<^isub>1\<rightarrow>T\<^isub>2" using fs by (auto simp add: fresh_prod) |
|
744 |
qed (auto) |
|
745 |
||
746 |
lemma path_equiv_implies_nf: |
|
747 |
assumes "\<Gamma> \<turnstile> s \<leftrightarrow> t : T" |
|
748 |
shows "s \<leadsto>|" and "t \<leadsto>|" |
|
749 |
using assms |
|
750 |
by (induct rule: alg_equiv_alg_path_equiv.inducts(2)) (simp, auto) |
|
751 |
||
752 |
section {* Logical Equivalence *} |
|
753 |
||
754 |
function log_equiv :: "(Ctxt \<Rightarrow> trm \<Rightarrow> trm \<Rightarrow> ty \<Rightarrow> bool)" ("_ \<turnstile> _ is _ : _" [60,60,60,60] 60) |
|
755 |
where |
|
756 |
"\<Gamma> \<turnstile> s is t : TUnit = True" |
|
757 |
| "\<Gamma> \<turnstile> s is t : TBase = \<Gamma> \<turnstile> s \<Leftrightarrow> t : TBase" |
|
758 |
| "\<Gamma> \<turnstile> s is t : (T\<^isub>1 \<rightarrow> T\<^isub>2) = |
|
22650
0c5b22076fb3
tuned the proof of lemma pt_list_set_fresh (as suggested by Randy Pollack) and tuned the syntax for sub_contexts
urbanc
parents:
22609
diff
changeset
|
759 |
(\<forall>\<Gamma>' s' t'. \<Gamma>\<subseteq>\<Gamma>' \<longrightarrow> valid \<Gamma>' \<longrightarrow> \<Gamma>' \<turnstile> s' is t' : T\<^isub>1 \<longrightarrow> (\<Gamma>' \<turnstile> (App s s') is (App t t') : T\<^isub>2))" |
22494 | 760 |
apply (auto simp add: ty.inject) |
761 |
apply (subgoal_tac "(\<exists>T\<^isub>1 T\<^isub>2. b=T\<^isub>1 \<rightarrow> T\<^isub>2) \<or> b=TUnit \<or> b=TBase" ) |
|
762 |
apply (force) |
|
763 |
apply (rule ty_cases) |
|
764 |
done |
|
765 |
||
766 |
termination |
|
767 |
apply(relation "measure (\<lambda>(_,_,_,T). size T)") |
|
768 |
apply(auto) |
|
769 |
done |
|
770 |
||
24231
85fb973a8207
added type constraints to resolve syntax ambiguities;
wenzelm
parents:
24088
diff
changeset
|
771 |
lemma logical_monotonicity: |
85fb973a8207
added type constraints to resolve syntax ambiguities;
wenzelm
parents:
24088
diff
changeset
|
772 |
fixes \<Gamma> \<Gamma>' :: Ctxt |
22494 | 773 |
assumes a1: "\<Gamma> \<turnstile> s is t : T" |
22650
0c5b22076fb3
tuned the proof of lemma pt_list_set_fresh (as suggested by Randy Pollack) and tuned the syntax for sub_contexts
urbanc
parents:
22609
diff
changeset
|
774 |
and a2: "\<Gamma> \<subseteq> \<Gamma>'" |
22494 | 775 |
and a3: "valid \<Gamma>'" |
776 |
shows "\<Gamma>' \<turnstile> s is t : T" |
|
777 |
using a1 a2 a3 |
|
778 |
proof (induct arbitrary: \<Gamma>' rule: log_equiv.induct) |
|
779 |
case (2 \<Gamma> s t \<Gamma>') |
|
780 |
then show "\<Gamma>' \<turnstile> s is t : TBase" using algorithmic_monotonicity by auto |
|
781 |
next |
|
782 |
case (3 \<Gamma> s t T\<^isub>1 T\<^isub>2 \<Gamma>') |
|
783 |
have "\<Gamma> \<turnstile> s is t : T\<^isub>1\<rightarrow>T\<^isub>2" |
|
24070 | 784 |
and "\<Gamma> \<subseteq> \<Gamma>'" |
25107 | 785 |
and "valid \<Gamma>'" by fact+ |
22494 | 786 |
then show "\<Gamma>' \<turnstile> s is t : T\<^isub>1\<rightarrow>T\<^isub>2" by simp |
787 |
qed (auto) |
|
788 |
||
789 |
lemma main_lemma: |
|
790 |
shows "\<Gamma> \<turnstile> s is t : T \<Longrightarrow> valid \<Gamma> \<Longrightarrow> \<Gamma> \<turnstile> s \<Leftrightarrow> t : T" |
|
791 |
and "\<Gamma> \<turnstile> p \<leftrightarrow> q : T \<Longrightarrow> \<Gamma> \<turnstile> p is q : T" |
|
792 |
proof (nominal_induct T arbitrary: \<Gamma> s t p q rule: ty.induct) |
|
793 |
case (Arrow T\<^isub>1 T\<^isub>2) |
|
794 |
{ |
|
795 |
case (1 \<Gamma> s t) |
|
796 |
have ih1:"\<And>\<Gamma> s t. \<lbrakk>\<Gamma> \<turnstile> s is t : T\<^isub>2; valid \<Gamma>\<rbrakk> \<Longrightarrow> \<Gamma> \<turnstile> s \<Leftrightarrow> t : T\<^isub>2" by fact |
|
797 |
have ih2:"\<And>\<Gamma> s t. \<Gamma> \<turnstile> s \<leftrightarrow> t : T\<^isub>1 \<Longrightarrow> \<Gamma> \<turnstile> s is t : T\<^isub>1" by fact |
|
798 |
have h:"\<Gamma> \<turnstile> s is t : T\<^isub>1\<rightarrow>T\<^isub>2" by fact |
|
799 |
obtain x::name where fs:"x\<sharp>(\<Gamma>,s,t)" by (erule exists_fresh[OF fs_name1]) |
|
800 |
have "valid \<Gamma>" by fact |
|
801 |
then have v: "valid ((x,T\<^isub>1)#\<Gamma>)" using fs by auto |
|
802 |
then have "(x,T\<^isub>1)#\<Gamma> \<turnstile> Var x \<leftrightarrow> Var x : T\<^isub>1" by auto |
|
803 |
then have "(x,T\<^isub>1)#\<Gamma> \<turnstile> Var x is Var x : T\<^isub>1" using ih2 by auto |
|
804 |
then have "(x,T\<^isub>1)#\<Gamma> \<turnstile> App s (Var x) is App t (Var x) : T\<^isub>2" using h v by auto |
|
805 |
then have "(x,T\<^isub>1)#\<Gamma> \<turnstile> App s (Var x) \<Leftrightarrow> App t (Var x) : T\<^isub>2" using ih1 v by auto |
|
806 |
then show "\<Gamma> \<turnstile> s \<Leftrightarrow> t : T\<^isub>1\<rightarrow>T\<^isub>2" using fs by (auto simp add: fresh_prod) |
|
807 |
next |
|
808 |
case (2 \<Gamma> p q) |
|
809 |
have h: "\<Gamma> \<turnstile> p \<leftrightarrow> q : T\<^isub>1\<rightarrow>T\<^isub>2" by fact |
|
810 |
have ih1:"\<And>\<Gamma> s t. \<Gamma> \<turnstile> s \<leftrightarrow> t : T\<^isub>2 \<Longrightarrow> \<Gamma> \<turnstile> s is t : T\<^isub>2" by fact |
|
811 |
have ih2:"\<And>\<Gamma> s t. \<lbrakk>\<Gamma> \<turnstile> s is t : T\<^isub>1; valid \<Gamma>\<rbrakk> \<Longrightarrow> \<Gamma> \<turnstile> s \<Leftrightarrow> t : T\<^isub>1" by fact |
|
812 |
{ |
|
813 |
fix \<Gamma>' s t |
|
22650
0c5b22076fb3
tuned the proof of lemma pt_list_set_fresh (as suggested by Randy Pollack) and tuned the syntax for sub_contexts
urbanc
parents:
22609
diff
changeset
|
814 |
assume "\<Gamma> \<subseteq> \<Gamma>'" and hl:"\<Gamma>' \<turnstile> s is t : T\<^isub>1" and hk: "valid \<Gamma>'" |
22494 | 815 |
then have "\<Gamma>' \<turnstile> p \<leftrightarrow> q : T\<^isub>1 \<rightarrow> T\<^isub>2" using h algorithmic_monotonicity by auto |
816 |
moreover have "\<Gamma>' \<turnstile> s \<Leftrightarrow> t : T\<^isub>1" using ih2 hl hk by auto |
|
817 |
ultimately have "\<Gamma>' \<turnstile> App p s \<leftrightarrow> App q t : T\<^isub>2" by auto |
|
818 |
then have "\<Gamma>' \<turnstile> App p s is App q t : T\<^isub>2" using ih1 by auto |
|
819 |
} |
|
820 |
then show "\<Gamma> \<turnstile> p is q : T\<^isub>1\<rightarrow>T\<^isub>2" by simp |
|
821 |
} |
|
822 |
next |
|
823 |
case TBase |
|
824 |
{ case 2 |
|
825 |
have h:"\<Gamma> \<turnstile> s \<leftrightarrow> t : TBase" by fact |
|
826 |
then have "s \<leadsto>|" and "t \<leadsto>|" using path_equiv_implies_nf by auto |
|
827 |
then have "s \<Down> s" and "t \<Down> t" by auto |
|
828 |
then have "\<Gamma> \<turnstile> s \<Leftrightarrow> t : TBase" using h by auto |
|
829 |
then show "\<Gamma> \<turnstile> s is t : TBase" by auto |
|
830 |
} |
|
831 |
qed (auto elim: alg_path_equiv_implies_valid) |
|
832 |
||
833 |
corollary corollary_main: |
|
834 |
assumes a: "\<Gamma> \<turnstile> s \<leftrightarrow> t : T" |
|
835 |
shows "\<Gamma> \<turnstile> s \<Leftrightarrow> t : T" |
|
836 |
using a main_lemma alg_path_equiv_implies_valid by blast |
|
22073 | 837 |
|
838 |
lemma logical_symmetry: |
|
22082 | 839 |
assumes a: "\<Gamma> \<turnstile> s is t : T" |
22073 | 840 |
shows "\<Gamma> \<turnstile> t is s : T" |
22082 | 841 |
using a |
22494 | 842 |
by (nominal_induct arbitrary: \<Gamma> s t rule: ty.induct) |
843 |
(auto simp add: algorithmic_symmetry) |
|
22073 | 844 |
|
845 |
lemma logical_transitivity: |
|
846 |
assumes "\<Gamma> \<turnstile> s is t : T" "\<Gamma> \<turnstile> t is u : T" |
|
847 |
shows "\<Gamma> \<turnstile> s is u : T" |
|
848 |
using assms |
|
849 |
proof (nominal_induct arbitrary: \<Gamma> s t u rule:ty.induct) |
|
850 |
case TBase |
|
851 |
then show "\<Gamma> \<turnstile> s is u : TBase" by (auto elim: algorithmic_transitivity) |
|
852 |
next |
|
22418
49e2d9744ae1
major update of the nominal package; there is now an infrastructure
urbanc
parents:
22231
diff
changeset
|
853 |
case (Arrow T\<^isub>1 T\<^isub>2 \<Gamma> s t u) |
49e2d9744ae1
major update of the nominal package; there is now an infrastructure
urbanc
parents:
22231
diff
changeset
|
854 |
have h1:"\<Gamma> \<turnstile> s is t : T\<^isub>1 \<rightarrow> T\<^isub>2" by fact |
49e2d9744ae1
major update of the nominal package; there is now an infrastructure
urbanc
parents:
22231
diff
changeset
|
855 |
have h2:"\<Gamma> \<turnstile> t is u : T\<^isub>1 \<rightarrow> T\<^isub>2" by fact |
49e2d9744ae1
major update of the nominal package; there is now an infrastructure
urbanc
parents:
22231
diff
changeset
|
856 |
have ih1:"\<And>\<Gamma> s t u. \<lbrakk>\<Gamma> \<turnstile> s is t : T\<^isub>1; \<Gamma> \<turnstile> t is u : T\<^isub>1\<rbrakk> \<Longrightarrow> \<Gamma> \<turnstile> s is u : T\<^isub>1" by fact |
49e2d9744ae1
major update of the nominal package; there is now an infrastructure
urbanc
parents:
22231
diff
changeset
|
857 |
have ih2:"\<And>\<Gamma> s t u. \<lbrakk>\<Gamma> \<turnstile> s is t : T\<^isub>2; \<Gamma> \<turnstile> t is u : T\<^isub>2\<rbrakk> \<Longrightarrow> \<Gamma> \<turnstile> s is u : T\<^isub>2" by fact |
22073 | 858 |
{ |
859 |
fix \<Gamma>' s' u' |
|
22650
0c5b22076fb3
tuned the proof of lemma pt_list_set_fresh (as suggested by Randy Pollack) and tuned the syntax for sub_contexts
urbanc
parents:
22609
diff
changeset
|
860 |
assume hsub:"\<Gamma> \<subseteq> \<Gamma>'" and hl:"\<Gamma>' \<turnstile> s' is u' : T\<^isub>1" and hk: "valid \<Gamma>'" |
22418
49e2d9744ae1
major update of the nominal package; there is now an infrastructure
urbanc
parents:
22231
diff
changeset
|
861 |
then have "\<Gamma>' \<turnstile> u' is s' : T\<^isub>1" using logical_symmetry by blast |
49e2d9744ae1
major update of the nominal package; there is now an infrastructure
urbanc
parents:
22231
diff
changeset
|
862 |
then have "\<Gamma>' \<turnstile> u' is u' : T\<^isub>1" using ih1 hl by blast |
22494 | 863 |
then have "\<Gamma>' \<turnstile> App t u' is App u u' : T\<^isub>2" using h2 hsub hk by auto |
864 |
moreover have "\<Gamma>' \<turnstile> App s s' is App t u' : T\<^isub>2" using h1 hsub hl hk by auto |
|
22418
49e2d9744ae1
major update of the nominal package; there is now an infrastructure
urbanc
parents:
22231
diff
changeset
|
865 |
ultimately have "\<Gamma>' \<turnstile> App s s' is App u u' : T\<^isub>2" using ih2 by blast |
22073 | 866 |
} |
22494 | 867 |
then show "\<Gamma> \<turnstile> s is u : T\<^isub>1 \<rightarrow> T\<^isub>2" by auto |
22073 | 868 |
qed (auto) |
869 |
||
870 |
lemma logical_weak_head_closure: |
|
22494 | 871 |
assumes a: "\<Gamma> \<turnstile> s is t : T" |
872 |
and b: "s' \<leadsto> s" |
|
873 |
and c: "t' \<leadsto> t" |
|
22073 | 874 |
shows "\<Gamma> \<turnstile> s' is t' : T" |
22494 | 875 |
using a b c algorithmic_weak_head_closure |
876 |
by (nominal_induct arbitrary: \<Gamma> s t s' t' rule: ty.induct) |
|
877 |
(auto, blast) |
|
22073 | 878 |
|
879 |
lemma logical_weak_head_closure': |
|
22494 | 880 |
assumes "\<Gamma> \<turnstile> s is t : T" and "s' \<leadsto> s" |
22073 | 881 |
shows "\<Gamma> \<turnstile> s' is t : T" |
882 |
using assms |
|
22082 | 883 |
proof (nominal_induct arbitrary: \<Gamma> s t s' rule: ty.induct) |
22073 | 884 |
case (TBase \<Gamma> s t s') |
885 |
then show ?case by force |
|
886 |
next |
|
887 |
case (TUnit \<Gamma> s t s') |
|
888 |
then show ?case by auto |
|
22418
49e2d9744ae1
major update of the nominal package; there is now an infrastructure
urbanc
parents:
22231
diff
changeset
|
889 |
next |
49e2d9744ae1
major update of the nominal package; there is now an infrastructure
urbanc
parents:
22231
diff
changeset
|
890 |
case (Arrow T\<^isub>1 T\<^isub>2 \<Gamma> s t s') |
22073 | 891 |
have h1:"s' \<leadsto> s" by fact |
22418
49e2d9744ae1
major update of the nominal package; there is now an infrastructure
urbanc
parents:
22231
diff
changeset
|
892 |
have ih:"\<And>\<Gamma> s t s'. \<lbrakk>\<Gamma> \<turnstile> s is t : T\<^isub>2; s' \<leadsto> s\<rbrakk> \<Longrightarrow> \<Gamma> \<turnstile> s' is t : T\<^isub>2" by fact |
49e2d9744ae1
major update of the nominal package; there is now an infrastructure
urbanc
parents:
22231
diff
changeset
|
893 |
have h2:"\<Gamma> \<turnstile> s is t : T\<^isub>1\<rightarrow>T\<^isub>2" by fact |
22494 | 894 |
then |
22650
0c5b22076fb3
tuned the proof of lemma pt_list_set_fresh (as suggested by Randy Pollack) and tuned the syntax for sub_contexts
urbanc
parents:
22609
diff
changeset
|
895 |
have hb:"\<forall>\<Gamma>' s' t'. \<Gamma>\<subseteq>\<Gamma>' \<longrightarrow> valid \<Gamma>' \<longrightarrow> \<Gamma>' \<turnstile> s' is t' : T\<^isub>1 \<longrightarrow> (\<Gamma>' \<turnstile> (App s s') is (App t t') : T\<^isub>2)" |
22494 | 896 |
by auto |
22073 | 897 |
{ |
22418
49e2d9744ae1
major update of the nominal package; there is now an infrastructure
urbanc
parents:
22231
diff
changeset
|
898 |
fix \<Gamma>' s\<^isub>2 t\<^isub>2 |
22650
0c5b22076fb3
tuned the proof of lemma pt_list_set_fresh (as suggested by Randy Pollack) and tuned the syntax for sub_contexts
urbanc
parents:
22609
diff
changeset
|
899 |
assume "\<Gamma> \<subseteq> \<Gamma>'" and "\<Gamma>' \<turnstile> s\<^isub>2 is t\<^isub>2 : T\<^isub>1" and "valid \<Gamma>'" |
22418
49e2d9744ae1
major update of the nominal package; there is now an infrastructure
urbanc
parents:
22231
diff
changeset
|
900 |
then have "\<Gamma>' \<turnstile> (App s s\<^isub>2) is (App t t\<^isub>2) : T\<^isub>2" using hb by auto |
49e2d9744ae1
major update of the nominal package; there is now an infrastructure
urbanc
parents:
22231
diff
changeset
|
901 |
moreover have "(App s' s\<^isub>2) \<leadsto> (App s s\<^isub>2)" using h1 by auto |
49e2d9744ae1
major update of the nominal package; there is now an infrastructure
urbanc
parents:
22231
diff
changeset
|
902 |
ultimately have "\<Gamma>' \<turnstile> App s' s\<^isub>2 is App t t\<^isub>2 : T\<^isub>2" using ih by auto |
22073 | 903 |
} |
22494 | 904 |
then show "\<Gamma> \<turnstile> s' is t : T\<^isub>1\<rightarrow>T\<^isub>2" by auto |
22418
49e2d9744ae1
major update of the nominal package; there is now an infrastructure
urbanc
parents:
22231
diff
changeset
|
905 |
qed |
22073 | 906 |
|
907 |
abbreviation |
|
22494 | 908 |
log_equiv_for_psubsts :: "Ctxt \<Rightarrow> Subst \<Rightarrow> Subst \<Rightarrow> Ctxt \<Rightarrow> bool" ("_ \<turnstile> _ is _ over _" [60,60] 60) |
22073 | 909 |
where |
22494 | 910 |
"\<Gamma>' \<turnstile> \<theta> is \<theta>' over \<Gamma> \<equiv> \<forall>x T. (x,T) \<in> set \<Gamma> \<longrightarrow> \<Gamma>' \<turnstile> \<theta><Var x> is \<theta>'<Var x> : T" |
22073 | 911 |
|
912 |
lemma logical_pseudo_reflexivity: |
|
913 |
assumes "\<Gamma>' \<turnstile> t is s over \<Gamma>" |
|
914 |
shows "\<Gamma>' \<turnstile> s is s over \<Gamma>" |
|
915 |
proof - |
|
916 |
have "\<Gamma>' \<turnstile> t is s over \<Gamma>" by fact |
|
917 |
moreover then have "\<Gamma>' \<turnstile> s is t over \<Gamma>" using logical_symmetry by blast |
|
918 |
ultimately show "\<Gamma>' \<turnstile> s is s over \<Gamma>" using logical_transitivity by blast |
|
919 |
qed |
|
920 |
||
921 |
lemma logical_subst_monotonicity : |
|
24231
85fb973a8207
added type constraints to resolve syntax ambiguities;
wenzelm
parents:
24088
diff
changeset
|
922 |
fixes \<Gamma> \<Gamma>' \<Gamma>'' :: Ctxt |
24070 | 923 |
assumes a: "\<Gamma>' \<turnstile> \<theta> is \<theta>' over \<Gamma>" |
22650
0c5b22076fb3
tuned the proof of lemma pt_list_set_fresh (as suggested by Randy Pollack) and tuned the syntax for sub_contexts
urbanc
parents:
22609
diff
changeset
|
924 |
and b: "\<Gamma>' \<subseteq> \<Gamma>''" |
22494 | 925 |
and c: "valid \<Gamma>''" |
24070 | 926 |
shows "\<Gamma>'' \<turnstile> \<theta> is \<theta>' over \<Gamma>" |
22494 | 927 |
using a b c logical_monotonicity by blast |
22073 | 928 |
|
929 |
lemma equiv_subst_ext : |
|
22494 | 930 |
assumes h1: "\<Gamma>' \<turnstile> \<theta> is \<theta>' over \<Gamma>" |
931 |
and h2: "\<Gamma>' \<turnstile> s is t : T" |
|
932 |
and fs: "x\<sharp>\<Gamma>" |
|
933 |
shows "\<Gamma>' \<turnstile> (x,s)#\<theta> is (x,t)#\<theta>' over (x,T)#\<Gamma>" |
|
22073 | 934 |
using assms |
935 |
proof - |
|
22494 | 936 |
{ |
937 |
fix y U |
|
938 |
assume "(y,U) \<in> set ((x,T)#\<Gamma>)" |
|
939 |
moreover |
|
940 |
{ |
|
941 |
assume "(y,U) \<in> set [(x,T)]" |
|
25107 | 942 |
with h2 have "\<Gamma>' \<turnstile> ((x,s)#\<theta>)<Var y> is ((x,t)#\<theta>')<Var y> : U" by auto |
22494 | 943 |
} |
944 |
moreover |
|
945 |
{ |
|
946 |
assume hl:"(y,U) \<in> set \<Gamma>" |
|
947 |
then have "\<not> y\<sharp>\<Gamma>" by (induct \<Gamma>) (auto simp add: fresh_list_cons fresh_atm fresh_prod) |
|
948 |
then have hf:"x\<sharp> Var y" using fs by (auto simp add: fresh_atm) |
|
24070 | 949 |
then have "((x,s)#\<theta>)<Var y> = \<theta><Var y>" "((x,t)#\<theta>')<Var y> = \<theta>'<Var y>" |
950 |
using fresh_psubst_simp by blast+ |
|
22494 | 951 |
moreover have "\<Gamma>' \<turnstile> \<theta><Var y> is \<theta>'<Var y> : U" using h1 hl by auto |
24070 | 952 |
ultimately have "\<Gamma>' \<turnstile> ((x,s)#\<theta>)<Var y> is ((x,t)#\<theta>')<Var y> : U" by auto |
22494 | 953 |
} |
24070 | 954 |
ultimately have "\<Gamma>' \<turnstile> ((x,s)#\<theta>)<Var y> is ((x,t)#\<theta>')<Var y> : U" by auto |
22073 | 955 |
} |
22494 | 956 |
then show "\<Gamma>' \<turnstile> (x,s)#\<theta> is (x,t)#\<theta>' over (x,T)#\<Gamma>" by auto |
22073 | 957 |
qed |
958 |
||
22494 | 959 |
theorem fundamental_theorem_1: |
24070 | 960 |
assumes a1: "\<Gamma> \<turnstile> t : T" |
961 |
and a2: "\<Gamma>' \<turnstile> \<theta> is \<theta>' over \<Gamma>" |
|
962 |
and a3: "valid \<Gamma>'" |
|
22494 | 963 |
shows "\<Gamma>' \<turnstile> \<theta><t> is \<theta>'<t> : T" |
24070 | 964 |
using a1 a2 a3 |
965 |
proof (nominal_induct \<Gamma> t T avoiding: \<theta> \<theta>' arbitrary: \<Gamma>' rule: typing.strong_induct) |
|
966 |
case (T_Lam x \<Gamma> T\<^isub>1 t\<^isub>2 T\<^isub>2 \<theta> \<theta>' \<Gamma>') |
|
25107 | 967 |
have vc: "x\<sharp>\<theta>" "x\<sharp>\<theta>'" "x\<sharp>\<Gamma>" by fact+ |
24070 | 968 |
have asm1: "\<Gamma>' \<turnstile> \<theta> is \<theta>' over \<Gamma>" by fact |
969 |
have ih:"\<And>\<theta> \<theta>' \<Gamma>'. \<lbrakk>\<Gamma>' \<turnstile> \<theta> is \<theta>' over (x,T\<^isub>1)#\<Gamma>; valid \<Gamma>'\<rbrakk> \<Longrightarrow> \<Gamma>' \<turnstile> \<theta><t\<^isub>2> is \<theta>'<t\<^isub>2> : T\<^isub>2" by fact |
|
970 |
show "\<Gamma>' \<turnstile> \<theta><Lam [x].t\<^isub>2> is \<theta>'<Lam [x].t\<^isub>2> : T\<^isub>1\<rightarrow>T\<^isub>2" using vc |
|
971 |
proof (simp, intro strip) |
|
22494 | 972 |
fix \<Gamma>'' s' t' |
24070 | 973 |
assume sub: "\<Gamma>' \<subseteq> \<Gamma>''" |
974 |
and asm2: "\<Gamma>''\<turnstile> s' is t' : T\<^isub>1" |
|
975 |
and val: "valid \<Gamma>''" |
|
976 |
from asm1 val sub have "\<Gamma>'' \<turnstile> \<theta> is \<theta>' over \<Gamma>" using logical_subst_monotonicity by blast |
|
977 |
with asm2 vc have "\<Gamma>'' \<turnstile> (x,s')#\<theta> is (x,t')#\<theta>' over (x,T\<^isub>1)#\<Gamma>" using equiv_subst_ext by blast |
|
978 |
with ih val have "\<Gamma>'' \<turnstile> ((x,s')#\<theta>)<t\<^isub>2> is ((x,t')#\<theta>')<t\<^isub>2> : T\<^isub>2" by auto |
|
979 |
with vc have "\<Gamma>''\<turnstile>\<theta><t\<^isub>2>[x::=s'] is \<theta>'<t\<^isub>2>[x::=t'] : T\<^isub>2" by (simp add: psubst_subst_psubst) |
|
980 |
moreover |
|
981 |
have "App (Lam [x].\<theta><t\<^isub>2>) s' \<leadsto> \<theta><t\<^isub>2>[x::=s']" by auto |
|
982 |
moreover |
|
983 |
have "App (Lam [x].\<theta>'<t\<^isub>2>) t' \<leadsto> \<theta>'<t\<^isub>2>[x::=t']" by auto |
|
984 |
ultimately show "\<Gamma>''\<turnstile> App (Lam [x].\<theta><t\<^isub>2>) s' is App (Lam [x].\<theta>'<t\<^isub>2>) t' : T\<^isub>2" |
|
22494 | 985 |
using logical_weak_head_closure by auto |
24070 | 986 |
qed |
22073 | 987 |
qed (auto) |
988 |
||
24070 | 989 |
|
22073 | 990 |
theorem fundamental_theorem_2: |
22418
49e2d9744ae1
major update of the nominal package; there is now an infrastructure
urbanc
parents:
22231
diff
changeset
|
991 |
assumes h1: "\<Gamma> \<turnstile> s \<equiv> t : T" |
22494 | 992 |
and h2: "\<Gamma>' \<turnstile> \<theta> is \<theta>' over \<Gamma>" |
993 |
and h3: "valid \<Gamma>'" |
|
994 |
shows "\<Gamma>' \<turnstile> \<theta><s> is \<theta>'<t> : T" |
|
995 |
using h1 h2 h3 |
|
22531 | 996 |
proof (nominal_induct \<Gamma> s t T avoiding: \<Gamma>' \<theta> \<theta>' rule: def_equiv.strong_induct) |
22494 | 997 |
case (Q_Refl \<Gamma> t T \<Gamma>' \<theta> \<theta>') |
998 |
have "\<Gamma> \<turnstile> t : T" |
|
25107 | 999 |
and "valid \<Gamma>'" by fact+ |
22494 | 1000 |
moreover |
1001 |
have "\<Gamma>' \<turnstile> \<theta> is \<theta>' over \<Gamma>" by fact |
|
1002 |
ultimately show "\<Gamma>' \<turnstile> \<theta><t> is \<theta>'<t> : T" using fundamental_theorem_1 by blast |
|
22073 | 1003 |
next |
22494 | 1004 |
case (Q_Symm \<Gamma> t s T \<Gamma>' \<theta> \<theta>') |
1005 |
have "\<Gamma>' \<turnstile> \<theta> is \<theta>' over \<Gamma>" |
|
25107 | 1006 |
and "valid \<Gamma>'" by fact+ |
22494 | 1007 |
moreover |
1008 |
have ih: "\<And> \<Gamma>' \<theta> \<theta>'. \<lbrakk>\<Gamma>' \<turnstile> \<theta> is \<theta>' over \<Gamma>; valid \<Gamma>'\<rbrakk> \<Longrightarrow> \<Gamma>' \<turnstile> \<theta><t> is \<theta>'<s> : T" by fact |
|
1009 |
ultimately show "\<Gamma>' \<turnstile> \<theta><s> is \<theta>'<t> : T" using logical_symmetry by blast |
|
22073 | 1010 |
next |
22494 | 1011 |
case (Q_Trans \<Gamma> s t T u \<Gamma>' \<theta> \<theta>') |
1012 |
have ih1: "\<And> \<Gamma>' \<theta> \<theta>'. \<lbrakk>\<Gamma>' \<turnstile> \<theta> is \<theta>' over \<Gamma>; valid \<Gamma>'\<rbrakk> \<Longrightarrow> \<Gamma>' \<turnstile> \<theta><s> is \<theta>'<t> : T" by fact |
|
1013 |
have ih2: "\<And> \<Gamma>' \<theta> \<theta>'. \<lbrakk>\<Gamma>' \<turnstile> \<theta> is \<theta>' over \<Gamma>; valid \<Gamma>'\<rbrakk> \<Longrightarrow> \<Gamma>' \<turnstile> \<theta><t> is \<theta>'<u> : T" by fact |
|
1014 |
have h: "\<Gamma>' \<turnstile> \<theta> is \<theta>' over \<Gamma>" |
|
25107 | 1015 |
and v: "valid \<Gamma>'" by fact+ |
22494 | 1016 |
then have "\<Gamma>' \<turnstile> \<theta>' is \<theta>' over \<Gamma>" using logical_pseudo_reflexivity by auto |
1017 |
then have "\<Gamma>' \<turnstile> \<theta>'<t> is \<theta>'<u> : T" using ih2 v by auto |
|
1018 |
moreover have "\<Gamma>' \<turnstile> \<theta><s> is \<theta>'<t> : T" using ih1 h v by auto |
|
1019 |
ultimately show "\<Gamma>' \<turnstile> \<theta><s> is \<theta>'<u> : T" using logical_transitivity by blast |
|
1020 |
next |
|
1021 |
case (Q_Abs x \<Gamma> T\<^isub>1 s\<^isub>2 t\<^isub>2 T\<^isub>2 \<Gamma>' \<theta> \<theta>') |
|
22073 | 1022 |
have fs:"x\<sharp>\<Gamma>" by fact |
25107 | 1023 |
have fs2: "x\<sharp>\<theta>" "x\<sharp>\<theta>'" by fact+ |
22494 | 1024 |
have h2: "\<Gamma>' \<turnstile> \<theta> is \<theta>' over \<Gamma>" |
25107 | 1025 |
and h3: "valid \<Gamma>'" by fact+ |
22494 | 1026 |
have ih:"\<And>\<Gamma>' \<theta> \<theta>'. \<lbrakk>\<Gamma>' \<turnstile> \<theta> is \<theta>' over (x,T\<^isub>1)#\<Gamma>; valid \<Gamma>'\<rbrakk> \<Longrightarrow> \<Gamma>' \<turnstile> \<theta><s\<^isub>2> is \<theta>'<t\<^isub>2> : T\<^isub>2" by fact |
22073 | 1027 |
{ |
1028 |
fix \<Gamma>'' s' t' |
|
22650
0c5b22076fb3
tuned the proof of lemma pt_list_set_fresh (as suggested by Randy Pollack) and tuned the syntax for sub_contexts
urbanc
parents:
22609
diff
changeset
|
1029 |
assume "\<Gamma>' \<subseteq> \<Gamma>''" and hl:"\<Gamma>''\<turnstile> s' is t' : T\<^isub>1" and hk: "valid \<Gamma>''" |
22494 | 1030 |
then have "\<Gamma>'' \<turnstile> \<theta> is \<theta>' over \<Gamma>" using h2 logical_subst_monotonicity by blast |
1031 |
then have "\<Gamma>'' \<turnstile> (x,s')#\<theta> is (x,t')#\<theta>' over (x,T\<^isub>1)#\<Gamma>" using equiv_subst_ext hl fs by blast |
|
24070 | 1032 |
then have "\<Gamma>'' \<turnstile> ((x,s')#\<theta>)<s\<^isub>2> is ((x,t')#\<theta>')<t\<^isub>2> : T\<^isub>2" using ih hk by blast |
22494 | 1033 |
then have "\<Gamma>''\<turnstile> \<theta><s\<^isub>2>[x::=s'] is \<theta>'<t\<^isub>2>[x::=t'] : T\<^isub>2" using fs2 psubst_subst_psubst by auto |
1034 |
moreover have "App (Lam [x]. \<theta><s\<^isub>2>) s' \<leadsto> \<theta><s\<^isub>2>[x::=s']" |
|
1035 |
and "App (Lam [x].\<theta>'<t\<^isub>2>) t' \<leadsto> \<theta>'<t\<^isub>2>[x::=t']" by auto |
|
1036 |
ultimately have "\<Gamma>'' \<turnstile> App (Lam [x]. \<theta><s\<^isub>2>) s' is App (Lam [x].\<theta>'<t\<^isub>2>) t' : T\<^isub>2" |
|
22073 | 1037 |
using logical_weak_head_closure by auto |
1038 |
} |
|
25107 | 1039 |
moreover have "valid \<Gamma>'" by fact |
22494 | 1040 |
ultimately have "\<Gamma>' \<turnstile> Lam [x].\<theta><s\<^isub>2> is Lam [x].\<theta>'<t\<^isub>2> : T\<^isub>1\<rightarrow>T\<^isub>2" by auto |
1041 |
then show "\<Gamma>' \<turnstile> \<theta><Lam [x].s\<^isub>2> is \<theta>'<Lam [x].t\<^isub>2> : T\<^isub>1\<rightarrow>T\<^isub>2" using fs2 by auto |
|
22073 | 1042 |
next |
22494 | 1043 |
case (Q_App \<Gamma> s\<^isub>1 t\<^isub>1 T\<^isub>1 T\<^isub>2 s\<^isub>2 t\<^isub>2 \<Gamma>' \<theta> \<theta>') |
1044 |
then show "\<Gamma>' \<turnstile> \<theta><App s\<^isub>1 s\<^isub>2> is \<theta>'<App t\<^isub>1 t\<^isub>2> : T\<^isub>2" by auto |
|
22073 | 1045 |
next |
22531 | 1046 |
case (Q_Beta x \<Gamma> s\<^isub>2 t\<^isub>2 T\<^isub>1 s12 t12 T\<^isub>2 \<Gamma>' \<theta> \<theta>') |
22494 | 1047 |
have h: "\<Gamma>' \<turnstile> \<theta> is \<theta>' over \<Gamma>" |
25107 | 1048 |
and h': "valid \<Gamma>'" by fact+ |
22494 | 1049 |
have fs: "x\<sharp>\<Gamma>" by fact |
25107 | 1050 |
have fs2: " x\<sharp>\<theta>" "x\<sharp>\<theta>'" by fact+ |
22494 | 1051 |
have ih1: "\<And>\<Gamma>' \<theta> \<theta>'. \<lbrakk>\<Gamma>' \<turnstile> \<theta> is \<theta>' over \<Gamma>; valid \<Gamma>'\<rbrakk> \<Longrightarrow> \<Gamma>' \<turnstile> \<theta><s\<^isub>2> is \<theta>'<t\<^isub>2> : T\<^isub>1" by fact |
1052 |
have ih2: "\<And>\<Gamma>' \<theta> \<theta>'. \<lbrakk>\<Gamma>' \<turnstile> \<theta> is \<theta>' over (x,T\<^isub>1)#\<Gamma>; valid \<Gamma>'\<rbrakk> \<Longrightarrow> \<Gamma>' \<turnstile> \<theta><s12> is \<theta>'<t12> : T\<^isub>2" by fact |
|
1053 |
have "\<Gamma>' \<turnstile> \<theta><s\<^isub>2> is \<theta>'<t\<^isub>2> : T\<^isub>1" using ih1 h' h by auto |
|
1054 |
then have "\<Gamma>' \<turnstile> (x,\<theta><s\<^isub>2>)#\<theta> is (x,\<theta>'<t\<^isub>2>)#\<theta>' over (x,T\<^isub>1)#\<Gamma>" using equiv_subst_ext h fs by blast |
|
24070 | 1055 |
then have "\<Gamma>' \<turnstile> ((x,\<theta><s\<^isub>2>)#\<theta>)<s12> is ((x,\<theta>'<t\<^isub>2>)#\<theta>')<t12> : T\<^isub>2" using ih2 h' by auto |
22494 | 1056 |
then have "\<Gamma>' \<turnstile> \<theta><s12>[x::=\<theta><s\<^isub>2>] is \<theta>'<t12>[x::=\<theta>'<t\<^isub>2>] : T\<^isub>2" using fs2 psubst_subst_psubst by auto |
1057 |
then have "\<Gamma>' \<turnstile> \<theta><s12>[x::=\<theta><s\<^isub>2>] is \<theta>'<t12[x::=t\<^isub>2]> : T\<^isub>2" using fs2 psubst_subst_propagate by auto |
|
1058 |
moreover have "App (Lam [x].\<theta><s12>) (\<theta><s\<^isub>2>) \<leadsto> \<theta><s12>[x::=\<theta><s\<^isub>2>]" by auto |
|
1059 |
ultimately have "\<Gamma>' \<turnstile> App (Lam [x].\<theta><s12>) (\<theta><s\<^isub>2>) is \<theta>'<t12[x::=t\<^isub>2]> : T\<^isub>2" |
|
22073 | 1060 |
using logical_weak_head_closure' by auto |
22494 | 1061 |
then show "\<Gamma>' \<turnstile> \<theta><App (Lam [x].s12) s\<^isub>2> is \<theta>'<t12[x::=t\<^isub>2]> : T\<^isub>2" using fs2 by simp |
22073 | 1062 |
next |
22494 | 1063 |
case (Q_Ext x \<Gamma> s t T\<^isub>1 T\<^isub>2 \<Gamma>' \<theta> \<theta>') |
1064 |
have h2: "\<Gamma>' \<turnstile> \<theta> is \<theta>' over \<Gamma>" |
|
25107 | 1065 |
and h2': "valid \<Gamma>'" by fact+ |
1066 |
have fs:"x\<sharp>\<Gamma>" "x\<sharp>s" "x\<sharp>t" by fact+ |
|
22494 | 1067 |
have ih:"\<And>\<Gamma>' \<theta> \<theta>'. \<lbrakk>\<Gamma>' \<turnstile> \<theta> is \<theta>' over (x,T\<^isub>1)#\<Gamma>; valid \<Gamma>'\<rbrakk> |
1068 |
\<Longrightarrow> \<Gamma>' \<turnstile> \<theta><App s (Var x)> is \<theta>'<App t (Var x)> : T\<^isub>2" by fact |
|
22073 | 1069 |
{ |
1070 |
fix \<Gamma>'' s' t' |
|
22650
0c5b22076fb3
tuned the proof of lemma pt_list_set_fresh (as suggested by Randy Pollack) and tuned the syntax for sub_contexts
urbanc
parents:
22609
diff
changeset
|
1071 |
assume hsub: "\<Gamma>' \<subseteq> \<Gamma>''" and hl: "\<Gamma>''\<turnstile> s' is t' : T\<^isub>1" and hk: "valid \<Gamma>''" |
22494 | 1072 |
then have "\<Gamma>'' \<turnstile> \<theta> is \<theta>' over \<Gamma>" using h2 logical_subst_monotonicity by blast |
1073 |
then have "\<Gamma>'' \<turnstile> (x,s')#\<theta> is (x,t')#\<theta>' over (x,T\<^isub>1)#\<Gamma>" using equiv_subst_ext hl fs by blast |
|
24070 | 1074 |
then have "\<Gamma>'' \<turnstile> ((x,s')#\<theta>)<App s (Var x)> is ((x,t')#\<theta>')<App t (Var x)> : T\<^isub>2" using ih hk by blast |
22494 | 1075 |
then |
24070 | 1076 |
have "\<Gamma>'' \<turnstile> App (((x,s')#\<theta>)<s>) (((x,s')#\<theta>)<(Var x)>) is App (((x,t')#\<theta>')<t>) (((x,t')#\<theta>')<(Var x)>) : T\<^isub>2" |
22082 | 1077 |
by auto |
24070 | 1078 |
then have "\<Gamma>'' \<turnstile> App ((x,s')#\<theta>)<s> s' is App ((x,t')#\<theta>')<t> t' : T\<^isub>2" by auto |
22494 | 1079 |
then have "\<Gamma>'' \<turnstile> App (\<theta><s>) s' is App (\<theta>'<t>) t' : T\<^isub>2" using fs fresh_psubst_simp by auto |
22073 | 1080 |
} |
25107 | 1081 |
moreover have "valid \<Gamma>'" by fact |
22494 | 1082 |
ultimately show "\<Gamma>' \<turnstile> \<theta><s> is \<theta>'<t> : T\<^isub>1\<rightarrow>T\<^isub>2" by auto |
23370
513a8ee192f1
added the Q_Unit rule (was missing) and adjusted the proof accordingly
urbanc
parents:
22829
diff
changeset
|
1083 |
next |
513a8ee192f1
added the Q_Unit rule (was missing) and adjusted the proof accordingly
urbanc
parents:
22829
diff
changeset
|
1084 |
case (Q_Unit \<Gamma> s t \<Gamma>' \<theta> \<theta>') |
513a8ee192f1
added the Q_Unit rule (was missing) and adjusted the proof accordingly
urbanc
parents:
22829
diff
changeset
|
1085 |
then show "\<Gamma>' \<turnstile> \<theta><s> is \<theta>'<t> : TUnit" by auto |
22073 | 1086 |
qed |
1087 |
||
22418
49e2d9744ae1
major update of the nominal package; there is now an infrastructure
urbanc
parents:
22231
diff
changeset
|
1088 |
|
22073 | 1089 |
theorem completeness: |
22494 | 1090 |
assumes asm: "\<Gamma> \<turnstile> s \<equiv> t : T" |
22418
49e2d9744ae1
major update of the nominal package; there is now an infrastructure
urbanc
parents:
22231
diff
changeset
|
1091 |
shows "\<Gamma> \<turnstile> s \<Leftrightarrow> t : T" |
22073 | 1092 |
proof - |
22494 | 1093 |
have val: "valid \<Gamma>" using def_equiv_implies_valid asm by simp |
1094 |
moreover |
|
22073 | 1095 |
{ |
1096 |
fix x T |
|
1097 |
assume "(x,T) \<in> set \<Gamma>" "valid \<Gamma>" |
|
22494 | 1098 |
then have "\<Gamma> \<turnstile> Var x is Var x : T" using main_lemma(2) by blast |
22073 | 1099 |
} |
1100 |
ultimately have "\<Gamma> \<turnstile> [] is [] over \<Gamma>" by auto |
|
22494 | 1101 |
then have "\<Gamma> \<turnstile> []<s> is []<t> : T" using fundamental_theorem_2 val asm by blast |
22073 | 1102 |
then have "\<Gamma> \<turnstile> s is t : T" by simp |
22494 | 1103 |
then show "\<Gamma> \<turnstile> s \<Leftrightarrow> t : T" using main_lemma(1) val by simp |
22073 | 1104 |
qed |
1105 |
||
22418
49e2d9744ae1
major update of the nominal package; there is now an infrastructure
urbanc
parents:
22231
diff
changeset
|
1106 |
text {* We leave soundness as an exercise - like in the book :-) \\ |
49e2d9744ae1
major update of the nominal package; there is now an infrastructure
urbanc
parents:
22231
diff
changeset
|
1107 |
@{prop[mode=IfThen] "\<lbrakk>\<Gamma> \<turnstile> s \<Leftrightarrow> t : T; \<Gamma> \<turnstile> t : T; \<Gamma> \<turnstile> s : T\<rbrakk> \<Longrightarrow> \<Gamma> \<turnstile> s \<equiv> t : T"} \\ |
49e2d9744ae1
major update of the nominal package; there is now an infrastructure
urbanc
parents:
22231
diff
changeset
|
1108 |
@{prop "\<lbrakk>\<Gamma> \<turnstile> s \<leftrightarrow> t : T; \<Gamma> \<turnstile> t : T; \<Gamma> \<turnstile> s : T\<rbrakk> \<Longrightarrow> \<Gamma> \<turnstile> s \<equiv> t : T"} |
49e2d9744ae1
major update of the nominal package; there is now an infrastructure
urbanc
parents:
22231
diff
changeset
|
1109 |
*} |
22073 | 1110 |
|
1111 |
end |
|
1112 |