| author | wenzelm |
| Mon, 08 Sep 2008 20:33:29 +0200 | |
| changeset 28169 | 356fc8734741 |
| parent 28042 | 1471f2974eb1 |
| child 29097 | 68245155eb58 |
| 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" |
|
|
26966
071f40487734
made the naming of the induction principles consistent: weak_induct is
urbanc
parents:
26677
diff
changeset
|
37 |
by (induct T rule: ty.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" |
|
26966
071f40487734
made the naming of the induction principles consistent: weak_induct is
urbanc
parents:
26677
diff
changeset
|
48 |
by (induct T rule:ty.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" |
|
|
26966
071f40487734
made the naming of the induction principles consistent: weak_induct is
urbanc
parents:
26677
diff
changeset
|
61 |
by (nominal_induct rule: ty.strong_induct) (simp_all) |
| 22073 | 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')]" |
|
|
26966
071f40487734
made the naming of the induction principles consistent: weak_induct is
urbanc
parents:
26677
diff
changeset
|
122 |
by (nominal_induct t avoiding: x t' rule: trm.strong_induct) |
| 22494 | 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 |
|
|
26966
071f40487734
made the naming of the induction principles consistent: weak_induct is
urbanc
parents:
26677
diff
changeset
|
130 |
apply(nominal_induct t\<^isub>1 avoiding: a c t\<^isub>2 rule: trm.strong_induct) |
| 22494 | 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 |
|
|
26966
071f40487734
made the naming of the induction principles consistent: weak_induct is
urbanc
parents:
26677
diff
changeset
|
139 |
by (nominal_induct t avoiding: z \<theta> t rule: trm.strong_induct) |
| 22494 | 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 |
|
|
26966
071f40487734
made the naming of the induction principles consistent: weak_induct is
urbanc
parents:
26677
diff
changeset
|
147 |
by (nominal_induct t\<^isub>1 avoiding: t\<^isub>2 z rule: trm.strong_induct) |
| 22494 | 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 |
|
|
26966
071f40487734
made the naming of the induction principles consistent: weak_induct is
urbanc
parents:
26677
diff
changeset
|
155 |
by (nominal_induct t\<^isub>1 avoiding: y t\<^isub>2 z rule: trm.strong_induct) |
| 22494 | 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 |
|
26966
071f40487734
made the naming of the induction principles consistent: weak_induct is
urbanc
parents:
26677
diff
changeset
|
169 |
proof (nominal_induct t avoiding: x u \<theta> rule: trm.strong_induct) |
| 22494 | 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 |
|
|
26966
071f40487734
made the naming of the induction principles consistent: weak_induct is
urbanc
parents:
26677
diff
changeset
|
187 |
by (nominal_induct t avoiding: x t' rule: trm.strong_induct) |
| 22494 | 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" |
|
|
26966
071f40487734
made the naming of the induction principles consistent: weak_induct is
urbanc
parents:
26677
diff
changeset
|
210 |
by (nominal_induct t rule: trm.strong_induct) |
| 22494 | 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 |
|
26966
071f40487734
made the naming of the induction principles consistent: weak_induct is
urbanc
parents:
26677
diff
changeset
|
217 |
by (nominal_induct t avoiding: \<theta> c s rule: trm.strong_induct) |
| 22494 | 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 |
|
|
26966
071f40487734
made the naming of the induction principles consistent: weak_induct is
urbanc
parents:
26677
diff
changeset
|
230 |
proof (nominal_induct t avoiding: x u \<theta> rule: trm.strong_induct) |
| 22494 | 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 |
|
| 22494 | 361 |
section {* Weak Head Reduction *}
|
|
22418
49e2d9744ae1
major update of the nominal package; there is now an infrastructure
urbanc
parents:
22231
diff
changeset
|
362 |
|
| 23760 | 363 |
inductive |
|
22418
49e2d9744ae1
major update of the nominal package; there is now an infrastructure
urbanc
parents:
22231
diff
changeset
|
364 |
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
|
365 |
where |
| 22494 | 366 |
QAR_Beta[intro]: "App (Lam [x]. t\<^isub>1) t\<^isub>2 \<leadsto> t\<^isub>1[x::=t\<^isub>2]" |
367 |
| 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
|
368 |
|
|
49e2d9744ae1
major update of the nominal package; there is now an infrastructure
urbanc
parents:
22231
diff
changeset
|
369 |
declare trm.inject [simp add] |
|
49e2d9744ae1
major update of the nominal package; there is now an infrastructure
urbanc
parents:
22231
diff
changeset
|
370 |
declare ty.inject [simp add] |
|
49e2d9744ae1
major update of the nominal package; there is now an infrastructure
urbanc
parents:
22231
diff
changeset
|
371 |
|
|
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
|
372 |
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
|
373 |
"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
|
374 |
"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
|
375 |
"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
|
376 |
"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
|
377 |
"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
|
378 |
"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
|
379 |
"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
|
380 |
"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
|
381 |
"t \<leadsto> App p q" |
|
22418
49e2d9744ae1
major update of the nominal package; there is now an infrastructure
urbanc
parents:
22231
diff
changeset
|
382 |
|
|
49e2d9744ae1
major update of the nominal package; there is now an infrastructure
urbanc
parents:
22231
diff
changeset
|
383 |
declare trm.inject [simp del] |
|
49e2d9744ae1
major update of the nominal package; there is now an infrastructure
urbanc
parents:
22231
diff
changeset
|
384 |
declare ty.inject [simp del] |
|
49e2d9744ae1
major update of the nominal package; there is now an infrastructure
urbanc
parents:
22231
diff
changeset
|
385 |
|
| 22531 | 386 |
equivariance whr_def |
|
22418
49e2d9744ae1
major update of the nominal package; there is now an infrastructure
urbanc
parents:
22231
diff
changeset
|
387 |
|
| 22494 | 388 |
section {* Weak Head Normalisation *}
|
|
22418
49e2d9744ae1
major update of the nominal package; there is now an infrastructure
urbanc
parents:
22231
diff
changeset
|
389 |
|
|
49e2d9744ae1
major update of the nominal package; there is now an infrastructure
urbanc
parents:
22231
diff
changeset
|
390 |
abbreviation |
|
49e2d9744ae1
major update of the nominal package; there is now an infrastructure
urbanc
parents:
22231
diff
changeset
|
391 |
nf :: "trm \<Rightarrow> bool" ("_ \<leadsto>|" [100] 100)
|
|
49e2d9744ae1
major update of the nominal package; there is now an infrastructure
urbanc
parents:
22231
diff
changeset
|
392 |
where |
|
49e2d9744ae1
major update of the nominal package; there is now an infrastructure
urbanc
parents:
22231
diff
changeset
|
393 |
"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
|
394 |
|
| 23760 | 395 |
inductive |
|
22418
49e2d9744ae1
major update of the nominal package; there is now an infrastructure
urbanc
parents:
22231
diff
changeset
|
396 |
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
|
397 |
where |
|
49e2d9744ae1
major update of the nominal package; there is now an infrastructure
urbanc
parents:
22231
diff
changeset
|
398 |
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
|
399 |
| 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
|
400 |
|
| 22494 | 401 |
declare trm.inject[simp] |
|
22418
49e2d9744ae1
major update of the nominal package; there is now an infrastructure
urbanc
parents:
22231
diff
changeset
|
402 |
|
| 23760 | 403 |
inductive_cases whn_inv_auto[elim]: "t \<Down> t'" |
| 22494 | 404 |
|
405 |
declare trm.inject[simp del] |
|
|
22418
49e2d9744ae1
major update of the nominal package; there is now an infrastructure
urbanc
parents:
22231
diff
changeset
|
406 |
|
|
49e2d9744ae1
major update of the nominal package; there is now an infrastructure
urbanc
parents:
22231
diff
changeset
|
407 |
lemma whn_eqvt[eqvt]: |
|
49e2d9744ae1
major update of the nominal package; there is now an infrastructure
urbanc
parents:
22231
diff
changeset
|
408 |
fixes pi::"name prm" |
|
49e2d9744ae1
major update of the nominal package; there is now an infrastructure
urbanc
parents:
22231
diff
changeset
|
409 |
assumes a: "t \<Down> t'" |
|
49e2d9744ae1
major update of the nominal package; there is now an infrastructure
urbanc
parents:
22231
diff
changeset
|
410 |
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
|
411 |
using a |
|
49e2d9744ae1
major update of the nominal package; there is now an infrastructure
urbanc
parents:
22231
diff
changeset
|
412 |
apply(induct) |
|
49e2d9744ae1
major update of the nominal package; there is now an infrastructure
urbanc
parents:
22231
diff
changeset
|
413 |
apply(rule QAN_Reduce) |
| 22542 | 414 |
apply(rule whr_def.eqvt) |
|
22418
49e2d9744ae1
major update of the nominal package; there is now an infrastructure
urbanc
parents:
22231
diff
changeset
|
415 |
apply(assumption)+ |
|
49e2d9744ae1
major update of the nominal package; there is now an infrastructure
urbanc
parents:
22231
diff
changeset
|
416 |
apply(rule QAN_Normal) |
|
49e2d9744ae1
major update of the nominal package; there is now an infrastructure
urbanc
parents:
22231
diff
changeset
|
417 |
apply(auto) |
| 22542 | 418 |
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
|
419 |
apply(perm_simp) |
|
49e2d9744ae1
major update of the nominal package; there is now an infrastructure
urbanc
parents:
22231
diff
changeset
|
420 |
done |
|
49e2d9744ae1
major update of the nominal package; there is now an infrastructure
urbanc
parents:
22231
diff
changeset
|
421 |
|
| 22494 | 422 |
lemma red_unicity : |
423 |
assumes a: "x \<leadsto> a" |
|
424 |
and b: "x \<leadsto> b" |
|
425 |
shows "a=b" |
|
426 |
using a b |
|
427 |
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
|
428 |
apply (erule whr_inv_auto(3)) |
| 22494 | 429 |
apply (clarify) |
430 |
apply (rule subst_fun_eq) |
|
431 |
apply (simp) |
|
432 |
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
|
433 |
apply (erule whr_inv_auto(6)) |
| 22494 | 434 |
apply (blast)+ |
435 |
done |
|
|
22418
49e2d9744ae1
major update of the nominal package; there is now an infrastructure
urbanc
parents:
22231
diff
changeset
|
436 |
|
| 22494 | 437 |
lemma nf_unicity : |
438 |
assumes "x \<Down> a" and "x \<Down> b" |
|
439 |
shows "a=b" |
|
440 |
using assms |
|
441 |
proof (induct arbitrary: b) |
|
442 |
case (QAN_Reduce x t a b) |
|
| 25107 | 443 |
have h:"x \<leadsto> t" "t \<Down> a" by fact+ |
| 22494 | 444 |
have ih:"\<And>b. t \<Down> b \<Longrightarrow> a = b" by fact |
445 |
have "x \<Down> b" by fact |
|
446 |
then obtain t' where "x \<leadsto> t'" and hl:"t' \<Down> b" using h by auto |
|
447 |
then have "t=t'" using h red_unicity by auto |
|
448 |
then show "a=b" using ih hl by auto |
|
449 |
qed (auto) |
|
450 |
||
| 24070 | 451 |
|
| 22494 | 452 |
section {* Algorithmic Term Equivalence and Algorithmic Path Equivalence *}
|
453 |
||
| 23760 | 454 |
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
|
455 |
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
|
456 |
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
|
457 |
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
|
458 |
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
|
459 |
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 | 460 |
| 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
|
461 |
\<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
|
462 |
| 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
|
463 |
| 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
|
464 |
| 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
|
465 |
| 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
|
466 |
|
|
22730
8bcc8809ed3b
nominal_inductive no longer proves equivariance.
berghofe
parents:
22650
diff
changeset
|
467 |
equivariance alg_equiv |
|
8bcc8809ed3b
nominal_inductive no longer proves equivariance.
berghofe
parents:
22650
diff
changeset
|
468 |
|
| 22531 | 469 |
nominal_inductive alg_equiv |
470 |
avoids QAT_Arrow: x |
|
471 |
by simp_all |
|
|
22418
49e2d9744ae1
major update of the nominal package; there is now an infrastructure
urbanc
parents:
22231
diff
changeset
|
472 |
|
| 22494 | 473 |
declare trm.inject [simp add] |
|
22418
49e2d9744ae1
major update of the nominal package; there is now an infrastructure
urbanc
parents:
22231
diff
changeset
|
474 |
declare ty.inject [simp add] |
|
49e2d9744ae1
major update of the nominal package; there is now an infrastructure
urbanc
parents:
22231
diff
changeset
|
475 |
|
|
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
|
476 |
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
|
477 |
"\<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
|
478 |
"\<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
|
479 |
"\<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
|
480 |
"\<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
|
481 |
"\<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
|
482 |
|
|
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
|
483 |
"\<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
|
484 |
"\<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
|
485 |
"\<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
|
486 |
"\<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
|
487 |
"\<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
|
488 |
"\<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
|
489 |
"\<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
|
490 |
"\<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
|
491 |
"\<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
|
492 |
"\<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
|
493 |
|
|
49e2d9744ae1
major update of the nominal package; there is now an infrastructure
urbanc
parents:
22231
diff
changeset
|
494 |
declare trm.inject [simp del] |
|
49e2d9744ae1
major update of the nominal package; there is now an infrastructure
urbanc
parents:
22231
diff
changeset
|
495 |
declare ty.inject [simp del] |
|
49e2d9744ae1
major update of the nominal package; there is now an infrastructure
urbanc
parents:
22231
diff
changeset
|
496 |
|
| 22073 | 497 |
lemma Q_Arrow_strong_inversion: |
| 22494 | 498 |
assumes fs: "x\<sharp>\<Gamma>" "x\<sharp>t" "x\<sharp>u" |
499 |
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
|
500 |
shows "(x,T\<^isub>1)#\<Gamma> \<turnstile> App t (Var x) \<Leftrightarrow> App u (Var x) : T\<^isub>2" |
| 22073 | 501 |
proof - |
| 22494 | 502 |
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 | 503 |
using h by auto |
|
22418
49e2d9744ae1
major update of the nominal package; there is now an infrastructure
urbanc
parents:
22231
diff
changeset
|
504 |
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 | 505 |
using alg_equiv.eqvt[simplified] by blast |
| 22082 | 506 |
then show ?thesis using fs fs2 by (perm_simp) |
| 22073 | 507 |
qed |
508 |
||
|
22418
49e2d9744ae1
major update of the nominal package; there is now an infrastructure
urbanc
parents:
22231
diff
changeset
|
509 |
(* |
|
22594
33a690455f88
add a few details in the Fst and Snd cases of unicity proof
narboux
parents:
22542
diff
changeset
|
510 |
Warning this lemma is false: |
|
33a690455f88
add a few details in the Fst and Snd cases of unicity proof
narboux
parents:
22542
diff
changeset
|
511 |
|
| 22073 | 512 |
lemma algorithmic_type_unicity: |
|
22418
49e2d9744ae1
major update of the nominal package; there is now an infrastructure
urbanc
parents:
22231
diff
changeset
|
513 |
shows "\<lbrakk> \<Gamma> \<turnstile> s \<Leftrightarrow> t : T ; \<Gamma> \<turnstile> s \<Leftrightarrow> u : T' \<rbrakk> \<Longrightarrow> T = T'" |
| 22073 | 514 |
and "\<lbrakk> \<Gamma> \<turnstile> s \<leftrightarrow> t : T ; \<Gamma> \<turnstile> s \<leftrightarrow> u : T' \<rbrakk> \<Longrightarrow> T = T'" |
515 |
||
516 |
Here is the counter example : |
|
|
22418
49e2d9744ae1
major update of the nominal package; there is now an infrastructure
urbanc
parents:
22231
diff
changeset
|
517 |
\<Gamma> \<turnstile> Const n \<Leftrightarrow> Const n : Tbase and \<Gamma> \<turnstile> Const n \<Leftrightarrow> Const n : TUnit |
| 22073 | 518 |
*) |
519 |
||
520 |
lemma algorithmic_path_type_unicity: |
|
| 22494 | 521 |
shows "\<Gamma> \<turnstile> s \<leftrightarrow> t : T \<Longrightarrow> \<Gamma> \<turnstile> s \<leftrightarrow> u : T' \<Longrightarrow> T = T'" |
| 22082 | 522 |
proof (induct arbitrary: u T' |
523 |
rule: alg_equiv_alg_path_equiv.inducts(2) [of _ _ _ _ _ "%a b c d . True" ]) |
|
| 22073 | 524 |
case (QAP_Var \<Gamma> x T u T') |
525 |
have "\<Gamma> \<turnstile> Var x \<leftrightarrow> u : T'" by fact |
|
526 |
then have "u=Var x" and "(x,T') \<in> set \<Gamma>" by auto |
|
| 25107 | 527 |
moreover have "valid \<Gamma>" "(x,T) \<in> set \<Gamma>" by fact+ |
| 22073 | 528 |
ultimately show "T=T'" using type_unicity_in_context by auto |
529 |
next |
|
|
22418
49e2d9744ae1
major update of the nominal package; there is now an infrastructure
urbanc
parents:
22231
diff
changeset
|
530 |
case (QAP_App \<Gamma> p q T\<^isub>1 T\<^isub>2 s t u T\<^isub>2') |
| 24070 | 531 |
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
|
532 |
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
|
533 |
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 | 534 |
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
|
535 |
then show "T\<^isub>2=T\<^isub>2'" using ty.inject by auto |
| 22073 | 536 |
qed (auto) |
537 |
||
| 22494 | 538 |
lemma alg_path_equiv_implies_valid: |
539 |
shows "\<Gamma> \<turnstile> s \<Leftrightarrow> t : T \<Longrightarrow> valid \<Gamma>" |
|
540 |
and "\<Gamma> \<turnstile> s \<leftrightarrow> t : T \<Longrightarrow> valid \<Gamma>" |
|
541 |
by (induct rule : alg_equiv_alg_path_equiv.inducts, auto) |
|
542 |
||
543 |
lemma algorithmic_symmetry: |
|
544 |
shows "\<Gamma> \<turnstile> s \<Leftrightarrow> t : T \<Longrightarrow> \<Gamma> \<turnstile> t \<Leftrightarrow> s : T" |
|
545 |
and "\<Gamma> \<turnstile> s \<leftrightarrow> t : T \<Longrightarrow> \<Gamma> \<turnstile> t \<leftrightarrow> s : T" |
|
546 |
by (induct rule: alg_equiv_alg_path_equiv.inducts) |
|
547 |
(auto simp add: fresh_prod) |
|
548 |
||
| 22073 | 549 |
lemma algorithmic_transitivity: |
| 22494 | 550 |
shows "\<Gamma> \<turnstile> s \<Leftrightarrow> t : T \<Longrightarrow> \<Gamma> \<turnstile> t \<Leftrightarrow> u : T \<Longrightarrow> \<Gamma> \<turnstile> s \<Leftrightarrow> u : T" |
551 |
and "\<Gamma> \<turnstile> s \<leftrightarrow> t : T \<Longrightarrow> \<Gamma> \<turnstile> t \<leftrightarrow> u : T \<Longrightarrow> \<Gamma> \<turnstile> s \<leftrightarrow> u : T" |
|
| 22531 | 552 |
proof (nominal_induct \<Gamma> s t T and \<Gamma> s t T avoiding: u rule: alg_equiv_alg_path_equiv.strong_inducts) |
| 22073 | 553 |
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
|
554 |
have "\<Gamma> \<turnstile> t \<Leftrightarrow> u : TBase" by fact |
| 22494 | 555 |
then obtain r' q' where b1: "t \<Down> q'" and b2: "u \<Down> r'" and b3: "\<Gamma> \<turnstile> q' \<leftrightarrow> r' : TBase" by auto |
556 |
have ih: "\<Gamma> \<turnstile> q \<leftrightarrow> r' : TBase \<Longrightarrow> \<Gamma> \<turnstile> p \<leftrightarrow> r' : TBase" by fact |
|
557 |
have "t \<Down> q" by fact |
|
558 |
with b1 have eq: "q=q'" by (simp add: nf_unicity) |
|
559 |
with ih b3 have "\<Gamma> \<turnstile> p \<leftrightarrow> r' : TBase" by simp |
|
560 |
moreover |
|
561 |
have "s \<Down> p" by fact |
|
562 |
ultimately show "\<Gamma> \<turnstile> s \<Leftrightarrow> u : TBase" using b2 by auto |
|
| 22073 | 563 |
next |
|
22418
49e2d9744ae1
major update of the nominal package; there is now an infrastructure
urbanc
parents:
22231
diff
changeset
|
564 |
case (QAT_Arrow x \<Gamma> s t T\<^isub>1 T\<^isub>2 u) |
| 22494 | 565 |
have ih:"(x,T\<^isub>1)#\<Gamma> \<turnstile> App t (Var x) \<Leftrightarrow> App u (Var x) : T\<^isub>2 |
566 |
\<Longrightarrow> (x,T\<^isub>1)#\<Gamma> \<turnstile> App s (Var x) \<Leftrightarrow> App u (Var x) : T\<^isub>2" by fact |
|
| 25107 | 567 |
have fs: "x\<sharp>\<Gamma>" "x\<sharp>s" "x\<sharp>t" "x\<sharp>u" by fact+ |
| 22494 | 568 |
have "\<Gamma> \<turnstile> t \<Leftrightarrow> u : T\<^isub>1\<rightarrow>T\<^isub>2" by fact |
569 |
then have "(x,T\<^isub>1)#\<Gamma> \<turnstile> App t (Var x) \<Leftrightarrow> App u (Var x) : T\<^isub>2" using fs |
|
570 |
by (simp add: Q_Arrow_strong_inversion) |
|
571 |
with ih have "(x,T\<^isub>1)#\<Gamma> \<turnstile> App s (Var x) \<Leftrightarrow> App u (Var x) : T\<^isub>2" by simp |
|
572 |
then show "\<Gamma> \<turnstile> s \<Leftrightarrow> u : T\<^isub>1\<rightarrow>T\<^isub>2" using fs by (auto simp add: fresh_prod) |
|
| 22073 | 573 |
next |
|
22418
49e2d9744ae1
major update of the nominal package; there is now an infrastructure
urbanc
parents:
22231
diff
changeset
|
574 |
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
|
575 |
have "\<Gamma> \<turnstile> App q t \<leftrightarrow> u : T\<^isub>2" by fact |
| 22494 | 576 |
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 | 577 |
by auto |
| 22494 | 578 |
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 |
579 |
have ih2:"\<Gamma> \<turnstile> t \<Leftrightarrow> v : T\<^isub>1 \<Longrightarrow> \<Gamma> \<turnstile> s \<Leftrightarrow> v : T\<^isub>1" by fact |
|
580 |
have "\<Gamma> \<turnstile> p \<leftrightarrow> q : T\<^isub>1\<rightarrow>T\<^isub>2" by fact |
|
581 |
then have "\<Gamma> \<turnstile> q \<leftrightarrow> p : T\<^isub>1\<rightarrow>T\<^isub>2" by (simp add: algorithmic_symmetry) |
|
582 |
with ha have "T\<^isub>1'\<rightarrow>T\<^isub>2 = T\<^isub>1\<rightarrow>T\<^isub>2" using algorithmic_path_type_unicity by simp |
|
583 |
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
|
584 |
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
|
585 |
then show "\<Gamma> \<turnstile> App p s \<leftrightarrow> u : T\<^isub>2" using eq by auto |
| 22073 | 586 |
qed (auto) |
587 |
||
588 |
lemma algorithmic_weak_head_closure: |
|
| 22494 | 589 |
shows "\<Gamma> \<turnstile> s \<Leftrightarrow> t : T \<Longrightarrow> s' \<leadsto> s \<Longrightarrow> t' \<leadsto> t \<Longrightarrow> \<Gamma> \<turnstile> s' \<Leftrightarrow> t' : T" |
590 |
apply (nominal_induct \<Gamma> s t T avoiding: s' t' |
|
| 22531 | 591 |
rule: alg_equiv_alg_path_equiv.strong_inducts(1) [of _ _ _ _ "%a b c d e. True"]) |
| 22494 | 592 |
apply(auto intro!: QAT_Arrow) |
593 |
done |
|
594 |
||
595 |
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
|
596 |
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
|
597 |
and "\<Gamma> \<turnstile> s \<leftrightarrow> t : T \<Longrightarrow> \<Gamma> \<subseteq> \<Gamma>' \<Longrightarrow> valid \<Gamma>' \<Longrightarrow> \<Gamma>' \<turnstile> s \<leftrightarrow> t : T" |
| 22531 | 598 |
proof (nominal_induct \<Gamma> s t T and \<Gamma> s t T avoiding: \<Gamma>' rule: alg_equiv_alg_path_equiv.strong_inducts) |
| 22494 | 599 |
case (QAT_Arrow x \<Gamma> s t T\<^isub>1 T\<^isub>2 \<Gamma>') |
| 25107 | 600 |
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
|
601 |
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
|
602 |
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 | 603 |
have "valid \<Gamma>'" by fact |
604 |
then have "valid ((x,T\<^isub>1)#\<Gamma>')" using fs by auto |
|
605 |
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
|
606 |
have sub: "(x,T\<^isub>1)#\<Gamma> \<subseteq> (x,T\<^isub>1)#\<Gamma>'" using h2 by auto |
| 22494 | 607 |
ultimately have "(x,T\<^isub>1)#\<Gamma>' \<turnstile> App s (Var x) \<Leftrightarrow> App t (Var x) : T\<^isub>2" using ih by simp |
608 |
then show "\<Gamma>' \<turnstile> s \<Leftrightarrow> t : T\<^isub>1\<rightarrow>T\<^isub>2" using fs by (auto simp add: fresh_prod) |
|
609 |
qed (auto) |
|
610 |
||
611 |
lemma path_equiv_implies_nf: |
|
612 |
assumes "\<Gamma> \<turnstile> s \<leftrightarrow> t : T" |
|
613 |
shows "s \<leadsto>|" and "t \<leadsto>|" |
|
614 |
using assms |
|
615 |
by (induct rule: alg_equiv_alg_path_equiv.inducts(2)) (simp, auto) |
|
616 |
||
617 |
section {* Logical Equivalence *}
|
|
618 |
||
619 |
function log_equiv :: "(Ctxt \<Rightarrow> trm \<Rightarrow> trm \<Rightarrow> ty \<Rightarrow> bool)" ("_ \<turnstile> _ is _ : _" [60,60,60,60] 60)
|
|
620 |
where |
|
621 |
"\<Gamma> \<turnstile> s is t : TUnit = True" |
|
622 |
| "\<Gamma> \<turnstile> s is t : TBase = \<Gamma> \<turnstile> s \<Leftrightarrow> t : TBase" |
|
623 |
| "\<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
|
624 |
(\<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 | 625 |
apply (auto simp add: ty.inject) |
626 |
apply (subgoal_tac "(\<exists>T\<^isub>1 T\<^isub>2. b=T\<^isub>1 \<rightarrow> T\<^isub>2) \<or> b=TUnit \<or> b=TBase" ) |
|
627 |
apply (force) |
|
628 |
apply (rule ty_cases) |
|
629 |
done |
|
| 28042 | 630 |
termination by lexicographic_order |
| 22494 | 631 |
|
|
24231
85fb973a8207
added type constraints to resolve syntax ambiguities;
wenzelm
parents:
24088
diff
changeset
|
632 |
lemma logical_monotonicity: |
|
85fb973a8207
added type constraints to resolve syntax ambiguities;
wenzelm
parents:
24088
diff
changeset
|
633 |
fixes \<Gamma> \<Gamma>' :: Ctxt |
| 22494 | 634 |
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
|
635 |
and a2: "\<Gamma> \<subseteq> \<Gamma>'" |
| 22494 | 636 |
and a3: "valid \<Gamma>'" |
637 |
shows "\<Gamma>' \<turnstile> s is t : T" |
|
638 |
using a1 a2 a3 |
|
639 |
proof (induct arbitrary: \<Gamma>' rule: log_equiv.induct) |
|
640 |
case (2 \<Gamma> s t \<Gamma>') |
|
641 |
then show "\<Gamma>' \<turnstile> s is t : TBase" using algorithmic_monotonicity by auto |
|
642 |
next |
|
643 |
case (3 \<Gamma> s t T\<^isub>1 T\<^isub>2 \<Gamma>') |
|
644 |
have "\<Gamma> \<turnstile> s is t : T\<^isub>1\<rightarrow>T\<^isub>2" |
|
| 24070 | 645 |
and "\<Gamma> \<subseteq> \<Gamma>'" |
| 25107 | 646 |
and "valid \<Gamma>'" by fact+ |
| 22494 | 647 |
then show "\<Gamma>' \<turnstile> s is t : T\<^isub>1\<rightarrow>T\<^isub>2" by simp |
648 |
qed (auto) |
|
649 |
||
650 |
lemma main_lemma: |
|
651 |
shows "\<Gamma> \<turnstile> s is t : T \<Longrightarrow> valid \<Gamma> \<Longrightarrow> \<Gamma> \<turnstile> s \<Leftrightarrow> t : T" |
|
652 |
and "\<Gamma> \<turnstile> p \<leftrightarrow> q : T \<Longrightarrow> \<Gamma> \<turnstile> p is q : T" |
|
|
26966
071f40487734
made the naming of the induction principles consistent: weak_induct is
urbanc
parents:
26677
diff
changeset
|
653 |
proof (nominal_induct T arbitrary: \<Gamma> s t p q rule: ty.strong_induct) |
| 22494 | 654 |
case (Arrow T\<^isub>1 T\<^isub>2) |
655 |
{
|
|
656 |
case (1 \<Gamma> s t) |
|
657 |
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 |
|
658 |
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 |
|
659 |
have h:"\<Gamma> \<turnstile> s is t : T\<^isub>1\<rightarrow>T\<^isub>2" by fact |
|
660 |
obtain x::name where fs:"x\<sharp>(\<Gamma>,s,t)" by (erule exists_fresh[OF fs_name1]) |
|
661 |
have "valid \<Gamma>" by fact |
|
662 |
then have v: "valid ((x,T\<^isub>1)#\<Gamma>)" using fs by auto |
|
663 |
then have "(x,T\<^isub>1)#\<Gamma> \<turnstile> Var x \<leftrightarrow> Var x : T\<^isub>1" by auto |
|
664 |
then have "(x,T\<^isub>1)#\<Gamma> \<turnstile> Var x is Var x : T\<^isub>1" using ih2 by auto |
|
665 |
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 |
|
666 |
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 |
|
667 |
then show "\<Gamma> \<turnstile> s \<Leftrightarrow> t : T\<^isub>1\<rightarrow>T\<^isub>2" using fs by (auto simp add: fresh_prod) |
|
668 |
next |
|
669 |
case (2 \<Gamma> p q) |
|
670 |
have h: "\<Gamma> \<turnstile> p \<leftrightarrow> q : T\<^isub>1\<rightarrow>T\<^isub>2" by fact |
|
671 |
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 |
|
672 |
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 |
|
673 |
{
|
|
674 |
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
|
675 |
assume "\<Gamma> \<subseteq> \<Gamma>'" and hl:"\<Gamma>' \<turnstile> s is t : T\<^isub>1" and hk: "valid \<Gamma>'" |
| 22494 | 676 |
then have "\<Gamma>' \<turnstile> p \<leftrightarrow> q : T\<^isub>1 \<rightarrow> T\<^isub>2" using h algorithmic_monotonicity by auto |
677 |
moreover have "\<Gamma>' \<turnstile> s \<Leftrightarrow> t : T\<^isub>1" using ih2 hl hk by auto |
|
678 |
ultimately have "\<Gamma>' \<turnstile> App p s \<leftrightarrow> App q t : T\<^isub>2" by auto |
|
679 |
then have "\<Gamma>' \<turnstile> App p s is App q t : T\<^isub>2" using ih1 by auto |
|
680 |
} |
|
681 |
then show "\<Gamma> \<turnstile> p is q : T\<^isub>1\<rightarrow>T\<^isub>2" by simp |
|
682 |
} |
|
683 |
next |
|
684 |
case TBase |
|
685 |
{ case 2
|
|
686 |
have h:"\<Gamma> \<turnstile> s \<leftrightarrow> t : TBase" by fact |
|
687 |
then have "s \<leadsto>|" and "t \<leadsto>|" using path_equiv_implies_nf by auto |
|
688 |
then have "s \<Down> s" and "t \<Down> t" by auto |
|
689 |
then have "\<Gamma> \<turnstile> s \<Leftrightarrow> t : TBase" using h by auto |
|
690 |
then show "\<Gamma> \<turnstile> s is t : TBase" by auto |
|
691 |
} |
|
692 |
qed (auto elim: alg_path_equiv_implies_valid) |
|
693 |
||
694 |
corollary corollary_main: |
|
695 |
assumes a: "\<Gamma> \<turnstile> s \<leftrightarrow> t : T" |
|
696 |
shows "\<Gamma> \<turnstile> s \<Leftrightarrow> t : T" |
|
697 |
using a main_lemma alg_path_equiv_implies_valid by blast |
|
| 22073 | 698 |
|
699 |
lemma logical_symmetry: |
|
| 22082 | 700 |
assumes a: "\<Gamma> \<turnstile> s is t : T" |
| 22073 | 701 |
shows "\<Gamma> \<turnstile> t is s : T" |
| 22082 | 702 |
using a |
|
26966
071f40487734
made the naming of the induction principles consistent: weak_induct is
urbanc
parents:
26677
diff
changeset
|
703 |
by (nominal_induct arbitrary: \<Gamma> s t rule: ty.strong_induct) |
| 22494 | 704 |
(auto simp add: algorithmic_symmetry) |
| 22073 | 705 |
|
706 |
lemma logical_transitivity: |
|
707 |
assumes "\<Gamma> \<turnstile> s is t : T" "\<Gamma> \<turnstile> t is u : T" |
|
708 |
shows "\<Gamma> \<turnstile> s is u : T" |
|
709 |
using assms |
|
|
26966
071f40487734
made the naming of the induction principles consistent: weak_induct is
urbanc
parents:
26677
diff
changeset
|
710 |
proof (nominal_induct arbitrary: \<Gamma> s t u rule:ty.strong_induct) |
| 22073 | 711 |
case TBase |
712 |
then show "\<Gamma> \<turnstile> s is u : TBase" by (auto elim: algorithmic_transitivity) |
|
713 |
next |
|
|
22418
49e2d9744ae1
major update of the nominal package; there is now an infrastructure
urbanc
parents:
22231
diff
changeset
|
714 |
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
|
715 |
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
|
716 |
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
|
717 |
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
|
718 |
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 | 719 |
{
|
720 |
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
|
721 |
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
|
722 |
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
|
723 |
then have "\<Gamma>' \<turnstile> u' is u' : T\<^isub>1" using ih1 hl by blast |
| 22494 | 724 |
then have "\<Gamma>' \<turnstile> App t u' is App u u' : T\<^isub>2" using h2 hsub hk by auto |
725 |
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
|
726 |
ultimately have "\<Gamma>' \<turnstile> App s s' is App u u' : T\<^isub>2" using ih2 by blast |
| 22073 | 727 |
} |
| 22494 | 728 |
then show "\<Gamma> \<turnstile> s is u : T\<^isub>1 \<rightarrow> T\<^isub>2" by auto |
| 22073 | 729 |
qed (auto) |
730 |
||
731 |
lemma logical_weak_head_closure: |
|
| 22494 | 732 |
assumes a: "\<Gamma> \<turnstile> s is t : T" |
733 |
and b: "s' \<leadsto> s" |
|
734 |
and c: "t' \<leadsto> t" |
|
| 22073 | 735 |
shows "\<Gamma> \<turnstile> s' is t' : T" |
| 22494 | 736 |
using a b c algorithmic_weak_head_closure |
|
26966
071f40487734
made the naming of the induction principles consistent: weak_induct is
urbanc
parents:
26677
diff
changeset
|
737 |
by (nominal_induct arbitrary: \<Gamma> s t s' t' rule: ty.strong_induct) |
| 22494 | 738 |
(auto, blast) |
| 22073 | 739 |
|
740 |
lemma logical_weak_head_closure': |
|
| 22494 | 741 |
assumes "\<Gamma> \<turnstile> s is t : T" and "s' \<leadsto> s" |
| 22073 | 742 |
shows "\<Gamma> \<turnstile> s' is t : T" |
743 |
using assms |
|
|
26966
071f40487734
made the naming of the induction principles consistent: weak_induct is
urbanc
parents:
26677
diff
changeset
|
744 |
proof (nominal_induct arbitrary: \<Gamma> s t s' rule: ty.strong_induct) |
| 22073 | 745 |
case (TBase \<Gamma> s t s') |
746 |
then show ?case by force |
|
747 |
next |
|
748 |
case (TUnit \<Gamma> s t s') |
|
749 |
then show ?case by auto |
|
|
22418
49e2d9744ae1
major update of the nominal package; there is now an infrastructure
urbanc
parents:
22231
diff
changeset
|
750 |
next |
|
49e2d9744ae1
major update of the nominal package; there is now an infrastructure
urbanc
parents:
22231
diff
changeset
|
751 |
case (Arrow T\<^isub>1 T\<^isub>2 \<Gamma> s t s') |
| 22073 | 752 |
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
|
753 |
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
|
754 |
have h2:"\<Gamma> \<turnstile> s is t : T\<^isub>1\<rightarrow>T\<^isub>2" by fact |
| 22494 | 755 |
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
|
756 |
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 | 757 |
by auto |
| 22073 | 758 |
{
|
|
22418
49e2d9744ae1
major update of the nominal package; there is now an infrastructure
urbanc
parents:
22231
diff
changeset
|
759 |
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
|
760 |
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
|
761 |
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
|
762 |
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
|
763 |
ultimately have "\<Gamma>' \<turnstile> App s' s\<^isub>2 is App t t\<^isub>2 : T\<^isub>2" using ih by auto |
| 22073 | 764 |
} |
| 22494 | 765 |
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
|
766 |
qed |
| 22073 | 767 |
|
768 |
abbreviation |
|
| 22494 | 769 |
log_equiv_for_psubsts :: "Ctxt \<Rightarrow> Subst \<Rightarrow> Subst \<Rightarrow> Ctxt \<Rightarrow> bool" ("_ \<turnstile> _ is _ over _" [60,60] 60)
|
| 22073 | 770 |
where |
| 22494 | 771 |
"\<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 | 772 |
|
773 |
lemma logical_pseudo_reflexivity: |
|
774 |
assumes "\<Gamma>' \<turnstile> t is s over \<Gamma>" |
|
775 |
shows "\<Gamma>' \<turnstile> s is s over \<Gamma>" |
|
776 |
proof - |
|
777 |
have "\<Gamma>' \<turnstile> t is s over \<Gamma>" by fact |
|
778 |
moreover then have "\<Gamma>' \<turnstile> s is t over \<Gamma>" using logical_symmetry by blast |
|
779 |
ultimately show "\<Gamma>' \<turnstile> s is s over \<Gamma>" using logical_transitivity by blast |
|
780 |
qed |
|
781 |
||
782 |
lemma logical_subst_monotonicity : |
|
|
24231
85fb973a8207
added type constraints to resolve syntax ambiguities;
wenzelm
parents:
24088
diff
changeset
|
783 |
fixes \<Gamma> \<Gamma>' \<Gamma>'' :: Ctxt |
| 24070 | 784 |
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
|
785 |
and b: "\<Gamma>' \<subseteq> \<Gamma>''" |
| 22494 | 786 |
and c: "valid \<Gamma>''" |
| 24070 | 787 |
shows "\<Gamma>'' \<turnstile> \<theta> is \<theta>' over \<Gamma>" |
| 22494 | 788 |
using a b c logical_monotonicity by blast |
| 22073 | 789 |
|
790 |
lemma equiv_subst_ext : |
|
| 22494 | 791 |
assumes h1: "\<Gamma>' \<turnstile> \<theta> is \<theta>' over \<Gamma>" |
792 |
and h2: "\<Gamma>' \<turnstile> s is t : T" |
|
793 |
and fs: "x\<sharp>\<Gamma>" |
|
794 |
shows "\<Gamma>' \<turnstile> (x,s)#\<theta> is (x,t)#\<theta>' over (x,T)#\<Gamma>" |
|
| 22073 | 795 |
using assms |
796 |
proof - |
|
| 22494 | 797 |
{
|
798 |
fix y U |
|
799 |
assume "(y,U) \<in> set ((x,T)#\<Gamma>)" |
|
800 |
moreover |
|
801 |
{
|
|
802 |
assume "(y,U) \<in> set [(x,T)]" |
|
| 25107 | 803 |
with h2 have "\<Gamma>' \<turnstile> ((x,s)#\<theta>)<Var y> is ((x,t)#\<theta>')<Var y> : U" by auto |
| 22494 | 804 |
} |
805 |
moreover |
|
806 |
{
|
|
807 |
assume hl:"(y,U) \<in> set \<Gamma>" |
|
808 |
then have "\<not> y\<sharp>\<Gamma>" by (induct \<Gamma>) (auto simp add: fresh_list_cons fresh_atm fresh_prod) |
|
809 |
then have hf:"x\<sharp> Var y" using fs by (auto simp add: fresh_atm) |
|
| 24070 | 810 |
then have "((x,s)#\<theta>)<Var y> = \<theta><Var y>" "((x,t)#\<theta>')<Var y> = \<theta>'<Var y>" |
811 |
using fresh_psubst_simp by blast+ |
|
| 22494 | 812 |
moreover have "\<Gamma>' \<turnstile> \<theta><Var y> is \<theta>'<Var y> : U" using h1 hl by auto |
| 24070 | 813 |
ultimately have "\<Gamma>' \<turnstile> ((x,s)#\<theta>)<Var y> is ((x,t)#\<theta>')<Var y> : U" by auto |
| 22494 | 814 |
} |
| 24070 | 815 |
ultimately have "\<Gamma>' \<turnstile> ((x,s)#\<theta>)<Var y> is ((x,t)#\<theta>')<Var y> : U" by auto |
| 22073 | 816 |
} |
| 22494 | 817 |
then show "\<Gamma>' \<turnstile> (x,s)#\<theta> is (x,t)#\<theta>' over (x,T)#\<Gamma>" by auto |
| 22073 | 818 |
qed |
819 |
||
| 22494 | 820 |
theorem fundamental_theorem_1: |
| 24070 | 821 |
assumes a1: "\<Gamma> \<turnstile> t : T" |
822 |
and a2: "\<Gamma>' \<turnstile> \<theta> is \<theta>' over \<Gamma>" |
|
823 |
and a3: "valid \<Gamma>'" |
|
| 22494 | 824 |
shows "\<Gamma>' \<turnstile> \<theta><t> is \<theta>'<t> : T" |
| 24070 | 825 |
using a1 a2 a3 |
826 |
proof (nominal_induct \<Gamma> t T avoiding: \<theta> \<theta>' arbitrary: \<Gamma>' rule: typing.strong_induct) |
|
827 |
case (T_Lam x \<Gamma> T\<^isub>1 t\<^isub>2 T\<^isub>2 \<theta> \<theta>' \<Gamma>') |
|
| 25107 | 828 |
have vc: "x\<sharp>\<theta>" "x\<sharp>\<theta>'" "x\<sharp>\<Gamma>" by fact+ |
| 24070 | 829 |
have asm1: "\<Gamma>' \<turnstile> \<theta> is \<theta>' over \<Gamma>" by fact |
830 |
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 |
|
831 |
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 |
|
832 |
proof (simp, intro strip) |
|
| 22494 | 833 |
fix \<Gamma>'' s' t' |
| 24070 | 834 |
assume sub: "\<Gamma>' \<subseteq> \<Gamma>''" |
835 |
and asm2: "\<Gamma>''\<turnstile> s' is t' : T\<^isub>1" |
|
836 |
and val: "valid \<Gamma>''" |
|
837 |
from asm1 val sub have "\<Gamma>'' \<turnstile> \<theta> is \<theta>' over \<Gamma>" using logical_subst_monotonicity by blast |
|
838 |
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 |
|
839 |
with ih val have "\<Gamma>'' \<turnstile> ((x,s')#\<theta>)<t\<^isub>2> is ((x,t')#\<theta>')<t\<^isub>2> : T\<^isub>2" by auto |
|
840 |
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) |
|
841 |
moreover |
|
842 |
have "App (Lam [x].\<theta><t\<^isub>2>) s' \<leadsto> \<theta><t\<^isub>2>[x::=s']" by auto |
|
843 |
moreover |
|
844 |
have "App (Lam [x].\<theta>'<t\<^isub>2>) t' \<leadsto> \<theta>'<t\<^isub>2>[x::=t']" by auto |
|
845 |
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 | 846 |
using logical_weak_head_closure by auto |
| 24070 | 847 |
qed |
| 22073 | 848 |
qed (auto) |
849 |
||
| 24070 | 850 |
|
| 22073 | 851 |
theorem fundamental_theorem_2: |
|
22418
49e2d9744ae1
major update of the nominal package; there is now an infrastructure
urbanc
parents:
22231
diff
changeset
|
852 |
assumes h1: "\<Gamma> \<turnstile> s \<equiv> t : T" |
| 22494 | 853 |
and h2: "\<Gamma>' \<turnstile> \<theta> is \<theta>' over \<Gamma>" |
854 |
and h3: "valid \<Gamma>'" |
|
855 |
shows "\<Gamma>' \<turnstile> \<theta><s> is \<theta>'<t> : T" |
|
856 |
using h1 h2 h3 |
|
| 22531 | 857 |
proof (nominal_induct \<Gamma> s t T avoiding: \<Gamma>' \<theta> \<theta>' rule: def_equiv.strong_induct) |
| 22494 | 858 |
case (Q_Refl \<Gamma> t T \<Gamma>' \<theta> \<theta>') |
859 |
have "\<Gamma> \<turnstile> t : T" |
|
| 25107 | 860 |
and "valid \<Gamma>'" by fact+ |
| 22494 | 861 |
moreover |
862 |
have "\<Gamma>' \<turnstile> \<theta> is \<theta>' over \<Gamma>" by fact |
|
863 |
ultimately show "\<Gamma>' \<turnstile> \<theta><t> is \<theta>'<t> : T" using fundamental_theorem_1 by blast |
|
| 22073 | 864 |
next |
| 22494 | 865 |
case (Q_Symm \<Gamma> t s T \<Gamma>' \<theta> \<theta>') |
866 |
have "\<Gamma>' \<turnstile> \<theta> is \<theta>' over \<Gamma>" |
|
| 25107 | 867 |
and "valid \<Gamma>'" by fact+ |
| 22494 | 868 |
moreover |
869 |
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 |
|
870 |
ultimately show "\<Gamma>' \<turnstile> \<theta><s> is \<theta>'<t> : T" using logical_symmetry by blast |
|
| 22073 | 871 |
next |
| 22494 | 872 |
case (Q_Trans \<Gamma> s t T u \<Gamma>' \<theta> \<theta>') |
873 |
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 |
|
874 |
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 |
|
875 |
have h: "\<Gamma>' \<turnstile> \<theta> is \<theta>' over \<Gamma>" |
|
| 25107 | 876 |
and v: "valid \<Gamma>'" by fact+ |
| 22494 | 877 |
then have "\<Gamma>' \<turnstile> \<theta>' is \<theta>' over \<Gamma>" using logical_pseudo_reflexivity by auto |
878 |
then have "\<Gamma>' \<turnstile> \<theta>'<t> is \<theta>'<u> : T" using ih2 v by auto |
|
879 |
moreover have "\<Gamma>' \<turnstile> \<theta><s> is \<theta>'<t> : T" using ih1 h v by auto |
|
880 |
ultimately show "\<Gamma>' \<turnstile> \<theta><s> is \<theta>'<u> : T" using logical_transitivity by blast |
|
881 |
next |
|
882 |
case (Q_Abs x \<Gamma> T\<^isub>1 s\<^isub>2 t\<^isub>2 T\<^isub>2 \<Gamma>' \<theta> \<theta>') |
|
| 22073 | 883 |
have fs:"x\<sharp>\<Gamma>" by fact |
| 25107 | 884 |
have fs2: "x\<sharp>\<theta>" "x\<sharp>\<theta>'" by fact+ |
| 22494 | 885 |
have h2: "\<Gamma>' \<turnstile> \<theta> is \<theta>' over \<Gamma>" |
| 25107 | 886 |
and h3: "valid \<Gamma>'" by fact+ |
| 22494 | 887 |
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 | 888 |
{
|
889 |
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
|
890 |
assume "\<Gamma>' \<subseteq> \<Gamma>''" and hl:"\<Gamma>''\<turnstile> s' is t' : T\<^isub>1" and hk: "valid \<Gamma>''" |
| 22494 | 891 |
then have "\<Gamma>'' \<turnstile> \<theta> is \<theta>' over \<Gamma>" using h2 logical_subst_monotonicity by blast |
892 |
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 | 893 |
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 | 894 |
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 |
895 |
moreover have "App (Lam [x]. \<theta><s\<^isub>2>) s' \<leadsto> \<theta><s\<^isub>2>[x::=s']" |
|
896 |
and "App (Lam [x].\<theta>'<t\<^isub>2>) t' \<leadsto> \<theta>'<t\<^isub>2>[x::=t']" by auto |
|
897 |
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 | 898 |
using logical_weak_head_closure by auto |
899 |
} |
|
| 25107 | 900 |
moreover have "valid \<Gamma>'" by fact |
| 22494 | 901 |
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 |
902 |
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 | 903 |
next |
| 22494 | 904 |
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>') |
905 |
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 | 906 |
next |
| 22531 | 907 |
case (Q_Beta x \<Gamma> s\<^isub>2 t\<^isub>2 T\<^isub>1 s12 t12 T\<^isub>2 \<Gamma>' \<theta> \<theta>') |
| 22494 | 908 |
have h: "\<Gamma>' \<turnstile> \<theta> is \<theta>' over \<Gamma>" |
| 25107 | 909 |
and h': "valid \<Gamma>'" by fact+ |
| 22494 | 910 |
have fs: "x\<sharp>\<Gamma>" by fact |
| 25107 | 911 |
have fs2: " x\<sharp>\<theta>" "x\<sharp>\<theta>'" by fact+ |
| 22494 | 912 |
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 |
913 |
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 |
|
914 |
have "\<Gamma>' \<turnstile> \<theta><s\<^isub>2> is \<theta>'<t\<^isub>2> : T\<^isub>1" using ih1 h' h by auto |
|
915 |
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 | 916 |
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 | 917 |
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 |
918 |
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 |
|
919 |
moreover have "App (Lam [x].\<theta><s12>) (\<theta><s\<^isub>2>) \<leadsto> \<theta><s12>[x::=\<theta><s\<^isub>2>]" by auto |
|
920 |
ultimately have "\<Gamma>' \<turnstile> App (Lam [x].\<theta><s12>) (\<theta><s\<^isub>2>) is \<theta>'<t12[x::=t\<^isub>2]> : T\<^isub>2" |
|
| 22073 | 921 |
using logical_weak_head_closure' by auto |
| 22494 | 922 |
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 | 923 |
next |
| 22494 | 924 |
case (Q_Ext x \<Gamma> s t T\<^isub>1 T\<^isub>2 \<Gamma>' \<theta> \<theta>') |
925 |
have h2: "\<Gamma>' \<turnstile> \<theta> is \<theta>' over \<Gamma>" |
|
| 25107 | 926 |
and h2': "valid \<Gamma>'" by fact+ |
927 |
have fs:"x\<sharp>\<Gamma>" "x\<sharp>s" "x\<sharp>t" by fact+ |
|
| 22494 | 928 |
have ih:"\<And>\<Gamma>' \<theta> \<theta>'. \<lbrakk>\<Gamma>' \<turnstile> \<theta> is \<theta>' over (x,T\<^isub>1)#\<Gamma>; valid \<Gamma>'\<rbrakk> |
929 |
\<Longrightarrow> \<Gamma>' \<turnstile> \<theta><App s (Var x)> is \<theta>'<App t (Var x)> : T\<^isub>2" by fact |
|
| 22073 | 930 |
{
|
931 |
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
|
932 |
assume hsub: "\<Gamma>' \<subseteq> \<Gamma>''" and hl: "\<Gamma>''\<turnstile> s' is t' : T\<^isub>1" and hk: "valid \<Gamma>''" |
| 22494 | 933 |
then have "\<Gamma>'' \<turnstile> \<theta> is \<theta>' over \<Gamma>" using h2 logical_subst_monotonicity by blast |
934 |
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 | 935 |
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 | 936 |
then |
| 24070 | 937 |
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 | 938 |
by auto |
| 24070 | 939 |
then have "\<Gamma>'' \<turnstile> App ((x,s')#\<theta>)<s> s' is App ((x,t')#\<theta>')<t> t' : T\<^isub>2" by auto |
| 22494 | 940 |
then have "\<Gamma>'' \<turnstile> App (\<theta><s>) s' is App (\<theta>'<t>) t' : T\<^isub>2" using fs fresh_psubst_simp by auto |
| 22073 | 941 |
} |
| 25107 | 942 |
moreover have "valid \<Gamma>'" by fact |
| 22494 | 943 |
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
|
944 |
next |
|
513a8ee192f1
added the Q_Unit rule (was missing) and adjusted the proof accordingly
urbanc
parents:
22829
diff
changeset
|
945 |
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
|
946 |
then show "\<Gamma>' \<turnstile> \<theta><s> is \<theta>'<t> : TUnit" by auto |
| 22073 | 947 |
qed |
948 |
||
|
22418
49e2d9744ae1
major update of the nominal package; there is now an infrastructure
urbanc
parents:
22231
diff
changeset
|
949 |
|
| 22073 | 950 |
theorem completeness: |
| 22494 | 951 |
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
|
952 |
shows "\<Gamma> \<turnstile> s \<Leftrightarrow> t : T" |
| 22073 | 953 |
proof - |
| 22494 | 954 |
have val: "valid \<Gamma>" using def_equiv_implies_valid asm by simp |
955 |
moreover |
|
| 22073 | 956 |
{
|
957 |
fix x T |
|
958 |
assume "(x,T) \<in> set \<Gamma>" "valid \<Gamma>" |
|
| 22494 | 959 |
then have "\<Gamma> \<turnstile> Var x is Var x : T" using main_lemma(2) by blast |
| 22073 | 960 |
} |
961 |
ultimately have "\<Gamma> \<turnstile> [] is [] over \<Gamma>" by auto |
|
| 22494 | 962 |
then have "\<Gamma> \<turnstile> []<s> is []<t> : T" using fundamental_theorem_2 val asm by blast |
| 22073 | 963 |
then have "\<Gamma> \<turnstile> s is t : T" by simp |
| 22494 | 964 |
then show "\<Gamma> \<turnstile> s \<Leftrightarrow> t : T" using main_lemma(1) val by simp |
| 22073 | 965 |
qed |
966 |
||
|
22418
49e2d9744ae1
major update of the nominal package; there is now an infrastructure
urbanc
parents:
22231
diff
changeset
|
967 |
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
|
968 |
@{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
|
969 |
@{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
|
970 |
*} |
| 22073 | 971 |
|
972 |
end |
|
973 |