author | paulson <lp15@cam.ac.uk> |
Wed, 24 Apr 2024 20:56:26 +0100 | |
changeset 80149 | 40a3fc07a587 |
parent 69597 | ff784d5a5bfb |
child 80914 | d97fdabd9e2b |
permissions | -rw-r--r-- |
22073 | 1 |
(* *) |
22082 | 2 |
(* Formalisation of the chapter on Logical Relations *) |
3 |
(* and a Case Study in Equivalence Checking *) |
|
4 |
(* by Karl Crary from the book on Advanced Topics in *) |
|
5 |
(* Types and Programming Languages, MIT Press 2005 *) |
|
6 |
||
7 |
(* 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
|
8 |
(* Christian Urban. *) |
22073 | 9 |
|
10 |
theory Crary |
|
66453
cc19f7ca2ed6
session-qualified theory imports: isabelle imports -U -i -d '~~/src/Benchmarks' -a;
wenzelm
parents:
63167
diff
changeset
|
11 |
imports "HOL-Nominal.Nominal" |
22073 | 12 |
begin |
13 |
||
14 |
atom_decl name |
|
15 |
||
22829
f1db55c7534d
tuned some proofs and changed variable names in some definitions of Nominal.thy
urbanc
parents:
22730
diff
changeset
|
16 |
nominal_datatype ty = |
f1db55c7534d
tuned some proofs and changed variable names in some definitions of Nominal.thy
urbanc
parents:
22730
diff
changeset
|
17 |
TBase |
f1db55c7534d
tuned some proofs and changed variable names in some definitions of Nominal.thy
urbanc
parents:
22730
diff
changeset
|
18 |
| TUnit |
f1db55c7534d
tuned some proofs and changed variable names in some definitions of Nominal.thy
urbanc
parents:
22730
diff
changeset
|
19 |
| Arrow "ty" "ty" ("_\<rightarrow>_" [100,100] 100) |
22073 | 20 |
|
22829
f1db55c7534d
tuned some proofs and changed variable names in some definitions of Nominal.thy
urbanc
parents:
22730
diff
changeset
|
21 |
nominal_datatype trm = |
f1db55c7534d
tuned some proofs and changed variable names in some definitions of Nominal.thy
urbanc
parents:
22730
diff
changeset
|
22 |
Unit |
24070 | 23 |
| 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
|
24 |
| Lam "\<guillemotleft>name\<guillemotright>trm" ("Lam [_]._" [100,100] 100) |
24070 | 25 |
| 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
|
26 |
| Const "nat" |
22073 | 27 |
|
41798 | 28 |
type_synonym Ctxt = "(name\<times>ty) list" |
29 |
type_synonym Subst = "(name\<times>trm) list" |
|
22494 | 30 |
|
22073 | 31 |
|
32 |
lemma perm_ty[simp]: |
|
33 |
fixes T::"ty" |
|
34 |
and pi::"name prm" |
|
35 |
shows "pi\<bullet>T = T" |
|
26966
071f40487734
made the naming of the induction principles consistent: weak_induct is
urbanc
parents:
26677
diff
changeset
|
36 |
by (induct T rule: ty.induct) (simp_all) |
22073 | 37 |
|
38 |
lemma fresh_ty[simp]: |
|
39 |
fixes x::"name" |
|
40 |
and T::"ty" |
|
41 |
shows "x\<sharp>T" |
|
42 |
by (simp add: fresh_def supp_def) |
|
43 |
||
44 |
lemma ty_cases: |
|
45 |
fixes T::ty |
|
53015
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
49171
diff
changeset
|
46 |
shows "(\<exists> T\<^sub>1 T\<^sub>2. T=T\<^sub>1\<rightarrow>T\<^sub>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
|
47 |
by (induct T rule:ty.induct) (auto) |
22073 | 48 |
|
29097
68245155eb58
Modified nominal_primrec to make it work with local theories, unified syntax
berghofe
parents:
28042
diff
changeset
|
49 |
instantiation ty :: size |
68245155eb58
Modified nominal_primrec to make it work with local theories, unified syntax
berghofe
parents:
28042
diff
changeset
|
50 |
begin |
22073 | 51 |
|
29097
68245155eb58
Modified nominal_primrec to make it work with local theories, unified syntax
berghofe
parents:
28042
diff
changeset
|
52 |
nominal_primrec size_ty |
68245155eb58
Modified nominal_primrec to make it work with local theories, unified syntax
berghofe
parents:
28042
diff
changeset
|
53 |
where |
22073 | 54 |
"size (TBase) = 1" |
29097
68245155eb58
Modified nominal_primrec to make it work with local theories, unified syntax
berghofe
parents:
28042
diff
changeset
|
55 |
| "size (TUnit) = 1" |
53015
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
49171
diff
changeset
|
56 |
| "size (T\<^sub>1\<rightarrow>T\<^sub>2) = size T\<^sub>1 + size T\<^sub>2" |
22073 | 57 |
by (rule TrueI)+ |
58 |
||
29097
68245155eb58
Modified nominal_primrec to make it work with local theories, unified syntax
berghofe
parents:
28042
diff
changeset
|
59 |
instance .. |
68245155eb58
Modified nominal_primrec to make it work with local theories, unified syntax
berghofe
parents:
28042
diff
changeset
|
60 |
|
68245155eb58
Modified nominal_primrec to make it work with local theories, unified syntax
berghofe
parents:
28042
diff
changeset
|
61 |
end |
68245155eb58
Modified nominal_primrec to make it work with local theories, unified syntax
berghofe
parents:
28042
diff
changeset
|
62 |
|
22073 | 63 |
lemma ty_size_greater_zero[simp]: |
64 |
fixes T::"ty" |
|
65 |
shows "size T > 0" |
|
26966
071f40487734
made the naming of the induction principles consistent: weak_induct is
urbanc
parents:
26677
diff
changeset
|
66 |
by (nominal_induct rule: ty.strong_induct) (simp_all) |
22073 | 67 |
|
63167 | 68 |
section \<open>Substitutions\<close> |
22494 | 69 |
|
70 |
fun |
|
71 |
lookup :: "Subst \<Rightarrow> name \<Rightarrow> trm" |
|
72 |
where |
|
73 |
"lookup [] x = Var x" |
|
22501 | 74 |
| "lookup ((y,T)#\<theta>) x = (if x=y then T else lookup \<theta> x)" |
22494 | 75 |
|
76 |
lemma lookup_eqvt[eqvt]: |
|
77 |
fixes pi::"name prm" |
|
78 |
shows "pi\<bullet>(lookup \<theta> x) = lookup (pi\<bullet>\<theta>) (pi\<bullet>x)" |
|
80149 | 79 |
by (induct \<theta>) (auto simp: perm_bij) |
22494 | 80 |
|
81 |
lemma lookup_fresh: |
|
82 |
fixes z::"name" |
|
83 |
assumes a: "z\<sharp>\<theta>" "z\<sharp>x" |
|
84 |
shows "z\<sharp> lookup \<theta> x" |
|
85 |
using a |
|
86 |
by (induct rule: lookup.induct) |
|
80149 | 87 |
(auto simp: fresh_list_cons) |
22494 | 88 |
|
89 |
lemma lookup_fresh': |
|
90 |
assumes a: "z\<sharp>\<theta>" |
|
91 |
shows "lookup \<theta> z = Var z" |
|
92 |
using a |
|
93 |
by (induct rule: lookup.induct) |
|
80149 | 94 |
(auto simp: fresh_list_cons fresh_prod fresh_atm) |
22494 | 95 |
|
96 |
nominal_primrec |
|
29097
68245155eb58
Modified nominal_primrec to make it work with local theories, unified syntax
berghofe
parents:
28042
diff
changeset
|
97 |
psubst :: "Subst \<Rightarrow> trm \<Rightarrow> trm" ("_<_>" [100,100] 130) |
68245155eb58
Modified nominal_primrec to make it work with local theories, unified syntax
berghofe
parents:
28042
diff
changeset
|
98 |
where |
22494 | 99 |
"\<theta><(Var x)> = (lookup \<theta> x)" |
53015
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
49171
diff
changeset
|
100 |
| "\<theta><(App t\<^sub>1 t\<^sub>2)> = App \<theta><t\<^sub>1> \<theta><t\<^sub>2>" |
29097
68245155eb58
Modified nominal_primrec to make it work with local theories, unified syntax
berghofe
parents:
28042
diff
changeset
|
101 |
| "x\<sharp>\<theta> \<Longrightarrow> \<theta><(Lam [x].t)> = Lam [x].(\<theta><t>)" |
68245155eb58
Modified nominal_primrec to make it work with local theories, unified syntax
berghofe
parents:
28042
diff
changeset
|
102 |
| "\<theta><(Const n)> = Const n" |
68245155eb58
Modified nominal_primrec to make it work with local theories, unified syntax
berghofe
parents:
28042
diff
changeset
|
103 |
| "\<theta><(Unit)> = Unit" |
80149 | 104 |
by(finite_guess | simp add: abs_fresh | fresh_guess)+ |
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))" |
|
53015
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
49171
diff
changeset
|
113 |
and "(App t\<^sub>1 t\<^sub>2)[y::=t'] = App (t\<^sub>1[y::=t']) (t\<^sub>2[y::=t'])" |
22494 | 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" |
|
53015
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
49171
diff
changeset
|
127 |
assumes a: "c\<sharp>t\<^sub>1" |
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
49171
diff
changeset
|
128 |
shows "t\<^sub>1[a::=t\<^sub>2] = ([(c,a)]\<bullet>t\<^sub>1)[c::=t\<^sub>2]" |
22494 | 129 |
using a |
80149 | 130 |
by (nominal_induct t\<^sub>1 avoiding: a c t\<^sub>2 rule: trm.strong_induct) |
131 |
(auto simp: trm.inject calc_atm fresh_atm abs_fresh perm_nat_def) |
|
22494 | 132 |
|
133 |
lemma fresh_psubst: |
|
134 |
fixes z::"name" |
|
135 |
assumes a: "z\<sharp>t" "z\<sharp>\<theta>" |
|
136 |
shows "z\<sharp>(\<theta><t>)" |
|
137 |
using a |
|
26966
071f40487734
made the naming of the induction principles consistent: weak_induct is
urbanc
parents:
26677
diff
changeset
|
138 |
by (nominal_induct t avoiding: z \<theta> t rule: trm.strong_induct) |
80149 | 139 |
(auto simp: abs_fresh lookup_fresh) |
22494 | 140 |
|
141 |
lemma fresh_subst'': |
|
142 |
fixes z::"name" |
|
53015
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
49171
diff
changeset
|
143 |
assumes "z\<sharp>t\<^sub>2" |
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
49171
diff
changeset
|
144 |
shows "z\<sharp>t\<^sub>1[z::=t\<^sub>2]" |
22494 | 145 |
using assms |
53015
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
49171
diff
changeset
|
146 |
by (nominal_induct t\<^sub>1 avoiding: t\<^sub>2 z rule: trm.strong_induct) |
80149 | 147 |
(auto simp: abs_fresh fresh_nat fresh_atm) |
22494 | 148 |
|
149 |
lemma fresh_subst': |
|
150 |
fixes z::"name" |
|
53015
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
49171
diff
changeset
|
151 |
assumes "z\<sharp>[y].t\<^sub>1" "z\<sharp>t\<^sub>2" |
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
49171
diff
changeset
|
152 |
shows "z\<sharp>t\<^sub>1[y::=t\<^sub>2]" |
22494 | 153 |
using assms |
53015
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
49171
diff
changeset
|
154 |
by (nominal_induct t\<^sub>1 avoiding: y t\<^sub>2 z rule: trm.strong_induct) |
80149 | 155 |
(auto simp: abs_fresh fresh_nat fresh_atm) |
22073 | 156 |
|
22494 | 157 |
lemma fresh_subst: |
158 |
fixes z::"name" |
|
53015
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
49171
diff
changeset
|
159 |
assumes a: "z\<sharp>t\<^sub>1" "z\<sharp>t\<^sub>2" |
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
49171
diff
changeset
|
160 |
shows "z\<sharp>t\<^sub>1[y::=t\<^sub>2]" |
22494 | 161 |
using a |
80149 | 162 |
by (auto simp: fresh_subst' abs_fresh) |
22494 | 163 |
|
164 |
lemma fresh_psubst_simp: |
|
165 |
assumes "x\<sharp>t" |
|
24070 | 166 |
shows "((x,u)#\<theta>)<t> = \<theta><t>" |
22494 | 167 |
using assms |
26966
071f40487734
made the naming of the induction principles consistent: weak_induct is
urbanc
parents:
26677
diff
changeset
|
168 |
proof (nominal_induct t avoiding: x u \<theta> rule: trm.strong_induct) |
22494 | 169 |
case (Lam y t x u) |
25107 | 170 |
have fs: "y\<sharp>\<theta>" "y\<sharp>x" "y\<sharp>u" by fact+ |
22494 | 171 |
moreover have "x\<sharp> Lam [y].t" by fact |
172 |
ultimately have "x\<sharp>t" by (simp add: abs_fresh fresh_atm) |
|
173 |
moreover have ih:"\<And>n T. n\<sharp>t \<Longrightarrow> ((n,T)#\<theta>)<t> = \<theta><t>" by fact |
|
24070 | 174 |
ultimately have "((x,u)#\<theta>)<t> = \<theta><t>" by auto |
175 |
moreover have "((x,u)#\<theta>)<Lam [y].t> = Lam [y].(((x,u)#\<theta>)<t>)" using fs |
|
22494 | 176 |
by (simp add: fresh_list_cons fresh_prod) |
177 |
moreover have " \<theta><Lam [y].t> = Lam [y]. (\<theta><t>)" using fs by simp |
|
24070 | 178 |
ultimately show "((x,u)#\<theta>)<Lam [y].t> = \<theta><Lam [y].t>" by auto |
80149 | 179 |
qed (auto simp: fresh_atm abs_fresh) |
22418
49e2d9744ae1
major update of the nominal package; there is now an infrastructure
urbanc
parents:
22231
diff
changeset
|
180 |
|
22494 | 181 |
lemma forget: |
182 |
fixes x::"name" |
|
183 |
assumes a: "x\<sharp>t" |
|
184 |
shows "t[x::=t'] = t" |
|
185 |
using a |
|
26966
071f40487734
made the naming of the induction principles consistent: weak_induct is
urbanc
parents:
26677
diff
changeset
|
186 |
by (nominal_induct t avoiding: x t' rule: trm.strong_induct) |
80149 | 187 |
(auto simp: fresh_atm abs_fresh) |
22494 | 188 |
|
189 |
lemma subst_fun_eq: |
|
190 |
fixes u::trm |
|
53015
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
49171
diff
changeset
|
191 |
assumes h:"[x].t\<^sub>1 = [y].t\<^sub>2" |
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
49171
diff
changeset
|
192 |
shows "t\<^sub>1[x::=u] = t\<^sub>2[y::=u]" |
22494 | 193 |
proof - |
194 |
{ |
|
53015
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
49171
diff
changeset
|
195 |
assume "x=y" and "t\<^sub>1=t\<^sub>2" |
22494 | 196 |
then have ?thesis using h by simp |
197 |
} |
|
198 |
moreover |
|
199 |
{ |
|
53015
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
49171
diff
changeset
|
200 |
assume h1:"x \<noteq> y" and h2:"t\<^sub>1=[(x,y)] \<bullet> t\<^sub>2" and h3:"x \<sharp> t\<^sub>2" |
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
49171
diff
changeset
|
201 |
then have "([(x,y)] \<bullet> t\<^sub>2)[x::=u] = t\<^sub>2[y::=u]" by (simp add: subst_rename) |
22494 | 202 |
then have ?thesis using h2 by simp |
203 |
} |
|
204 |
ultimately show ?thesis using alpha h by blast |
|
205 |
qed |
|
22418
49e2d9744ae1
major update of the nominal package; there is now an infrastructure
urbanc
parents:
22231
diff
changeset
|
206 |
|
22494 | 207 |
lemma psubst_empty[simp]: |
208 |
shows "[]<t> = t" |
|
26966
071f40487734
made the naming of the induction principles consistent: weak_induct is
urbanc
parents:
26677
diff
changeset
|
209 |
by (nominal_induct t rule: trm.strong_induct) |
80149 | 210 |
(auto simp: fresh_list_nil) |
22494 | 211 |
|
212 |
lemma psubst_subst_psubst: |
|
213 |
assumes h:"c\<sharp>\<theta>" |
|
24070 | 214 |
shows "\<theta><t>[c::=s] = ((c,s)#\<theta>)<t>" |
22494 | 215 |
using h |
26966
071f40487734
made the naming of the induction principles consistent: weak_induct is
urbanc
parents:
26677
diff
changeset
|
216 |
by (nominal_induct t avoiding: \<theta> c s rule: trm.strong_induct) |
80149 | 217 |
(auto simp: fresh_list_cons fresh_atm forget lookup_fresh lookup_fresh' fresh_psubst) |
22494 | 218 |
|
219 |
lemma subst_fresh_simp: |
|
220 |
assumes a: "x\<sharp>\<theta>" |
|
221 |
shows "\<theta><Var x> = Var x" |
|
222 |
using a |
|
80149 | 223 |
by (induct \<theta> arbitrary: x) (auto simp: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
|
224 |
|
22494 | 225 |
lemma psubst_subst_propagate: |
226 |
assumes "x\<sharp>\<theta>" |
|
227 |
shows "\<theta><t[x::=u]> = \<theta><t>[x::=\<theta><u>]" |
|
228 |
using assms |
|
26966
071f40487734
made the naming of the induction principles consistent: weak_induct is
urbanc
parents:
26677
diff
changeset
|
229 |
proof (nominal_induct t avoiding: x u \<theta> rule: trm.strong_induct) |
22494 | 230 |
case (Var n x u \<theta>) |
231 |
{ assume "x=n" |
|
232 |
moreover have "x\<sharp>\<theta>" by fact |
|
233 |
ultimately have "\<theta><Var n[x::=u]> = \<theta><Var n>[x::=\<theta><u>]" using subst_fresh_simp by auto |
|
234 |
} |
|
235 |
moreover |
|
236 |
{ assume h:"x\<noteq>n" |
|
80149 | 237 |
then have "x\<sharp>Var n" by (auto simp: fresh_atm) |
22494 | 238 |
moreover have "x\<sharp>\<theta>" by fact |
239 |
ultimately have "x\<sharp>\<theta><Var n>" using fresh_psubst by blast |
|
240 |
then have " \<theta><Var n>[x::=\<theta><u>] = \<theta><Var n>" using forget by auto |
|
241 |
then have "\<theta><Var n[x::=u]> = \<theta><Var n>[x::=\<theta><u>]" using h by auto |
|
242 |
} |
|
243 |
ultimately show ?case by auto |
|
244 |
next |
|
245 |
case (Lam n t x u \<theta>) |
|
25107 | 246 |
have fs:"n\<sharp>x" "n\<sharp>u" "n\<sharp>\<theta>" "x\<sharp>\<theta>" by fact+ |
22494 | 247 |
have ih:"\<And> y s \<theta>. y\<sharp>\<theta> \<Longrightarrow> ((\<theta><(t[y::=s])>) = ((\<theta><t>)[y::=(\<theta><s>)]))" by fact |
248 |
have "\<theta> <(Lam [n].t)[x::=u]> = \<theta><Lam [n]. (t [x::=u])>" using fs by auto |
|
249 |
then have "\<theta> <(Lam [n].t)[x::=u]> = Lam [n]. \<theta><t [x::=u]>" using fs by auto |
|
250 |
moreover have "\<theta><t[x::=u]> = \<theta><t>[x::=\<theta><u>]" using ih fs by blast |
|
251 |
ultimately have "\<theta> <(Lam [n].t)[x::=u]> = Lam [n].(\<theta><t>[x::=\<theta><u>])" by auto |
|
252 |
moreover have "Lam [n].(\<theta><t>[x::=\<theta><u>]) = (Lam [n].\<theta><t>)[x::=\<theta><u>]" using fs fresh_psubst by auto |
|
253 |
ultimately have "\<theta><(Lam [n].t)[x::=u]> = (Lam [n].\<theta><t>)[x::=\<theta><u>]" using fs by auto |
|
254 |
then show "\<theta><(Lam [n].t)[x::=u]> = \<theta><Lam [n].t>[x::=\<theta><u>]" using fs by auto |
|
255 |
qed (auto) |
|
256 |
||
63167 | 257 |
section \<open>Typing\<close> |
22494 | 258 |
|
23760 | 259 |
inductive |
22494 | 260 |
valid :: "Ctxt \<Rightarrow> bool" |
22073 | 261 |
where |
22494 | 262 |
v_nil[intro]: "valid []" |
263 |
| 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
|
264 |
|
22538
3ccb92dfb5e9
tuned proofs (taking full advantage of nominal_inductive)
urbanc
parents:
22531
diff
changeset
|
265 |
equivariance valid |
22418
49e2d9744ae1
major update of the nominal package; there is now an infrastructure
urbanc
parents:
22231
diff
changeset
|
266 |
|
24070 | 267 |
inductive_cases |
22073 | 268 |
valid_cons_elim_auto[elim]:"valid ((x,T)#\<Gamma>)" |
269 |
||
22494 | 270 |
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
|
271 |
"sub_context" :: "Ctxt \<Rightarrow> Ctxt \<Rightarrow> bool" (" _ \<subseteq> _ " [55,55] 55) |
22494 | 272 |
where |
53015
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
49171
diff
changeset
|
273 |
"\<Gamma>\<^sub>1 \<subseteq> \<Gamma>\<^sub>2 \<equiv> \<forall>a T. (a,T)\<in>set \<Gamma>\<^sub>1 \<longrightarrow> (a,T)\<in>set \<Gamma>\<^sub>2" |
22418
49e2d9744ae1
major update of the nominal package; there is now an infrastructure
urbanc
parents:
22231
diff
changeset
|
274 |
|
22494 | 275 |
lemma valid_monotonicity[elim]: |
24231
85fb973a8207
added type constraints to resolve syntax ambiguities;
wenzelm
parents:
24088
diff
changeset
|
276 |
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
|
277 |
assumes a: "\<Gamma> \<subseteq> \<Gamma>'" |
22494 | 278 |
and b: "x\<sharp>\<Gamma>'" |
53015
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
49171
diff
changeset
|
279 |
shows "(x,T\<^sub>1)#\<Gamma> \<subseteq> (x,T\<^sub>1)#\<Gamma>'" |
22494 | 280 |
using a b by auto |
22418
49e2d9744ae1
major update of the nominal package; there is now an infrastructure
urbanc
parents:
22231
diff
changeset
|
281 |
|
49e2d9744ae1
major update of the nominal package; there is now an infrastructure
urbanc
parents:
22231
diff
changeset
|
282 |
lemma fresh_context: |
22494 | 283 |
fixes \<Gamma> :: "Ctxt" |
22418
49e2d9744ae1
major update of the nominal package; there is now an infrastructure
urbanc
parents:
22231
diff
changeset
|
284 |
and a :: "name" |
49e2d9744ae1
major update of the nominal package; there is now an infrastructure
urbanc
parents:
22231
diff
changeset
|
285 |
assumes "a\<sharp>\<Gamma>" |
49e2d9744ae1
major update of the nominal package; there is now an infrastructure
urbanc
parents:
22231
diff
changeset
|
286 |
shows "\<not>(\<exists>\<tau>::ty. (a,\<tau>)\<in>set \<Gamma>)" |
22494 | 287 |
using assms |
288 |
by (induct \<Gamma>) |
|
80149 | 289 |
(auto simp: 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
|
290 |
|
49e2d9744ae1
major update of the nominal package; there is now an infrastructure
urbanc
parents:
22231
diff
changeset
|
291 |
lemma type_unicity_in_context: |
22494 | 292 |
assumes a: "valid \<Gamma>" |
53015
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
49171
diff
changeset
|
293 |
and b: "(x,T\<^sub>1) \<in> set \<Gamma>" |
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
49171
diff
changeset
|
294 |
and c: "(x,T\<^sub>2) \<in> set \<Gamma>" |
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
49171
diff
changeset
|
295 |
shows "T\<^sub>1=T\<^sub>2" |
22494 | 296 |
using a b c |
297 |
by (induct \<Gamma>) |
|
298 |
(auto dest!: fresh_context) |
|
22073 | 299 |
|
23760 | 300 |
inductive |
22494 | 301 |
typing :: "Ctxt\<Rightarrow>trm\<Rightarrow>ty\<Rightarrow>bool" (" _ \<turnstile> _ : _ " [60,60,60] 60) |
22073 | 302 |
where |
24070 | 303 |
T_Var[intro]: "\<lbrakk>valid \<Gamma>; (x,T)\<in>set \<Gamma>\<rbrakk> \<Longrightarrow> \<Gamma> \<turnstile> Var x : T" |
53015
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
49171
diff
changeset
|
304 |
| T_App[intro]: "\<lbrakk>\<Gamma> \<turnstile> e\<^sub>1 : T\<^sub>1\<rightarrow>T\<^sub>2; \<Gamma> \<turnstile> e\<^sub>2 : T\<^sub>1\<rbrakk> \<Longrightarrow> \<Gamma> \<turnstile> App e\<^sub>1 e\<^sub>2 : T\<^sub>2" |
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
49171
diff
changeset
|
305 |
| T_Lam[intro]: "\<lbrakk>x\<sharp>\<Gamma>; (x,T\<^sub>1)#\<Gamma> \<turnstile> t : T\<^sub>2\<rbrakk> \<Longrightarrow> \<Gamma> \<turnstile> Lam [x].t : T\<^sub>1\<rightarrow>T\<^sub>2" |
24070 | 306 |
| T_Const[intro]: "valid \<Gamma> \<Longrightarrow> \<Gamma> \<turnstile> Const n : TBase" |
307 |
| 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
|
308 |
|
22730
8bcc8809ed3b
nominal_inductive no longer proves equivariance.
berghofe
parents:
22650
diff
changeset
|
309 |
equivariance typing |
8bcc8809ed3b
nominal_inductive no longer proves equivariance.
berghofe
parents:
22650
diff
changeset
|
310 |
|
22418
49e2d9744ae1
major update of the nominal package; there is now an infrastructure
urbanc
parents:
22231
diff
changeset
|
311 |
nominal_inductive typing |
22531 | 312 |
by (simp_all add: abs_fresh) |
22073 | 313 |
|
22494 | 314 |
lemma typing_implies_valid: |
315 |
assumes a: "\<Gamma> \<turnstile> t : T" |
|
316 |
shows "valid \<Gamma>" |
|
317 |
using a by (induct) (auto) |
|
22073 | 318 |
|
319 |
declare trm.inject [simp add] |
|
320 |
declare ty.inject [simp add] |
|
321 |
||
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
|
322 |
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
|
323 |
"\<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
|
324 |
"\<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
|
325 |
"\<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
|
326 |
"\<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
|
327 |
"\<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
|
328 |
"\<Gamma> \<turnstile> s : TUnit" |
22073 | 329 |
|
330 |
declare trm.inject [simp del] |
|
331 |
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
|
332 |
|
22073 | 333 |
|
63167 | 334 |
section \<open>Definitional Equivalence\<close> |
22073 | 335 |
|
23760 | 336 |
inductive |
22494 | 337 |
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
|
338 |
where |
49e2d9744ae1
major update of the nominal package; there is now an infrastructure
urbanc
parents:
22231
diff
changeset
|
339 |
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
|
340 |
| 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
|
341 |
| Q_Trans[intro]: "\<lbrakk>\<Gamma> \<turnstile> s \<equiv> t : T; \<Gamma> \<turnstile> t \<equiv> u : T\<rbrakk> \<Longrightarrow> \<Gamma> \<turnstile> s \<equiv> u : T" |
53015
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
49171
diff
changeset
|
342 |
| Q_Abs[intro]: "\<lbrakk>x\<sharp>\<Gamma>; (x,T\<^sub>1)#\<Gamma> \<turnstile> s\<^sub>2 \<equiv> t\<^sub>2 : T\<^sub>2\<rbrakk> \<Longrightarrow> \<Gamma> \<turnstile> Lam [x]. s\<^sub>2 \<equiv> Lam [x]. t\<^sub>2 : T\<^sub>1 \<rightarrow> T\<^sub>2" |
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
49171
diff
changeset
|
343 |
| Q_App[intro]: "\<lbrakk>\<Gamma> \<turnstile> s\<^sub>1 \<equiv> t\<^sub>1 : T\<^sub>1 \<rightarrow> T\<^sub>2 ; \<Gamma> \<turnstile> s\<^sub>2 \<equiv> t\<^sub>2 : T\<^sub>1\<rbrakk> \<Longrightarrow> \<Gamma> \<turnstile> App s\<^sub>1 s\<^sub>2 \<equiv> App t\<^sub>1 t\<^sub>2 : T\<^sub>2" |
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
49171
diff
changeset
|
344 |
| Q_Beta[intro]: "\<lbrakk>x\<sharp>(\<Gamma>,s\<^sub>2,t\<^sub>2); (x,T\<^sub>1)#\<Gamma> \<turnstile> s\<^sub>1 \<equiv> t\<^sub>1 : T\<^sub>2 ; \<Gamma> \<turnstile> s\<^sub>2 \<equiv> t\<^sub>2 : T\<^sub>1\<rbrakk> |
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
49171
diff
changeset
|
345 |
\<Longrightarrow> \<Gamma> \<turnstile> App (Lam [x]. s\<^sub>1) s\<^sub>2 \<equiv> t\<^sub>1[x::=t\<^sub>2] : T\<^sub>2" |
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
49171
diff
changeset
|
346 |
| Q_Ext[intro]: "\<lbrakk>x\<sharp>(\<Gamma>,s,t); (x,T\<^sub>1)#\<Gamma> \<turnstile> App s (Var x) \<equiv> App t (Var x) : T\<^sub>2\<rbrakk> |
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
49171
diff
changeset
|
347 |
\<Longrightarrow> \<Gamma> \<turnstile> s \<equiv> t : T\<^sub>1 \<rightarrow> T\<^sub>2" |
23370
513a8ee192f1
added the Q_Unit rule (was missing) and adjusted the proof accordingly
urbanc
parents:
22829
diff
changeset
|
348 |
| 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
|
349 |
|
22730
8bcc8809ed3b
nominal_inductive no longer proves equivariance.
berghofe
parents:
22650
diff
changeset
|
350 |
equivariance def_equiv |
8bcc8809ed3b
nominal_inductive no longer proves equivariance.
berghofe
parents:
22650
diff
changeset
|
351 |
|
22494 | 352 |
nominal_inductive def_equiv |
22531 | 353 |
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
|
354 |
|
22494 | 355 |
lemma def_equiv_implies_valid: |
356 |
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
|
357 |
shows "valid \<Gamma>" |
22494 | 358 |
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
|
359 |
|
63167 | 360 |
section \<open>Weak Head Reduction\<close> |
22418
49e2d9744ae1
major update of the nominal package; there is now an infrastructure
urbanc
parents:
22231
diff
changeset
|
361 |
|
23760 | 362 |
inductive |
22418
49e2d9744ae1
major update of the nominal package; there is now an infrastructure
urbanc
parents:
22231
diff
changeset
|
363 |
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
|
364 |
where |
53015
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
49171
diff
changeset
|
365 |
QAR_Beta[intro]: "App (Lam [x]. t\<^sub>1) t\<^sub>2 \<leadsto> t\<^sub>1[x::=t\<^sub>2]" |
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
49171
diff
changeset
|
366 |
| QAR_App[intro]: "t\<^sub>1 \<leadsto> t\<^sub>1' \<Longrightarrow> App t\<^sub>1 t\<^sub>2 \<leadsto> App t\<^sub>1' t\<^sub>2" |
22418
49e2d9744ae1
major update of the nominal package; there is now an infrastructure
urbanc
parents:
22231
diff
changeset
|
367 |
|
49e2d9744ae1
major update of the nominal package; there is now an infrastructure
urbanc
parents:
22231
diff
changeset
|
368 |
declare trm.inject [simp add] |
49e2d9744ae1
major update of the nominal package; there is now an infrastructure
urbanc
parents:
22231
diff
changeset
|
369 |
declare ty.inject [simp add] |
49e2d9744ae1
major update of the nominal package; there is now an infrastructure
urbanc
parents:
22231
diff
changeset
|
370 |
|
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
|
371 |
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
|
372 |
"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
|
373 |
"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
|
374 |
"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
|
375 |
"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
|
376 |
"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
|
377 |
"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
|
378 |
"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
|
379 |
"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
|
380 |
"t \<leadsto> App p q" |
22418
49e2d9744ae1
major update of the nominal package; there is now an infrastructure
urbanc
parents:
22231
diff
changeset
|
381 |
|
49e2d9744ae1
major update of the nominal package; there is now an infrastructure
urbanc
parents:
22231
diff
changeset
|
382 |
declare trm.inject [simp del] |
49e2d9744ae1
major update of the nominal package; there is now an infrastructure
urbanc
parents:
22231
diff
changeset
|
383 |
declare ty.inject [simp del] |
49e2d9744ae1
major update of the nominal package; there is now an infrastructure
urbanc
parents:
22231
diff
changeset
|
384 |
|
22531 | 385 |
equivariance whr_def |
22418
49e2d9744ae1
major update of the nominal package; there is now an infrastructure
urbanc
parents:
22231
diff
changeset
|
386 |
|
63167 | 387 |
section \<open>Weak Head Normalisation\<close> |
22418
49e2d9744ae1
major update of the nominal package; there is now an infrastructure
urbanc
parents:
22231
diff
changeset
|
388 |
|
49e2d9744ae1
major update of the nominal package; there is now an infrastructure
urbanc
parents:
22231
diff
changeset
|
389 |
abbreviation |
49e2d9744ae1
major update of the nominal package; there is now an infrastructure
urbanc
parents:
22231
diff
changeset
|
390 |
nf :: "trm \<Rightarrow> bool" ("_ \<leadsto>|" [100] 100) |
49e2d9744ae1
major update of the nominal package; there is now an infrastructure
urbanc
parents:
22231
diff
changeset
|
391 |
where |
49e2d9744ae1
major update of the nominal package; there is now an infrastructure
urbanc
parents:
22231
diff
changeset
|
392 |
"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
|
393 |
|
23760 | 394 |
inductive |
22418
49e2d9744ae1
major update of the nominal package; there is now an infrastructure
urbanc
parents:
22231
diff
changeset
|
395 |
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
|
396 |
where |
49e2d9744ae1
major update of the nominal package; there is now an infrastructure
urbanc
parents:
22231
diff
changeset
|
397 |
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
|
398 |
| 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
|
399 |
|
22494 | 400 |
declare trm.inject[simp] |
22418
49e2d9744ae1
major update of the nominal package; there is now an infrastructure
urbanc
parents:
22231
diff
changeset
|
401 |
|
23760 | 402 |
inductive_cases whn_inv_auto[elim]: "t \<Down> t'" |
22494 | 403 |
|
404 |
declare trm.inject[simp del] |
|
22418
49e2d9744ae1
major update of the nominal package; there is now an infrastructure
urbanc
parents:
22231
diff
changeset
|
405 |
|
32638 | 406 |
equivariance whn_def |
22418
49e2d9744ae1
major update of the nominal package; there is now an infrastructure
urbanc
parents:
22231
diff
changeset
|
407 |
|
22494 | 408 |
lemma red_unicity : |
409 |
assumes a: "x \<leadsto> a" |
|
410 |
and b: "x \<leadsto> b" |
|
411 |
shows "a=b" |
|
412 |
using a b |
|
80149 | 413 |
by (induct arbitrary: b) (use subst_fun_eq in blast)+ |
22418
49e2d9744ae1
major update of the nominal package; there is now an infrastructure
urbanc
parents:
22231
diff
changeset
|
414 |
|
22494 | 415 |
lemma nf_unicity : |
416 |
assumes "x \<Down> a" and "x \<Down> b" |
|
417 |
shows "a=b" |
|
418 |
using assms |
|
419 |
proof (induct arbitrary: b) |
|
420 |
case (QAN_Reduce x t a b) |
|
25107 | 421 |
have h:"x \<leadsto> t" "t \<Down> a" by fact+ |
22494 | 422 |
have ih:"\<And>b. t \<Down> b \<Longrightarrow> a = b" by fact |
80149 | 423 |
obtain t' where "x \<leadsto> t'" and hl:"t' \<Down> b" using h \<open>x \<Down> b\<close> by auto |
22494 | 424 |
then have "t=t'" using h red_unicity by auto |
425 |
then show "a=b" using ih hl by auto |
|
426 |
qed (auto) |
|
427 |
||
24070 | 428 |
|
63167 | 429 |
section \<open>Algorithmic Term Equivalence and Algorithmic Path Equivalence\<close> |
22494 | 430 |
|
23760 | 431 |
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
|
432 |
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
|
433 |
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
|
434 |
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
|
435 |
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
|
436 |
QAT_Base[intro]: "\<lbrakk>s \<Down> p; t \<Down> q; \<Gamma> \<turnstile> p \<leftrightarrow> q : TBase\<rbrakk> \<Longrightarrow> \<Gamma> \<turnstile> s \<Leftrightarrow> t : TBase" |
53015
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
49171
diff
changeset
|
437 |
| QAT_Arrow[intro]: "\<lbrakk>x\<sharp>(\<Gamma>,s,t); (x,T\<^sub>1)#\<Gamma> \<turnstile> App s (Var x) \<Leftrightarrow> App t (Var x) : T\<^sub>2\<rbrakk> |
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
49171
diff
changeset
|
438 |
\<Longrightarrow> \<Gamma> \<turnstile> s \<Leftrightarrow> t : T\<^sub>1 \<rightarrow> T\<^sub>2" |
22418
49e2d9744ae1
major update of the nominal package; there is now an infrastructure
urbanc
parents:
22231
diff
changeset
|
439 |
| 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
|
440 |
| QAP_Var[intro]: "\<lbrakk>valid \<Gamma>;(x,T) \<in> set \<Gamma>\<rbrakk> \<Longrightarrow> \<Gamma> \<turnstile> Var x \<leftrightarrow> Var x : T" |
53015
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
49171
diff
changeset
|
441 |
| QAP_App[intro]: "\<lbrakk>\<Gamma> \<turnstile> p \<leftrightarrow> q : T\<^sub>1 \<rightarrow> T\<^sub>2; \<Gamma> \<turnstile> s \<Leftrightarrow> t : T\<^sub>1\<rbrakk> \<Longrightarrow> \<Gamma> \<turnstile> App p s \<leftrightarrow> App q t : T\<^sub>2" |
22418
49e2d9744ae1
major update of the nominal package; there is now an infrastructure
urbanc
parents:
22231
diff
changeset
|
442 |
| 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
|
443 |
|
22730
8bcc8809ed3b
nominal_inductive no longer proves equivariance.
berghofe
parents:
22650
diff
changeset
|
444 |
equivariance alg_equiv |
8bcc8809ed3b
nominal_inductive no longer proves equivariance.
berghofe
parents:
22650
diff
changeset
|
445 |
|
22531 | 446 |
nominal_inductive alg_equiv |
447 |
avoids QAT_Arrow: x |
|
448 |
by simp_all |
|
22418
49e2d9744ae1
major update of the nominal package; there is now an infrastructure
urbanc
parents:
22231
diff
changeset
|
449 |
|
22494 | 450 |
declare trm.inject [simp add] |
22418
49e2d9744ae1
major update of the nominal package; there is now an infrastructure
urbanc
parents:
22231
diff
changeset
|
451 |
declare ty.inject [simp add] |
49e2d9744ae1
major update of the nominal package; there is now an infrastructure
urbanc
parents:
22231
diff
changeset
|
452 |
|
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
|
453 |
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
|
454 |
"\<Gamma> \<turnstile> s\<Leftrightarrow>t : TBase" |
53015
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
49171
diff
changeset
|
455 |
"\<Gamma> \<turnstile> s\<Leftrightarrow>t : T\<^sub>1 \<rightarrow> T\<^sub>2" |
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
|
456 |
"\<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
|
457 |
"\<Gamma> \<turnstile> s\<leftrightarrow>t : TUnit" |
53015
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
49171
diff
changeset
|
458 |
"\<Gamma> \<turnstile> s\<leftrightarrow>t : T\<^sub>1 \<rightarrow> T\<^sub>2" |
22418
49e2d9744ae1
major update of the nominal package; there is now an infrastructure
urbanc
parents:
22231
diff
changeset
|
459 |
|
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
|
460 |
"\<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
|
461 |
"\<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
|
462 |
"\<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
|
463 |
"\<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
|
464 |
"\<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
|
465 |
"\<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
|
466 |
"\<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
|
467 |
"\<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
|
468 |
"\<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
|
469 |
"\<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
|
470 |
|
49e2d9744ae1
major update of the nominal package; there is now an infrastructure
urbanc
parents:
22231
diff
changeset
|
471 |
declare trm.inject [simp del] |
49e2d9744ae1
major update of the nominal package; there is now an infrastructure
urbanc
parents:
22231
diff
changeset
|
472 |
declare ty.inject [simp del] |
49e2d9744ae1
major update of the nominal package; there is now an infrastructure
urbanc
parents:
22231
diff
changeset
|
473 |
|
22073 | 474 |
lemma Q_Arrow_strong_inversion: |
22494 | 475 |
assumes fs: "x\<sharp>\<Gamma>" "x\<sharp>t" "x\<sharp>u" |
53015
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
49171
diff
changeset
|
476 |
and h: "\<Gamma> \<turnstile> t \<Leftrightarrow> u : T\<^sub>1\<rightarrow>T\<^sub>2" |
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
49171
diff
changeset
|
477 |
shows "(x,T\<^sub>1)#\<Gamma> \<turnstile> App t (Var x) \<Leftrightarrow> App u (Var x) : T\<^sub>2" |
22073 | 478 |
proof - |
53015
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
49171
diff
changeset
|
479 |
obtain y where fs2: "y\<sharp>(\<Gamma>,t,u)" and "(y,T\<^sub>1)#\<Gamma> \<turnstile> App t (Var y) \<Leftrightarrow> App u (Var y) : T\<^sub>2" |
22082 | 480 |
using h by auto |
53015
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
49171
diff
changeset
|
481 |
then have "([(x,y)]\<bullet>((y,T\<^sub>1)#\<Gamma>)) \<turnstile> [(x,y)]\<bullet> App t (Var y) \<Leftrightarrow> [(x,y)]\<bullet> App u (Var y) : T\<^sub>2" |
22542 | 482 |
using alg_equiv.eqvt[simplified] by blast |
22082 | 483 |
then show ?thesis using fs fs2 by (perm_simp) |
22073 | 484 |
qed |
485 |
||
22418
49e2d9744ae1
major update of the nominal package; there is now an infrastructure
urbanc
parents:
22231
diff
changeset
|
486 |
(* |
22594
33a690455f88
add a few details in the Fst and Snd cases of unicity proof
narboux
parents:
22542
diff
changeset
|
487 |
Warning this lemma is false: |
33a690455f88
add a few details in the Fst and Snd cases of unicity proof
narboux
parents:
22542
diff
changeset
|
488 |
|
22073 | 489 |
lemma algorithmic_type_unicity: |
22418
49e2d9744ae1
major update of the nominal package; there is now an infrastructure
urbanc
parents:
22231
diff
changeset
|
490 |
shows "\<lbrakk> \<Gamma> \<turnstile> s \<Leftrightarrow> t : T ; \<Gamma> \<turnstile> s \<Leftrightarrow> u : T' \<rbrakk> \<Longrightarrow> T = T'" |
22073 | 491 |
and "\<lbrakk> \<Gamma> \<turnstile> s \<leftrightarrow> t : T ; \<Gamma> \<turnstile> s \<leftrightarrow> u : T' \<rbrakk> \<Longrightarrow> T = T'" |
492 |
||
493 |
Here is the counter example : |
|
22418
49e2d9744ae1
major update of the nominal package; there is now an infrastructure
urbanc
parents:
22231
diff
changeset
|
494 |
\<Gamma> \<turnstile> Const n \<Leftrightarrow> Const n : Tbase and \<Gamma> \<turnstile> Const n \<Leftrightarrow> Const n : TUnit |
22073 | 495 |
*) |
496 |
||
497 |
lemma algorithmic_path_type_unicity: |
|
22494 | 498 |
shows "\<Gamma> \<turnstile> s \<leftrightarrow> t : T \<Longrightarrow> \<Gamma> \<turnstile> s \<leftrightarrow> u : T' \<Longrightarrow> T = T'" |
22082 | 499 |
proof (induct arbitrary: u T' |
500 |
rule: alg_equiv_alg_path_equiv.inducts(2) [of _ _ _ _ _ "%a b c d . True" ]) |
|
22073 | 501 |
case (QAP_Var \<Gamma> x T u T') |
502 |
have "\<Gamma> \<turnstile> Var x \<leftrightarrow> u : T'" by fact |
|
503 |
then have "u=Var x" and "(x,T') \<in> set \<Gamma>" by auto |
|
25107 | 504 |
moreover have "valid \<Gamma>" "(x,T) \<in> set \<Gamma>" by fact+ |
22073 | 505 |
ultimately show "T=T'" using type_unicity_in_context by auto |
506 |
next |
|
53015
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
49171
diff
changeset
|
507 |
case (QAP_App \<Gamma> p q T\<^sub>1 T\<^sub>2 s t u T\<^sub>2') |
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
49171
diff
changeset
|
508 |
have ih:"\<And>u T. \<Gamma> \<turnstile> p \<leftrightarrow> u : T \<Longrightarrow> T\<^sub>1\<rightarrow>T\<^sub>2 = T" by fact |
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
49171
diff
changeset
|
509 |
have "\<Gamma> \<turnstile> App p s \<leftrightarrow> u : T\<^sub>2'" by fact |
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
49171
diff
changeset
|
510 |
then obtain r t T\<^sub>1' where "u = App r t" "\<Gamma> \<turnstile> p \<leftrightarrow> r : T\<^sub>1' \<rightarrow> T\<^sub>2'" by auto |
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
49171
diff
changeset
|
511 |
with ih have "T\<^sub>1\<rightarrow>T\<^sub>2 = T\<^sub>1' \<rightarrow> T\<^sub>2'" by auto |
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
49171
diff
changeset
|
512 |
then show "T\<^sub>2=T\<^sub>2'" using ty.inject by auto |
22073 | 513 |
qed (auto) |
514 |
||
22494 | 515 |
lemma alg_path_equiv_implies_valid: |
516 |
shows "\<Gamma> \<turnstile> s \<Leftrightarrow> t : T \<Longrightarrow> valid \<Gamma>" |
|
517 |
and "\<Gamma> \<turnstile> s \<leftrightarrow> t : T \<Longrightarrow> valid \<Gamma>" |
|
49171 | 518 |
by (induct rule : alg_equiv_alg_path_equiv.inducts) auto |
22494 | 519 |
|
520 |
lemma algorithmic_symmetry: |
|
521 |
shows "\<Gamma> \<turnstile> s \<Leftrightarrow> t : T \<Longrightarrow> \<Gamma> \<turnstile> t \<Leftrightarrow> s : T" |
|
522 |
and "\<Gamma> \<turnstile> s \<leftrightarrow> t : T \<Longrightarrow> \<Gamma> \<turnstile> t \<leftrightarrow> s : T" |
|
523 |
by (induct rule: alg_equiv_alg_path_equiv.inducts) |
|
80149 | 524 |
(auto simp: fresh_prod) |
22494 | 525 |
|
22073 | 526 |
lemma algorithmic_transitivity: |
22494 | 527 |
shows "\<Gamma> \<turnstile> s \<Leftrightarrow> t : T \<Longrightarrow> \<Gamma> \<turnstile> t \<Leftrightarrow> u : T \<Longrightarrow> \<Gamma> \<turnstile> s \<Leftrightarrow> u : T" |
528 |
and "\<Gamma> \<turnstile> s \<leftrightarrow> t : T \<Longrightarrow> \<Gamma> \<turnstile> t \<leftrightarrow> u : T \<Longrightarrow> \<Gamma> \<turnstile> s \<leftrightarrow> u : T" |
|
22531 | 529 |
proof (nominal_induct \<Gamma> s t T and \<Gamma> s t T avoiding: u rule: alg_equiv_alg_path_equiv.strong_inducts) |
22073 | 530 |
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
|
531 |
have "\<Gamma> \<turnstile> t \<Leftrightarrow> u : TBase" by fact |
22494 | 532 |
then obtain r' q' where b1: "t \<Down> q'" and b2: "u \<Down> r'" and b3: "\<Gamma> \<turnstile> q' \<leftrightarrow> r' : TBase" by auto |
533 |
have ih: "\<Gamma> \<turnstile> q \<leftrightarrow> r' : TBase \<Longrightarrow> \<Gamma> \<turnstile> p \<leftrightarrow> r' : TBase" by fact |
|
534 |
have "t \<Down> q" by fact |
|
535 |
with b1 have eq: "q=q'" by (simp add: nf_unicity) |
|
536 |
with ih b3 have "\<Gamma> \<turnstile> p \<leftrightarrow> r' : TBase" by simp |
|
537 |
moreover |
|
538 |
have "s \<Down> p" by fact |
|
539 |
ultimately show "\<Gamma> \<turnstile> s \<Leftrightarrow> u : TBase" using b2 by auto |
|
22073 | 540 |
next |
53015
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
49171
diff
changeset
|
541 |
case (QAT_Arrow x \<Gamma> s t T\<^sub>1 T\<^sub>2 u) |
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
49171
diff
changeset
|
542 |
have ih:"(x,T\<^sub>1)#\<Gamma> \<turnstile> App t (Var x) \<Leftrightarrow> App u (Var x) : T\<^sub>2 |
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
49171
diff
changeset
|
543 |
\<Longrightarrow> (x,T\<^sub>1)#\<Gamma> \<turnstile> App s (Var x) \<Leftrightarrow> App u (Var x) : T\<^sub>2" by fact |
25107 | 544 |
have fs: "x\<sharp>\<Gamma>" "x\<sharp>s" "x\<sharp>t" "x\<sharp>u" by fact+ |
53015
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
49171
diff
changeset
|
545 |
have "\<Gamma> \<turnstile> t \<Leftrightarrow> u : T\<^sub>1\<rightarrow>T\<^sub>2" by fact |
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
49171
diff
changeset
|
546 |
then have "(x,T\<^sub>1)#\<Gamma> \<turnstile> App t (Var x) \<Leftrightarrow> App u (Var x) : T\<^sub>2" using fs |
22494 | 547 |
by (simp add: Q_Arrow_strong_inversion) |
53015
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
49171
diff
changeset
|
548 |
with ih have "(x,T\<^sub>1)#\<Gamma> \<turnstile> App s (Var x) \<Leftrightarrow> App u (Var x) : T\<^sub>2" by simp |
80149 | 549 |
then show "\<Gamma> \<turnstile> s \<Leftrightarrow> u : T\<^sub>1\<rightarrow>T\<^sub>2" using fs by (auto simp: fresh_prod) |
22073 | 550 |
next |
53015
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
49171
diff
changeset
|
551 |
case (QAP_App \<Gamma> p q T\<^sub>1 T\<^sub>2 s t u) |
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
49171
diff
changeset
|
552 |
have "\<Gamma> \<turnstile> App q t \<leftrightarrow> u : T\<^sub>2" by fact |
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
49171
diff
changeset
|
553 |
then obtain r T\<^sub>1' v where ha: "\<Gamma> \<turnstile> q \<leftrightarrow> r : T\<^sub>1'\<rightarrow>T\<^sub>2" and hb: "\<Gamma> \<turnstile> t \<Leftrightarrow> v : T\<^sub>1'" and eq: "u = App r v" |
22082 | 554 |
by auto |
53015
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
49171
diff
changeset
|
555 |
have ih1: "\<Gamma> \<turnstile> q \<leftrightarrow> r : T\<^sub>1\<rightarrow>T\<^sub>2 \<Longrightarrow> \<Gamma> \<turnstile> p \<leftrightarrow> r : T\<^sub>1\<rightarrow>T\<^sub>2" by fact |
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
49171
diff
changeset
|
556 |
have ih2:"\<Gamma> \<turnstile> t \<Leftrightarrow> v : T\<^sub>1 \<Longrightarrow> \<Gamma> \<turnstile> s \<Leftrightarrow> v : T\<^sub>1" by fact |
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
49171
diff
changeset
|
557 |
have "\<Gamma> \<turnstile> p \<leftrightarrow> q : T\<^sub>1\<rightarrow>T\<^sub>2" by fact |
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
49171
diff
changeset
|
558 |
then have "\<Gamma> \<turnstile> q \<leftrightarrow> p : T\<^sub>1\<rightarrow>T\<^sub>2" by (simp add: algorithmic_symmetry) |
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
49171
diff
changeset
|
559 |
with ha have "T\<^sub>1'\<rightarrow>T\<^sub>2 = T\<^sub>1\<rightarrow>T\<^sub>2" using algorithmic_path_type_unicity by simp |
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
49171
diff
changeset
|
560 |
then have "T\<^sub>1' = T\<^sub>1" by (simp add: ty.inject) |
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
49171
diff
changeset
|
561 |
then have "\<Gamma> \<turnstile> s \<Leftrightarrow> v : T\<^sub>1" "\<Gamma> \<turnstile> p \<leftrightarrow> r : T\<^sub>1\<rightarrow>T\<^sub>2" using ih1 ih2 ha hb by auto |
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
49171
diff
changeset
|
562 |
then show "\<Gamma> \<turnstile> App p s \<leftrightarrow> u : T\<^sub>2" using eq by auto |
22073 | 563 |
qed (auto) |
564 |
||
565 |
lemma algorithmic_weak_head_closure: |
|
22494 | 566 |
shows "\<Gamma> \<turnstile> s \<Leftrightarrow> t : T \<Longrightarrow> s' \<leadsto> s \<Longrightarrow> t' \<leadsto> t \<Longrightarrow> \<Gamma> \<turnstile> s' \<Leftrightarrow> t' : T" |
80149 | 567 |
proof (nominal_induct \<Gamma> s t T avoiding: s' t' |
568 |
rule: alg_equiv_alg_path_equiv.strong_inducts(1) [of _ _ _ _ "\<lambda>a b c d e. True"]) |
|
569 |
qed(auto intro!: QAT_Arrow) |
|
22494 | 570 |
|
571 |
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
|
572 |
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
|
573 |
and "\<Gamma> \<turnstile> s \<leftrightarrow> t : T \<Longrightarrow> \<Gamma> \<subseteq> \<Gamma>' \<Longrightarrow> valid \<Gamma>' \<Longrightarrow> \<Gamma>' \<turnstile> s \<leftrightarrow> t : T" |
22531 | 574 |
proof (nominal_induct \<Gamma> s t T and \<Gamma> s t T avoiding: \<Gamma>' rule: alg_equiv_alg_path_equiv.strong_inducts) |
53015
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
49171
diff
changeset
|
575 |
case (QAT_Arrow x \<Gamma> s t T\<^sub>1 T\<^sub>2 \<Gamma>') |
25107 | 576 |
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
|
577 |
have h2:"\<Gamma> \<subseteq> \<Gamma>'" by fact |
53015
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
49171
diff
changeset
|
578 |
have ih:"\<And>\<Gamma>'. \<lbrakk>(x,T\<^sub>1)#\<Gamma> \<subseteq> \<Gamma>'; valid \<Gamma>'\<rbrakk> \<Longrightarrow> \<Gamma>' \<turnstile> App s (Var x) \<Leftrightarrow> App t (Var x) : T\<^sub>2" by fact |
22494 | 579 |
have "valid \<Gamma>'" by fact |
53015
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
49171
diff
changeset
|
580 |
then have "valid ((x,T\<^sub>1)#\<Gamma>')" using fs by auto |
22494 | 581 |
moreover |
53015
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
49171
diff
changeset
|
582 |
have sub: "(x,T\<^sub>1)#\<Gamma> \<subseteq> (x,T\<^sub>1)#\<Gamma>'" using h2 by auto |
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
49171
diff
changeset
|
583 |
ultimately have "(x,T\<^sub>1)#\<Gamma>' \<turnstile> App s (Var x) \<Leftrightarrow> App t (Var x) : T\<^sub>2" using ih by simp |
80149 | 584 |
then show "\<Gamma>' \<turnstile> s \<Leftrightarrow> t : T\<^sub>1\<rightarrow>T\<^sub>2" using fs by (auto simp: fresh_prod) |
22494 | 585 |
qed (auto) |
586 |
||
587 |
lemma path_equiv_implies_nf: |
|
588 |
assumes "\<Gamma> \<turnstile> s \<leftrightarrow> t : T" |
|
589 |
shows "s \<leadsto>|" and "t \<leadsto>|" |
|
590 |
using assms |
|
591 |
by (induct rule: alg_equiv_alg_path_equiv.inducts(2)) (simp, auto) |
|
592 |
||
63167 | 593 |
section \<open>Logical Equivalence\<close> |
22494 | 594 |
|
595 |
function log_equiv :: "(Ctxt \<Rightarrow> trm \<Rightarrow> trm \<Rightarrow> ty \<Rightarrow> bool)" ("_ \<turnstile> _ is _ : _" [60,60,60,60] 60) |
|
596 |
where |
|
597 |
"\<Gamma> \<turnstile> s is t : TUnit = True" |
|
598 |
| "\<Gamma> \<turnstile> s is t : TBase = \<Gamma> \<turnstile> s \<Leftrightarrow> t : TBase" |
|
53015
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
49171
diff
changeset
|
599 |
| "\<Gamma> \<turnstile> s is t : (T\<^sub>1 \<rightarrow> T\<^sub>2) = |
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
49171
diff
changeset
|
600 |
(\<forall>\<Gamma>' s' t'. \<Gamma>\<subseteq>\<Gamma>' \<longrightarrow> valid \<Gamma>' \<longrightarrow> \<Gamma>' \<turnstile> s' is t' : T\<^sub>1 \<longrightarrow> (\<Gamma>' \<turnstile> (App s s') is (App t t') : T\<^sub>2))" |
80149 | 601 |
using ty_cases by (force simp: ty.inject)+ |
32638 | 602 |
|
28042 | 603 |
termination by lexicographic_order |
22494 | 604 |
|
24231
85fb973a8207
added type constraints to resolve syntax ambiguities;
wenzelm
parents:
24088
diff
changeset
|
605 |
lemma logical_monotonicity: |
85fb973a8207
added type constraints to resolve syntax ambiguities;
wenzelm
parents:
24088
diff
changeset
|
606 |
fixes \<Gamma> \<Gamma>' :: Ctxt |
22494 | 607 |
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
|
608 |
and a2: "\<Gamma> \<subseteq> \<Gamma>'" |
22494 | 609 |
and a3: "valid \<Gamma>'" |
610 |
shows "\<Gamma>' \<turnstile> s is t : T" |
|
611 |
using a1 a2 a3 |
|
612 |
proof (induct arbitrary: \<Gamma>' rule: log_equiv.induct) |
|
613 |
case (2 \<Gamma> s t \<Gamma>') |
|
614 |
then show "\<Gamma>' \<turnstile> s is t : TBase" using algorithmic_monotonicity by auto |
|
615 |
next |
|
53015
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
49171
diff
changeset
|
616 |
case (3 \<Gamma> s t T\<^sub>1 T\<^sub>2 \<Gamma>') |
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
49171
diff
changeset
|
617 |
have "\<Gamma> \<turnstile> s is t : T\<^sub>1\<rightarrow>T\<^sub>2" |
24070 | 618 |
and "\<Gamma> \<subseteq> \<Gamma>'" |
25107 | 619 |
and "valid \<Gamma>'" by fact+ |
53015
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
49171
diff
changeset
|
620 |
then show "\<Gamma>' \<turnstile> s is t : T\<^sub>1\<rightarrow>T\<^sub>2" by simp |
22494 | 621 |
qed (auto) |
622 |
||
623 |
lemma main_lemma: |
|
624 |
shows "\<Gamma> \<turnstile> s is t : T \<Longrightarrow> valid \<Gamma> \<Longrightarrow> \<Gamma> \<turnstile> s \<Leftrightarrow> t : T" |
|
625 |
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
|
626 |
proof (nominal_induct T arbitrary: \<Gamma> s t p q rule: ty.strong_induct) |
53015
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
49171
diff
changeset
|
627 |
case (Arrow T\<^sub>1 T\<^sub>2) |
22494 | 628 |
{ |
629 |
case (1 \<Gamma> s t) |
|
53015
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
49171
diff
changeset
|
630 |
have ih1:"\<And>\<Gamma> s t. \<lbrakk>\<Gamma> \<turnstile> s is t : T\<^sub>2; valid \<Gamma>\<rbrakk> \<Longrightarrow> \<Gamma> \<turnstile> s \<Leftrightarrow> t : T\<^sub>2" by fact |
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
49171
diff
changeset
|
631 |
have ih2:"\<And>\<Gamma> s t. \<Gamma> \<turnstile> s \<leftrightarrow> t : T\<^sub>1 \<Longrightarrow> \<Gamma> \<turnstile> s is t : T\<^sub>1" by fact |
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
49171
diff
changeset
|
632 |
have h:"\<Gamma> \<turnstile> s is t : T\<^sub>1\<rightarrow>T\<^sub>2" by fact |
22494 | 633 |
obtain x::name where fs:"x\<sharp>(\<Gamma>,s,t)" by (erule exists_fresh[OF fs_name1]) |
634 |
have "valid \<Gamma>" by fact |
|
53015
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
49171
diff
changeset
|
635 |
then have v: "valid ((x,T\<^sub>1)#\<Gamma>)" using fs by auto |
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
49171
diff
changeset
|
636 |
then have "(x,T\<^sub>1)#\<Gamma> \<turnstile> Var x \<leftrightarrow> Var x : T\<^sub>1" by auto |
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
49171
diff
changeset
|
637 |
then have "(x,T\<^sub>1)#\<Gamma> \<turnstile> Var x is Var x : T\<^sub>1" using ih2 by auto |
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
49171
diff
changeset
|
638 |
then have "(x,T\<^sub>1)#\<Gamma> \<turnstile> App s (Var x) is App t (Var x) : T\<^sub>2" using h v by auto |
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
49171
diff
changeset
|
639 |
then have "(x,T\<^sub>1)#\<Gamma> \<turnstile> App s (Var x) \<Leftrightarrow> App t (Var x) : T\<^sub>2" using ih1 v by auto |
80149 | 640 |
then show "\<Gamma> \<turnstile> s \<Leftrightarrow> t : T\<^sub>1\<rightarrow>T\<^sub>2" using fs by (auto simp: fresh_prod) |
22494 | 641 |
next |
642 |
case (2 \<Gamma> p q) |
|
53015
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
49171
diff
changeset
|
643 |
have h: "\<Gamma> \<turnstile> p \<leftrightarrow> q : T\<^sub>1\<rightarrow>T\<^sub>2" by fact |
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
49171
diff
changeset
|
644 |
have ih1:"\<And>\<Gamma> s t. \<Gamma> \<turnstile> s \<leftrightarrow> t : T\<^sub>2 \<Longrightarrow> \<Gamma> \<turnstile> s is t : T\<^sub>2" by fact |
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
49171
diff
changeset
|
645 |
have ih2:"\<And>\<Gamma> s t. \<lbrakk>\<Gamma> \<turnstile> s is t : T\<^sub>1; valid \<Gamma>\<rbrakk> \<Longrightarrow> \<Gamma> \<turnstile> s \<Leftrightarrow> t : T\<^sub>1" by fact |
22494 | 646 |
{ |
647 |
fix \<Gamma>' s t |
|
53015
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
49171
diff
changeset
|
648 |
assume "\<Gamma> \<subseteq> \<Gamma>'" and hl:"\<Gamma>' \<turnstile> s is t : T\<^sub>1" and hk: "valid \<Gamma>'" |
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
49171
diff
changeset
|
649 |
then have "\<Gamma>' \<turnstile> p \<leftrightarrow> q : T\<^sub>1 \<rightarrow> T\<^sub>2" using h algorithmic_monotonicity by auto |
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
49171
diff
changeset
|
650 |
moreover have "\<Gamma>' \<turnstile> s \<Leftrightarrow> t : T\<^sub>1" using ih2 hl hk by auto |
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
49171
diff
changeset
|
651 |
ultimately have "\<Gamma>' \<turnstile> App p s \<leftrightarrow> App q t : T\<^sub>2" by auto |
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
49171
diff
changeset
|
652 |
then have "\<Gamma>' \<turnstile> App p s is App q t : T\<^sub>2" using ih1 by auto |
22494 | 653 |
} |
53015
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
49171
diff
changeset
|
654 |
then show "\<Gamma> \<turnstile> p is q : T\<^sub>1\<rightarrow>T\<^sub>2" by simp |
22494 | 655 |
} |
656 |
next |
|
657 |
case TBase |
|
658 |
{ case 2 |
|
659 |
have h:"\<Gamma> \<turnstile> s \<leftrightarrow> t : TBase" by fact |
|
660 |
then have "s \<leadsto>|" and "t \<leadsto>|" using path_equiv_implies_nf by auto |
|
661 |
then have "s \<Down> s" and "t \<Down> t" by auto |
|
662 |
then have "\<Gamma> \<turnstile> s \<Leftrightarrow> t : TBase" using h by auto |
|
663 |
then show "\<Gamma> \<turnstile> s is t : TBase" by auto |
|
664 |
} |
|
665 |
qed (auto elim: alg_path_equiv_implies_valid) |
|
666 |
||
667 |
corollary corollary_main: |
|
668 |
assumes a: "\<Gamma> \<turnstile> s \<leftrightarrow> t : T" |
|
669 |
shows "\<Gamma> \<turnstile> s \<Leftrightarrow> t : T" |
|
670 |
using a main_lemma alg_path_equiv_implies_valid by blast |
|
22073 | 671 |
|
672 |
lemma logical_symmetry: |
|
22082 | 673 |
assumes a: "\<Gamma> \<turnstile> s is t : T" |
22073 | 674 |
shows "\<Gamma> \<turnstile> t is s : T" |
22082 | 675 |
using a |
26966
071f40487734
made the naming of the induction principles consistent: weak_induct is
urbanc
parents:
26677
diff
changeset
|
676 |
by (nominal_induct arbitrary: \<Gamma> s t rule: ty.strong_induct) |
80149 | 677 |
(auto simp: algorithmic_symmetry) |
22073 | 678 |
|
679 |
lemma logical_transitivity: |
|
680 |
assumes "\<Gamma> \<turnstile> s is t : T" "\<Gamma> \<turnstile> t is u : T" |
|
681 |
shows "\<Gamma> \<turnstile> s is u : T" |
|
682 |
using assms |
|
26966
071f40487734
made the naming of the induction principles consistent: weak_induct is
urbanc
parents:
26677
diff
changeset
|
683 |
proof (nominal_induct arbitrary: \<Gamma> s t u rule:ty.strong_induct) |
22073 | 684 |
case TBase |
685 |
then show "\<Gamma> \<turnstile> s is u : TBase" by (auto elim: algorithmic_transitivity) |
|
686 |
next |
|
53015
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
49171
diff
changeset
|
687 |
case (Arrow T\<^sub>1 T\<^sub>2 \<Gamma> s t u) |
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
49171
diff
changeset
|
688 |
have h1:"\<Gamma> \<turnstile> s is t : T\<^sub>1 \<rightarrow> T\<^sub>2" by fact |
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
49171
diff
changeset
|
689 |
have h2:"\<Gamma> \<turnstile> t is u : T\<^sub>1 \<rightarrow> T\<^sub>2" by fact |
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
49171
diff
changeset
|
690 |
have ih1:"\<And>\<Gamma> s t u. \<lbrakk>\<Gamma> \<turnstile> s is t : T\<^sub>1; \<Gamma> \<turnstile> t is u : T\<^sub>1\<rbrakk> \<Longrightarrow> \<Gamma> \<turnstile> s is u : T\<^sub>1" by fact |
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
49171
diff
changeset
|
691 |
have ih2:"\<And>\<Gamma> s t u. \<lbrakk>\<Gamma> \<turnstile> s is t : T\<^sub>2; \<Gamma> \<turnstile> t is u : T\<^sub>2\<rbrakk> \<Longrightarrow> \<Gamma> \<turnstile> s is u : T\<^sub>2" by fact |
22073 | 692 |
{ |
693 |
fix \<Gamma>' s' u' |
|
53015
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
49171
diff
changeset
|
694 |
assume hsub:"\<Gamma> \<subseteq> \<Gamma>'" and hl:"\<Gamma>' \<turnstile> s' is u' : T\<^sub>1" and hk: "valid \<Gamma>'" |
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
49171
diff
changeset
|
695 |
then have "\<Gamma>' \<turnstile> u' is s' : T\<^sub>1" using logical_symmetry by blast |
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
49171
diff
changeset
|
696 |
then have "\<Gamma>' \<turnstile> u' is u' : T\<^sub>1" using ih1 hl by blast |
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
49171
diff
changeset
|
697 |
then have "\<Gamma>' \<turnstile> App t u' is App u u' : T\<^sub>2" using h2 hsub hk by auto |
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
49171
diff
changeset
|
698 |
moreover have "\<Gamma>' \<turnstile> App s s' is App t u' : T\<^sub>2" using h1 hsub hl hk by auto |
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
49171
diff
changeset
|
699 |
ultimately have "\<Gamma>' \<turnstile> App s s' is App u u' : T\<^sub>2" using ih2 by blast |
22073 | 700 |
} |
53015
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
49171
diff
changeset
|
701 |
then show "\<Gamma> \<turnstile> s is u : T\<^sub>1 \<rightarrow> T\<^sub>2" by auto |
22073 | 702 |
qed (auto) |
703 |
||
704 |
lemma logical_weak_head_closure: |
|
22494 | 705 |
assumes a: "\<Gamma> \<turnstile> s is t : T" |
706 |
and b: "s' \<leadsto> s" |
|
707 |
and c: "t' \<leadsto> t" |
|
22073 | 708 |
shows "\<Gamma> \<turnstile> s' is t' : T" |
22494 | 709 |
using a b c algorithmic_weak_head_closure |
80149 | 710 |
proof (nominal_induct arbitrary: \<Gamma> s t s' t' rule: ty.strong_induct) |
711 |
next |
|
712 |
case (Arrow ty1 ty2) |
|
713 |
then show ?case |
|
714 |
by (smt (verit, ccfv_threshold) QAR_App log_equiv.simps(3)) |
|
715 |
qed auto |
|
716 |
||
22073 | 717 |
|
718 |
lemma logical_weak_head_closure': |
|
22494 | 719 |
assumes "\<Gamma> \<turnstile> s is t : T" and "s' \<leadsto> s" |
22073 | 720 |
shows "\<Gamma> \<turnstile> s' is t : T" |
721 |
using assms |
|
26966
071f40487734
made the naming of the induction principles consistent: weak_induct is
urbanc
parents:
26677
diff
changeset
|
722 |
proof (nominal_induct arbitrary: \<Gamma> s t s' rule: ty.strong_induct) |
22073 | 723 |
case (TBase \<Gamma> s t s') |
724 |
then show ?case by force |
|
725 |
next |
|
726 |
case (TUnit \<Gamma> s t s') |
|
727 |
then show ?case by auto |
|
22418
49e2d9744ae1
major update of the nominal package; there is now an infrastructure
urbanc
parents:
22231
diff
changeset
|
728 |
next |
53015
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
49171
diff
changeset
|
729 |
case (Arrow T\<^sub>1 T\<^sub>2 \<Gamma> s t s') |
22073 | 730 |
have h1:"s' \<leadsto> s" by fact |
53015
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
49171
diff
changeset
|
731 |
have ih:"\<And>\<Gamma> s t s'. \<lbrakk>\<Gamma> \<turnstile> s is t : T\<^sub>2; s' \<leadsto> s\<rbrakk> \<Longrightarrow> \<Gamma> \<turnstile> s' is t : T\<^sub>2" by fact |
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
49171
diff
changeset
|
732 |
have h2:"\<Gamma> \<turnstile> s is t : T\<^sub>1\<rightarrow>T\<^sub>2" by fact |
22494 | 733 |
then |
53015
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
49171
diff
changeset
|
734 |
have hb:"\<forall>\<Gamma>' s' t'. \<Gamma>\<subseteq>\<Gamma>' \<longrightarrow> valid \<Gamma>' \<longrightarrow> \<Gamma>' \<turnstile> s' is t' : T\<^sub>1 \<longrightarrow> (\<Gamma>' \<turnstile> (App s s') is (App t t') : T\<^sub>2)" |
22494 | 735 |
by auto |
22073 | 736 |
{ |
53015
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
49171
diff
changeset
|
737 |
fix \<Gamma>' s\<^sub>2 t\<^sub>2 |
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
49171
diff
changeset
|
738 |
assume "\<Gamma> \<subseteq> \<Gamma>'" and "\<Gamma>' \<turnstile> s\<^sub>2 is t\<^sub>2 : T\<^sub>1" and "valid \<Gamma>'" |
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
49171
diff
changeset
|
739 |
then have "\<Gamma>' \<turnstile> (App s s\<^sub>2) is (App t t\<^sub>2) : T\<^sub>2" using hb by auto |
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
49171
diff
changeset
|
740 |
moreover have "(App s' s\<^sub>2) \<leadsto> (App s s\<^sub>2)" using h1 by auto |
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
49171
diff
changeset
|
741 |
ultimately have "\<Gamma>' \<turnstile> App s' s\<^sub>2 is App t t\<^sub>2 : T\<^sub>2" using ih by auto |
22073 | 742 |
} |
53015
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
49171
diff
changeset
|
743 |
then show "\<Gamma> \<turnstile> s' is t : T\<^sub>1\<rightarrow>T\<^sub>2" by auto |
22418
49e2d9744ae1
major update of the nominal package; there is now an infrastructure
urbanc
parents:
22231
diff
changeset
|
744 |
qed |
22073 | 745 |
|
746 |
abbreviation |
|
22494 | 747 |
log_equiv_for_psubsts :: "Ctxt \<Rightarrow> Subst \<Rightarrow> Subst \<Rightarrow> Ctxt \<Rightarrow> bool" ("_ \<turnstile> _ is _ over _" [60,60] 60) |
22073 | 748 |
where |
22494 | 749 |
"\<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 | 750 |
|
751 |
lemma logical_pseudo_reflexivity: |
|
752 |
assumes "\<Gamma>' \<turnstile> t is s over \<Gamma>" |
|
80149 | 753 |
shows "\<Gamma>' \<turnstile> s is s over \<Gamma>" |
754 |
by (meson assms logical_symmetry logical_transitivity) |
|
22073 | 755 |
|
756 |
lemma logical_subst_monotonicity : |
|
24231
85fb973a8207
added type constraints to resolve syntax ambiguities;
wenzelm
parents:
24088
diff
changeset
|
757 |
fixes \<Gamma> \<Gamma>' \<Gamma>'' :: Ctxt |
24070 | 758 |
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
|
759 |
and b: "\<Gamma>' \<subseteq> \<Gamma>''" |
22494 | 760 |
and c: "valid \<Gamma>''" |
24070 | 761 |
shows "\<Gamma>'' \<turnstile> \<theta> is \<theta>' over \<Gamma>" |
22494 | 762 |
using a b c logical_monotonicity by blast |
22073 | 763 |
|
764 |
lemma equiv_subst_ext : |
|
22494 | 765 |
assumes h1: "\<Gamma>' \<turnstile> \<theta> is \<theta>' over \<Gamma>" |
766 |
and h2: "\<Gamma>' \<turnstile> s is t : T" |
|
767 |
and fs: "x\<sharp>\<Gamma>" |
|
768 |
shows "\<Gamma>' \<turnstile> (x,s)#\<theta> is (x,t)#\<theta>' over (x,T)#\<Gamma>" |
|
22073 | 769 |
using assms |
770 |
proof - |
|
22494 | 771 |
{ |
772 |
fix y U |
|
773 |
assume "(y,U) \<in> set ((x,T)#\<Gamma>)" |
|
774 |
moreover |
|
775 |
{ |
|
776 |
assume "(y,U) \<in> set [(x,T)]" |
|
25107 | 777 |
with h2 have "\<Gamma>' \<turnstile> ((x,s)#\<theta>)<Var y> is ((x,t)#\<theta>')<Var y> : U" by auto |
22494 | 778 |
} |
779 |
moreover |
|
780 |
{ |
|
781 |
assume hl:"(y,U) \<in> set \<Gamma>" |
|
80149 | 782 |
then have "\<not> y\<sharp>\<Gamma>" by (induct \<Gamma>) (auto simp: fresh_list_cons fresh_atm fresh_prod) |
783 |
then have hf:"x\<sharp> Var y" using fs by (auto simp: fresh_atm) |
|
24070 | 784 |
then have "((x,s)#\<theta>)<Var y> = \<theta><Var y>" "((x,t)#\<theta>')<Var y> = \<theta>'<Var y>" |
32960
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents:
32638
diff
changeset
|
785 |
using fresh_psubst_simp by blast+ |
22494 | 786 |
moreover have "\<Gamma>' \<turnstile> \<theta><Var y> is \<theta>'<Var y> : U" using h1 hl by auto |
24070 | 787 |
ultimately have "\<Gamma>' \<turnstile> ((x,s)#\<theta>)<Var y> is ((x,t)#\<theta>')<Var y> : U" by auto |
22494 | 788 |
} |
24070 | 789 |
ultimately have "\<Gamma>' \<turnstile> ((x,s)#\<theta>)<Var y> is ((x,t)#\<theta>')<Var y> : U" by auto |
22073 | 790 |
} |
22494 | 791 |
then show "\<Gamma>' \<turnstile> (x,s)#\<theta> is (x,t)#\<theta>' over (x,T)#\<Gamma>" by auto |
22073 | 792 |
qed |
793 |
||
22494 | 794 |
theorem fundamental_theorem_1: |
24070 | 795 |
assumes a1: "\<Gamma> \<turnstile> t : T" |
796 |
and a2: "\<Gamma>' \<turnstile> \<theta> is \<theta>' over \<Gamma>" |
|
797 |
and a3: "valid \<Gamma>'" |
|
22494 | 798 |
shows "\<Gamma>' \<turnstile> \<theta><t> is \<theta>'<t> : T" |
24070 | 799 |
using a1 a2 a3 |
800 |
proof (nominal_induct \<Gamma> t T avoiding: \<theta> \<theta>' arbitrary: \<Gamma>' rule: typing.strong_induct) |
|
53015
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
49171
diff
changeset
|
801 |
case (T_Lam x \<Gamma> T\<^sub>1 t\<^sub>2 T\<^sub>2 \<theta> \<theta>' \<Gamma>') |
25107 | 802 |
have vc: "x\<sharp>\<theta>" "x\<sharp>\<theta>'" "x\<sharp>\<Gamma>" by fact+ |
24070 | 803 |
have asm1: "\<Gamma>' \<turnstile> \<theta> is \<theta>' over \<Gamma>" by fact |
53015
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
49171
diff
changeset
|
804 |
have ih:"\<And>\<theta> \<theta>' \<Gamma>'. \<lbrakk>\<Gamma>' \<turnstile> \<theta> is \<theta>' over (x,T\<^sub>1)#\<Gamma>; valid \<Gamma>'\<rbrakk> \<Longrightarrow> \<Gamma>' \<turnstile> \<theta><t\<^sub>2> is \<theta>'<t\<^sub>2> : T\<^sub>2" by fact |
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
49171
diff
changeset
|
805 |
show "\<Gamma>' \<turnstile> \<theta><Lam [x].t\<^sub>2> is \<theta>'<Lam [x].t\<^sub>2> : T\<^sub>1\<rightarrow>T\<^sub>2" using vc |
24070 | 806 |
proof (simp, intro strip) |
22494 | 807 |
fix \<Gamma>'' s' t' |
24070 | 808 |
assume sub: "\<Gamma>' \<subseteq> \<Gamma>''" |
53015
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
49171
diff
changeset
|
809 |
and asm2: "\<Gamma>''\<turnstile> s' is t' : T\<^sub>1" |
24070 | 810 |
and val: "valid \<Gamma>''" |
811 |
from asm1 val sub have "\<Gamma>'' \<turnstile> \<theta> is \<theta>' over \<Gamma>" using logical_subst_monotonicity by blast |
|
53015
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
49171
diff
changeset
|
812 |
with asm2 vc have "\<Gamma>'' \<turnstile> (x,s')#\<theta> is (x,t')#\<theta>' over (x,T\<^sub>1)#\<Gamma>" using equiv_subst_ext by blast |
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
49171
diff
changeset
|
813 |
with ih val have "\<Gamma>'' \<turnstile> ((x,s')#\<theta>)<t\<^sub>2> is ((x,t')#\<theta>')<t\<^sub>2> : T\<^sub>2" by auto |
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
49171
diff
changeset
|
814 |
with vc have "\<Gamma>''\<turnstile>\<theta><t\<^sub>2>[x::=s'] is \<theta>'<t\<^sub>2>[x::=t'] : T\<^sub>2" by (simp add: psubst_subst_psubst) |
24070 | 815 |
moreover |
53015
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
49171
diff
changeset
|
816 |
have "App (Lam [x].\<theta><t\<^sub>2>) s' \<leadsto> \<theta><t\<^sub>2>[x::=s']" by auto |
24070 | 817 |
moreover |
53015
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
49171
diff
changeset
|
818 |
have "App (Lam [x].\<theta>'<t\<^sub>2>) t' \<leadsto> \<theta>'<t\<^sub>2>[x::=t']" by auto |
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
49171
diff
changeset
|
819 |
ultimately show "\<Gamma>''\<turnstile> App (Lam [x].\<theta><t\<^sub>2>) s' is App (Lam [x].\<theta>'<t\<^sub>2>) t' : T\<^sub>2" |
22494 | 820 |
using logical_weak_head_closure by auto |
24070 | 821 |
qed |
22073 | 822 |
qed (auto) |
823 |
||
24070 | 824 |
|
22073 | 825 |
theorem fundamental_theorem_2: |
22418
49e2d9744ae1
major update of the nominal package; there is now an infrastructure
urbanc
parents:
22231
diff
changeset
|
826 |
assumes h1: "\<Gamma> \<turnstile> s \<equiv> t : T" |
22494 | 827 |
and h2: "\<Gamma>' \<turnstile> \<theta> is \<theta>' over \<Gamma>" |
828 |
and h3: "valid \<Gamma>'" |
|
829 |
shows "\<Gamma>' \<turnstile> \<theta><s> is \<theta>'<t> : T" |
|
830 |
using h1 h2 h3 |
|
22531 | 831 |
proof (nominal_induct \<Gamma> s t T avoiding: \<Gamma>' \<theta> \<theta>' rule: def_equiv.strong_induct) |
22494 | 832 |
case (Q_Refl \<Gamma> t T \<Gamma>' \<theta> \<theta>') |
80149 | 833 |
then show "\<Gamma>' \<turnstile> \<theta><t> is \<theta>'<t> : T" using fundamental_theorem_1 |
834 |
by blast |
|
22073 | 835 |
next |
22494 | 836 |
case (Q_Symm \<Gamma> t s T \<Gamma>' \<theta> \<theta>') |
80149 | 837 |
then show "\<Gamma>' \<turnstile> \<theta><s> is \<theta>'<t> : T" using logical_symmetry by blast |
22073 | 838 |
next |
22494 | 839 |
case (Q_Trans \<Gamma> s t T u \<Gamma>' \<theta> \<theta>') |
840 |
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 |
|
841 |
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 |
|
842 |
have h: "\<Gamma>' \<turnstile> \<theta> is \<theta>' over \<Gamma>" |
|
25107 | 843 |
and v: "valid \<Gamma>'" by fact+ |
22494 | 844 |
then have "\<Gamma>' \<turnstile> \<theta>' is \<theta>' over \<Gamma>" using logical_pseudo_reflexivity by auto |
845 |
then have "\<Gamma>' \<turnstile> \<theta>'<t> is \<theta>'<u> : T" using ih2 v by auto |
|
846 |
moreover have "\<Gamma>' \<turnstile> \<theta><s> is \<theta>'<t> : T" using ih1 h v by auto |
|
847 |
ultimately show "\<Gamma>' \<turnstile> \<theta><s> is \<theta>'<u> : T" using logical_transitivity by blast |
|
848 |
next |
|
53015
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
49171
diff
changeset
|
849 |
case (Q_Abs x \<Gamma> T\<^sub>1 s\<^sub>2 t\<^sub>2 T\<^sub>2 \<Gamma>' \<theta> \<theta>') |
22073 | 850 |
have fs:"x\<sharp>\<Gamma>" by fact |
25107 | 851 |
have fs2: "x\<sharp>\<theta>" "x\<sharp>\<theta>'" by fact+ |
22494 | 852 |
have h2: "\<Gamma>' \<turnstile> \<theta> is \<theta>' over \<Gamma>" |
25107 | 853 |
and h3: "valid \<Gamma>'" by fact+ |
53015
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
49171
diff
changeset
|
854 |
have ih:"\<And>\<Gamma>' \<theta> \<theta>'. \<lbrakk>\<Gamma>' \<turnstile> \<theta> is \<theta>' over (x,T\<^sub>1)#\<Gamma>; valid \<Gamma>'\<rbrakk> \<Longrightarrow> \<Gamma>' \<turnstile> \<theta><s\<^sub>2> is \<theta>'<t\<^sub>2> : T\<^sub>2" by fact |
22073 | 855 |
{ |
856 |
fix \<Gamma>'' s' t' |
|
53015
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
49171
diff
changeset
|
857 |
assume "\<Gamma>' \<subseteq> \<Gamma>''" and hl:"\<Gamma>''\<turnstile> s' is t' : T\<^sub>1" and hk: "valid \<Gamma>''" |
22494 | 858 |
then have "\<Gamma>'' \<turnstile> \<theta> is \<theta>' over \<Gamma>" using h2 logical_subst_monotonicity by blast |
53015
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
49171
diff
changeset
|
859 |
then have "\<Gamma>'' \<turnstile> (x,s')#\<theta> is (x,t')#\<theta>' over (x,T\<^sub>1)#\<Gamma>" using equiv_subst_ext hl fs by blast |
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
49171
diff
changeset
|
860 |
then have "\<Gamma>'' \<turnstile> ((x,s')#\<theta>)<s\<^sub>2> is ((x,t')#\<theta>')<t\<^sub>2> : T\<^sub>2" using ih hk by blast |
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
49171
diff
changeset
|
861 |
then have "\<Gamma>''\<turnstile> \<theta><s\<^sub>2>[x::=s'] is \<theta>'<t\<^sub>2>[x::=t'] : T\<^sub>2" using fs2 psubst_subst_psubst by auto |
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
49171
diff
changeset
|
862 |
moreover have "App (Lam [x]. \<theta><s\<^sub>2>) s' \<leadsto> \<theta><s\<^sub>2>[x::=s']" |
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
49171
diff
changeset
|
863 |
and "App (Lam [x].\<theta>'<t\<^sub>2>) t' \<leadsto> \<theta>'<t\<^sub>2>[x::=t']" by auto |
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
49171
diff
changeset
|
864 |
ultimately have "\<Gamma>'' \<turnstile> App (Lam [x]. \<theta><s\<^sub>2>) s' is App (Lam [x].\<theta>'<t\<^sub>2>) t' : T\<^sub>2" |
22073 | 865 |
using logical_weak_head_closure by auto |
866 |
} |
|
25107 | 867 |
moreover have "valid \<Gamma>'" by fact |
53015
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
49171
diff
changeset
|
868 |
ultimately have "\<Gamma>' \<turnstile> Lam [x].\<theta><s\<^sub>2> is Lam [x].\<theta>'<t\<^sub>2> : T\<^sub>1\<rightarrow>T\<^sub>2" by auto |
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
49171
diff
changeset
|
869 |
then show "\<Gamma>' \<turnstile> \<theta><Lam [x].s\<^sub>2> is \<theta>'<Lam [x].t\<^sub>2> : T\<^sub>1\<rightarrow>T\<^sub>2" using fs2 by auto |
22073 | 870 |
next |
53015
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
49171
diff
changeset
|
871 |
case (Q_App \<Gamma> s\<^sub>1 t\<^sub>1 T\<^sub>1 T\<^sub>2 s\<^sub>2 t\<^sub>2 \<Gamma>' \<theta> \<theta>') |
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
49171
diff
changeset
|
872 |
then show "\<Gamma>' \<turnstile> \<theta><App s\<^sub>1 s\<^sub>2> is \<theta>'<App t\<^sub>1 t\<^sub>2> : T\<^sub>2" by auto |
22073 | 873 |
next |
53015
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
49171
diff
changeset
|
874 |
case (Q_Beta x \<Gamma> s\<^sub>2 t\<^sub>2 T\<^sub>1 s12 t12 T\<^sub>2 \<Gamma>' \<theta> \<theta>') |
22494 | 875 |
have h: "\<Gamma>' \<turnstile> \<theta> is \<theta>' over \<Gamma>" |
25107 | 876 |
and h': "valid \<Gamma>'" by fact+ |
22494 | 877 |
have fs: "x\<sharp>\<Gamma>" by fact |
25107 | 878 |
have fs2: " x\<sharp>\<theta>" "x\<sharp>\<theta>'" by fact+ |
53015
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
49171
diff
changeset
|
879 |
have ih1: "\<And>\<Gamma>' \<theta> \<theta>'. \<lbrakk>\<Gamma>' \<turnstile> \<theta> is \<theta>' over \<Gamma>; valid \<Gamma>'\<rbrakk> \<Longrightarrow> \<Gamma>' \<turnstile> \<theta><s\<^sub>2> is \<theta>'<t\<^sub>2> : T\<^sub>1" by fact |
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
49171
diff
changeset
|
880 |
have ih2: "\<And>\<Gamma>' \<theta> \<theta>'. \<lbrakk>\<Gamma>' \<turnstile> \<theta> is \<theta>' over (x,T\<^sub>1)#\<Gamma>; valid \<Gamma>'\<rbrakk> \<Longrightarrow> \<Gamma>' \<turnstile> \<theta><s12> is \<theta>'<t12> : T\<^sub>2" by fact |
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
49171
diff
changeset
|
881 |
have "\<Gamma>' \<turnstile> \<theta><s\<^sub>2> is \<theta>'<t\<^sub>2> : T\<^sub>1" using ih1 h' h by auto |
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
49171
diff
changeset
|
882 |
then have "\<Gamma>' \<turnstile> (x,\<theta><s\<^sub>2>)#\<theta> is (x,\<theta>'<t\<^sub>2>)#\<theta>' over (x,T\<^sub>1)#\<Gamma>" using equiv_subst_ext h fs by blast |
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
49171
diff
changeset
|
883 |
then have "\<Gamma>' \<turnstile> ((x,\<theta><s\<^sub>2>)#\<theta>)<s12> is ((x,\<theta>'<t\<^sub>2>)#\<theta>')<t12> : T\<^sub>2" using ih2 h' by auto |
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
49171
diff
changeset
|
884 |
then have "\<Gamma>' \<turnstile> \<theta><s12>[x::=\<theta><s\<^sub>2>] is \<theta>'<t12>[x::=\<theta>'<t\<^sub>2>] : T\<^sub>2" using fs2 psubst_subst_psubst by auto |
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
49171
diff
changeset
|
885 |
then have "\<Gamma>' \<turnstile> \<theta><s12>[x::=\<theta><s\<^sub>2>] is \<theta>'<t12[x::=t\<^sub>2]> : T\<^sub>2" using fs2 psubst_subst_propagate by auto |
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
49171
diff
changeset
|
886 |
moreover have "App (Lam [x].\<theta><s12>) (\<theta><s\<^sub>2>) \<leadsto> \<theta><s12>[x::=\<theta><s\<^sub>2>]" by auto |
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
49171
diff
changeset
|
887 |
ultimately have "\<Gamma>' \<turnstile> App (Lam [x].\<theta><s12>) (\<theta><s\<^sub>2>) is \<theta>'<t12[x::=t\<^sub>2]> : T\<^sub>2" |
22073 | 888 |
using logical_weak_head_closure' by auto |
53015
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
49171
diff
changeset
|
889 |
then show "\<Gamma>' \<turnstile> \<theta><App (Lam [x].s12) s\<^sub>2> is \<theta>'<t12[x::=t\<^sub>2]> : T\<^sub>2" using fs2 by simp |
22073 | 890 |
next |
53015
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
49171
diff
changeset
|
891 |
case (Q_Ext x \<Gamma> s t T\<^sub>1 T\<^sub>2 \<Gamma>' \<theta> \<theta>') |
22494 | 892 |
have h2: "\<Gamma>' \<turnstile> \<theta> is \<theta>' over \<Gamma>" |
25107 | 893 |
and h2': "valid \<Gamma>'" by fact+ |
894 |
have fs:"x\<sharp>\<Gamma>" "x\<sharp>s" "x\<sharp>t" by fact+ |
|
53015
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
49171
diff
changeset
|
895 |
have ih:"\<And>\<Gamma>' \<theta> \<theta>'. \<lbrakk>\<Gamma>' \<turnstile> \<theta> is \<theta>' over (x,T\<^sub>1)#\<Gamma>; valid \<Gamma>'\<rbrakk> |
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
49171
diff
changeset
|
896 |
\<Longrightarrow> \<Gamma>' \<turnstile> \<theta><App s (Var x)> is \<theta>'<App t (Var x)> : T\<^sub>2" by fact |
22073 | 897 |
{ |
898 |
fix \<Gamma>'' s' t' |
|
53015
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
49171
diff
changeset
|
899 |
assume hsub: "\<Gamma>' \<subseteq> \<Gamma>''" and hl: "\<Gamma>''\<turnstile> s' is t' : T\<^sub>1" and hk: "valid \<Gamma>''" |
22494 | 900 |
then have "\<Gamma>'' \<turnstile> \<theta> is \<theta>' over \<Gamma>" using h2 logical_subst_monotonicity by blast |
53015
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
49171
diff
changeset
|
901 |
then have "\<Gamma>'' \<turnstile> (x,s')#\<theta> is (x,t')#\<theta>' over (x,T\<^sub>1)#\<Gamma>" using equiv_subst_ext hl fs by blast |
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
49171
diff
changeset
|
902 |
then have "\<Gamma>'' \<turnstile> ((x,s')#\<theta>)<App s (Var x)> is ((x,t')#\<theta>')<App t (Var x)> : T\<^sub>2" using ih hk by blast |
22494 | 903 |
then |
53015
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
49171
diff
changeset
|
904 |
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\<^sub>2" |
22082 | 905 |
by auto |
53015
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
49171
diff
changeset
|
906 |
then have "\<Gamma>'' \<turnstile> App ((x,s')#\<theta>)<s> s' is App ((x,t')#\<theta>')<t> t' : T\<^sub>2" by auto |
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
49171
diff
changeset
|
907 |
then have "\<Gamma>'' \<turnstile> App (\<theta><s>) s' is App (\<theta>'<t>) t' : T\<^sub>2" using fs fresh_psubst_simp by auto |
22073 | 908 |
} |
25107 | 909 |
moreover have "valid \<Gamma>'" by fact |
53015
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
49171
diff
changeset
|
910 |
ultimately show "\<Gamma>' \<turnstile> \<theta><s> is \<theta>'<t> : T\<^sub>1\<rightarrow>T\<^sub>2" by auto |
23370
513a8ee192f1
added the Q_Unit rule (was missing) and adjusted the proof accordingly
urbanc
parents:
22829
diff
changeset
|
911 |
next |
513a8ee192f1
added the Q_Unit rule (was missing) and adjusted the proof accordingly
urbanc
parents:
22829
diff
changeset
|
912 |
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
|
913 |
then show "\<Gamma>' \<turnstile> \<theta><s> is \<theta>'<t> : TUnit" by auto |
22073 | 914 |
qed |
915 |
||
22418
49e2d9744ae1
major update of the nominal package; there is now an infrastructure
urbanc
parents:
22231
diff
changeset
|
916 |
|
22073 | 917 |
theorem completeness: |
22494 | 918 |
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
|
919 |
shows "\<Gamma> \<turnstile> s \<Leftrightarrow> t : T" |
22073 | 920 |
proof - |
22494 | 921 |
have val: "valid \<Gamma>" using def_equiv_implies_valid asm by simp |
80149 | 922 |
then have "\<Gamma> \<turnstile> [] is [] over \<Gamma>" |
923 |
by (simp add: QAP_Var main_lemma(2)) |
|
22494 | 924 |
then have "\<Gamma> \<turnstile> []<s> is []<t> : T" using fundamental_theorem_2 val asm by blast |
22073 | 925 |
then have "\<Gamma> \<turnstile> s is t : T" by simp |
22494 | 926 |
then show "\<Gamma> \<turnstile> s \<Leftrightarrow> t : T" using main_lemma(1) val by simp |
22073 | 927 |
qed |
928 |
||
63167 | 929 |
text \<open>We leave soundness as an exercise - just like Crary in the ATS book :-) \\ |
22418
49e2d9744ae1
major update of the nominal package; there is now an infrastructure
urbanc
parents:
22231
diff
changeset
|
930 |
@{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"} \\ |
69597 | 931 |
\<^prop>\<open>\<lbrakk>\<Gamma> \<turnstile> s \<leftrightarrow> t : T; \<Gamma> \<turnstile> t : T; \<Gamma> \<turnstile> s : T\<rbrakk> \<Longrightarrow> \<Gamma> \<turnstile> s \<equiv> t : T\<close> |
63167 | 932 |
\<close> |
22073 | 933 |
|
934 |
end |
|
935 |