author | wenzelm |
Wed, 12 Mar 2025 11:39:00 +0100 | |
changeset 82265 | 4b875a4c83b0 |
parent 81127 | 12990a6dddcb |
permissions | -rw-r--r-- |
18577
a636846a02c7
added more documentation; will now try out a modification
urbanc
parents:
18424
diff
changeset
|
1 |
(*<*) |
19501 | 2 |
theory Fsub |
66453
cc19f7ca2ed6
session-qualified theory imports: isabelle imports -U -i -d '~~/src/Benchmarks' -a;
wenzelm
parents:
63167
diff
changeset
|
3 |
imports "HOL-Nominal.Nominal" |
18269 | 4 |
begin |
18577
a636846a02c7
added more documentation; will now try out a modification
urbanc
parents:
18424
diff
changeset
|
5 |
(*>*) |
18269 | 6 |
|
63167 | 7 |
text\<open>Authors: Christian Urban, |
18577
a636846a02c7
added more documentation; will now try out a modification
urbanc
parents:
18424
diff
changeset
|
8 |
Benjamin Pierce, |
18650 | 9 |
Dimitrios Vytiniotis |
30091
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
10 |
Stephanie Weirich |
18650 | 11 |
Steve Zdancewic |
30091
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
12 |
Julien Narboux |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
13 |
Stefan Berghofer |
18266
55c201fe4c95
added an authors section (please let me know if somebody is left out or unhappy)
urbanc
parents:
18263
diff
changeset
|
14 |
|
63167 | 15 |
with great help from Markus Wenzel.\<close> |
18246 | 16 |
|
63167 | 17 |
section \<open>Types for Names, Nominal Datatype Declaration for Types and Terms\<close> |
18424 | 18 |
|
63167 | 19 |
text \<open>The main point of this solution is to use names everywhere (be they bound, |
18621 | 20 |
binding or free). In System \FSUB{} there are two kinds of names corresponding to |
21 |
type-variables and to term-variables. These two kinds of names are represented in |
|
63167 | 22 |
the nominal datatype package as atom-types \<open>tyvrs\<close> and \<open>vrs\<close>:\<close> |
18577
a636846a02c7
added more documentation; will now try out a modification
urbanc
parents:
18424
diff
changeset
|
23 |
|
18246 | 24 |
atom_decl tyvrs vrs |
25 |
||
63167 | 26 |
text\<open>There are numerous facts that come with this declaration: for example that |
27 |
there are infinitely many elements in \<open>tyvrs\<close> and \<open>vrs\<close>.\<close> |
|
18577
a636846a02c7
added more documentation; will now try out a modification
urbanc
parents:
18424
diff
changeset
|
28 |
|
63167 | 29 |
text\<open>The constructors for types and terms in System \FSUB{} contain abstractions |
58305
57752a91eec4
renamed 'datatype' to 'old_datatype'; 'datatype' is now alias for 'datatype_new'
blanchet
parents:
55417
diff
changeset
|
30 |
over type-variables and term-variables. The nominal datatype package uses |
63167 | 31 |
\<open>\<guillemotleft>\<dots>\<guillemotright>\<dots>\<close> to indicate where abstractions occur.\<close> |
18577
a636846a02c7
added more documentation; will now try out a modification
urbanc
parents:
18424
diff
changeset
|
32 |
|
18424 | 33 |
nominal_datatype ty = |
18577
a636846a02c7
added more documentation; will now try out a modification
urbanc
parents:
18424
diff
changeset
|
34 |
Tvar "tyvrs" |
18424 | 35 |
| Top |
80914
d97fdabd9e2b
standardize mixfix annotations via "isabelle update -a -u mixfix_cartouches" --- to simplify systematic editing;
wenzelm
parents:
80149
diff
changeset
|
36 |
| Arrow "ty" "ty" (infixr \<open>\<rightarrow>\<close> 200) |
18577
a636846a02c7
added more documentation; will now try out a modification
urbanc
parents:
18424
diff
changeset
|
37 |
| Forall "\<guillemotleft>tyvrs\<guillemotright>ty" "ty" |
18246 | 38 |
|
18424 | 39 |
nominal_datatype trm = |
40 |
Var "vrs" |
|
30091
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
41 |
| Abs "\<guillemotleft>vrs\<guillemotright>trm" "ty" |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
42 |
| TAbs "\<guillemotleft>tyvrs\<guillemotright>trm" "ty" |
80914
d97fdabd9e2b
standardize mixfix annotations via "isabelle update -a -u mixfix_cartouches" --- to simplify systematic editing;
wenzelm
parents:
80149
diff
changeset
|
43 |
| App "trm" "trm" (infixl \<open>\<cdot>\<close> 200) |
d97fdabd9e2b
standardize mixfix annotations via "isabelle update -a -u mixfix_cartouches" --- to simplify systematic editing;
wenzelm
parents:
80149
diff
changeset
|
44 |
| TApp "trm" "ty" (infixl \<open>\<cdot>\<^sub>\<tau>\<close> 200) |
18577
a636846a02c7
added more documentation; will now try out a modification
urbanc
parents:
18424
diff
changeset
|
45 |
|
63167 | 46 |
text \<open>To be polite to the eye, some more familiar notation is introduced. |
18621 | 47 |
Because of the change in the order of arguments, one needs to use |
18577
a636846a02c7
added more documentation; will now try out a modification
urbanc
parents:
18424
diff
changeset
|
48 |
translation rules, instead of syntax annotations at the term-constructors |
69597 | 49 |
as given above for \<^term>\<open>Arrow\<close>.\<close> |
18246 | 50 |
|
30091
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
51 |
abbreviation |
80914
d97fdabd9e2b
standardize mixfix annotations via "isabelle update -a -u mixfix_cartouches" --- to simplify systematic editing;
wenzelm
parents:
80149
diff
changeset
|
52 |
Forall_syn :: "tyvrs \<Rightarrow> ty \<Rightarrow> ty \<Rightarrow> ty" (\<open>(3\<forall>_<:_./ _)\<close> [0, 0, 10] 10) |
30091
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
53 |
where |
53015
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
50252
diff
changeset
|
54 |
"\<forall>X<:T\<^sub>1. T\<^sub>2 \<equiv> ty.Forall X T\<^sub>2 T\<^sub>1" |
18424 | 55 |
|
30091
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
56 |
abbreviation |
80914
d97fdabd9e2b
standardize mixfix annotations via "isabelle update -a -u mixfix_cartouches" --- to simplify systematic editing;
wenzelm
parents:
80149
diff
changeset
|
57 |
Abs_syn :: "vrs \<Rightarrow> ty \<Rightarrow> trm \<Rightarrow> trm" (\<open>(3\<lambda>_:_./ _)\<close> [0, 0, 10] 10) |
30091
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
58 |
where |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
59 |
"\<lambda>x:T. t \<equiv> trm.Abs x t T" |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
60 |
|
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
61 |
abbreviation |
80914
d97fdabd9e2b
standardize mixfix annotations via "isabelle update -a -u mixfix_cartouches" --- to simplify systematic editing;
wenzelm
parents:
80149
diff
changeset
|
62 |
TAbs_syn :: "tyvrs \<Rightarrow> ty \<Rightarrow> trm \<Rightarrow> trm" (\<open>(3\<lambda>_<:_./ _)\<close> [0, 0, 10] 10) |
30091
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
63 |
where |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
64 |
"\<lambda>X<:T. t \<equiv> trm.TAbs X t T" |
18246 | 65 |
|
69597 | 66 |
text \<open>Again there are numerous facts that are proved automatically for \<^typ>\<open>ty\<close> |
67 |
and \<^typ>\<open>trm\<close>: for example that the set of free variables, i.e.~the \<open>support\<close>, |
|
18650 | 68 |
is finite. However note that nominal-datatype declarations do \emph{not} define |
69 |
``classical" constructor-based datatypes, but rather define $\alpha$-equivalence |
|
69597 | 70 |
classes---we can for example show that $\alpha$-equivalent \<^typ>\<open>ty\<close>s |
71 |
and \<^typ>\<open>trm\<close>s are equal:\<close> |
|
18577
a636846a02c7
added more documentation; will now try out a modification
urbanc
parents:
18424
diff
changeset
|
72 |
|
a636846a02c7
added more documentation; will now try out a modification
urbanc
parents:
18424
diff
changeset
|
73 |
lemma alpha_illustration: |
30091
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
74 |
shows "(\<forall>X<:T. Tvar X) = (\<forall>Y<:T. Tvar Y)" |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
75 |
and "(\<lambda>x:T. Var x) = (\<lambda>y:T. Var y)" |
18577
a636846a02c7
added more documentation; will now try out a modification
urbanc
parents:
18424
diff
changeset
|
76 |
by (simp_all add: ty.inject trm.inject alpha calc_atm fresh_atm) |
a636846a02c7
added more documentation; will now try out a modification
urbanc
parents:
18424
diff
changeset
|
77 |
|
63167 | 78 |
section \<open>SubTyping Contexts\<close> |
18246 | 79 |
|
30091
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
80 |
nominal_datatype binding = |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
81 |
VarB vrs ty |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
82 |
| TVarB tyvrs ty |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
83 |
|
41798 | 84 |
type_synonym env = "binding list" |
18246 | 85 |
|
63167 | 86 |
text \<open>Typing contexts are represented as lists that ``grow" on the left; we |
18621 | 87 |
thereby deviating from the convention in the POPLmark-paper. The lists contain |
63167 | 88 |
pairs of type-variables and types (this is sufficient for Part 1A).\<close> |
18577
a636846a02c7
added more documentation; will now try out a modification
urbanc
parents:
18424
diff
changeset
|
89 |
|
63167 | 90 |
text \<open>In order to state validity-conditions for typing-contexts, the notion of |
91 |
a \<open>dom\<close> of a typing-context is handy.\<close> |
|
18577
a636846a02c7
added more documentation; will now try out a modification
urbanc
parents:
18424
diff
changeset
|
92 |
|
30091
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
93 |
nominal_primrec |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
94 |
"tyvrs_of" :: "binding \<Rightarrow> tyvrs set" |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
95 |
where |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
96 |
"tyvrs_of (VarB x y) = {}" |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
97 |
| "tyvrs_of (TVarB x y) = {x}" |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
98 |
by auto |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
99 |
|
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
100 |
nominal_primrec |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
101 |
"vrs_of" :: "binding \<Rightarrow> vrs set" |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
102 |
where |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
103 |
"vrs_of (VarB x y) = {x}" |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
104 |
| "vrs_of (TVarB x y) = {}" |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
105 |
by auto |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
106 |
|
39246 | 107 |
primrec |
32011 | 108 |
"ty_dom" :: "env \<Rightarrow> tyvrs set" |
39246 | 109 |
where |
32011 | 110 |
"ty_dom [] = {}" |
39246 | 111 |
| "ty_dom (X#\<Gamma>) = (tyvrs_of X)\<union>(ty_dom \<Gamma>)" |
30091
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
112 |
|
39246 | 113 |
primrec |
32011 | 114 |
"trm_dom" :: "env \<Rightarrow> vrs set" |
39246 | 115 |
where |
32011 | 116 |
"trm_dom [] = {}" |
39246 | 117 |
| "trm_dom (X#\<Gamma>) = (vrs_of X)\<union>(trm_dom \<Gamma>)" |
18246 | 118 |
|
30091
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
119 |
lemma vrs_of_eqvt[eqvt]: |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
120 |
fixes pi ::"tyvrs prm" |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
121 |
and pi'::"vrs prm" |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
122 |
shows "pi \<bullet>(tyvrs_of x) = tyvrs_of (pi\<bullet>x)" |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
123 |
and "pi'\<bullet>(tyvrs_of x) = tyvrs_of (pi'\<bullet>x)" |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
124 |
and "pi \<bullet>(vrs_of x) = vrs_of (pi\<bullet>x)" |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
125 |
and "pi'\<bullet>(vrs_of x) = vrs_of (pi'\<bullet>x)" |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
126 |
by (nominal_induct x rule: binding.strong_induct) (simp_all add: tyvrs_of.simps eqvts) |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
127 |
|
32011 | 128 |
lemma doms_eqvt[eqvt]: |
18246 | 129 |
fixes pi::"tyvrs prm" |
22537 | 130 |
and pi'::"vrs prm" |
32011 | 131 |
shows "pi \<bullet>(ty_dom \<Gamma>) = ty_dom (pi\<bullet>\<Gamma>)" |
132 |
and "pi'\<bullet>(ty_dom \<Gamma>) = ty_dom (pi'\<bullet>\<Gamma>)" |
|
133 |
and "pi \<bullet>(trm_dom \<Gamma>) = trm_dom (pi\<bullet>\<Gamma>)" |
|
134 |
and "pi'\<bullet>(trm_dom \<Gamma>) = trm_dom (pi'\<bullet>\<Gamma>)" |
|
30091
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
135 |
by (induct \<Gamma>) (simp_all add: eqvts) |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
136 |
|
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
137 |
lemma finite_vrs: |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
138 |
shows "finite (tyvrs_of x)" |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
139 |
and "finite (vrs_of x)" |
49171 | 140 |
by (nominal_induct rule:binding.strong_induct) auto |
30091
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
141 |
|
32011 | 142 |
lemma finite_doms: |
143 |
shows "finite (ty_dom \<Gamma>)" |
|
144 |
and "finite (trm_dom \<Gamma>)" |
|
80142 | 145 |
by (induct \<Gamma>) (auto simp: finite_vrs) |
30091
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
146 |
|
32011 | 147 |
lemma ty_dom_supp: |
148 |
shows "(supp (ty_dom \<Gamma>)) = (ty_dom \<Gamma>)" |
|
149 |
and "(supp (trm_dom \<Gamma>)) = (trm_dom \<Gamma>)" |
|
150 |
by (simp only: at_fin_set_supp at_tyvrs_inst at_vrs_inst finite_doms)+ |
|
18246 | 151 |
|
32011 | 152 |
lemma ty_dom_inclusion: |
30091
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
153 |
assumes a: "(TVarB X T)\<in>set \<Gamma>" |
32011 | 154 |
shows "X\<in>(ty_dom \<Gamma>)" |
49171 | 155 |
using a by (induct \<Gamma>) (auto) |
30091
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
156 |
|
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
157 |
lemma ty_binding_existence: |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
158 |
assumes "X \<in> (tyvrs_of a)" |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
159 |
shows "\<exists>T.(TVarB X T=a)" |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
160 |
using assms |
49171 | 161 |
by (nominal_induct a rule: binding.strong_induct) (auto) |
30091
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
162 |
|
32011 | 163 |
lemma ty_dom_existence: |
164 |
assumes a: "X\<in>(ty_dom \<Gamma>)" |
|
30091
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
165 |
shows "\<exists>T.(TVarB X T)\<in>set \<Gamma>" |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
166 |
using a |
80142 | 167 |
proof (induction \<Gamma>) |
168 |
case Nil then show ?case by simp |
|
169 |
next |
|
170 |
case (Cons a \<Gamma>) then show ?case |
|
171 |
using ty_binding_existence by fastforce |
|
172 |
qed |
|
30091
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
173 |
|
32011 | 174 |
lemma doms_append: |
175 |
shows "ty_dom (\<Gamma>@\<Delta>) = ((ty_dom \<Gamma>) \<union> (ty_dom \<Delta>))" |
|
176 |
and "trm_dom (\<Gamma>@\<Delta>) = ((trm_dom \<Gamma>) \<union> (trm_dom \<Delta>))" |
|
49171 | 177 |
by (induct \<Gamma>) (auto) |
18246 | 178 |
|
30091
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
179 |
lemma ty_vrs_prm_simp: |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
180 |
fixes pi::"vrs prm" |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
181 |
and S::"ty" |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
182 |
shows "pi\<bullet>S = S" |
80142 | 183 |
by (induct S rule: ty.induct) (auto simp: calc_atm) |
18246 | 184 |
|
32011 | 185 |
lemma fresh_ty_dom_cons: |
30091
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
186 |
fixes X::"tyvrs" |
32011 | 187 |
shows "X\<sharp>(ty_dom (Y#\<Gamma>)) = (X\<sharp>(tyvrs_of Y) \<and> X\<sharp>(ty_dom \<Gamma>))" |
80142 | 188 |
proof (nominal_induct rule:binding.strong_induct) |
189 |
case (VarB vrs ty) |
|
190 |
then show ?case by auto |
|
191 |
next |
|
192 |
case (TVarB tyvrs ty) |
|
193 |
then show ?case |
|
194 |
by (simp add: at_fin_set_supp at_tyvrs_inst finite_doms(1) fresh_def supp_atm(1)) |
|
195 |
qed |
|
18246 | 196 |
|
30091
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
197 |
lemma tyvrs_fresh: |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
198 |
fixes X::"tyvrs" |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
199 |
assumes "X \<sharp> a" |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
200 |
shows "X \<sharp> tyvrs_of a" |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
201 |
and "X \<sharp> vrs_of a" |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
202 |
using assms |
80142 | 203 |
by (nominal_induct a rule:binding.strong_induct) (force simp: fresh_singleton)+ |
18621 | 204 |
|
32011 | 205 |
lemma fresh_dom: |
18621 | 206 |
fixes X::"tyvrs" |
207 |
assumes a: "X\<sharp>\<Gamma>" |
|
32011 | 208 |
shows "X\<sharp>(ty_dom \<Gamma>)" |
18621 | 209 |
using a |
80142 | 210 |
proof (induct \<Gamma>) |
211 |
case Nil then show ?case by auto |
|
212 |
next |
|
213 |
case (Cons a \<Gamma>) then show ?case |
|
214 |
by (meson fresh_list_cons fresh_ty_dom_cons tyvrs_fresh(1)) |
|
215 |
qed |
|
18621 | 216 |
|
69597 | 217 |
text \<open>Not all lists of type \<^typ>\<open>env\<close> are well-formed. One condition |
218 |
requires that in \<^term>\<open>TVarB X S#\<Gamma>\<close> all free variables of \<^term>\<open>S\<close> must be |
|
219 |
in the \<^term>\<open>ty_dom\<close> of \<^term>\<open>\<Gamma>\<close>, that is \<^term>\<open>S\<close> must be \<open>closed\<close> |
|
220 |
in \<^term>\<open>\<Gamma>\<close>. The set of free variables of \<^term>\<open>S\<close> is the |
|
221 |
\<open>support\<close> of \<^term>\<open>S\<close>.\<close> |
|
18246 | 222 |
|
80914
d97fdabd9e2b
standardize mixfix annotations via "isabelle update -a -u mixfix_cartouches" --- to simplify systematic editing;
wenzelm
parents:
80149
diff
changeset
|
223 |
definition "closed_in" :: "ty \<Rightarrow> env \<Rightarrow> bool" (\<open>_ closed'_in _\<close> [100,100] 100) where |
32011 | 224 |
"S closed_in \<Gamma> \<equiv> (supp S)\<subseteq>(ty_dom \<Gamma>)" |
18246 | 225 |
|
22537 | 226 |
lemma closed_in_eqvt[eqvt]: |
18246 | 227 |
fixes pi::"tyvrs prm" |
228 |
assumes a: "S closed_in \<Gamma>" |
|
229 |
shows "(pi\<bullet>S) closed_in (pi\<bullet>\<Gamma>)" |
|
230 |
using a |
|
26091 | 231 |
proof - |
232 |
from a have "pi\<bullet>(S closed_in \<Gamma>)" by (simp add: perm_bool) |
|
233 |
then show "(pi\<bullet>S) closed_in (pi\<bullet>\<Gamma>)" by (simp add: closed_in_def eqvts) |
|
18246 | 234 |
qed |
235 |
||
30091
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
236 |
lemma tyvrs_vrs_prm_simp: |
22537 | 237 |
fixes pi::"vrs prm" |
30091
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
238 |
shows "tyvrs_of (pi\<bullet>a) = tyvrs_of a" |
80142 | 239 |
by (nominal_induct rule:binding.strong_induct) (auto simp: vrs_prm_tyvrs_def) |
22537 | 240 |
|
30986
047fa04a9fe8
deleted thm-attributes "fresh" and "bij" (not used); same features can later be implemented by simpler means
Christian Urban <urbanc@in.tum.de>
parents:
30091
diff
changeset
|
241 |
lemma ty_vrs_fresh: |
30091
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
242 |
fixes x::"vrs" |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
243 |
and T::"ty" |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
244 |
shows "x \<sharp> T" |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
245 |
by (simp add: fresh_def supp_def ty_vrs_prm_simp) |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
246 |
|
32011 | 247 |
lemma ty_dom_vrs_prm_simp: |
22537 | 248 |
fixes pi::"vrs prm" |
30091
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
249 |
and \<Gamma>::"env" |
32011 | 250 |
shows "(ty_dom (pi\<bullet>\<Gamma>)) = (ty_dom \<Gamma>)" |
80142 | 251 |
by (induct \<Gamma>) (auto simp: tyvrs_vrs_prm_simp) |
22537 | 252 |
|
253 |
lemma closed_in_eqvt'[eqvt]: |
|
254 |
fixes pi::"vrs prm" |
|
255 |
assumes a: "S closed_in \<Gamma>" |
|
256 |
shows "(pi\<bullet>S) closed_in (pi\<bullet>\<Gamma>)" |
|
80142 | 257 |
using assms closed_in_def ty_dom_vrs_prm_simp ty_vrs_prm_simp by force |
30091
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
258 |
|
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
259 |
lemma fresh_vrs_of: |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
260 |
fixes x::"vrs" |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
261 |
shows "x\<sharp>vrs_of b = x\<sharp>b" |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
262 |
by (nominal_induct b rule: binding.strong_induct) |
46182
b4aa5e39f944
Removed strange hack introduced in b27e93132603, since equivariance
berghofe
parents:
45971
diff
changeset
|
263 |
(simp_all add: fresh_singleton fresh_set_empty ty_vrs_fresh fresh_atm) |
30091
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
264 |
|
32011 | 265 |
lemma fresh_trm_dom: |
30091
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
266 |
fixes x::"vrs" |
32011 | 267 |
shows "x\<sharp> trm_dom \<Gamma> = x\<sharp>\<Gamma>" |
30091
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
268 |
by (induct \<Gamma>) |
80142 | 269 |
(simp_all add: fresh_list_cons |
30091
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
270 |
fresh_fin_union [OF pt_vrs_inst at_vrs_inst fs_vrs_inst] |
80142 | 271 |
finite_doms finite_vrs fresh_vrs_of) |
30091
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
272 |
|
32011 | 273 |
lemma closed_in_fresh: "(X::tyvrs) \<sharp> ty_dom \<Gamma> \<Longrightarrow> T closed_in \<Gamma> \<Longrightarrow> X \<sharp> T" |
80142 | 274 |
by (auto simp: closed_in_def fresh_def ty_dom_supp) |
22537 | 275 |
|
63167 | 276 |
text \<open>Now validity of a context is a straightforward inductive definition.\<close> |
18621 | 277 |
|
30091
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
278 |
inductive |
80914
d97fdabd9e2b
standardize mixfix annotations via "isabelle update -a -u mixfix_cartouches" --- to simplify systematic editing;
wenzelm
parents:
80149
diff
changeset
|
279 |
valid_rel :: "env \<Rightarrow> bool" (\<open>\<turnstile> _ ok\<close> [100] 100) |
22436 | 280 |
where |
30091
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
281 |
valid_nil[simp]: "\<turnstile> [] ok" |
32011 | 282 |
| valid_consT[simp]: "\<lbrakk>\<turnstile> \<Gamma> ok; X\<sharp>(ty_dom \<Gamma>); T closed_in \<Gamma>\<rbrakk> \<Longrightarrow> \<turnstile> (TVarB X T#\<Gamma>) ok" |
283 |
| valid_cons [simp]: "\<lbrakk>\<turnstile> \<Gamma> ok; x\<sharp>(trm_dom \<Gamma>); T closed_in \<Gamma>\<rbrakk> \<Longrightarrow> \<turnstile> (VarB x T#\<Gamma>) ok" |
|
18246 | 284 |
|
22537 | 285 |
equivariance valid_rel |
18246 | 286 |
|
30091
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
287 |
declare binding.inject [simp add] |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
288 |
declare trm.inject [simp add] |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
289 |
|
32011 | 290 |
inductive_cases validE[elim]: |
291 |
"\<turnstile> (TVarB X T#\<Gamma>) ok" |
|
292 |
"\<turnstile> (VarB x T#\<Gamma>) ok" |
|
293 |
"\<turnstile> (b#\<Gamma>) ok" |
|
30091
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
294 |
|
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
295 |
declare binding.inject [simp del] |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
296 |
declare trm.inject [simp del] |
18246 | 297 |
|
18424 | 298 |
lemma validE_append: |
299 |
assumes a: "\<turnstile> (\<Delta>@\<Gamma>) ok" |
|
300 |
shows "\<turnstile> \<Gamma> ok" |
|
30091
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
301 |
using a |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
302 |
proof (induct \<Delta>) |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
303 |
case (Cons a \<Gamma>') |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
304 |
then show ?case |
80142 | 305 |
by (nominal_induct a rule:binding.strong_induct) auto |
30091
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
306 |
qed (auto) |
18246 | 307 |
|
18424 | 308 |
lemma replace_type: |
30091
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
309 |
assumes a: "\<turnstile> (\<Delta>@(TVarB X T)#\<Gamma>) ok" |
18424 | 310 |
and b: "S closed_in \<Gamma>" |
30091
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
311 |
shows "\<turnstile> (\<Delta>@(TVarB X S)#\<Gamma>) ok" |
18621 | 312 |
using a b |
30091
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
313 |
proof(induct \<Delta>) |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
314 |
case Nil |
80142 | 315 |
then show ?case by (auto intro: valid_cons simp add: doms_append closed_in_def) |
30091
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
316 |
next |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
317 |
case (Cons a \<Gamma>') |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
318 |
then show ?case |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
319 |
by (nominal_induct a rule:binding.strong_induct) |
80142 | 320 |
(auto intro!: valid_cons simp add: doms_append closed_in_def) |
30091
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
321 |
qed |
18246 | 322 |
|
63167 | 323 |
text \<open>Well-formed contexts have a unique type-binding for a type-variable.\<close> |
18650 | 324 |
|
18246 | 325 |
lemma uniqueness_of_ctxt: |
30091
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
326 |
fixes \<Gamma>::"env" |
18412 | 327 |
assumes a: "\<turnstile> \<Gamma> ok" |
30091
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
328 |
and b: "(TVarB X T)\<in>set \<Gamma>" |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
329 |
and c: "(TVarB X S)\<in>set \<Gamma>" |
18412 | 330 |
shows "T=S" |
18621 | 331 |
using a b c |
332 |
proof (induct) |
|
30091
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
333 |
case (valid_consT \<Gamma> X' T') |
18621 | 334 |
moreover |
30091
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
335 |
{ fix \<Gamma>'::"env" |
32011 | 336 |
assume a: "X'\<sharp>(ty_dom \<Gamma>')" |
30091
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
337 |
have "\<not>(\<exists>T.(TVarB X' T)\<in>(set \<Gamma>'))" using a |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
338 |
proof (induct \<Gamma>') |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
339 |
case (Cons Y \<Gamma>') |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
340 |
thus "\<not> (\<exists>T.(TVarB X' T)\<in>set(Y#\<Gamma>'))" |
32960
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents:
32011
diff
changeset
|
341 |
by (simp add: fresh_ty_dom_cons |
30091
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
342 |
fresh_fin_union[OF pt_tyvrs_inst at_tyvrs_inst fs_tyvrs_inst] |
32011 | 343 |
finite_vrs finite_doms, |
80142 | 344 |
auto simp: fresh_atm fresh_singleton) |
18621 | 345 |
qed (simp) |
346 |
} |
|
80142 | 347 |
ultimately show "T=S" by (auto simp: binding.inject) |
30091
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
348 |
qed (auto) |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
349 |
|
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
350 |
lemma uniqueness_of_ctxt': |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
351 |
fixes \<Gamma>::"env" |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
352 |
assumes a: "\<turnstile> \<Gamma> ok" |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
353 |
and b: "(VarB x T)\<in>set \<Gamma>" |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
354 |
and c: "(VarB x S)\<in>set \<Gamma>" |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
355 |
shows "T=S" |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
356 |
using a b c |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
357 |
proof (induct) |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
358 |
case (valid_cons \<Gamma> x' T') |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
359 |
moreover |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
360 |
{ fix \<Gamma>'::"env" |
32011 | 361 |
assume a: "x'\<sharp>(trm_dom \<Gamma>')" |
30091
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
362 |
have "\<not>(\<exists>T.(VarB x' T)\<in>(set \<Gamma>'))" using a |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
363 |
proof (induct \<Gamma>') |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
364 |
case (Cons y \<Gamma>') |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
365 |
thus "\<not> (\<exists>T.(VarB x' T)\<in>set(y#\<Gamma>'))" |
32960
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents:
32011
diff
changeset
|
366 |
by (simp add: fresh_fin_union[OF pt_vrs_inst at_vrs_inst fs_vrs_inst] |
32011 | 367 |
finite_vrs finite_doms, |
80142 | 368 |
auto simp: fresh_atm fresh_singleton) |
30091
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
369 |
qed (simp) |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
370 |
} |
80142 | 371 |
ultimately show "T=S" by (auto simp: binding.inject) |
30091
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
372 |
qed (auto) |
18577
a636846a02c7
added more documentation; will now try out a modification
urbanc
parents:
18424
diff
changeset
|
373 |
|
63167 | 374 |
section \<open>Size and Capture-Avoiding Substitution for Types\<close> |
18621 | 375 |
|
21554 | 376 |
nominal_primrec |
29097
68245155eb58
Modified nominal_primrec to make it work with local theories, unified syntax
berghofe
parents:
26966
diff
changeset
|
377 |
size_ty :: "ty \<Rightarrow> nat" |
68245155eb58
Modified nominal_primrec to make it work with local theories, unified syntax
berghofe
parents:
26966
diff
changeset
|
378 |
where |
21554 | 379 |
"size_ty (Tvar X) = 1" |
29097
68245155eb58
Modified nominal_primrec to make it work with local theories, unified syntax
berghofe
parents:
26966
diff
changeset
|
380 |
| "size_ty (Top) = 1" |
68245155eb58
Modified nominal_primrec to make it work with local theories, unified syntax
berghofe
parents:
26966
diff
changeset
|
381 |
| "size_ty (T1 \<rightarrow> T2) = (size_ty T1) + (size_ty T2) + 1" |
30091
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
382 |
| "X \<sharp> T1 \<Longrightarrow> size_ty (\<forall>X<:T1. T2) = (size_ty T1) + (size_ty T2) + 1" |
80142 | 383 |
by (finite_guess | fresh_guess | simp)+ |
20395
9a60e3151244
added definition for size and substitution using the recursion
urbanc
parents:
19972
diff
changeset
|
384 |
|
21554 | 385 |
nominal_primrec |
81127 | 386 |
subst_ty :: "ty \<Rightarrow> tyvrs \<Rightarrow> ty \<Rightarrow> ty" (\<open>_[_ \<leadsto> _]\<^sub>\<tau>\<close> [300, 0, 0] 300) |
29097
68245155eb58
Modified nominal_primrec to make it work with local theories, unified syntax
berghofe
parents:
26966
diff
changeset
|
387 |
where |
81127 | 388 |
"(Tvar X)[Y \<leadsto> T]\<^sub>\<tau> = (if X=Y then T else Tvar X)" |
389 |
| "(Top)[Y \<leadsto> T]\<^sub>\<tau> = Top" |
|
390 |
| "(T\<^sub>1 \<rightarrow> T\<^sub>2)[Y \<leadsto> T]\<^sub>\<tau> = T\<^sub>1[Y \<leadsto> T]\<^sub>\<tau> \<rightarrow> T\<^sub>2[Y \<leadsto> T]\<^sub>\<tau>" |
|
391 |
| "X\<sharp>(Y,T,T\<^sub>1) \<Longrightarrow> (\<forall>X<:T\<^sub>1. T\<^sub>2)[Y \<leadsto> T]\<^sub>\<tau> = (\<forall>X<:T\<^sub>1[Y \<leadsto> T]\<^sub>\<tau>. T\<^sub>2[Y \<leadsto> T]\<^sub>\<tau>)" |
|
80142 | 392 |
by (finite_guess | fresh_guess | simp add: abs_fresh)+ |
18577
a636846a02c7
added more documentation; will now try out a modification
urbanc
parents:
18424
diff
changeset
|
393 |
|
30091
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
394 |
lemma subst_eqvt[eqvt]: |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
395 |
fixes pi::"tyvrs prm" |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
396 |
and T::"ty" |
81127 | 397 |
shows "pi\<bullet>(T[X \<leadsto> T']\<^sub>\<tau>) = (pi\<bullet>T)[(pi\<bullet>X) \<leadsto> (pi\<bullet>T')]\<^sub>\<tau>" |
30091
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
398 |
by (nominal_induct T avoiding: X T' rule: ty.strong_induct) |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
399 |
(perm_simp add: fresh_bij)+ |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
400 |
|
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
401 |
lemma subst_eqvt'[eqvt]: |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
402 |
fixes pi::"vrs prm" |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
403 |
and T::"ty" |
81127 | 404 |
shows "pi\<bullet>(T[X \<leadsto> T']\<^sub>\<tau>) = (pi\<bullet>T)[(pi\<bullet>X) \<leadsto> (pi\<bullet>T')]\<^sub>\<tau>" |
30091
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
405 |
by (nominal_induct T avoiding: X T' rule: ty.strong_induct) |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
406 |
(perm_simp add: fresh_left)+ |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
407 |
|
30986
047fa04a9fe8
deleted thm-attributes "fresh" and "bij" (not used); same features can later be implemented by simpler means
Christian Urban <urbanc@in.tum.de>
parents:
30091
diff
changeset
|
408 |
lemma type_subst_fresh: |
30091
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
409 |
fixes X::"tyvrs" |
32011 | 410 |
assumes "X\<sharp>T" and "X\<sharp>P" |
81127 | 411 |
shows "X\<sharp>T[Y \<leadsto> P]\<^sub>\<tau>" |
80142 | 412 |
using assms |
413 |
by (nominal_induct T avoiding: X Y P rule:ty.strong_induct) |
|
414 |
(auto simp: abs_fresh) |
|
30091
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
415 |
|
30986
047fa04a9fe8
deleted thm-attributes "fresh" and "bij" (not used); same features can later be implemented by simpler means
Christian Urban <urbanc@in.tum.de>
parents:
30091
diff
changeset
|
416 |
lemma fresh_type_subst_fresh: |
80142 | 417 |
assumes "X\<sharp>T'" |
81127 | 418 |
shows "X\<sharp>T[X \<leadsto> T']\<^sub>\<tau>" |
80142 | 419 |
using assms |
420 |
by (nominal_induct T avoiding: X T' rule: ty.strong_induct) |
|
421 |
(auto simp: fresh_atm abs_fresh) |
|
30091
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
422 |
|
32011 | 423 |
lemma type_subst_identity: |
81127 | 424 |
"X\<sharp>T \<Longrightarrow> T[X \<leadsto> U]\<^sub>\<tau> = T" |
30091
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
425 |
by (nominal_induct T avoiding: X U rule: ty.strong_induct) |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
426 |
(simp_all add: fresh_atm abs_fresh) |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
427 |
|
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
428 |
lemma type_substitution_lemma: |
81127 | 429 |
"X \<noteq> Y \<Longrightarrow> X\<sharp>L \<Longrightarrow> M[X \<leadsto> N]\<^sub>\<tau>[Y \<leadsto> L]\<^sub>\<tau> = M[Y \<leadsto> L]\<^sub>\<tau>[X \<leadsto> N[Y \<leadsto> L]\<^sub>\<tau>]\<^sub>\<tau>" |
30091
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
430 |
by (nominal_induct M avoiding: X Y N L rule: ty.strong_induct) |
80142 | 431 |
(auto simp: type_subst_fresh type_subst_identity) |
30091
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
432 |
|
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
433 |
lemma type_subst_rename: |
81127 | 434 |
"Y\<sharp>T \<Longrightarrow> ([(Y,X)]\<bullet>T)[Y \<leadsto> U]\<^sub>\<tau> = T[X \<leadsto> U]\<^sub>\<tau>" |
30091
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
435 |
by (nominal_induct T avoiding: X Y U rule: ty.strong_induct) |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
436 |
(simp_all add: fresh_atm calc_atm abs_fresh fresh_aux) |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
437 |
|
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
438 |
nominal_primrec |
81127 | 439 |
subst_tyb :: "binding \<Rightarrow> tyvrs \<Rightarrow> ty \<Rightarrow> binding" (\<open>_[_ \<leadsto> _]\<^sub>b\<close> [100,100,100] 100) |
30091
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
440 |
where |
81127 | 441 |
"(TVarB X U)[Y \<leadsto> T]\<^sub>b = TVarB X (U[Y \<leadsto> T]\<^sub>\<tau>)" |
442 |
| "(VarB X U)[Y \<leadsto> T]\<^sub>b = VarB X (U[Y \<leadsto> T]\<^sub>\<tau>)" |
|
30091
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
443 |
by auto |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
444 |
|
30986
047fa04a9fe8
deleted thm-attributes "fresh" and "bij" (not used); same features can later be implemented by simpler means
Christian Urban <urbanc@in.tum.de>
parents:
30091
diff
changeset
|
445 |
lemma binding_subst_fresh: |
30091
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
446 |
fixes X::"tyvrs" |
32011 | 447 |
assumes "X\<sharp>a" |
448 |
and "X\<sharp>P" |
|
81127 | 449 |
shows "X\<sharp>a[Y \<leadsto> P]\<^sub>b" |
30091
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
450 |
using assms |
30986
047fa04a9fe8
deleted thm-attributes "fresh" and "bij" (not used); same features can later be implemented by simpler means
Christian Urban <urbanc@in.tum.de>
parents:
30091
diff
changeset
|
451 |
by (nominal_induct a rule: binding.strong_induct) |
80142 | 452 |
(auto simp: type_subst_fresh) |
30091
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
453 |
|
30986
047fa04a9fe8
deleted thm-attributes "fresh" and "bij" (not used); same features can later be implemented by simpler means
Christian Urban <urbanc@in.tum.de>
parents:
30091
diff
changeset
|
454 |
lemma binding_subst_identity: |
81127 | 455 |
shows "X\<sharp>B \<Longrightarrow> B[X \<leadsto> U]\<^sub>b = B" |
30986
047fa04a9fe8
deleted thm-attributes "fresh" and "bij" (not used); same features can later be implemented by simpler means
Christian Urban <urbanc@in.tum.de>
parents:
30091
diff
changeset
|
456 |
by (induct B rule: binding.induct) |
047fa04a9fe8
deleted thm-attributes "fresh" and "bij" (not used); same features can later be implemented by simpler means
Christian Urban <urbanc@in.tum.de>
parents:
30091
diff
changeset
|
457 |
(simp_all add: fresh_atm type_subst_identity) |
30091
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
458 |
|
81127 | 459 |
primrec subst_tyc :: "env \<Rightarrow> tyvrs \<Rightarrow> ty \<Rightarrow> env" (\<open>_[_ \<leadsto> _]\<^sub>e\<close> [100,100,100] 100) where |
460 |
"([])[Y \<leadsto> T]\<^sub>e= []" |
|
461 |
| "(B#\<Gamma>)[Y \<leadsto> T]\<^sub>e = (B[Y \<leadsto> T]\<^sub>b)#(\<Gamma>[Y \<leadsto> T]\<^sub>e)" |
|
30091
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
462 |
|
30986
047fa04a9fe8
deleted thm-attributes "fresh" and "bij" (not used); same features can later be implemented by simpler means
Christian Urban <urbanc@in.tum.de>
parents:
30091
diff
changeset
|
463 |
lemma ctxt_subst_fresh': |
30091
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
464 |
fixes X::"tyvrs" |
32011 | 465 |
assumes "X\<sharp>\<Gamma>" |
466 |
and "X\<sharp>P" |
|
81127 | 467 |
shows "X\<sharp>\<Gamma>[Y \<leadsto> P]\<^sub>e" |
30091
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
468 |
using assms |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
469 |
by (induct \<Gamma>) |
80142 | 470 |
(auto simp: fresh_list_cons binding_subst_fresh) |
30091
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
471 |
|
81127 | 472 |
lemma ctxt_subst_mem_TVarB: "TVarB X T \<in> set \<Gamma> \<Longrightarrow> TVarB X (T[Y \<leadsto> U]\<^sub>\<tau>) \<in> set (\<Gamma>[Y \<leadsto> U]\<^sub>e)" |
30091
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
473 |
by (induct \<Gamma>) auto |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
474 |
|
81127 | 475 |
lemma ctxt_subst_mem_VarB: "VarB x T \<in> set \<Gamma> \<Longrightarrow> VarB x (T[Y \<leadsto> U]\<^sub>\<tau>) \<in> set (\<Gamma>[Y \<leadsto> U]\<^sub>e)" |
30091
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
476 |
by (induct \<Gamma>) auto |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
477 |
|
81127 | 478 |
lemma ctxt_subst_identity: "X\<sharp>\<Gamma> \<Longrightarrow> \<Gamma>[X \<leadsto> U]\<^sub>e = \<Gamma>" |
30091
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
479 |
by (induct \<Gamma>) (simp_all add: fresh_list_cons binding_subst_identity) |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
480 |
|
81127 | 481 |
lemma ctxt_subst_append: "(\<Delta> @ \<Gamma>)[X \<leadsto> T]\<^sub>e = \<Delta>[X \<leadsto> T]\<^sub>e @ \<Gamma>[X \<leadsto> T]\<^sub>e" |
30091
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
482 |
by (induct \<Delta>) simp_all |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
483 |
|
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
484 |
nominal_primrec |
81127 | 485 |
subst_trm :: "trm \<Rightarrow> vrs \<Rightarrow> trm \<Rightarrow> trm" (\<open>_[_ \<leadsto> _]\<close> [300, 0, 0] 300) |
30091
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
486 |
where |
81127 | 487 |
"(Var x)[y \<leadsto> t'] = (if x=y then t' else (Var x))" |
488 |
| "(t1 \<cdot> t2)[y \<leadsto> t'] = t1[y \<leadsto> t'] \<cdot> t2[y \<leadsto> t']" |
|
489 |
| "(t \<cdot>\<^sub>\<tau> T)[y \<leadsto> t'] = t[y \<leadsto> t'] \<cdot>\<^sub>\<tau> T" |
|
490 |
| "X\<sharp>(T,t') \<Longrightarrow> (\<lambda>X<:T. t)[y \<leadsto> t'] = (\<lambda>X<:T. t[y \<leadsto> t'])" |
|
491 |
| "x\<sharp>(y,t') \<Longrightarrow> (\<lambda>x:T. t)[y \<leadsto> t'] = (\<lambda>x:T. t[y \<leadsto> t'])" |
|
80149 | 492 |
by (finite_guess | simp add: abs_fresh | fresh_guess add: ty_vrs_fresh abs_fresh)+ |
30091
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
493 |
|
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
494 |
lemma subst_trm_fresh_tyvar: |
32011 | 495 |
fixes X::"tyvrs" |
81127 | 496 |
shows "X\<sharp>t \<Longrightarrow> X\<sharp>u \<Longrightarrow> X\<sharp>t[x \<leadsto> u]" |
30091
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
497 |
by (nominal_induct t avoiding: x u rule: trm.strong_induct) |
80142 | 498 |
(auto simp: abs_fresh) |
30091
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
499 |
|
32011 | 500 |
lemma subst_trm_fresh_var: |
81127 | 501 |
"x\<sharp>u \<Longrightarrow> x\<sharp>t[x \<leadsto> u]" |
30091
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
502 |
by (nominal_induct t avoiding: x u rule: trm.strong_induct) |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
503 |
(simp_all add: abs_fresh fresh_atm ty_vrs_fresh) |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
504 |
|
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
505 |
lemma subst_trm_eqvt[eqvt]: |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
506 |
fixes pi::"tyvrs prm" |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
507 |
and t::"trm" |
81127 | 508 |
shows "pi\<bullet>(t[x \<leadsto> u]) = (pi\<bullet>t)[(pi\<bullet>x) \<leadsto> (pi\<bullet>u)]" |
30091
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
509 |
by (nominal_induct t avoiding: x u rule: trm.strong_induct) |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
510 |
(perm_simp add: fresh_left)+ |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
511 |
|
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
512 |
lemma subst_trm_eqvt'[eqvt]: |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
513 |
fixes pi::"vrs prm" |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
514 |
and t::"trm" |
81127 | 515 |
shows "pi\<bullet>(t[x \<leadsto> u]) = (pi\<bullet>t)[(pi\<bullet>x) \<leadsto> (pi\<bullet>u)]" |
30091
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
516 |
by (nominal_induct t avoiding: x u rule: trm.strong_induct) |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
517 |
(perm_simp add: fresh_left)+ |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
518 |
|
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
519 |
lemma subst_trm_rename: |
81127 | 520 |
"y\<sharp>t \<Longrightarrow> ([(y, x)] \<bullet> t)[y \<leadsto> u] = t[x \<leadsto> u]" |
30091
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
521 |
by (nominal_induct t avoiding: x y u rule: trm.strong_induct) |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
522 |
(simp_all add: fresh_atm calc_atm abs_fresh fresh_aux ty_vrs_fresh perm_fresh_fresh) |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
523 |
|
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
524 |
nominal_primrec (freshness_context: "T2::ty") |
81127 | 525 |
subst_trm_ty :: "trm \<Rightarrow> tyvrs \<Rightarrow> ty \<Rightarrow> trm" (\<open>_[_ \<leadsto>\<^sub>\<tau> _]\<close> [300, 0, 0] 300) |
30091
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
526 |
where |
81127 | 527 |
"(Var x)[Y \<leadsto>\<^sub>\<tau> T2] = Var x" |
528 |
| "(t1 \<cdot> t2)[Y \<leadsto>\<^sub>\<tau> T2] = t1[Y \<leadsto>\<^sub>\<tau> T2] \<cdot> t2[Y \<leadsto>\<^sub>\<tau> T2]" |
|
529 |
| "(t1 \<cdot>\<^sub>\<tau> T)[Y \<leadsto>\<^sub>\<tau> T2] = t1[Y \<leadsto>\<^sub>\<tau> T2] \<cdot>\<^sub>\<tau> T[Y \<leadsto> T2]\<^sub>\<tau>" |
|
530 |
| "X\<sharp>(Y,T,T2) \<Longrightarrow> (\<lambda>X<:T. t)[Y \<leadsto>\<^sub>\<tau> T2] = (\<lambda>X<:T[Y \<leadsto> T2]\<^sub>\<tau>. t[Y \<leadsto>\<^sub>\<tau> T2])" |
|
531 |
| "(\<lambda>x:T. t)[Y \<leadsto>\<^sub>\<tau> T2] = (\<lambda>x:T[Y \<leadsto> T2]\<^sub>\<tau>. t[Y \<leadsto>\<^sub>\<tau> T2])" |
|
80142 | 532 |
apply(finite_guess | simp add: abs_fresh ty_vrs_fresh type_subst_fresh)+ |
30091
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
533 |
apply(fresh_guess add: ty_vrs_fresh abs_fresh)+ |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
534 |
done |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
535 |
|
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
536 |
lemma subst_trm_ty_fresh: |
32011 | 537 |
fixes X::"tyvrs" |
81127 | 538 |
shows "X\<sharp>t \<Longrightarrow> X\<sharp>T \<Longrightarrow> X\<sharp>t[Y \<leadsto>\<^sub>\<tau> T]" |
30091
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
539 |
by (nominal_induct t avoiding: Y T rule: trm.strong_induct) |
80142 | 540 |
(auto simp: abs_fresh type_subst_fresh) |
30091
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
541 |
|
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
542 |
lemma subst_trm_ty_fresh': |
81127 | 543 |
"X\<sharp>T \<Longrightarrow> X\<sharp>t[X \<leadsto>\<^sub>\<tau> T]" |
30091
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
544 |
by (nominal_induct t avoiding: X T rule: trm.strong_induct) |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
545 |
(simp_all add: abs_fresh fresh_type_subst_fresh fresh_atm) |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
546 |
|
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
547 |
lemma subst_trm_ty_eqvt[eqvt]: |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
548 |
fixes pi::"tyvrs prm" |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
549 |
and t::"trm" |
81127 | 550 |
shows "pi\<bullet>(t[X \<leadsto>\<^sub>\<tau> T]) = (pi\<bullet>t)[(pi\<bullet>X) \<leadsto>\<^sub>\<tau> (pi\<bullet>T)]" |
30091
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
551 |
by (nominal_induct t avoiding: X T rule: trm.strong_induct) |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
552 |
(perm_simp add: fresh_bij subst_eqvt)+ |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
553 |
|
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
554 |
lemma subst_trm_ty_eqvt'[eqvt]: |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
555 |
fixes pi::"vrs prm" |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
556 |
and t::"trm" |
81127 | 557 |
shows "pi\<bullet>(t[X \<leadsto>\<^sub>\<tau> T]) = (pi\<bullet>t)[(pi\<bullet>X) \<leadsto>\<^sub>\<tau> (pi\<bullet>T)]" |
30091
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
558 |
by (nominal_induct t avoiding: X T rule: trm.strong_induct) |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
559 |
(perm_simp add: fresh_left subst_eqvt')+ |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
560 |
|
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
561 |
lemma subst_trm_ty_rename: |
81127 | 562 |
"Y\<sharp>t \<Longrightarrow> ([(Y, X)] \<bullet> t)[Y \<leadsto>\<^sub>\<tau> U] = t[X \<leadsto>\<^sub>\<tau> U]" |
30091
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
563 |
by (nominal_induct t avoiding: X Y U rule: trm.strong_induct) |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
564 |
(simp_all add: fresh_atm calc_atm abs_fresh fresh_aux type_subst_rename) |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
565 |
|
63167 | 566 |
section \<open>Subtyping-Relation\<close> |
18246 | 567 |
|
63167 | 568 |
text \<open>The definition for the subtyping-relation follows quite closely what is written |
18650 | 569 |
in the POPLmark-paper, except for the premises dealing with well-formed contexts and |
69597 | 570 |
the freshness constraint \<^term>\<open>X\<sharp>\<Gamma>\<close> in the \<open>S_Forall\<close>-rule. (The freshness |
18650 | 571 |
constraint is specific to the \emph{nominal approach}. Note, however, that the constraint |
572 |
does \emph{not} make the subtyping-relation ``partial"\ldots because we work over |
|
63167 | 573 |
$\alpha$-equivalence classes.)\<close> |
18628 | 574 |
|
23760 | 575 |
inductive |
80914
d97fdabd9e2b
standardize mixfix annotations via "isabelle update -a -u mixfix_cartouches" --- to simplify systematic editing;
wenzelm
parents:
80149
diff
changeset
|
576 |
subtype_of :: "env \<Rightarrow> ty \<Rightarrow> ty \<Rightarrow> bool" (\<open>_\<turnstile>_<:_\<close> [100,100,100] 100) |
22436 | 577 |
where |
30091
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
578 |
SA_Top[intro]: "\<lbrakk>\<turnstile> \<Gamma> ok; S closed_in \<Gamma>\<rbrakk> \<Longrightarrow> \<Gamma> \<turnstile> S <: Top" |
32011 | 579 |
| SA_refl_TVar[intro]: "\<lbrakk>\<turnstile> \<Gamma> ok; X \<in> ty_dom \<Gamma>\<rbrakk>\<Longrightarrow> \<Gamma> \<turnstile> Tvar X <: Tvar X" |
30091
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
580 |
| SA_trans_TVar[intro]: "\<lbrakk>(TVarB X S) \<in> set \<Gamma>; \<Gamma> \<turnstile> S <: T\<rbrakk> \<Longrightarrow> \<Gamma> \<turnstile> (Tvar X) <: T" |
53015
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
50252
diff
changeset
|
581 |
| SA_arrow[intro]: "\<lbrakk>\<Gamma> \<turnstile> T\<^sub>1 <: S\<^sub>1; \<Gamma> \<turnstile> S\<^sub>2 <: T\<^sub>2\<rbrakk> \<Longrightarrow> \<Gamma> \<turnstile> (S\<^sub>1 \<rightarrow> S\<^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:
50252
diff
changeset
|
582 |
| SA_all[intro]: "\<lbrakk>\<Gamma> \<turnstile> T\<^sub>1 <: S\<^sub>1; ((TVarB X T\<^sub>1)#\<Gamma>) \<turnstile> S\<^sub>2 <: T\<^sub>2\<rbrakk> \<Longrightarrow> \<Gamma> \<turnstile> (\<forall>X<:S\<^sub>1. S\<^sub>2) <: (\<forall>X<:T\<^sub>1. T\<^sub>2)" |
22537 | 583 |
|
584 |
lemma subtype_implies_ok: |
|
585 |
fixes X::"tyvrs" |
|
586 |
assumes a: "\<Gamma> \<turnstile> S <: T" |
|
587 |
shows "\<turnstile> \<Gamma> ok" |
|
588 |
using a by (induct) (auto) |
|
18246 | 589 |
|
590 |
lemma subtype_implies_closed: |
|
591 |
assumes a: "\<Gamma> \<turnstile> S <: T" |
|
592 |
shows "S closed_in \<Gamma> \<and> T closed_in \<Gamma>" |
|
593 |
using a |
|
594 |
proof (induct) |
|
30091
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
595 |
case (SA_Top \<Gamma> S) |
18424 | 596 |
have "Top closed_in \<Gamma>" by (simp add: closed_in_def ty.supp) |
18246 | 597 |
moreover |
598 |
have "S closed_in \<Gamma>" by fact |
|
599 |
ultimately show "S closed_in \<Gamma> \<and> Top closed_in \<Gamma>" by simp |
|
600 |
next |
|
30091
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
601 |
case (SA_trans_TVar X S \<Gamma> T) |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
602 |
have "(TVarB X S)\<in>set \<Gamma>" by fact |
32011 | 603 |
hence "X \<in> ty_dom \<Gamma>" by (rule ty_dom_inclusion) |
18577
a636846a02c7
added more documentation; will now try out a modification
urbanc
parents:
18424
diff
changeset
|
604 |
hence "(Tvar X) closed_in \<Gamma>" by (simp add: closed_in_def ty.supp supp_atm) |
18246 | 605 |
moreover |
606 |
have "S closed_in \<Gamma> \<and> T closed_in \<Gamma>" by fact |
|
607 |
hence "T closed_in \<Gamma>" by force |
|
18577
a636846a02c7
added more documentation; will now try out a modification
urbanc
parents:
18424
diff
changeset
|
608 |
ultimately show "(Tvar X) closed_in \<Gamma> \<and> T closed_in \<Gamma>" by simp |
80142 | 609 |
qed (auto simp: closed_in_def ty.supp supp_atm abs_supp) |
18246 | 610 |
|
611 |
lemma subtype_implies_fresh: |
|
612 |
fixes X::"tyvrs" |
|
613 |
assumes a1: "\<Gamma> \<turnstile> S <: T" |
|
614 |
and a2: "X\<sharp>\<Gamma>" |
|
18424 | 615 |
shows "X\<sharp>S \<and> X\<sharp>T" |
18246 | 616 |
proof - |
617 |
from a1 have "\<turnstile> \<Gamma> ok" by (rule subtype_implies_ok) |
|
32011 | 618 |
with a2 have "X\<sharp>ty_dom(\<Gamma>)" by (simp add: fresh_dom) |
18424 | 619 |
moreover |
18246 | 620 |
from a1 have "S closed_in \<Gamma> \<and> T closed_in \<Gamma>" by (rule subtype_implies_closed) |
32011 | 621 |
hence "supp S \<subseteq> ((supp (ty_dom \<Gamma>))::tyvrs set)" |
622 |
and "supp T \<subseteq> ((supp (ty_dom \<Gamma>))::tyvrs set)" by (simp_all add: ty_dom_supp closed_in_def) |
|
80142 | 623 |
ultimately show "X\<sharp>S \<and> X\<sharp>T" by (force simp: supp_prod fresh_def) |
18246 | 624 |
qed |
625 |
||
32011 | 626 |
lemma valid_ty_dom_fresh: |
30091
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
627 |
fixes X::"tyvrs" |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
628 |
assumes valid: "\<turnstile> \<Gamma> ok" |
32011 | 629 |
shows "X\<sharp>(ty_dom \<Gamma>) = X\<sharp>\<Gamma>" |
30091
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
630 |
using valid |
80142 | 631 |
proof induct |
632 |
case valid_nil |
|
633 |
then show ?case by auto |
|
634 |
next |
|
635 |
case (valid_consT \<Gamma> X T) |
|
636 |
then show ?case |
|
637 |
by (auto simp: fresh_list_cons closed_in_fresh |
|
638 |
fresh_fin_insert [OF pt_tyvrs_inst at_tyvrs_inst fs_tyvrs_inst] finite_doms) |
|
639 |
next |
|
640 |
case (valid_cons \<Gamma> x T) |
|
641 |
then show ?case |
|
642 |
using fresh_atm by (auto simp: fresh_list_cons closed_in_fresh) |
|
643 |
qed |
|
30091
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
644 |
|
22730
8bcc8809ed3b
nominal_inductive no longer proves equivariance.
berghofe
parents:
22542
diff
changeset
|
645 |
equivariance subtype_of |
8bcc8809ed3b
nominal_inductive no longer proves equivariance.
berghofe
parents:
22542
diff
changeset
|
646 |
|
30091
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
647 |
nominal_inductive subtype_of |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
648 |
apply (simp_all add: abs_fresh) |
80142 | 649 |
apply (fastforce simp: valid_ty_dom_fresh dest: subtype_implies_ok) |
650 |
apply (force simp: closed_in_fresh dest: subtype_implies_closed subtype_implies_ok)+ |
|
30091
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
651 |
done |
18246 | 652 |
|
63167 | 653 |
section \<open>Reflexivity of Subtyping\<close> |
18246 | 654 |
|
655 |
lemma subtype_reflexivity: |
|
18353
4dd468ccfdf7
transitivity should be now in a reasonable state. But
urbanc
parents:
18306
diff
changeset
|
656 |
assumes a: "\<turnstile> \<Gamma> ok" |
18424 | 657 |
and b: "T closed_in \<Gamma>" |
18353
4dd468ccfdf7
transitivity should be now in a reasonable state. But
urbanc
parents:
18306
diff
changeset
|
658 |
shows "\<Gamma> \<turnstile> T <: T" |
4dd468ccfdf7
transitivity should be now in a reasonable state. But
urbanc
parents:
18306
diff
changeset
|
659 |
using a b |
26966
071f40487734
made the naming of the induction principles consistent: weak_induct is
urbanc
parents:
26091
diff
changeset
|
660 |
proof(nominal_induct T avoiding: \<Gamma> rule: ty.strong_induct) |
53015
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
50252
diff
changeset
|
661 |
case (Forall X T\<^sub>1 T\<^sub>2) |
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
50252
diff
changeset
|
662 |
have ih_T\<^sub>1: "\<And>\<Gamma>. \<lbrakk>\<turnstile> \<Gamma> ok; T\<^sub>1 closed_in \<Gamma>\<rbrakk> \<Longrightarrow> \<Gamma> \<turnstile> T\<^sub>1 <: T\<^sub>1" by fact |
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
50252
diff
changeset
|
663 |
have ih_T\<^sub>2: "\<And>\<Gamma>. \<lbrakk>\<turnstile> \<Gamma> ok; T\<^sub>2 closed_in \<Gamma>\<rbrakk> \<Longrightarrow> \<Gamma> \<turnstile> T\<^sub>2 <: T\<^sub>2" by fact |
18424 | 664 |
have fresh_cond: "X\<sharp>\<Gamma>" by fact |
32011 | 665 |
hence fresh_ty_dom: "X\<sharp>(ty_dom \<Gamma>)" by (simp add: fresh_dom) |
53015
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
50252
diff
changeset
|
666 |
have "(\<forall>X<:T\<^sub>2. T\<^sub>1) closed_in \<Gamma>" by fact |
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
50252
diff
changeset
|
667 |
hence closed\<^sub>T2: "T\<^sub>2 closed_in \<Gamma>" and closed\<^sub>T1: "T\<^sub>1 closed_in ((TVarB X T\<^sub>2)#\<Gamma>)" |
80142 | 668 |
by (auto simp: closed_in_def ty.supp abs_supp) |
18424 | 669 |
have ok: "\<turnstile> \<Gamma> ok" by fact |
53015
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
50252
diff
changeset
|
670 |
hence ok': "\<turnstile> ((TVarB X T\<^sub>2)#\<Gamma>) ok" using closed\<^sub>T2 fresh_ty_dom by simp |
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
50252
diff
changeset
|
671 |
have "\<Gamma> \<turnstile> T\<^sub>2 <: T\<^sub>2" using ih_T\<^sub>2 closed\<^sub>T2 ok by simp |
18353
4dd468ccfdf7
transitivity should be now in a reasonable state. But
urbanc
parents:
18306
diff
changeset
|
672 |
moreover |
53015
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
50252
diff
changeset
|
673 |
have "((TVarB X T\<^sub>2)#\<Gamma>) \<turnstile> T\<^sub>1 <: T\<^sub>1" using ih_T\<^sub>1 closed\<^sub>T1 ok' by simp |
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
50252
diff
changeset
|
674 |
ultimately show "\<Gamma> \<turnstile> (\<forall>X<:T\<^sub>2. T\<^sub>1) <: (\<forall>X<:T\<^sub>2. T\<^sub>1)" using fresh_cond |
30091
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
675 |
by (simp add: subtype_of.SA_all) |
80142 | 676 |
qed (auto simp: closed_in_def ty.supp supp_atm) |
18246 | 677 |
|
18621 | 678 |
lemma subtype_reflexivity_semiautomated: |
18305
a780f9c1538b
changed everything until the interesting transitivity_narrowing
urbanc
parents:
18269
diff
changeset
|
679 |
assumes a: "\<turnstile> \<Gamma> ok" |
a780f9c1538b
changed everything until the interesting transitivity_narrowing
urbanc
parents:
18269
diff
changeset
|
680 |
and b: "T closed_in \<Gamma>" |
a780f9c1538b
changed everything until the interesting transitivity_narrowing
urbanc
parents:
18269
diff
changeset
|
681 |
shows "\<Gamma> \<turnstile> T <: T" |
a780f9c1538b
changed everything until the interesting transitivity_narrowing
urbanc
parents:
18269
diff
changeset
|
682 |
using a b |
26966
071f40487734
made the naming of the induction principles consistent: weak_induct is
urbanc
parents:
26091
diff
changeset
|
683 |
apply(nominal_induct T avoiding: \<Gamma> rule: ty.strong_induct) |
80142 | 684 |
apply(auto simp: ty.supp abs_supp supp_atm closed_in_def) |
67443
3abf6a722518
standardized towards new-style formal comments: isabelle update_comments;
wenzelm
parents:
66453
diff
changeset
|
685 |
\<comment> \<open>Too bad that this instantiation cannot be found automatically by |
18621 | 686 |
\isakeyword{auto}; \isakeyword{blast} would find it if we had not used |
63167 | 687 |
an explicit definition for \<open>closed_in_def\<close>.\<close> |
30091
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
688 |
apply(drule_tac x="(TVarB tyvrs ty2)#\<Gamma>" in meta_spec) |
32011 | 689 |
apply(force dest: fresh_dom simp add: closed_in_def) |
18246 | 690 |
done |
691 |
||
63167 | 692 |
section \<open>Weakening\<close> |
18246 | 693 |
|
63167 | 694 |
text \<open>In order to prove weakening we introduce the notion of a type-context extending |
18628 | 695 |
another. This generalization seems to make the proof for weakening to be |
63167 | 696 |
smoother than if we had strictly adhered to the version in the POPLmark-paper.\<close> |
18246 | 697 |
|
80914
d97fdabd9e2b
standardize mixfix annotations via "isabelle update -a -u mixfix_cartouches" --- to simplify systematic editing;
wenzelm
parents:
80149
diff
changeset
|
698 |
definition extends :: "env \<Rightarrow> env \<Rightarrow> bool" (\<open>_ extends _\<close> [100,100] 100) where |
30091
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
699 |
"\<Delta> extends \<Gamma> \<equiv> \<forall>X Q. (TVarB X Q)\<in>set \<Gamma> \<longrightarrow> (TVarB X Q)\<in>set \<Delta>" |
18246 | 700 |
|
32011 | 701 |
lemma extends_ty_dom: |
80142 | 702 |
assumes "\<Delta> extends \<Gamma>" |
32011 | 703 |
shows "ty_dom \<Gamma> \<subseteq> ty_dom \<Delta>" |
80142 | 704 |
using assms |
705 |
by (meson extends_def subsetI ty_dom_existence ty_dom_inclusion) |
|
18246 | 706 |
|
707 |
lemma extends_closed: |
|
80142 | 708 |
assumes "T closed_in \<Gamma>" and "\<Delta> extends \<Gamma>" |
18246 | 709 |
shows "T closed_in \<Delta>" |
80142 | 710 |
by (meson assms closed_in_def extends_ty_dom order.trans) |
18246 | 711 |
|
18424 | 712 |
lemma extends_memb: |
713 |
assumes a: "\<Delta> extends \<Gamma>" |
|
30091
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
714 |
and b: "(TVarB X T) \<in> set \<Gamma>" |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
715 |
shows "(TVarB X T) \<in> set \<Delta>" |
18424 | 716 |
using a b by (simp add: extends_def) |
717 |
||
18246 | 718 |
lemma weakening: |
18353
4dd468ccfdf7
transitivity should be now in a reasonable state. But
urbanc
parents:
18306
diff
changeset
|
719 |
assumes a: "\<Gamma> \<turnstile> S <: T" |
18424 | 720 |
and b: "\<turnstile> \<Delta> ok" |
721 |
and c: "\<Delta> extends \<Gamma>" |
|
18353
4dd468ccfdf7
transitivity should be now in a reasonable state. But
urbanc
parents:
18306
diff
changeset
|
722 |
shows "\<Delta> \<turnstile> S <: T" |
4dd468ccfdf7
transitivity should be now in a reasonable state. But
urbanc
parents:
18306
diff
changeset
|
723 |
using a b c |
22537 | 724 |
proof (nominal_induct \<Gamma> S T avoiding: \<Delta> rule: subtype_of.strong_induct) |
30091
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
725 |
case (SA_Top \<Gamma> S) |
18246 | 726 |
have lh_drv_prem: "S closed_in \<Gamma>" by fact |
18353
4dd468ccfdf7
transitivity should be now in a reasonable state. But
urbanc
parents:
18306
diff
changeset
|
727 |
have "\<turnstile> \<Delta> ok" by fact |
4dd468ccfdf7
transitivity should be now in a reasonable state. But
urbanc
parents:
18306
diff
changeset
|
728 |
moreover |
4dd468ccfdf7
transitivity should be now in a reasonable state. But
urbanc
parents:
18306
diff
changeset
|
729 |
have "\<Delta> extends \<Gamma>" by fact |
18424 | 730 |
hence "S closed_in \<Delta>" using lh_drv_prem by (simp only: extends_closed) |
18353
4dd468ccfdf7
transitivity should be now in a reasonable state. But
urbanc
parents:
18306
diff
changeset
|
731 |
ultimately show "\<Delta> \<turnstile> S <: Top" by force |
18246 | 732 |
next |
30091
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
733 |
case (SA_trans_TVar X S \<Gamma> T) |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
734 |
have lh_drv_prem: "(TVarB X S) \<in> set \<Gamma>" by fact |
18353
4dd468ccfdf7
transitivity should be now in a reasonable state. But
urbanc
parents:
18306
diff
changeset
|
735 |
have ih: "\<And>\<Delta>. \<turnstile> \<Delta> ok \<Longrightarrow> \<Delta> extends \<Gamma> \<Longrightarrow> \<Delta> \<turnstile> S <: T" by fact |
4dd468ccfdf7
transitivity should be now in a reasonable state. But
urbanc
parents:
18306
diff
changeset
|
736 |
have ok: "\<turnstile> \<Delta> ok" by fact |
4dd468ccfdf7
transitivity should be now in a reasonable state. But
urbanc
parents:
18306
diff
changeset
|
737 |
have extends: "\<Delta> extends \<Gamma>" by fact |
30091
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
738 |
have "(TVarB X S) \<in> set \<Delta>" using lh_drv_prem extends by (simp only: extends_memb) |
18353
4dd468ccfdf7
transitivity should be now in a reasonable state. But
urbanc
parents:
18306
diff
changeset
|
739 |
moreover |
4dd468ccfdf7
transitivity should be now in a reasonable state. But
urbanc
parents:
18306
diff
changeset
|
740 |
have "\<Delta> \<turnstile> S <: T" using ok extends ih by simp |
18577
a636846a02c7
added more documentation; will now try out a modification
urbanc
parents:
18424
diff
changeset
|
741 |
ultimately show "\<Delta> \<turnstile> Tvar X <: T" using ok by force |
18246 | 742 |
next |
30091
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
743 |
case (SA_refl_TVar \<Gamma> X) |
32011 | 744 |
have lh_drv_prem: "X \<in> ty_dom \<Gamma>" by fact |
18353
4dd468ccfdf7
transitivity should be now in a reasonable state. But
urbanc
parents:
18306
diff
changeset
|
745 |
have "\<turnstile> \<Delta> ok" by fact |
4dd468ccfdf7
transitivity should be now in a reasonable state. But
urbanc
parents:
18306
diff
changeset
|
746 |
moreover |
4dd468ccfdf7
transitivity should be now in a reasonable state. But
urbanc
parents:
18306
diff
changeset
|
747 |
have "\<Delta> extends \<Gamma>" by fact |
32011 | 748 |
hence "X \<in> ty_dom \<Delta>" using lh_drv_prem by (force dest: extends_ty_dom) |
18577
a636846a02c7
added more documentation; will now try out a modification
urbanc
parents:
18424
diff
changeset
|
749 |
ultimately show "\<Delta> \<turnstile> Tvar X <: Tvar X" by force |
18246 | 750 |
next |
53015
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
50252
diff
changeset
|
751 |
case (SA_arrow \<Gamma> T\<^sub>1 S\<^sub>1 S\<^sub>2 T\<^sub>2) thus "\<Delta> \<turnstile> S\<^sub>1 \<rightarrow> S\<^sub>2 <: T\<^sub>1 \<rightarrow> T\<^sub>2" by blast |
18246 | 752 |
next |
53015
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
50252
diff
changeset
|
753 |
case (SA_all \<Gamma> T\<^sub>1 S\<^sub>1 X S\<^sub>2 T\<^sub>2) |
18424 | 754 |
have fresh_cond: "X\<sharp>\<Delta>" by fact |
32011 | 755 |
hence fresh_dom: "X\<sharp>(ty_dom \<Delta>)" by (simp add: fresh_dom) |
53015
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
50252
diff
changeset
|
756 |
have ih\<^sub>1: "\<And>\<Delta>. \<turnstile> \<Delta> ok \<Longrightarrow> \<Delta> extends \<Gamma> \<Longrightarrow> \<Delta> \<turnstile> T\<^sub>1 <: S\<^sub>1" by fact |
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
50252
diff
changeset
|
757 |
have ih\<^sub>2: "\<And>\<Delta>. \<turnstile> \<Delta> ok \<Longrightarrow> \<Delta> extends ((TVarB X T\<^sub>1)#\<Gamma>) \<Longrightarrow> \<Delta> \<turnstile> S\<^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:
50252
diff
changeset
|
758 |
have lh_drv_prem: "\<Gamma> \<turnstile> T\<^sub>1 <: S\<^sub>1" by fact |
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
50252
diff
changeset
|
759 |
hence closed\<^sub>T1: "T\<^sub>1 closed_in \<Gamma>" by (simp add: subtype_implies_closed) |
18353
4dd468ccfdf7
transitivity should be now in a reasonable state. But
urbanc
parents:
18306
diff
changeset
|
760 |
have ok: "\<turnstile> \<Delta> ok" by fact |
18424 | 761 |
have ext: "\<Delta> extends \<Gamma>" by fact |
53015
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
50252
diff
changeset
|
762 |
have "T\<^sub>1 closed_in \<Delta>" using ext closed\<^sub>T1 by (simp only: extends_closed) |
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
50252
diff
changeset
|
763 |
hence "\<turnstile> ((TVarB X T\<^sub>1)#\<Delta>) ok" using fresh_dom ok by force |
18353
4dd468ccfdf7
transitivity should be now in a reasonable state. But
urbanc
parents:
18306
diff
changeset
|
764 |
moreover |
80142 | 765 |
have "((TVarB X T\<^sub>1)#\<Delta>) extends ((TVarB X T\<^sub>1)#\<Gamma>)" using ext by (force simp: extends_def) |
53015
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
50252
diff
changeset
|
766 |
ultimately have "((TVarB X T\<^sub>1)#\<Delta>) \<turnstile> S\<^sub>2 <: T\<^sub>2" using ih\<^sub>2 by simp |
18353
4dd468ccfdf7
transitivity should be now in a reasonable state. But
urbanc
parents:
18306
diff
changeset
|
767 |
moreover |
53015
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
50252
diff
changeset
|
768 |
have "\<Delta> \<turnstile> T\<^sub>1 <: S\<^sub>1" using ok ext ih\<^sub>1 by simp |
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
50252
diff
changeset
|
769 |
ultimately show "\<Delta> \<turnstile> (\<forall>X<:S\<^sub>1. S\<^sub>2) <: (\<forall>X<:T\<^sub>1. T\<^sub>2)" using ok by (force intro: SA_all) |
18246 | 770 |
qed |
771 |
||
63167 | 772 |
text \<open>In fact all ``non-binding" cases can be solved automatically:\<close> |
18246 | 773 |
|
18628 | 774 |
lemma weakening_more_automated: |
18353
4dd468ccfdf7
transitivity should be now in a reasonable state. But
urbanc
parents:
18306
diff
changeset
|
775 |
assumes a: "\<Gamma> \<turnstile> S <: T" |
18424 | 776 |
and b: "\<turnstile> \<Delta> ok" |
777 |
and c: "\<Delta> extends \<Gamma>" |
|
18353
4dd468ccfdf7
transitivity should be now in a reasonable state. But
urbanc
parents:
18306
diff
changeset
|
778 |
shows "\<Delta> \<turnstile> S <: T" |
4dd468ccfdf7
transitivity should be now in a reasonable state. But
urbanc
parents:
18306
diff
changeset
|
779 |
using a b c |
22537 | 780 |
proof (nominal_induct \<Gamma> S T avoiding: \<Delta> rule: subtype_of.strong_induct) |
53015
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
50252
diff
changeset
|
781 |
case (SA_all \<Gamma> T\<^sub>1 S\<^sub>1 X S\<^sub>2 T\<^sub>2) |
18424 | 782 |
have fresh_cond: "X\<sharp>\<Delta>" by fact |
32011 | 783 |
hence fresh_dom: "X\<sharp>(ty_dom \<Delta>)" by (simp add: fresh_dom) |
53015
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
50252
diff
changeset
|
784 |
have ih\<^sub>1: "\<And>\<Delta>. \<turnstile> \<Delta> ok \<Longrightarrow> \<Delta> extends \<Gamma> \<Longrightarrow> \<Delta> \<turnstile> T\<^sub>1 <: S\<^sub>1" by fact |
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
50252
diff
changeset
|
785 |
have ih\<^sub>2: "\<And>\<Delta>. \<turnstile> \<Delta> ok \<Longrightarrow> \<Delta> extends ((TVarB X T\<^sub>1)#\<Gamma>) \<Longrightarrow> \<Delta> \<turnstile> S\<^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:
50252
diff
changeset
|
786 |
have lh_drv_prem: "\<Gamma> \<turnstile> T\<^sub>1 <: S\<^sub>1" by fact |
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
50252
diff
changeset
|
787 |
hence closed\<^sub>T1: "T\<^sub>1 closed_in \<Gamma>" by (simp add: subtype_implies_closed) |
18353
4dd468ccfdf7
transitivity should be now in a reasonable state. But
urbanc
parents:
18306
diff
changeset
|
788 |
have ok: "\<turnstile> \<Delta> ok" by fact |
18424 | 789 |
have ext: "\<Delta> extends \<Gamma>" by fact |
53015
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
50252
diff
changeset
|
790 |
have "T\<^sub>1 closed_in \<Delta>" using ext closed\<^sub>T1 by (simp only: extends_closed) |
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
50252
diff
changeset
|
791 |
hence "\<turnstile> ((TVarB X T\<^sub>1)#\<Delta>) ok" using fresh_dom ok by force |
18628 | 792 |
moreover |
80142 | 793 |
have "((TVarB X T\<^sub>1)#\<Delta>) extends ((TVarB X T\<^sub>1)#\<Gamma>)" using ext by (force simp: extends_def) |
53015
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
50252
diff
changeset
|
794 |
ultimately have "((TVarB X T\<^sub>1)#\<Delta>) \<turnstile> S\<^sub>2 <: T\<^sub>2" using ih\<^sub>2 by simp |
18353
4dd468ccfdf7
transitivity should be now in a reasonable state. But
urbanc
parents:
18306
diff
changeset
|
795 |
moreover |
53015
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
50252
diff
changeset
|
796 |
have "\<Delta> \<turnstile> T\<^sub>1 <: S\<^sub>1" using ok ext ih\<^sub>1 by simp |
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
50252
diff
changeset
|
797 |
ultimately show "\<Delta> \<turnstile> (\<forall>X<:S\<^sub>1. S\<^sub>2) <: (\<forall>X<:T\<^sub>1. T\<^sub>2)" using ok by (force intro: SA_all) |
32011 | 798 |
qed (blast intro: extends_closed extends_memb dest: extends_ty_dom)+ |
18246 | 799 |
|
63167 | 800 |
section \<open>Transitivity and Narrowing\<close> |
18628 | 801 |
|
63167 | 802 |
text \<open>Some inversion lemmas that are needed in the transitivity and narrowing proof.\<close> |
18650 | 803 |
|
30091
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
804 |
declare ty.inject [simp add] |
18650 | 805 |
|
30091
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
806 |
inductive_cases S_TopE: "\<Gamma> \<turnstile> Top <: T" |
53015
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
50252
diff
changeset
|
807 |
inductive_cases S_ArrowE_left: "\<Gamma> \<turnstile> S\<^sub>1 \<rightarrow> S\<^sub>2 <: T" |
30091
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
808 |
|
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
809 |
declare ty.inject [simp del] |
18650 | 810 |
|
811 |
lemma S_ForallE_left: |
|
53015
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
50252
diff
changeset
|
812 |
shows "\<lbrakk>\<Gamma> \<turnstile> (\<forall>X<:S\<^sub>1. S\<^sub>2) <: T; X\<sharp>\<Gamma>; X\<sharp>S\<^sub>1; X\<sharp>T\<rbrakk> |
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
50252
diff
changeset
|
813 |
\<Longrightarrow> T = Top \<or> (\<exists>T\<^sub>1 T\<^sub>2. T = (\<forall>X<:T\<^sub>1. T\<^sub>2) \<and> \<Gamma> \<turnstile> T\<^sub>1 <: S\<^sub>1 \<and> ((TVarB X T\<^sub>1)#\<Gamma>) \<turnstile> S\<^sub>2 <: T\<^sub>2)" |
80142 | 814 |
using subtype_of.strong_cases[where X="X"] |
815 |
by(force simp: abs_fresh ty.inject alpha) |
|
18650 | 816 |
|
63167 | 817 |
text \<open>Next we prove the transitivity and narrowing for the subtyping-relation. |
18621 | 818 |
The POPLmark-paper says the following: |
819 |
||
18650 | 820 |
\begin{quote} |
18621 | 821 |
\begin{lemma}[Transitivity and Narrowing] \ |
822 |
\begin{enumerate} |
|
69597 | 823 |
\item If \<^term>\<open>\<Gamma> \<turnstile> S<:Q\<close> and \<^term>\<open>\<Gamma> \<turnstile> Q<:T\<close>, then \<^term>\<open>\<Gamma> \<turnstile> S<:T\<close>. |
824 |
\item If \<open>\<Gamma>,X<:Q,\<Delta> \<turnstile> M<:N\<close> and \<^term>\<open>\<Gamma> \<turnstile> P<:Q\<close> then \<open>\<Gamma>,X<:P,\<Delta> \<turnstile> M<:N\<close>. |
|
18621 | 825 |
\end{enumerate} |
826 |
\end{lemma} |
|
827 |
||
828 |
The two parts are proved simultaneously, by induction on the size |
|
69597 | 829 |
of \<^term>\<open>Q\<close>. The argument for part (2) assumes that part (1) has |
830 |
been established already for the \<^term>\<open>Q\<close> in question; part (1) uses |
|
831 |
part (2) only for strictly smaller \<^term>\<open>Q\<close>. |
|
18650 | 832 |
\end{quote} |
18621 | 833 |
|
69597 | 834 |
For the induction on the size of \<^term>\<open>Q\<close>, we use the induction-rule |
63167 | 835 |
\<open>measure_induct_rule\<close>: |
18621 | 836 |
|
837 |
\begin{center} |
|
838 |
@{thm measure_induct_rule[of "size_ty",no_vars]} |
|
839 |
\end{center} |
|
18410 | 840 |
|
69597 | 841 |
That means in order to show a property \<^term>\<open>P a\<close> for all \<^term>\<open>a\<close>, |
842 |
the induct-rule requires to prove that for all \<^term>\<open>x\<close> \<^term>\<open>P x\<close> holds using the |
|
843 |
assumption that for all \<^term>\<open>y\<close> whose size is strictly smaller than |
|
844 |
that of \<^term>\<open>x\<close> the property \<^term>\<open>P y\<close> holds.\<close> |
|
18353
4dd468ccfdf7
transitivity should be now in a reasonable state. But
urbanc
parents:
18306
diff
changeset
|
845 |
|
18621 | 846 |
lemma |
30091
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
847 |
shows subtype_transitivity: "\<Gamma>\<turnstile>S<:Q \<Longrightarrow> \<Gamma>\<turnstile>Q<:T \<Longrightarrow> \<Gamma>\<turnstile>S<:T" |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
848 |
and subtype_narrow: "(\<Delta>@[(TVarB X Q)]@\<Gamma>)\<turnstile>M<:N \<Longrightarrow> \<Gamma>\<turnstile>P<:Q \<Longrightarrow> (\<Delta>@[(TVarB X P)]@\<Gamma>)\<turnstile>M<:N" |
20503 | 849 |
proof (induct Q arbitrary: \<Gamma> S T \<Delta> X P M N taking: "size_ty" rule: measure_induct_rule) |
18621 | 850 |
case (less Q) |
851 |
have IH_trans: |
|
852 |
"\<And>Q' \<Gamma> S T. \<lbrakk>size_ty Q' < size_ty Q; \<Gamma>\<turnstile>S<:Q'; \<Gamma>\<turnstile>Q'<:T\<rbrakk> \<Longrightarrow> \<Gamma>\<turnstile>S<:T" by fact |
|
853 |
have IH_narrow: |
|
30091
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
854 |
"\<And>Q' \<Delta> \<Gamma> X M N P. \<lbrakk>size_ty Q' < size_ty Q; (\<Delta>@[(TVarB X Q')]@\<Gamma>)\<turnstile>M<:N; \<Gamma>\<turnstile>P<:Q'\<rbrakk> |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
855 |
\<Longrightarrow> (\<Delta>@[(TVarB X P)]@\<Gamma>)\<turnstile>M<:N" by fact |
32011 | 856 |
|
857 |
{ fix \<Gamma> S T |
|
858 |
have "\<lbrakk>\<Gamma> \<turnstile> S <: Q; \<Gamma> \<turnstile> Q <: T\<rbrakk> \<Longrightarrow> \<Gamma> \<turnstile> S <: T" |
|
859 |
proof (induct \<Gamma> S Q\<equiv>Q rule: subtype_of.induct) |
|
30091
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
860 |
case (SA_Top \<Gamma> S) |
32011 | 861 |
then have rh_drv: "\<Gamma> \<turnstile> Top <: T" by simp |
862 |
then have T_inst: "T = Top" by (auto elim: S_TopE) |
|
63167 | 863 |
from \<open>\<turnstile> \<Gamma> ok\<close> and \<open>S closed_in \<Gamma>\<close> |
32011 | 864 |
have "\<Gamma> \<turnstile> S <: Top" by auto |
865 |
then show "\<Gamma> \<turnstile> S <: T" using T_inst by simp |
|
18246 | 866 |
next |
30091
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
867 |
case (SA_trans_TVar Y U \<Gamma>) |
32011 | 868 |
then have IH_inner: "\<Gamma> \<turnstile> U <: T" by simp |
30091
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
869 |
have "(TVarB Y U) \<in> set \<Gamma>" by fact |
32011 | 870 |
with IH_inner show "\<Gamma> \<turnstile> Tvar Y <: T" by auto |
18246 | 871 |
next |
30091
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
872 |
case (SA_refl_TVar \<Gamma> X) |
32011 | 873 |
then show "\<Gamma> \<turnstile> Tvar X <: T" by simp |
18246 | 874 |
next |
53015
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
50252
diff
changeset
|
875 |
case (SA_arrow \<Gamma> Q\<^sub>1 S\<^sub>1 S\<^sub>2 Q\<^sub>2) |
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
50252
diff
changeset
|
876 |
then have rh_drv: "\<Gamma> \<turnstile> Q\<^sub>1 \<rightarrow> Q\<^sub>2 <: T" by simp |
63167 | 877 |
from \<open>Q\<^sub>1 \<rightarrow> Q\<^sub>2 = Q\<close> |
53015
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
50252
diff
changeset
|
878 |
have Q\<^sub>12_less: "size_ty Q\<^sub>1 < size_ty Q" "size_ty Q\<^sub>2 < size_ty Q" by auto |
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
50252
diff
changeset
|
879 |
have lh_drv_prm\<^sub>1: "\<Gamma> \<turnstile> Q\<^sub>1 <: S\<^sub>1" by fact |
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
50252
diff
changeset
|
880 |
have lh_drv_prm\<^sub>2: "\<Gamma> \<turnstile> S\<^sub>2 <: Q\<^sub>2" by fact |
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
50252
diff
changeset
|
881 |
from rh_drv have "T=Top \<or> (\<exists>T\<^sub>1 T\<^sub>2. T=T\<^sub>1\<rightarrow>T\<^sub>2 \<and> \<Gamma>\<turnstile>T\<^sub>1<:Q\<^sub>1 \<and> \<Gamma>\<turnstile>Q\<^sub>2<:T\<^sub>2)" |
32960
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents:
32011
diff
changeset
|
882 |
by (auto elim: S_ArrowE_left) |
18621 | 883 |
moreover |
53015
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
50252
diff
changeset
|
884 |
have "S\<^sub>1 closed_in \<Gamma>" and "S\<^sub>2 closed_in \<Gamma>" |
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
50252
diff
changeset
|
885 |
using lh_drv_prm\<^sub>1 lh_drv_prm\<^sub>2 by (simp_all add: subtype_implies_closed) |
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
50252
diff
changeset
|
886 |
hence "(S\<^sub>1 \<rightarrow> S\<^sub>2) closed_in \<Gamma>" by (simp add: closed_in_def ty.supp) |
18353
4dd468ccfdf7
transitivity should be now in a reasonable state. But
urbanc
parents:
18306
diff
changeset
|
887 |
moreover |
18424 | 888 |
have "\<turnstile> \<Gamma> ok" using rh_drv by (rule subtype_implies_ok) |
18353
4dd468ccfdf7
transitivity should be now in a reasonable state. But
urbanc
parents:
18306
diff
changeset
|
889 |
moreover |
53015
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
50252
diff
changeset
|
890 |
{ assume "\<exists>T\<^sub>1 T\<^sub>2. T = T\<^sub>1\<rightarrow>T\<^sub>2 \<and> \<Gamma> \<turnstile> T\<^sub>1 <: Q\<^sub>1 \<and> \<Gamma> \<turnstile> Q\<^sub>2 <: T\<^sub>2" |
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
50252
diff
changeset
|
891 |
then obtain T\<^sub>1 T\<^sub>2 |
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
50252
diff
changeset
|
892 |
where T_inst: "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:
50252
diff
changeset
|
893 |
and rh_drv_prm\<^sub>1: "\<Gamma> \<turnstile> T\<^sub>1 <: Q\<^sub>1" |
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
50252
diff
changeset
|
894 |
and rh_drv_prm\<^sub>2: "\<Gamma> \<turnstile> Q\<^sub>2 <: T\<^sub>2" by force |
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
50252
diff
changeset
|
895 |
from IH_trans[of "Q\<^sub>1"] |
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
50252
diff
changeset
|
896 |
have "\<Gamma> \<turnstile> T\<^sub>1 <: S\<^sub>1" using Q\<^sub>12_less rh_drv_prm\<^sub>1 lh_drv_prm\<^sub>1 by simp |
32960
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents:
32011
diff
changeset
|
897 |
moreover |
53015
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
50252
diff
changeset
|
898 |
from IH_trans[of "Q\<^sub>2"] |
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
50252
diff
changeset
|
899 |
have "\<Gamma> \<turnstile> S\<^sub>2 <: T\<^sub>2" using Q\<^sub>12_less rh_drv_prm\<^sub>2 lh_drv_prm\<^sub>2 by simp |
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
50252
diff
changeset
|
900 |
ultimately have "\<Gamma> \<turnstile> S\<^sub>1 \<rightarrow> S\<^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:
50252
diff
changeset
|
901 |
then have "\<Gamma> \<turnstile> S\<^sub>1 \<rightarrow> S\<^sub>2 <: T" using T_inst by simp |
18353
4dd468ccfdf7
transitivity should be now in a reasonable state. But
urbanc
parents:
18306
diff
changeset
|
902 |
} |
53015
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
50252
diff
changeset
|
903 |
ultimately show "\<Gamma> \<turnstile> S\<^sub>1 \<rightarrow> S\<^sub>2 <: T" by blast |
18246 | 904 |
next |
53015
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
50252
diff
changeset
|
905 |
case (SA_all \<Gamma> Q\<^sub>1 S\<^sub>1 X S\<^sub>2 Q\<^sub>2) |
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
50252
diff
changeset
|
906 |
then have rh_drv: "\<Gamma> \<turnstile> (\<forall>X<:Q\<^sub>1. Q\<^sub>2) <: T" by simp |
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
50252
diff
changeset
|
907 |
have lh_drv_prm\<^sub>1: "\<Gamma> \<turnstile> Q\<^sub>1 <: S\<^sub>1" by fact |
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
50252
diff
changeset
|
908 |
have lh_drv_prm\<^sub>2: "((TVarB X Q\<^sub>1)#\<Gamma>) \<turnstile> S\<^sub>2 <: Q\<^sub>2" by fact |
32011 | 909 |
then have "X\<sharp>\<Gamma>" by (force dest: subtype_implies_ok simp add: valid_ty_dom_fresh) |
53015
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
50252
diff
changeset
|
910 |
then have fresh_cond: "X\<sharp>\<Gamma>" "X\<sharp>Q\<^sub>1" "X\<sharp>T" using rh_drv lh_drv_prm\<^sub>1 |
32960
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents:
32011
diff
changeset
|
911 |
by (simp_all add: subtype_implies_fresh) |
18621 | 912 |
from rh_drv |
32011 | 913 |
have "T = Top \<or> |
53015
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
50252
diff
changeset
|
914 |
(\<exists>T\<^sub>1 T\<^sub>2. T = (\<forall>X<:T\<^sub>1. T\<^sub>2) \<and> \<Gamma> \<turnstile> T\<^sub>1 <: Q\<^sub>1 \<and> ((TVarB X T\<^sub>1)#\<Gamma>) \<turnstile> Q\<^sub>2 <: T\<^sub>2)" |
32960
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents:
32011
diff
changeset
|
915 |
using fresh_cond by (simp add: S_ForallE_left) |
18621 | 916 |
moreover |
53015
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
50252
diff
changeset
|
917 |
have "S\<^sub>1 closed_in \<Gamma>" and "S\<^sub>2 closed_in ((TVarB X Q\<^sub>1)#\<Gamma>)" |
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
50252
diff
changeset
|
918 |
using lh_drv_prm\<^sub>1 lh_drv_prm\<^sub>2 by (simp_all add: subtype_implies_closed) |
80142 | 919 |
then have "(\<forall>X<:S\<^sub>1. S\<^sub>2) closed_in \<Gamma>" by (force simp: closed_in_def ty.supp abs_supp) |
18353
4dd468ccfdf7
transitivity should be now in a reasonable state. But
urbanc
parents:
18306
diff
changeset
|
920 |
moreover |
18424 | 921 |
have "\<turnstile> \<Gamma> ok" using rh_drv by (rule subtype_implies_ok) |
18353
4dd468ccfdf7
transitivity should be now in a reasonable state. But
urbanc
parents:
18306
diff
changeset
|
922 |
moreover |
53015
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
50252
diff
changeset
|
923 |
{ assume "\<exists>T\<^sub>1 T\<^sub>2. T=(\<forall>X<:T\<^sub>1. T\<^sub>2) \<and> \<Gamma>\<turnstile>T\<^sub>1<:Q\<^sub>1 \<and> ((TVarB X T\<^sub>1)#\<Gamma>)\<turnstile>Q\<^sub>2<:T\<^sub>2" |
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
50252
diff
changeset
|
924 |
then obtain T\<^sub>1 T\<^sub>2 |
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
50252
diff
changeset
|
925 |
where T_inst: "T = (\<forall>X<:T\<^sub>1. T\<^sub>2)" |
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
50252
diff
changeset
|
926 |
and rh_drv_prm\<^sub>1: "\<Gamma> \<turnstile> T\<^sub>1 <: Q\<^sub>1" |
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
50252
diff
changeset
|
927 |
and rh_drv_prm\<^sub>2:"((TVarB X T\<^sub>1)#\<Gamma>) \<turnstile> Q\<^sub>2 <: T\<^sub>2" by force |
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
50252
diff
changeset
|
928 |
have "(\<forall>X<:Q\<^sub>1. Q\<^sub>2) = Q" by fact |
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
50252
diff
changeset
|
929 |
then have Q\<^sub>12_less: "size_ty Q\<^sub>1 < size_ty Q" "size_ty Q\<^sub>2 < size_ty Q" |
32960
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents:
32011
diff
changeset
|
930 |
using fresh_cond by auto |
53015
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
50252
diff
changeset
|
931 |
from IH_trans[of "Q\<^sub>1"] |
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
50252
diff
changeset
|
932 |
have "\<Gamma> \<turnstile> T\<^sub>1 <: S\<^sub>1" using lh_drv_prm\<^sub>1 rh_drv_prm\<^sub>1 Q\<^sub>12_less by blast |
32960
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents:
32011
diff
changeset
|
933 |
moreover |
53015
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
50252
diff
changeset
|
934 |
from IH_narrow[of "Q\<^sub>1" "[]"] |
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
50252
diff
changeset
|
935 |
have "((TVarB X T\<^sub>1)#\<Gamma>) \<turnstile> S\<^sub>2 <: Q\<^sub>2" using Q\<^sub>12_less lh_drv_prm\<^sub>2 rh_drv_prm\<^sub>1 by simp |
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
50252
diff
changeset
|
936 |
with IH_trans[of "Q\<^sub>2"] |
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
50252
diff
changeset
|
937 |
have "((TVarB X T\<^sub>1)#\<Gamma>) \<turnstile> S\<^sub>2 <: T\<^sub>2" using Q\<^sub>12_less rh_drv_prm\<^sub>2 by simp |
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
50252
diff
changeset
|
938 |
ultimately have "\<Gamma> \<turnstile> (\<forall>X<:S\<^sub>1. S\<^sub>2) <: (\<forall>X<:T\<^sub>1. T\<^sub>2)" |
32960
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents:
32011
diff
changeset
|
939 |
using fresh_cond by (simp add: subtype_of.SA_all) |
53015
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
50252
diff
changeset
|
940 |
hence "\<Gamma> \<turnstile> (\<forall>X<:S\<^sub>1. S\<^sub>2) <: T" using T_inst by simp |
18353
4dd468ccfdf7
transitivity should be now in a reasonable state. But
urbanc
parents:
18306
diff
changeset
|
941 |
} |
53015
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
50252
diff
changeset
|
942 |
ultimately show "\<Gamma> \<turnstile> (\<forall>X<:S\<^sub>1. S\<^sub>2) <: T" by blast |
18246 | 943 |
qed |
32011 | 944 |
} note transitivity_lemma = this |
18246 | 945 |
|
67443
3abf6a722518
standardized towards new-style formal comments: isabelle update_comments;
wenzelm
parents:
66453
diff
changeset
|
946 |
{ \<comment> \<open>The transitivity proof is now by the auxiliary lemma.\<close> |
18621 | 947 |
case 1 |
63167 | 948 |
from \<open>\<Gamma> \<turnstile> S <: Q\<close> and \<open>\<Gamma> \<turnstile> Q <: T\<close> |
32011 | 949 |
show "\<Gamma> \<turnstile> S <: T" by (rule transitivity_lemma) |
18621 | 950 |
next |
951 |
case 2 |
|
63167 | 952 |
from \<open>(\<Delta>@[(TVarB X Q)]@\<Gamma>) \<turnstile> M <: N\<close> |
953 |
and \<open>\<Gamma> \<turnstile> P<:Q\<close> |
|
30091
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
954 |
show "(\<Delta>@[(TVarB X P)]@\<Gamma>) \<turnstile> M <: N" |
34915 | 955 |
proof (induct "\<Delta>@[(TVarB X Q)]@\<Gamma>" M N arbitrary: \<Gamma> X \<Delta> rule: subtype_of.induct) |
956 |
case (SA_Top S \<Gamma> X \<Delta>) |
|
63167 | 957 |
from \<open>\<Gamma> \<turnstile> P <: Q\<close> |
34915 | 958 |
have "P closed_in \<Gamma>" by (simp add: subtype_implies_closed) |
63167 | 959 |
with \<open>\<turnstile> (\<Delta>@[(TVarB X Q)]@\<Gamma>) ok\<close> have "\<turnstile> (\<Delta>@[(TVarB X P)]@\<Gamma>) ok" |
34915 | 960 |
by (simp add: replace_type) |
18412 | 961 |
moreover |
63167 | 962 |
from \<open>S closed_in (\<Delta>@[(TVarB X Q)]@\<Gamma>)\<close> have "S closed_in (\<Delta>@[(TVarB X P)]@\<Gamma>)" |
32960
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents:
32011
diff
changeset
|
963 |
by (simp add: closed_in_def doms_append) |
30091
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
964 |
ultimately show "(\<Delta>@[(TVarB X P)]@\<Gamma>) \<turnstile> S <: Top" by (simp add: subtype_of.SA_Top) |
18246 | 965 |
next |
34915 | 966 |
case (SA_trans_TVar Y S N \<Gamma> X \<Delta>) |
32011 | 967 |
then have IH_inner: "(\<Delta>@[(TVarB X P)]@\<Gamma>) \<turnstile> S <: N" |
32960
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents:
32011
diff
changeset
|
968 |
and lh_drv_prm: "(TVarB Y S) \<in> set (\<Delta>@[(TVarB X Q)]@\<Gamma>)" |
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents:
32011
diff
changeset
|
969 |
and rh_drv: "\<Gamma> \<turnstile> P<:Q" |
53015
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
50252
diff
changeset
|
970 |
and ok\<^sub>Q: "\<turnstile> (\<Delta>@[(TVarB X Q)]@\<Gamma>) ok" by (simp_all add: subtype_implies_ok) |
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
50252
diff
changeset
|
971 |
then have ok\<^sub>P: "\<turnstile> (\<Delta>@[(TVarB X P)]@\<Gamma>) ok" by (simp add: subtype_implies_ok) |
30091
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
972 |
show "(\<Delta>@[(TVarB X P)]@\<Gamma>) \<turnstile> Tvar Y <: N" |
18621 | 973 |
proof (cases "X=Y") |
32960
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents:
32011
diff
changeset
|
974 |
case False |
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents:
32011
diff
changeset
|
975 |
have "X\<noteq>Y" by fact |
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents:
32011
diff
changeset
|
976 |
hence "(TVarB Y S)\<in>set (\<Delta>@[(TVarB X P)]@\<Gamma>)" using lh_drv_prm by (simp add:binding.inject) |
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents:
32011
diff
changeset
|
977 |
with IH_inner show "(\<Delta>@[(TVarB X P)]@\<Gamma>) \<turnstile> Tvar Y <: N" by (simp add: subtype_of.SA_trans_TVar) |
18621 | 978 |
next |
32960
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents:
32011
diff
changeset
|
979 |
case True |
53015
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
50252
diff
changeset
|
980 |
have memb\<^sub>XQ: "(TVarB X Q)\<in>set (\<Delta>@[(TVarB X Q)]@\<Gamma>)" by simp |
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
50252
diff
changeset
|
981 |
have memb\<^sub>XP: "(TVarB X P)\<in>set (\<Delta>@[(TVarB X P)]@\<Gamma>)" by simp |
32960
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents:
32011
diff
changeset
|
982 |
have eq: "X=Y" by fact |
53015
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
50252
diff
changeset
|
983 |
hence "S=Q" using ok\<^sub>Q lh_drv_prm memb\<^sub>XQ by (simp only: uniqueness_of_ctxt) |
32960
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents:
32011
diff
changeset
|
984 |
hence "(\<Delta>@[(TVarB X P)]@\<Gamma>) \<turnstile> Q <: N" using IH_inner by simp |
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents:
32011
diff
changeset
|
985 |
moreover |
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents:
32011
diff
changeset
|
986 |
have "(\<Delta>@[(TVarB X P)]@\<Gamma>) extends \<Gamma>" by (simp add: extends_def) |
53015
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
50252
diff
changeset
|
987 |
hence "(\<Delta>@[(TVarB X P)]@\<Gamma>) \<turnstile> P <: Q" using rh_drv ok\<^sub>P by (simp only: weakening) |
32960
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents:
32011
diff
changeset
|
988 |
ultimately have "(\<Delta>@[(TVarB X P)]@\<Gamma>) \<turnstile> P <: N" by (simp add: transitivity_lemma) |
53015
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
50252
diff
changeset
|
989 |
then show "(\<Delta>@[(TVarB X P)]@\<Gamma>) \<turnstile> Tvar Y <: N" using memb\<^sub>XP eq by auto |
18621 | 990 |
qed |
18246 | 991 |
next |
34915 | 992 |
case (SA_refl_TVar Y \<Gamma> X \<Delta>) |
63167 | 993 |
from \<open>\<Gamma> \<turnstile> P <: Q\<close> |
34915 | 994 |
have "P closed_in \<Gamma>" by (simp add: subtype_implies_closed) |
63167 | 995 |
with \<open>\<turnstile> (\<Delta>@[(TVarB X Q)]@\<Gamma>) ok\<close> have "\<turnstile> (\<Delta>@[(TVarB X P)]@\<Gamma>) ok" |
34915 | 996 |
by (simp add: replace_type) |
18424 | 997 |
moreover |
63167 | 998 |
from \<open>Y \<in> ty_dom (\<Delta>@[(TVarB X Q)]@\<Gamma>)\<close> have "Y \<in> ty_dom (\<Delta>@[(TVarB X P)]@\<Gamma>)" |
34915 | 999 |
by (simp add: doms_append) |
30091
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1000 |
ultimately show "(\<Delta>@[(TVarB X P)]@\<Gamma>) \<turnstile> Tvar Y <: Tvar Y" by (simp add: subtype_of.SA_refl_TVar) |
18246 | 1001 |
next |
53015
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
50252
diff
changeset
|
1002 |
case (SA_arrow S\<^sub>1 Q\<^sub>1 Q\<^sub>2 S\<^sub>2 \<Gamma> X \<Delta>) |
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
50252
diff
changeset
|
1003 |
then show "(\<Delta>@[(TVarB X P)]@\<Gamma>) \<turnstile> Q\<^sub>1 \<rightarrow> Q\<^sub>2 <: S\<^sub>1 \<rightarrow> S\<^sub>2" by blast |
18424 | 1004 |
next |
53015
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
50252
diff
changeset
|
1005 |
case (SA_all T\<^sub>1 S\<^sub>1 Y S\<^sub>2 T\<^sub>2 \<Gamma> X \<Delta>) |
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
50252
diff
changeset
|
1006 |
have IH_inner\<^sub>1: "(\<Delta>@[(TVarB X P)]@\<Gamma>) \<turnstile> T\<^sub>1 <: S\<^sub>1" |
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
50252
diff
changeset
|
1007 |
and IH_inner\<^sub>2: "(((TVarB Y T\<^sub>1)#\<Delta>)@[(TVarB X P)]@\<Gamma>) \<turnstile> S\<^sub>2 <: T\<^sub>2" |
44890
22f665a2e91c
new fastforce replacing fastsimp - less confusing name
nipkow
parents:
41798
diff
changeset
|
1008 |
by (fastforce intro: SA_all)+ |
53015
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
50252
diff
changeset
|
1009 |
then show "(\<Delta>@[(TVarB X P)]@\<Gamma>) \<turnstile> (\<forall>Y<:S\<^sub>1. S\<^sub>2) <: (\<forall>Y<:T\<^sub>1. T\<^sub>2)" by auto |
18246 | 1010 |
qed |
18621 | 1011 |
} |
18246 | 1012 |
qed |
1013 |
||
63167 | 1014 |
section \<open>Typing\<close> |
30091
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1015 |
|
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1016 |
inductive |
80914
d97fdabd9e2b
standardize mixfix annotations via "isabelle update -a -u mixfix_cartouches" --- to simplify systematic editing;
wenzelm
parents:
80149
diff
changeset
|
1017 |
typing :: "env \<Rightarrow> trm \<Rightarrow> ty \<Rightarrow> bool" (\<open>_ \<turnstile> _ : _\<close> [60,60,60] 60) |
30091
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1018 |
where |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1019 |
T_Var[intro]: "\<lbrakk> VarB x T \<in> set \<Gamma>; \<turnstile> \<Gamma> ok \<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:
50252
diff
changeset
|
1020 |
| T_App[intro]: "\<lbrakk> \<Gamma> \<turnstile> t\<^sub>1 : T\<^sub>1 \<rightarrow> T\<^sub>2; \<Gamma> \<turnstile> t\<^sub>2 : T\<^sub>1 \<rbrakk> \<Longrightarrow> \<Gamma> \<turnstile> t\<^sub>1 \<cdot> t\<^sub>2 : T\<^sub>2" |
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
50252
diff
changeset
|
1021 |
| T_Abs[intro]: "\<lbrakk> VarB x T\<^sub>1 # \<Gamma> \<turnstile> t\<^sub>2 : T\<^sub>2 \<rbrakk> \<Longrightarrow> \<Gamma> \<turnstile> (\<lambda>x:T\<^sub>1. t\<^sub>2) : T\<^sub>1 \<rightarrow> T\<^sub>2" |
30091
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1022 |
| T_Sub[intro]: "\<lbrakk> \<Gamma> \<turnstile> t : S; \<Gamma> \<turnstile> S <: T \<rbrakk> \<Longrightarrow> \<Gamma> \<turnstile> t : T" |
53015
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
50252
diff
changeset
|
1023 |
| T_TAbs[intro]:"\<lbrakk> TVarB X T\<^sub>1 # \<Gamma> \<turnstile> t\<^sub>2 : T\<^sub>2 \<rbrakk> \<Longrightarrow> \<Gamma> \<turnstile> (\<lambda>X<:T\<^sub>1. t\<^sub>2) : (\<forall>X<:T\<^sub>1. T\<^sub>2)" |
81127 | 1024 |
| T_TApp[intro]:"\<lbrakk>X\<sharp>(\<Gamma>,t\<^sub>1,T\<^sub>2); \<Gamma> \<turnstile> t\<^sub>1 : (\<forall>X<:T\<^sub>11. T\<^sub>12); \<Gamma> \<turnstile> T\<^sub>2 <: T\<^sub>11\<rbrakk> \<Longrightarrow> \<Gamma> \<turnstile> t\<^sub>1 \<cdot>\<^sub>\<tau> T\<^sub>2 : (T\<^sub>12[X \<leadsto> T\<^sub>2]\<^sub>\<tau>)" |
30091
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1025 |
|
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1026 |
equivariance typing |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1027 |
|
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1028 |
lemma better_T_TApp: |
53015
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
50252
diff
changeset
|
1029 |
assumes H1: "\<Gamma> \<turnstile> t\<^sub>1 : (\<forall>X<:T11. T12)" |
30091
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1030 |
and H2: "\<Gamma> \<turnstile> T2 <: T11" |
81127 | 1031 |
shows "\<Gamma> \<turnstile> t\<^sub>1 \<cdot>\<^sub>\<tau> T2 : (T12[X \<leadsto> T2]\<^sub>\<tau>)" |
30091
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1032 |
proof - |
53015
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
50252
diff
changeset
|
1033 |
obtain Y::tyvrs where Y: "Y \<sharp> (X, T12, \<Gamma>, t\<^sub>1, T2)" |
30091
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1034 |
by (rule exists_fresh) (rule fin_supp) |
53015
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
50252
diff
changeset
|
1035 |
then have "Y \<sharp> (\<Gamma>, t\<^sub>1, T2)" by simp |
30091
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1036 |
moreover from Y have "(\<forall>X<:T11. T12) = (\<forall>Y<:T11. [(Y, X)] \<bullet> T12)" |
80142 | 1037 |
by (auto simp: ty.inject alpha' fresh_prod fresh_atm) |
53015
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
50252
diff
changeset
|
1038 |
with H1 have "\<Gamma> \<turnstile> t\<^sub>1 : (\<forall>Y<:T11. [(Y, X)] \<bullet> T12)" by simp |
81127 | 1039 |
ultimately have "\<Gamma> \<turnstile> t\<^sub>1 \<cdot>\<^sub>\<tau> T2 : (([(Y, X)] \<bullet> T12)[Y \<leadsto> T2]\<^sub>\<tau>)" using H2 |
30091
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1040 |
by (rule T_TApp) |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1041 |
with Y show ?thesis by (simp add: type_subst_rename) |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1042 |
qed |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1043 |
|
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1044 |
lemma typing_ok: |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1045 |
assumes "\<Gamma> \<turnstile> t : T" |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1046 |
shows "\<turnstile> \<Gamma> ok" |
49171 | 1047 |
using assms by (induct) (auto) |
30091
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1048 |
|
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1049 |
nominal_inductive typing |
32011 | 1050 |
by (auto dest!: typing_ok intro: closed_in_fresh fresh_dom type_subst_fresh |
1051 |
simp: abs_fresh fresh_type_subst_fresh ty_vrs_fresh valid_ty_dom_fresh fresh_trm_dom) |
|
30091
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1052 |
|
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1053 |
lemma ok_imp_VarB_closed_in: |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1054 |
assumes ok: "\<turnstile> \<Gamma> ok" |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1055 |
shows "VarB x T \<in> set \<Gamma> \<Longrightarrow> T closed_in \<Gamma>" using ok |
80142 | 1056 |
by induct (auto simp: binding.inject closed_in_def) |
30091
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1057 |
|
81127 | 1058 |
lemma tyvrs_of_subst: "tyvrs_of (B[X \<leadsto> T]\<^sub>b) = tyvrs_of B" |
30091
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1059 |
by (nominal_induct B rule: binding.strong_induct) simp_all |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1060 |
|
81127 | 1061 |
lemma ty_dom_subst: "ty_dom (\<Gamma>[X \<leadsto> T]\<^sub>e) = ty_dom \<Gamma>" |
30091
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1062 |
by (induct \<Gamma>) (simp_all add: tyvrs_of_subst) |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1063 |
|
81127 | 1064 |
lemma vrs_of_subst: "vrs_of (B[X \<leadsto> T]\<^sub>b) = vrs_of B" |
30091
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1065 |
by (nominal_induct B rule: binding.strong_induct) simp_all |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1066 |
|
81127 | 1067 |
lemma trm_dom_subst: "trm_dom (\<Gamma>[X \<leadsto> T]\<^sub>e) = trm_dom \<Gamma>" |
30091
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1068 |
by (induct \<Gamma>) (simp_all add: vrs_of_subst) |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1069 |
|
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1070 |
lemma subst_closed_in: |
81127 | 1071 |
"T closed_in (\<Delta> @ TVarB X S # \<Gamma>) \<Longrightarrow> U closed_in \<Gamma> \<Longrightarrow> T[X \<leadsto> U]\<^sub>\<tau> closed_in (\<Delta>[X \<leadsto> U]\<^sub>e @ \<Gamma>)" |
80142 | 1072 |
proof (nominal_induct T avoiding: X U \<Gamma> rule: ty.strong_induct) |
1073 |
case (Tvar tyvrs) |
|
1074 |
then show ?case |
|
1075 |
by (auto simp add: closed_in_def ty.supp supp_atm doms_append ty_dom_subst) |
|
1076 |
next |
|
1077 |
case Top |
|
1078 |
then show ?case |
|
1079 |
using closed_in_def fresh_def by fastforce |
|
1080 |
next |
|
1081 |
case (Arrow ty1 ty2) |
|
1082 |
then show ?case |
|
1083 |
by (simp add: closed_in_def ty.supp) |
|
1084 |
next |
|
1085 |
case (Forall tyvrs ty1 ty2) |
|
81127 | 1086 |
then have "supp (ty1[X \<leadsto> U]\<^sub>\<tau>) \<subseteq> ty_dom (\<Delta>[X \<leadsto> U]\<^sub>e @ TVarB tyvrs ty2 # \<Gamma>)" |
80142 | 1087 |
apply (simp add: closed_in_def ty.supp abs_supp) |
1088 |
by (metis Diff_subset_conv Un_left_commute doms_append(1) le_supI2 ty_dom.simps(2) tyvrs_of.simps(2)) |
|
1089 |
with Forall show ?case |
|
1090 |
by (auto simp add: closed_in_def ty.supp abs_supp doms_append) |
|
1091 |
qed |
|
30091
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1092 |
|
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1093 |
lemmas subst_closed_in' = subst_closed_in [where \<Delta>="[]", simplified] |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1094 |
|
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1095 |
lemma typing_closed_in: |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1096 |
assumes "\<Gamma> \<turnstile> t : T" |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1097 |
shows "T closed_in \<Gamma>" |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1098 |
using assms |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1099 |
proof induct |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1100 |
case (T_Var x T \<Gamma>) |
63167 | 1101 |
from \<open>\<turnstile> \<Gamma> ok\<close> and \<open>VarB x T \<in> set \<Gamma>\<close> |
30091
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1102 |
show ?case by (rule ok_imp_VarB_closed_in) |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1103 |
next |
53015
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
50252
diff
changeset
|
1104 |
case (T_App \<Gamma> t\<^sub>1 T\<^sub>1 T\<^sub>2 t\<^sub>2) |
80142 | 1105 |
then show ?case by (auto simp: ty.supp closed_in_def) |
30091
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1106 |
next |
53015
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
50252
diff
changeset
|
1107 |
case (T_Abs x T\<^sub>1 \<Gamma> t\<^sub>2 T\<^sub>2) |
63167 | 1108 |
from \<open>VarB x T\<^sub>1 # \<Gamma> \<turnstile> t\<^sub>2 : T\<^sub>2\<close> |
53015
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
50252
diff
changeset
|
1109 |
have "T\<^sub>1 closed_in \<Gamma>" by (auto dest: typing_ok) |
80142 | 1110 |
with T_Abs show ?case by (auto simp: ty.supp closed_in_def) |
30091
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1111 |
next |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1112 |
case (T_Sub \<Gamma> t S T) |
63167 | 1113 |
from \<open>\<Gamma> \<turnstile> S <: T\<close> show ?case by (simp add: subtype_implies_closed) |
30091
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1114 |
next |
53015
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
50252
diff
changeset
|
1115 |
case (T_TAbs X T\<^sub>1 \<Gamma> t\<^sub>2 T\<^sub>2) |
63167 | 1116 |
from \<open>TVarB X T\<^sub>1 # \<Gamma> \<turnstile> t\<^sub>2 : T\<^sub>2\<close> |
53015
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
50252
diff
changeset
|
1117 |
have "T\<^sub>1 closed_in \<Gamma>" by (auto dest: typing_ok) |
80142 | 1118 |
with T_TAbs show ?case by (auto simp: ty.supp closed_in_def abs_supp) |
30091
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1119 |
next |
53015
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
50252
diff
changeset
|
1120 |
case (T_TApp X \<Gamma> t\<^sub>1 T2 T11 T12) |
30091
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1121 |
then have "T12 closed_in (TVarB X T11 # \<Gamma>)" |
80142 | 1122 |
by (auto simp: closed_in_def ty.supp abs_supp) |
30091
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1123 |
moreover from T_TApp have "T2 closed_in \<Gamma>" |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1124 |
by (simp add: subtype_implies_closed) |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1125 |
ultimately show ?case by (rule subst_closed_in') |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1126 |
qed |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1127 |
|
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1128 |
|
63167 | 1129 |
subsection \<open>Evaluation\<close> |
30091
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1130 |
|
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1131 |
inductive |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1132 |
val :: "trm \<Rightarrow> bool" |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1133 |
where |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1134 |
Abs[intro]: "val (\<lambda>x:T. t)" |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1135 |
| TAbs[intro]: "val (\<lambda>X<:T. t)" |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1136 |
|
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1137 |
equivariance val |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1138 |
|
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1139 |
inductive_cases val_inv_auto[elim]: |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1140 |
"val (Var x)" |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1141 |
"val (t1 \<cdot> t2)" |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1142 |
"val (t1 \<cdot>\<^sub>\<tau> t2)" |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1143 |
|
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1144 |
inductive |
80914
d97fdabd9e2b
standardize mixfix annotations via "isabelle update -a -u mixfix_cartouches" --- to simplify systematic editing;
wenzelm
parents:
80149
diff
changeset
|
1145 |
eval :: "trm \<Rightarrow> trm \<Rightarrow> bool" (\<open>_ \<longmapsto> _\<close> [60,60] 60) |
30091
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1146 |
where |
81127 | 1147 |
E_Abs : "\<lbrakk> x \<sharp> v\<^sub>2; val v\<^sub>2 \<rbrakk> \<Longrightarrow> (\<lambda>x:T\<^sub>11. t\<^sub>12) \<cdot> v\<^sub>2 \<longmapsto> t\<^sub>12[x \<leadsto> v\<^sub>2]" |
30091
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1148 |
| E_App1 [intro]: "t \<longmapsto> t' \<Longrightarrow> t \<cdot> u \<longmapsto> t' \<cdot> u" |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1149 |
| E_App2 [intro]: "\<lbrakk> val v; t \<longmapsto> t' \<rbrakk> \<Longrightarrow> v \<cdot> t \<longmapsto> v \<cdot> t'" |
81127 | 1150 |
| E_TAbs : "X \<sharp> (T\<^sub>11, T\<^sub>2) \<Longrightarrow> (\<lambda>X<:T\<^sub>11. t\<^sub>12) \<cdot>\<^sub>\<tau> T\<^sub>2 \<longmapsto> t\<^sub>12[X \<leadsto>\<^sub>\<tau> T\<^sub>2]" |
30091
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1151 |
| E_TApp [intro]: "t \<longmapsto> t' \<Longrightarrow> t \<cdot>\<^sub>\<tau> T \<longmapsto> t' \<cdot>\<^sub>\<tau> T" |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1152 |
|
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1153 |
lemma better_E_Abs[intro]: |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1154 |
assumes H: "val v2" |
81127 | 1155 |
shows "(\<lambda>x:T11. t12) \<cdot> v2 \<longmapsto> t12[x \<leadsto> v2]" |
30091
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1156 |
proof - |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1157 |
obtain y::vrs where y: "y \<sharp> (x, t12, v2)" by (rule exists_fresh) (rule fin_supp) |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1158 |
then have "y \<sharp> v2" by simp |
81127 | 1159 |
then have "(\<lambda>y:T11. [(y, x)] \<bullet> t12) \<cdot> v2 \<longmapsto> ([(y, x)] \<bullet> t12)[y \<leadsto> v2]" using H |
30091
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1160 |
by (rule E_Abs) |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1161 |
moreover from y have "(\<lambda>x:T11. t12) \<cdot> v2 = (\<lambda>y:T11. [(y, x)] \<bullet> t12) \<cdot> v2" |
80142 | 1162 |
by (auto simp: trm.inject alpha' fresh_prod fresh_atm) |
81127 | 1163 |
ultimately have "(\<lambda>x:T11. t12) \<cdot> v2 \<longmapsto> ([(y, x)] \<bullet> t12)[y \<leadsto> v2]" |
30091
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1164 |
by simp |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1165 |
with y show ?thesis by (simp add: subst_trm_rename) |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1166 |
qed |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1167 |
|
81127 | 1168 |
lemma better_E_TAbs[intro]: "(\<lambda>X<:T11. t12) \<cdot>\<^sub>\<tau> T2 \<longmapsto> t12[X \<leadsto>\<^sub>\<tau> T2]" |
30091
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1169 |
proof - |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1170 |
obtain Y::tyvrs where Y: "Y \<sharp> (X, t12, T11, T2)" by (rule exists_fresh) (rule fin_supp) |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1171 |
then have "Y \<sharp> (T11, T2)" by simp |
81127 | 1172 |
then have "(\<lambda>Y<:T11. [(Y, X)] \<bullet> t12) \<cdot>\<^sub>\<tau> T2 \<longmapsto> ([(Y, X)] \<bullet> t12)[Y \<leadsto>\<^sub>\<tau> T2]" |
30091
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1173 |
by (rule E_TAbs) |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1174 |
moreover from Y have "(\<lambda>X<:T11. t12) \<cdot>\<^sub>\<tau> T2 = (\<lambda>Y<:T11. [(Y, X)] \<bullet> t12) \<cdot>\<^sub>\<tau> T2" |
80142 | 1175 |
by (auto simp: trm.inject alpha' fresh_prod fresh_atm) |
81127 | 1176 |
ultimately have "(\<lambda>X<:T11. t12) \<cdot>\<^sub>\<tau> T2 \<longmapsto> ([(Y, X)] \<bullet> t12)[Y \<leadsto>\<^sub>\<tau> T2]" |
30091
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1177 |
by simp |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1178 |
with Y show ?thesis by (simp add: subst_trm_ty_rename) |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1179 |
qed |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1180 |
|
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1181 |
equivariance eval |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1182 |
|
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1183 |
nominal_inductive eval |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1184 |
by (simp_all add: abs_fresh ty_vrs_fresh subst_trm_fresh_tyvar |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1185 |
subst_trm_fresh_var subst_trm_ty_fresh') |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1186 |
|
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1187 |
inductive_cases eval_inv_auto[elim]: |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1188 |
"Var x \<longmapsto> t'" |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1189 |
"(\<lambda>x:T. t) \<longmapsto> t'" |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1190 |
"(\<lambda>X<:T. t) \<longmapsto> t'" |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1191 |
|
32011 | 1192 |
lemma ty_dom_cons: |
1193 |
shows "ty_dom (\<Gamma>@[VarB X Q]@\<Delta>) = ty_dom (\<Gamma>@\<Delta>)" |
|
49171 | 1194 |
by (induct \<Gamma>) (auto) |
30091
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1195 |
|
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1196 |
lemma closed_in_cons: |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1197 |
assumes "S closed_in (\<Gamma> @ VarB X Q # \<Delta>)" |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1198 |
shows "S closed_in (\<Gamma>@\<Delta>)" |
32011 | 1199 |
using assms ty_dom_cons closed_in_def by auto |
30091
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1200 |
|
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1201 |
lemma closed_in_weaken: "T closed_in (\<Delta> @ \<Gamma>) \<Longrightarrow> T closed_in (\<Delta> @ B # \<Gamma>)" |
80142 | 1202 |
by (auto simp: closed_in_def doms_append) |
30091
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1203 |
|
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1204 |
lemma closed_in_weaken': "T closed_in \<Gamma> \<Longrightarrow> T closed_in (\<Delta> @ \<Gamma>)" |
80142 | 1205 |
by (auto simp: closed_in_def doms_append) |
30091
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1206 |
|
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1207 |
lemma valid_subst: |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1208 |
assumes ok: "\<turnstile> (\<Delta> @ TVarB X Q # \<Gamma>) ok" |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1209 |
and closed: "P closed_in \<Gamma>" |
81127 | 1210 |
shows "\<turnstile> (\<Delta>[X \<leadsto> P]\<^sub>e @ \<Gamma>) ok" using ok closed |
80142 | 1211 |
proof (induct \<Delta>) |
1212 |
case Nil |
|
1213 |
then show ?case |
|
1214 |
by auto |
|
1215 |
next |
|
1216 |
case (Cons a \<Delta>) |
|
1217 |
then have *: "\<turnstile> (a # \<Delta> @ TVarB X Q # \<Gamma>) ok" |
|
1218 |
by fastforce |
|
1219 |
then show ?case |
|
1220 |
apply (rule validE) |
|
1221 |
using Cons |
|
1222 |
apply (simp add: at_tyvrs_inst closed doms_append(1) finite_doms(1) fresh_fin_insert fs_tyvrs_inst pt_tyvrs_inst subst_closed_in ty_dom_subst) |
|
1223 |
by (simp add: doms_append(2) subst_closed_in Cons.hyps closed trm_dom_subst) |
|
1224 |
qed |
|
30091
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1225 |
|
32011 | 1226 |
lemma ty_dom_vrs: |
1227 |
shows "ty_dom (G @ [VarB x Q] @ D) = ty_dom (G @ D)" |
|
80142 | 1228 |
by (induct G) (auto) |
30091
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1229 |
|
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1230 |
lemma valid_cons': |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1231 |
assumes "\<turnstile> (\<Gamma> @ VarB x Q # \<Delta>) ok" |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1232 |
shows "\<turnstile> (\<Gamma> @ \<Delta>) ok" |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1233 |
using assms |
34915 | 1234 |
proof (induct "\<Gamma> @ VarB x Q # \<Delta>" arbitrary: \<Gamma> \<Delta>) |
30091
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1235 |
case valid_nil |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1236 |
have "[] = \<Gamma> @ VarB x Q # \<Delta>" by fact |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1237 |
then have "False" by auto |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1238 |
then show ?case by auto |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1239 |
next |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1240 |
case (valid_consT G X T) |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1241 |
then show ?case |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1242 |
proof (cases \<Gamma>) |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1243 |
case Nil |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1244 |
with valid_consT show ?thesis by simp |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1245 |
next |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1246 |
case (Cons b bs) |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1247 |
with valid_consT |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1248 |
have "\<turnstile> (bs @ \<Delta>) ok" by simp |
32011 | 1249 |
moreover from Cons and valid_consT have "X \<sharp> ty_dom (bs @ \<Delta>)" |
1250 |
by (simp add: doms_append) |
|
30091
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1251 |
moreover from Cons and valid_consT have "T closed_in (bs @ \<Delta>)" |
32011 | 1252 |
by (simp add: closed_in_def doms_append) |
30091
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1253 |
ultimately have "\<turnstile> (TVarB X T # bs @ \<Delta>) ok" |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1254 |
by (rule valid_rel.valid_consT) |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1255 |
with Cons and valid_consT show ?thesis by simp |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1256 |
qed |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1257 |
next |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1258 |
case (valid_cons G x T) |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1259 |
then show ?case |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1260 |
proof (cases \<Gamma>) |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1261 |
case Nil |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1262 |
with valid_cons show ?thesis by simp |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1263 |
next |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1264 |
case (Cons b bs) |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1265 |
with valid_cons |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1266 |
have "\<turnstile> (bs @ \<Delta>) ok" by simp |
32011 | 1267 |
moreover from Cons and valid_cons have "x \<sharp> trm_dom (bs @ \<Delta>)" |
1268 |
by (simp add: doms_append finite_doms |
|
32960
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents:
32011
diff
changeset
|
1269 |
fresh_fin_insert [OF pt_vrs_inst at_vrs_inst fs_vrs_inst]) |
30091
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1270 |
moreover from Cons and valid_cons have "T closed_in (bs @ \<Delta>)" |
32011 | 1271 |
by (simp add: closed_in_def doms_append) |
30091
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1272 |
ultimately have "\<turnstile> (VarB x T # bs @ \<Delta>) ok" |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1273 |
by (rule valid_rel.valid_cons) |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1274 |
with Cons and valid_cons show ?thesis by simp |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1275 |
qed |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1276 |
qed |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1277 |
|
63167 | 1278 |
text \<open>A.5(6)\<close> |
30091
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1279 |
|
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1280 |
lemma type_weaken: |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1281 |
assumes "(\<Delta>@\<Gamma>) \<turnstile> t : T" |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1282 |
and "\<turnstile> (\<Delta> @ B # \<Gamma>) ok" |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1283 |
shows "(\<Delta> @ B # \<Gamma>) \<turnstile> t : T" |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1284 |
using assms |
34915 | 1285 |
proof(nominal_induct "\<Delta> @ \<Gamma>" t T avoiding: \<Delta> \<Gamma> B rule: typing.strong_induct) |
1286 |
case (T_Var x T) |
|
30091
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1287 |
then show ?case by auto |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1288 |
next |
53015
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
50252
diff
changeset
|
1289 |
case (T_App X t\<^sub>1 T\<^sub>2 T\<^sub>11 T\<^sub>12) |
30091
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1290 |
then show ?case by force |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1291 |
next |
53015
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
50252
diff
changeset
|
1292 |
case (T_Abs y T\<^sub>1 t\<^sub>2 T\<^sub>2 \<Delta> \<Gamma>) |
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
50252
diff
changeset
|
1293 |
then have "VarB y T\<^sub>1 # \<Delta> @ \<Gamma> \<turnstile> t\<^sub>2 : T\<^sub>2" by simp |
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
50252
diff
changeset
|
1294 |
then have closed: "T\<^sub>1 closed_in (\<Delta> @ \<Gamma>)" |
30091
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1295 |
by (auto dest: typing_ok) |
53015
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
50252
diff
changeset
|
1296 |
have "\<turnstile> (VarB y T\<^sub>1 # \<Delta> @ B # \<Gamma>) ok" |
80142 | 1297 |
by (simp add: T_Abs closed closed_in_weaken fresh_list_append fresh_list_cons fresh_trm_dom) |
53015
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
50252
diff
changeset
|
1298 |
then have "\<turnstile> ((VarB y T\<^sub>1 # \<Delta>) @ B # \<Gamma>) ok" by simp |
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
50252
diff
changeset
|
1299 |
with _ have "(VarB y T\<^sub>1 # \<Delta>) @ B # \<Gamma> \<turnstile> t\<^sub>2 : T\<^sub>2" |
34915 | 1300 |
by (rule T_Abs) simp |
53015
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
50252
diff
changeset
|
1301 |
then have "VarB y T\<^sub>1 # \<Delta> @ B # \<Gamma> \<turnstile> t\<^sub>2 : T\<^sub>2" by simp |
30091
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1302 |
then show ?case by (rule typing.T_Abs) |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1303 |
next |
34915 | 1304 |
case (T_Sub t S T \<Delta> \<Gamma>) |
63167 | 1305 |
from refl and \<open>\<turnstile> (\<Delta> @ B # \<Gamma>) ok\<close> |
30091
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1306 |
have "\<Delta> @ B # \<Gamma> \<turnstile> t : S" by (rule T_Sub) |
63167 | 1307 |
moreover from \<open>(\<Delta> @ \<Gamma>)\<turnstile>S<:T\<close> and \<open>\<turnstile> (\<Delta> @ B # \<Gamma>) ok\<close> |
30091
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1308 |
have "(\<Delta> @ B # \<Gamma>)\<turnstile>S<:T" |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1309 |
by (rule weakening) (simp add: extends_def T_Sub) |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1310 |
ultimately show ?case by (rule typing.T_Sub) |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1311 |
next |
53015
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
50252
diff
changeset
|
1312 |
case (T_TAbs X T\<^sub>1 t\<^sub>2 T\<^sub>2 \<Delta> \<Gamma>) |
63167 | 1313 |
from \<open>TVarB X T\<^sub>1 # \<Delta> @ \<Gamma> \<turnstile> t\<^sub>2 : T\<^sub>2\<close> |
53015
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
50252
diff
changeset
|
1314 |
have closed: "T\<^sub>1 closed_in (\<Delta> @ \<Gamma>)" |
30091
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1315 |
by (auto dest: typing_ok) |
53015
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
50252
diff
changeset
|
1316 |
have "\<turnstile> (TVarB X T\<^sub>1 # \<Delta> @ B # \<Gamma>) ok" |
80142 | 1317 |
by (simp add: T_TAbs at_tyvrs_inst closed closed_in_weaken doms_append finite_doms finite_vrs |
1318 |
fresh_dom fresh_fin_union fs_tyvrs_inst pt_tyvrs_inst tyvrs_fresh) |
|
53015
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
50252
diff
changeset
|
1319 |
then have "\<turnstile> ((TVarB X T\<^sub>1 # \<Delta>) @ B # \<Gamma>) ok" by simp |
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
50252
diff
changeset
|
1320 |
with _ have "(TVarB X T\<^sub>1 # \<Delta>) @ B # \<Gamma> \<turnstile> t\<^sub>2 : T\<^sub>2" |
34915 | 1321 |
by (rule T_TAbs) simp |
53015
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
50252
diff
changeset
|
1322 |
then have "TVarB X T\<^sub>1 # \<Delta> @ B # \<Gamma> \<turnstile> t\<^sub>2 : T\<^sub>2" by simp |
30091
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1323 |
then show ?case by (rule typing.T_TAbs) |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1324 |
next |
53015
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
50252
diff
changeset
|
1325 |
case (T_TApp X t\<^sub>1 T2 T11 T12 \<Delta> \<Gamma>) |
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
50252
diff
changeset
|
1326 |
have "\<Delta> @ B # \<Gamma> \<turnstile> t\<^sub>1 : (\<forall>X<:T11. T12)" |
34915 | 1327 |
by (rule T_TApp refl)+ |
63167 | 1328 |
moreover from \<open>(\<Delta> @ \<Gamma>)\<turnstile>T2<:T11\<close> and \<open>\<turnstile> (\<Delta> @ B # \<Gamma>) ok\<close> |
30091
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1329 |
have "(\<Delta> @ B # \<Gamma>)\<turnstile>T2<:T11" |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1330 |
by (rule weakening) (simp add: extends_def T_TApp) |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1331 |
ultimately show ?case by (rule better_T_TApp) |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1332 |
qed |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1333 |
|
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1334 |
lemma type_weaken': |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1335 |
"\<Gamma> \<turnstile> t : T \<Longrightarrow> \<turnstile> (\<Delta>@\<Gamma>) ok \<Longrightarrow> (\<Delta>@\<Gamma>) \<turnstile> t : T" |
80142 | 1336 |
proof (induct \<Delta>) |
1337 |
case Nil |
|
1338 |
then show ?case by auto |
|
1339 |
next |
|
1340 |
case (Cons a \<Delta>) |
|
1341 |
then show ?case |
|
1342 |
by (metis append_Cons append_Nil type_weaken validE(3)) |
|
1343 |
qed |
|
30091
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1344 |
|
63167 | 1345 |
text \<open>A.6\<close> |
30091
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1346 |
|
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1347 |
lemma strengthening: |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1348 |
assumes "(\<Gamma> @ VarB x Q # \<Delta>) \<turnstile> S <: T" |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1349 |
shows "(\<Gamma>@\<Delta>) \<turnstile> S <: T" |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1350 |
using assms |
34915 | 1351 |
proof (induct "\<Gamma> @ VarB x Q # \<Delta>" S T arbitrary: \<Gamma>) |
1352 |
case (SA_Top S) |
|
1353 |
then have "\<turnstile> (\<Gamma> @ \<Delta>) ok" by (auto dest: valid_cons') |
|
1354 |
moreover have "S closed_in (\<Gamma> @ \<Delta>)" using SA_Top by (auto dest: closed_in_cons) |
|
30091
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1355 |
ultimately show ?case using subtype_of.SA_Top by auto |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1356 |
next |
34915 | 1357 |
case (SA_refl_TVar X) |
63167 | 1358 |
from \<open>\<turnstile> (\<Gamma> @ VarB x Q # \<Delta>) ok\<close> |
34915 | 1359 |
have h1:"\<turnstile> (\<Gamma> @ \<Delta>) ok" by (auto dest: valid_cons') |
1360 |
have "X \<in> ty_dom (\<Gamma> @ VarB x Q # \<Delta>)" using SA_refl_TVar by auto |
|
1361 |
then have h2:"X \<in> ty_dom (\<Gamma> @ \<Delta>)" using ty_dom_vrs by auto |
|
30091
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1362 |
show ?case using h1 h2 by auto |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1363 |
next |
34915 | 1364 |
case (SA_all T1 S1 X S2 T2) |
44890
22f665a2e91c
new fastforce replacing fastsimp - less confusing name
nipkow
parents:
41798
diff
changeset
|
1365 |
have h1:"((TVarB X T1 # \<Gamma>) @ \<Delta>)\<turnstile>S2<:T2" by (fastforce intro: SA_all) |
34915 | 1366 |
have h2:"(\<Gamma> @ \<Delta>)\<turnstile>T1<:S1" using SA_all by auto |
30091
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1367 |
then show ?case using h1 h2 by auto |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1368 |
qed (auto) |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1369 |
|
63167 | 1370 |
lemma narrow_type: \<comment> \<open>A.7\<close> |
30091
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1371 |
assumes H: "\<Delta> @ (TVarB X Q) # \<Gamma> \<turnstile> t : T" |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1372 |
shows "\<Gamma> \<turnstile> P <: Q \<Longrightarrow> \<Delta> @ (TVarB X P) # \<Gamma> \<turnstile> t : T" |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1373 |
using H |
34915 | 1374 |
proof (nominal_induct "\<Delta> @ (TVarB X Q) # \<Gamma>" t T avoiding: P arbitrary: \<Delta> rule: typing.strong_induct) |
1375 |
case (T_Var x T P D) |
|
30091
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1376 |
then have "VarB x T \<in> set (D @ TVarB X P # \<Gamma>)" |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1377 |
and "\<turnstile> (D @ TVarB X P # \<Gamma>) ok" |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1378 |
by (auto intro: replace_type dest!: subtype_implies_closed) |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1379 |
then show ?case by auto |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1380 |
next |
34915 | 1381 |
case (T_App t1 T1 T2 t2 P D) |
30091
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1382 |
then show ?case by force |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1383 |
next |
34915 | 1384 |
case (T_Abs x T1 t2 T2 P D) |
44890
22f665a2e91c
new fastforce replacing fastsimp - less confusing name
nipkow
parents:
41798
diff
changeset
|
1385 |
then show ?case by (fastforce dest: typing_ok) |
30091
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1386 |
next |
34915 | 1387 |
case (T_Sub t S T P D) |
44890
22f665a2e91c
new fastforce replacing fastsimp - less confusing name
nipkow
parents:
41798
diff
changeset
|
1388 |
then show ?case using subtype_narrow by fastforce |
30091
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1389 |
next |
34915 | 1390 |
case (T_TAbs X' T1 t2 T2 P D) |
44890
22f665a2e91c
new fastforce replacing fastsimp - less confusing name
nipkow
parents:
41798
diff
changeset
|
1391 |
then show ?case by (fastforce dest: typing_ok) |
30091
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1392 |
next |
34915 | 1393 |
case (T_TApp X' t1 T2 T11 T12 P D) |
44890
22f665a2e91c
new fastforce replacing fastsimp - less confusing name
nipkow
parents:
41798
diff
changeset
|
1394 |
then have "D @ TVarB X P # \<Gamma> \<turnstile> t1 : Forall X' T12 T11" by fastforce |
30091
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1395 |
moreover have "(D @ [TVarB X Q] @ \<Gamma>) \<turnstile> T2<:T11" using T_TApp by auto |
63167 | 1396 |
then have "(D @ [TVarB X P] @ \<Gamma>) \<turnstile> T2<:T11" using \<open>\<Gamma>\<turnstile>P<:Q\<close> |
30091
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1397 |
by (rule subtype_narrow) |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1398 |
moreover from T_TApp have "X' \<sharp> (D @ TVarB X P # \<Gamma>, t1, T2)" |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1399 |
by (simp add: fresh_list_append fresh_list_cons fresh_prod) |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1400 |
ultimately show ?case by auto |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1401 |
qed |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1402 |
|
63167 | 1403 |
subsection \<open>Substitution lemmas\<close> |
30091
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1404 |
|
63167 | 1405 |
subsubsection \<open>Substition Preserves Typing\<close> |
30091
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1406 |
|
63167 | 1407 |
theorem subst_type: \<comment> \<open>A.8\<close> |
30091
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1408 |
assumes H: "(\<Delta> @ (VarB x U) # \<Gamma>) \<turnstile> t : T" |
81127 | 1409 |
shows "\<Gamma> \<turnstile> u : U \<Longrightarrow> \<Delta> @ \<Gamma> \<turnstile> t[x \<leadsto> u] : T" using H |
34915 | 1410 |
proof (nominal_induct "\<Delta> @ (VarB x U) # \<Gamma>" t T avoiding: x u arbitrary: \<Delta> rule: typing.strong_induct) |
1411 |
case (T_Var y T x u D) |
|
30091
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1412 |
show ?case |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1413 |
proof (cases "x = y") |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1414 |
assume eq:"x=y" |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1415 |
then have "T=U" using T_Var uniqueness_of_ctxt' by auto |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1416 |
then show ?case using eq T_Var |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1417 |
by (auto intro: type_weaken' dest: valid_cons') |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1418 |
next |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1419 |
assume "x\<noteq>y" |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1420 |
then show ?case using T_Var |
80142 | 1421 |
by (auto simp:binding.inject dest: valid_cons') |
30091
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1422 |
qed |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1423 |
next |
34915 | 1424 |
case (T_App t1 T1 T2 t2 x u D) |
30091
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1425 |
then show ?case by force |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1426 |
next |
34915 | 1427 |
case (T_Abs y T1 t2 T2 x u D) |
30091
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1428 |
then show ?case by force |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1429 |
next |
34915 | 1430 |
case (T_Sub t S T x u D) |
81127 | 1431 |
then have "D @ \<Gamma> \<turnstile> t[x \<leadsto> u] : S" by auto |
30091
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1432 |
moreover have "(D @ \<Gamma>) \<turnstile> S<:T" using T_Sub by (auto dest: strengthening) |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1433 |
ultimately show ?case by auto |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1434 |
next |
34915 | 1435 |
case (T_TAbs X T1 t2 T2 x u D) |
63167 | 1436 |
from \<open>TVarB X T1 # D @ VarB x U # \<Gamma> \<turnstile> t2 : T2\<close> have "X \<sharp> T1" |
80142 | 1437 |
by (auto simp: valid_ty_dom_fresh dest: typing_ok intro!: closed_in_fresh) |
63167 | 1438 |
with \<open>X \<sharp> u\<close> and T_TAbs show ?case by fastforce |
30091
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1439 |
next |
34915 | 1440 |
case (T_TApp X t1 T2 T11 T12 x u D) |
30091
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1441 |
then have "(D@\<Gamma>) \<turnstile>T2<:T11" using T_TApp by (auto dest: strengthening) |
81127 | 1442 |
then show "((D @ \<Gamma>) \<turnstile> ((t1 \<cdot>\<^sub>\<tau> T2)[x \<leadsto> u]) : (T12[X \<leadsto> T2]\<^sub>\<tau>))" using T_TApp |
80142 | 1443 |
by (force simp: fresh_prod fresh_list_append fresh_list_cons subst_trm_fresh_tyvar) |
30091
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1444 |
qed |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1445 |
|
63167 | 1446 |
subsubsection \<open>Type Substitution Preserves Subtyping\<close> |
30091
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1447 |
|
63167 | 1448 |
lemma substT_subtype: \<comment> \<open>A.10\<close> |
30091
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1449 |
assumes H: "(\<Delta> @ ((TVarB X Q) # \<Gamma>)) \<turnstile> S <: T" |
81127 | 1450 |
shows "\<Gamma> \<turnstile> P <: Q \<Longrightarrow> (\<Delta>[X \<leadsto> P]\<^sub>e @ \<Gamma>) \<turnstile> S[X \<leadsto> P]\<^sub>\<tau> <: T[X \<leadsto> P]\<^sub>\<tau>" |
30091
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1451 |
using H |
34915 | 1452 |
proof (nominal_induct "\<Delta> @ TVarB X Q # \<Gamma>" S T avoiding: X P arbitrary: \<Delta> rule: subtype_of.strong_induct) |
1453 |
case (SA_Top S X P D) |
|
30091
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1454 |
then have "\<turnstile> (D @ TVarB X Q # \<Gamma>) ok" by simp |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1455 |
moreover have closed: "P closed_in \<Gamma>" using SA_Top subtype_implies_closed by auto |
81127 | 1456 |
ultimately have "\<turnstile> (D[X \<leadsto> P]\<^sub>e @ \<Gamma>) ok" by (rule valid_subst) |
30091
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1457 |
moreover from SA_Top have "S closed_in (D @ TVarB X Q # \<Gamma>)" by simp |
81127 | 1458 |
then have "S[X \<leadsto> P]\<^sub>\<tau> closed_in (D[X \<leadsto> P]\<^sub>e @ \<Gamma>)" using closed by (rule subst_closed_in) |
30091
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1459 |
ultimately show ?case by auto |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1460 |
next |
34915 | 1461 |
case (SA_trans_TVar Y S T X P D) |
1462 |
have h:"(D @ TVarB X Q # \<Gamma>)\<turnstile>S<:T" by fact |
|
81127 | 1463 |
then have ST: "(D[X \<leadsto> P]\<^sub>e @ \<Gamma>) \<turnstile> S[X \<leadsto> P]\<^sub>\<tau> <: T[X \<leadsto> P]\<^sub>\<tau>" using SA_trans_TVar by auto |
34915 | 1464 |
from h have G_ok: "\<turnstile> (D @ TVarB X Q # \<Gamma>) ok" by (rule subtype_implies_ok) |
50252 | 1465 |
from G_ok and SA_trans_TVar have X_\<Gamma>_ok: "\<turnstile> (TVarB X Q # \<Gamma>) ok" |
30091
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1466 |
by (auto intro: validE_append) |
81127 | 1467 |
show "(D[X \<leadsto> P]\<^sub>e @ \<Gamma>) \<turnstile> Tvar Y[X \<leadsto> P]\<^sub>\<tau><:T[X \<leadsto> P]\<^sub>\<tau>" |
30091
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1468 |
proof (cases "X = Y") |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1469 |
assume eq: "X = Y" |
34915 | 1470 |
from eq and SA_trans_TVar have "TVarB Y Q \<in> set (D @ TVarB X Q # \<Gamma>)" by simp |
63167 | 1471 |
with G_ok have QS: "Q = S" using \<open>TVarB Y S \<in> set (D @ TVarB X Q # \<Gamma>)\<close> |
34915 | 1472 |
by (rule uniqueness_of_ctxt) |
50252 | 1473 |
from X_\<Gamma>_ok have "X \<sharp> ty_dom \<Gamma>" and "Q closed_in \<Gamma>" by auto |
30091
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1474 |
then have XQ: "X \<sharp> Q" by (rule closed_in_fresh) |
63167 | 1475 |
note \<open>\<Gamma>\<turnstile>P<:Q\<close> |
81127 | 1476 |
moreover from ST have "\<turnstile> (D[X \<leadsto> P]\<^sub>e @ \<Gamma>) ok" by (rule subtype_implies_ok) |
1477 |
moreover have "(D[X \<leadsto> P]\<^sub>e @ \<Gamma>) extends \<Gamma>" by (simp add: extends_def) |
|
1478 |
ultimately have "(D[X \<leadsto> P]\<^sub>e @ \<Gamma>) \<turnstile> P<:Q" by (rule weakening) |
|
1479 |
with QS have "(D[X \<leadsto> P]\<^sub>e @ \<Gamma>) \<turnstile> P<:S" by simp |
|
1480 |
moreover from XQ and ST and QS have "(D[X \<leadsto> P]\<^sub>e @ \<Gamma>) \<turnstile> S<:T[X \<leadsto> P]\<^sub>\<tau>" |
|
30091
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1481 |
by (simp add: type_subst_identity) |
81127 | 1482 |
ultimately have "(D[X \<leadsto> P]\<^sub>e @ \<Gamma>) \<turnstile> P<:T[X \<leadsto> P]\<^sub>\<tau>" |
30091
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1483 |
by (rule subtype_transitivity) |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1484 |
with eq show ?case by simp |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1485 |
next |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1486 |
assume neq: "X \<noteq> Y" |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1487 |
with SA_trans_TVar have "TVarB Y S \<in> set D \<or> TVarB Y S \<in> set \<Gamma>" |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1488 |
by (simp add: binding.inject) |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1489 |
then show ?case |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1490 |
proof |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1491 |
assume "TVarB Y S \<in> set D" |
81127 | 1492 |
then have "TVarB Y (S[X \<leadsto> P]\<^sub>\<tau>) \<in> set (D[X \<leadsto> P]\<^sub>e)" |
32960
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents:
32011
diff
changeset
|
1493 |
by (rule ctxt_subst_mem_TVarB) |
81127 | 1494 |
then have "TVarB Y (S[X \<leadsto> P]\<^sub>\<tau>) \<in> set (D[X \<leadsto> P]\<^sub>e @ \<Gamma>)" by simp |
30091
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1495 |
with neq and ST show ?thesis by auto |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1496 |
next |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1497 |
assume Y: "TVarB Y S \<in> set \<Gamma>" |
50252 | 1498 |
from X_\<Gamma>_ok have "X \<sharp> ty_dom \<Gamma>" and "\<turnstile> \<Gamma> ok" by auto |
32011 | 1499 |
then have "X \<sharp> \<Gamma>" by (simp add: valid_ty_dom_fresh) |
30091
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1500 |
with Y have "X \<sharp> S" |
80142 | 1501 |
by (induct \<Gamma>) (auto simp: fresh_list_nil fresh_list_cons) |
81127 | 1502 |
with ST have "(D[X \<leadsto> P]\<^sub>e @ \<Gamma>)\<turnstile>S<:T[X \<leadsto> P]\<^sub>\<tau>" |
32960
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents:
32011
diff
changeset
|
1503 |
by (simp add: type_subst_identity) |
81127 | 1504 |
moreover from Y have "TVarB Y S \<in> set (D[X \<leadsto> P]\<^sub>e @ \<Gamma>)" by simp |
30091
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1505 |
ultimately show ?thesis using neq by auto |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1506 |
qed |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1507 |
qed |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1508 |
next |
34915 | 1509 |
case (SA_refl_TVar Y X P D) |
63167 | 1510 |
note \<open>\<turnstile> (D @ TVarB X Q # \<Gamma>) ok\<close> |
30091
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1511 |
moreover from SA_refl_TVar have closed: "P closed_in \<Gamma>" |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1512 |
by (auto dest: subtype_implies_closed) |
81127 | 1513 |
ultimately have ok: "\<turnstile> (D[X \<leadsto> P]\<^sub>e @ \<Gamma>) ok" using valid_subst by auto |
1514 |
from closed have closed': "P closed_in (D[X \<leadsto> P]\<^sub>e @ \<Gamma>)" |
|
30091
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1515 |
by (simp add: closed_in_weaken') |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1516 |
show ?case |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1517 |
proof (cases "X = Y") |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1518 |
assume "X = Y" |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1519 |
with closed' and ok show ?thesis |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1520 |
by (auto intro: subtype_reflexivity) |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1521 |
next |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1522 |
assume neq: "X \<noteq> Y" |
81127 | 1523 |
with SA_refl_TVar have "Y \<in> ty_dom (D[X \<leadsto> P]\<^sub>e @ \<Gamma>)" |
32011 | 1524 |
by (simp add: ty_dom_subst doms_append) |
30091
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1525 |
with neq and ok show ?thesis by auto |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1526 |
qed |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1527 |
next |
34915 | 1528 |
case (SA_arrow T1 S1 S2 T2 X P D) |
81127 | 1529 |
then have h1:"(D[X \<leadsto> P]\<^sub>e @ \<Gamma>)\<turnstile>T1[X \<leadsto> P]\<^sub>\<tau><:S1[X \<leadsto> P]\<^sub>\<tau>" using SA_arrow by auto |
1530 |
from SA_arrow have h2:"(D[X \<leadsto> P]\<^sub>e @ \<Gamma>)\<turnstile>S2[X \<leadsto> P]\<^sub>\<tau><:T2[X \<leadsto> P]\<^sub>\<tau>" using SA_arrow by auto |
|
30091
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1531 |
show ?case using subtype_of.SA_arrow h1 h2 by auto |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1532 |
next |
34915 | 1533 |
case (SA_all T1 S1 Y S2 T2 X P D) |
32011 | 1534 |
then have Y: "Y \<sharp> ty_dom (D @ TVarB X Q # \<Gamma>)" |
1535 |
by (auto dest: subtype_implies_ok intro: fresh_dom) |
|
30091
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1536 |
moreover from SA_all have "S1 closed_in (D @ TVarB X Q # \<Gamma>)" |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1537 |
by (auto dest: subtype_implies_closed) |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1538 |
ultimately have S1: "Y \<sharp> S1" by (rule closed_in_fresh) |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1539 |
from SA_all have "T1 closed_in (D @ TVarB X Q # \<Gamma>)" |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1540 |
by (auto dest: subtype_implies_closed) |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1541 |
with Y have T1: "Y \<sharp> T1" by (rule closed_in_fresh) |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1542 |
with SA_all and S1 show ?case by force |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1543 |
qed |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1544 |
|
63167 | 1545 |
subsubsection \<open>Type Substitution Preserves Typing\<close> |
30091
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1546 |
|
63167 | 1547 |
theorem substT_type: \<comment> \<open>A.11\<close> |
30091
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1548 |
assumes H: "(D @ TVarB X Q # G) \<turnstile> t : T" |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1549 |
shows "G \<turnstile> P <: Q \<Longrightarrow> |
81127 | 1550 |
(D[X \<leadsto> P]\<^sub>e @ G) \<turnstile> t[X \<leadsto>\<^sub>\<tau> P] : T[X \<leadsto> P]\<^sub>\<tau>" using H |
34915 | 1551 |
proof (nominal_induct "D @ TVarB X Q # G" t T avoiding: X P arbitrary: D rule: typing.strong_induct) |
1552 |
case (T_Var x T X P D') |
|
30091
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1553 |
have "G\<turnstile>P<:Q" by fact |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1554 |
then have "P closed_in G" using subtype_implies_closed by auto |
63167 | 1555 |
moreover note \<open>\<turnstile> (D' @ TVarB X Q # G) ok\<close> |
81127 | 1556 |
ultimately have "\<turnstile> (D'[X \<leadsto> P]\<^sub>e @ G) ok" using valid_subst by auto |
63167 | 1557 |
moreover note \<open>VarB x T \<in> set (D' @ TVarB X Q # G)\<close> |
30091
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1558 |
then have "VarB x T \<in> set D' \<or> VarB x T \<in> set G" by simp |
81127 | 1559 |
then have "(VarB x (T[X \<leadsto> P]\<^sub>\<tau>)) \<in> set (D'[X \<leadsto> P]\<^sub>e @ G)" |
30091
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1560 |
proof |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1561 |
assume "VarB x T \<in> set D'" |
81127 | 1562 |
then have "VarB x (T[X \<leadsto> P]\<^sub>\<tau>) \<in> set (D'[X \<leadsto> P]\<^sub>e)" |
30091
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1563 |
by (rule ctxt_subst_mem_VarB) |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1564 |
then show ?thesis by simp |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1565 |
next |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1566 |
assume x: "VarB x T \<in> set G" |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1567 |
from T_Var have ok: "\<turnstile> G ok" by (auto dest: subtype_implies_ok) |
32011 | 1568 |
then have "X \<sharp> ty_dom G" using T_Var by (auto dest: validE_append) |
1569 |
with ok have "X \<sharp> G" by (simp add: valid_ty_dom_fresh) |
|
30091
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1570 |
moreover from x have "VarB x T \<in> set (D' @ G)" by simp |
81127 | 1571 |
then have "VarB x (T[X \<leadsto> P]\<^sub>\<tau>) \<in> set ((D' @ G)[X \<leadsto> P]\<^sub>e)" |
30091
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1572 |
by (rule ctxt_subst_mem_VarB) |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1573 |
ultimately show ?thesis |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1574 |
by (simp add: ctxt_subst_append ctxt_subst_identity) |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1575 |
qed |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1576 |
ultimately show ?case by auto |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1577 |
next |
34915 | 1578 |
case (T_App t1 T1 T2 t2 X P D') |
81127 | 1579 |
then have "D'[X \<leadsto> P]\<^sub>e @ G \<turnstile> t1[X \<leadsto>\<^sub>\<tau> P] : (T1 \<rightarrow> T2)[X \<leadsto> P]\<^sub>\<tau>" by auto |
1580 |
moreover from T_App have "D'[X \<leadsto> P]\<^sub>e @ G \<turnstile> t2[X \<leadsto>\<^sub>\<tau> P] : T1[X \<leadsto> P]\<^sub>\<tau>" by auto |
|
30091
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1581 |
ultimately show ?case by auto |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1582 |
next |
34915 | 1583 |
case (T_Abs x T1 t2 T2 X P D') |
30091
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1584 |
then show ?case by force |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1585 |
next |
34915 | 1586 |
case (T_Sub t S T X P D') |
30091
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1587 |
then show ?case using substT_subtype by force |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1588 |
next |
34915 | 1589 |
case (T_TAbs X' T1 t2 T2 X P D') |
32011 | 1590 |
then have "X' \<sharp> ty_dom (D' @ TVarB X Q # G)" |
34915 | 1591 |
and "T1 closed_in (D' @ TVarB X Q # G)" |
30091
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1592 |
by (auto dest: typing_ok) |
34915 | 1593 |
then have "X' \<sharp> T1" by (rule closed_in_fresh) |
30091
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1594 |
with T_TAbs show ?case by force |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1595 |
next |
34915 | 1596 |
case (T_TApp X' t1 T2 T11 T12 X P D') |
32011 | 1597 |
then have "X' \<sharp> ty_dom (D' @ TVarB X Q # G)" |
1598 |
by (simp add: fresh_dom) |
|
30091
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1599 |
moreover from T_TApp have "T11 closed_in (D' @ TVarB X Q # G)" |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1600 |
by (auto dest: subtype_implies_closed) |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1601 |
ultimately have X': "X' \<sharp> T11" by (rule closed_in_fresh) |
81127 | 1602 |
from T_TApp have "D'[X \<leadsto> P]\<^sub>e @ G \<turnstile> t1[X \<leadsto>\<^sub>\<tau> P] : (\<forall>X'<:T11. T12)[X \<leadsto> P]\<^sub>\<tau>" |
30091
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1603 |
by simp |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1604 |
with X' and T_TApp show ?case |
80142 | 1605 |
by (auto simp: fresh_atm type_substitution_lemma |
30091
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1606 |
fresh_list_append fresh_list_cons |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1607 |
ctxt_subst_fresh' type_subst_fresh subst_trm_ty_fresh |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1608 |
intro: substT_subtype) |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1609 |
qed |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1610 |
|
63167 | 1611 |
lemma Abs_type: \<comment> \<open>A.13(1)\<close> |
30091
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1612 |
assumes H: "\<Gamma> \<turnstile> (\<lambda>x:S. s) : T" |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1613 |
and H': "\<Gamma> \<turnstile> T <: U \<rightarrow> U'" |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1614 |
and H'': "x \<sharp> \<Gamma>" |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1615 |
obtains S' where "\<Gamma> \<turnstile> U <: S" |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1616 |
and "(VarB x S) # \<Gamma> \<turnstile> s : S'" |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1617 |
and "\<Gamma> \<turnstile> S' <: U'" |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1618 |
using H H' H'' |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1619 |
proof (nominal_induct \<Gamma> t \<equiv> "\<lambda>x:S. s" T avoiding: x arbitrary: U U' S s rule: typing.strong_induct) |
53015
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
50252
diff
changeset
|
1620 |
case (T_Abs y T\<^sub>1 \<Gamma> t\<^sub>2 T\<^sub>2) |
63167 | 1621 |
from \<open>\<Gamma> \<turnstile> T\<^sub>1 \<rightarrow> T\<^sub>2 <: U \<rightarrow> U'\<close> |
53015
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
50252
diff
changeset
|
1622 |
obtain ty1: "\<Gamma> \<turnstile> U <: S" and ty2: "\<Gamma> \<turnstile> T\<^sub>2 <: U'" using T_Abs |
30091
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1623 |
by cases (simp_all add: ty.inject trm.inject alpha fresh_atm) |
53015
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
50252
diff
changeset
|
1624 |
from T_Abs have "VarB y S # \<Gamma> \<turnstile> [(y, x)] \<bullet> s : T\<^sub>2" |
30091
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1625 |
by (simp add: trm.inject alpha fresh_atm) |
53015
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
50252
diff
changeset
|
1626 |
then have "[(y, x)] \<bullet> (VarB y S # \<Gamma>) \<turnstile> [(y, x)] \<bullet> [(y, x)] \<bullet> s : [(y, x)] \<bullet> T\<^sub>2" |
30091
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1627 |
by (rule typing.eqvt) |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1628 |
moreover from T_Abs have "y \<sharp> \<Gamma>" |
32011 | 1629 |
by (auto dest!: typing_ok simp add: fresh_trm_dom) |
53015
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
50252
diff
changeset
|
1630 |
ultimately have "VarB x S # \<Gamma> \<turnstile> s : T\<^sub>2" using T_Abs |
30091
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1631 |
by (perm_simp add: ty_vrs_prm_simp) |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1632 |
with ty1 show ?case using ty2 by (rule T_Abs) |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1633 |
next |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1634 |
case (T_Sub \<Gamma> t S T) |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1635 |
then show ?case using subtype_transitivity by blast |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1636 |
qed simp_all |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1637 |
|
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1638 |
lemma subtype_reflexivity_from_typing: |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1639 |
assumes "\<Gamma> \<turnstile> t : T" |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1640 |
shows "\<Gamma> \<turnstile> T <: T" |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1641 |
using assms subtype_reflexivity typing_ok typing_closed_in by simp |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1642 |
|
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1643 |
lemma Abs_type': |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1644 |
assumes H: "\<Gamma> \<turnstile> (\<lambda>x:S. s) : U \<rightarrow> U'" |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1645 |
and H': "x \<sharp> \<Gamma>" |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1646 |
obtains S' |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1647 |
where "\<Gamma> \<turnstile> U <: S" |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1648 |
and "(VarB x S) # \<Gamma> \<turnstile> s : S'" |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1649 |
and "\<Gamma> \<turnstile> S' <: U'" |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1650 |
using H subtype_reflexivity_from_typing [OF H] H' |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1651 |
by (rule Abs_type) |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1652 |
|
63167 | 1653 |
lemma TAbs_type: \<comment> \<open>A.13(2)\<close> |
30091
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1654 |
assumes H: "\<Gamma> \<turnstile> (\<lambda>X<:S. s) : T" |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1655 |
and H': "\<Gamma> \<turnstile> T <: (\<forall>X<:U. U')" |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1656 |
and fresh: "X \<sharp> \<Gamma>" "X \<sharp> S" "X \<sharp> U" |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1657 |
obtains S' |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1658 |
where "\<Gamma> \<turnstile> U <: S" |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1659 |
and "(TVarB X U # \<Gamma>) \<turnstile> s : S'" |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1660 |
and "(TVarB X U # \<Gamma>) \<turnstile> S' <: U'" |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1661 |
using H H' fresh |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1662 |
proof (nominal_induct \<Gamma> t \<equiv> "\<lambda>X<:S. s" T avoiding: X U U' S arbitrary: s rule: typing.strong_induct) |
53015
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
50252
diff
changeset
|
1663 |
case (T_TAbs Y T\<^sub>1 \<Gamma> t\<^sub>2 T\<^sub>2) |
63167 | 1664 |
from \<open>TVarB Y T\<^sub>1 # \<Gamma> \<turnstile> t\<^sub>2 : T\<^sub>2\<close> have Y: "Y \<sharp> \<Gamma>" |
32011 | 1665 |
by (auto dest!: typing_ok simp add: valid_ty_dom_fresh) |
63167 | 1666 |
from \<open>Y \<sharp> U'\<close> and \<open>Y \<sharp> X\<close> |
30091
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1667 |
have "(\<forall>X<:U. U') = (\<forall>Y<:U. [(Y, X)] \<bullet> U')" |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1668 |
by (simp add: ty.inject alpha' fresh_atm) |
53015
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
50252
diff
changeset
|
1669 |
with T_TAbs have "\<Gamma> \<turnstile> (\<forall>Y<:S. T\<^sub>2) <: (\<forall>Y<:U. [(Y, X)] \<bullet> U')" by (simp add: trm.inject) |
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
50252
diff
changeset
|
1670 |
then obtain ty1: "\<Gamma> \<turnstile> U <: S" and ty2: "(TVarB Y U # \<Gamma>) \<turnstile> T\<^sub>2 <: ([(Y, X)] \<bullet> U')" using T_TAbs Y |
30091
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1671 |
by (cases rule: subtype_of.strong_cases [where X=Y]) (simp_all add: ty.inject alpha abs_fresh) |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1672 |
note ty1 |
53015
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
50252
diff
changeset
|
1673 |
moreover from T_TAbs have "TVarB Y S # \<Gamma> \<turnstile> ([(Y, X)] \<bullet> s) : T\<^sub>2" |
30091
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1674 |
by (simp add: trm.inject alpha fresh_atm) |
53015
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
50252
diff
changeset
|
1675 |
then have "[(Y, X)] \<bullet> (TVarB Y S # \<Gamma>) \<turnstile> [(Y, X)] \<bullet> [(Y, X)] \<bullet> s : [(Y, X)] \<bullet> T\<^sub>2" |
30091
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1676 |
by (rule typing.eqvt) |
63167 | 1677 |
with \<open>X \<sharp> \<Gamma>\<close> \<open>X \<sharp> S\<close> Y \<open>Y \<sharp> S\<close> have "TVarB X S # \<Gamma> \<turnstile> s : [(Y, X)] \<bullet> T\<^sub>2" |
30091
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1678 |
by perm_simp |
53015
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
50252
diff
changeset
|
1679 |
then have "TVarB X U # \<Gamma> \<turnstile> s : [(Y, X)] \<bullet> T\<^sub>2" using ty1 |
30091
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1680 |
by (rule narrow_type [of "[]", simplified]) |
53015
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
50252
diff
changeset
|
1681 |
moreover from ty2 have "([(Y, X)] \<bullet> (TVarB Y U # \<Gamma>)) \<turnstile> ([(Y, X)] \<bullet> T\<^sub>2) <: ([(Y, X)] \<bullet> [(Y, X)] \<bullet> U')" |
30091
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1682 |
by (rule subtype_of.eqvt) |
63167 | 1683 |
with \<open>X \<sharp> \<Gamma>\<close> \<open>X \<sharp> U\<close> Y \<open>Y \<sharp> U\<close> have "(TVarB X U # \<Gamma>) \<turnstile> ([(Y, X)] \<bullet> T\<^sub>2) <: U'" |
30091
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1684 |
by perm_simp |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1685 |
ultimately show ?case by (rule T_TAbs) |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1686 |
next |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1687 |
case (T_Sub \<Gamma> t S T) |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1688 |
then show ?case using subtype_transitivity by blast |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1689 |
qed simp_all |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1690 |
|
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1691 |
lemma TAbs_type': |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1692 |
assumes H: "\<Gamma> \<turnstile> (\<lambda>X<:S. s) : (\<forall>X<:U. U')" |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1693 |
and fresh: "X \<sharp> \<Gamma>" "X \<sharp> S" "X \<sharp> U" |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1694 |
obtains S' |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1695 |
where "\<Gamma> \<turnstile> U <: S" |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1696 |
and "(TVarB X U # \<Gamma>) \<turnstile> s : S'" |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1697 |
and "(TVarB X U # \<Gamma>) \<turnstile> S' <: U'" |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1698 |
using H subtype_reflexivity_from_typing [OF H] fresh |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1699 |
by (rule TAbs_type) |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1700 |
|
63167 | 1701 |
theorem preservation: \<comment> \<open>A.20\<close> |
30091
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1702 |
assumes H: "\<Gamma> \<turnstile> t : T" |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1703 |
shows "t \<longmapsto> t' \<Longrightarrow> \<Gamma> \<turnstile> t' : T" using H |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1704 |
proof (nominal_induct avoiding: t' rule: typing.strong_induct) |
53015
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
50252
diff
changeset
|
1705 |
case (T_App \<Gamma> t\<^sub>1 T\<^sub>11 T\<^sub>12 t\<^sub>2 t') |
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
50252
diff
changeset
|
1706 |
obtain x::vrs where x_fresh: "x \<sharp> (\<Gamma>, t\<^sub>1 \<cdot> t\<^sub>2, t')" |
30091
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1707 |
by (rule exists_fresh) (rule fin_supp) |
53015
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
50252
diff
changeset
|
1708 |
obtain X::tyvrs where "X \<sharp> (t\<^sub>1 \<cdot> t\<^sub>2, t')" |
30091
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1709 |
by (rule exists_fresh) (rule fin_supp) |
63167 | 1710 |
with \<open>t\<^sub>1 \<cdot> t\<^sub>2 \<longmapsto> t'\<close> show ?case |
30091
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1711 |
proof (cases rule: eval.strong_cases [where x=x and X=X]) |
53015
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
50252
diff
changeset
|
1712 |
case (E_Abs v\<^sub>2 T\<^sub>11' t\<^sub>12) |
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
50252
diff
changeset
|
1713 |
with T_App and x_fresh have h: "\<Gamma> \<turnstile> (\<lambda>x:T\<^sub>11'. t\<^sub>12) : T\<^sub>11 \<rightarrow> T\<^sub>12" |
30091
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1714 |
by (simp add: trm.inject fresh_prod) |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1715 |
moreover from x_fresh have "x \<sharp> \<Gamma>" by simp |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1716 |
ultimately obtain S' |
53015
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
50252
diff
changeset
|
1717 |
where T\<^sub>11: "\<Gamma> \<turnstile> T\<^sub>11 <: T\<^sub>11'" |
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
50252
diff
changeset
|
1718 |
and t\<^sub>12: "(VarB x T\<^sub>11') # \<Gamma> \<turnstile> t\<^sub>12 : S'" |
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
50252
diff
changeset
|
1719 |
and S': "\<Gamma> \<turnstile> S' <: T\<^sub>12" |
30091
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1720 |
by (rule Abs_type') blast |
63167 | 1721 |
from \<open>\<Gamma> \<turnstile> t\<^sub>2 : T\<^sub>11\<close> |
53015
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
50252
diff
changeset
|
1722 |
have "\<Gamma> \<turnstile> t\<^sub>2 : T\<^sub>11'" using T\<^sub>11 by (rule T_Sub) |
81127 | 1723 |
with t\<^sub>12 have "\<Gamma> \<turnstile> t\<^sub>12[x \<leadsto> t\<^sub>2] : S'" |
30091
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1724 |
by (rule subst_type [where \<Delta>="[]", simplified]) |
81127 | 1725 |
hence "\<Gamma> \<turnstile> t\<^sub>12[x \<leadsto> t\<^sub>2] : T\<^sub>12" using S' by (rule T_Sub) |
30091
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1726 |
with E_Abs and x_fresh show ?thesis by (simp add: trm.inject fresh_prod) |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1727 |
next |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1728 |
case (E_App1 t''' t'' u) |
53015
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
50252
diff
changeset
|
1729 |
hence "t\<^sub>1 \<longmapsto> t''" by (simp add:trm.inject) |
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
50252
diff
changeset
|
1730 |
hence "\<Gamma> \<turnstile> t'' : T\<^sub>11 \<rightarrow> T\<^sub>12" by (rule T_App) |
63167 | 1731 |
hence "\<Gamma> \<turnstile> t'' \<cdot> t\<^sub>2 : T\<^sub>12" using \<open>\<Gamma> \<turnstile> t\<^sub>2 : T\<^sub>11\<close> |
30091
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1732 |
by (rule typing.T_App) |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1733 |
with E_App1 show ?thesis by (simp add:trm.inject) |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1734 |
next |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1735 |
case (E_App2 v t''' t'') |
53015
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
50252
diff
changeset
|
1736 |
hence "t\<^sub>2 \<longmapsto> t''" by (simp add:trm.inject) |
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
50252
diff
changeset
|
1737 |
hence "\<Gamma> \<turnstile> t'' : T\<^sub>11" by (rule T_App) |
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
50252
diff
changeset
|
1738 |
with T_App(1) have "\<Gamma> \<turnstile> t\<^sub>1 \<cdot> t'' : T\<^sub>12" |
30091
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1739 |
by (rule typing.T_App) |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1740 |
with E_App2 show ?thesis by (simp add:trm.inject) |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1741 |
qed (simp_all add: fresh_prod) |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1742 |
next |
53015
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
50252
diff
changeset
|
1743 |
case (T_TApp X \<Gamma> t\<^sub>1 T\<^sub>2 T\<^sub>11 T\<^sub>12 t') |
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
50252
diff
changeset
|
1744 |
obtain x::vrs where "x \<sharp> (t\<^sub>1 \<cdot>\<^sub>\<tau> T\<^sub>2, t')" |
30091
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1745 |
by (rule exists_fresh) (rule fin_supp) |
63167 | 1746 |
with \<open>t\<^sub>1 \<cdot>\<^sub>\<tau> T\<^sub>2 \<longmapsto> t'\<close> |
30091
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1747 |
show ?case |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1748 |
proof (cases rule: eval.strong_cases [where X=X and x=x]) |
53015
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
50252
diff
changeset
|
1749 |
case (E_TAbs T\<^sub>11' T\<^sub>2' t\<^sub>12) |
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
50252
diff
changeset
|
1750 |
with T_TApp have "\<Gamma> \<turnstile> (\<lambda>X<:T\<^sub>11'. t\<^sub>12) : (\<forall>X<:T\<^sub>11. T\<^sub>12)" and "X \<sharp> \<Gamma>" and "X \<sharp> T\<^sub>11'" |
30091
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1751 |
by (simp_all add: trm.inject) |
63167 | 1752 |
moreover from \<open>\<Gamma>\<turnstile>T\<^sub>2<:T\<^sub>11\<close> and \<open>X \<sharp> \<Gamma>\<close> have "X \<sharp> T\<^sub>11" |
32011 | 1753 |
by (blast intro: closed_in_fresh fresh_dom dest: subtype_implies_closed) |
30091
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1754 |
ultimately obtain S' |
53015
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
50252
diff
changeset
|
1755 |
where "TVarB X T\<^sub>11 # \<Gamma> \<turnstile> t\<^sub>12 : S'" |
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
50252
diff
changeset
|
1756 |
and "(TVarB X T\<^sub>11 # \<Gamma>) \<turnstile> S' <: T\<^sub>12" |
30091
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1757 |
by (rule TAbs_type') blast |
53015
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
50252
diff
changeset
|
1758 |
hence "TVarB X T\<^sub>11 # \<Gamma> \<turnstile> t\<^sub>12 : T\<^sub>12" by (rule T_Sub) |
81127 | 1759 |
hence "\<Gamma> \<turnstile> t\<^sub>12[X \<leadsto>\<^sub>\<tau> T\<^sub>2] : T\<^sub>12[X \<leadsto> T\<^sub>2]\<^sub>\<tau>" using \<open>\<Gamma> \<turnstile> T\<^sub>2 <: T\<^sub>11\<close> |
30091
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1760 |
by (rule substT_type [where D="[]", simplified]) |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1761 |
with T_TApp and E_TAbs show ?thesis by (simp add: trm.inject) |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1762 |
next |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1763 |
case (E_TApp t''' t'' T) |
53015
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
50252
diff
changeset
|
1764 |
from E_TApp have "t\<^sub>1 \<longmapsto> t''" by (simp add: trm.inject) |
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
50252
diff
changeset
|
1765 |
then have "\<Gamma> \<turnstile> t'' : (\<forall>X<:T\<^sub>11. T\<^sub>12)" by (rule T_TApp) |
81127 | 1766 |
then have "\<Gamma> \<turnstile> t'' \<cdot>\<^sub>\<tau> T\<^sub>2 : T\<^sub>12[X \<leadsto> T\<^sub>2]\<^sub>\<tau>" using \<open>\<Gamma> \<turnstile> T\<^sub>2 <: T\<^sub>11\<close> |
30091
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1767 |
by (rule better_T_TApp) |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1768 |
with E_TApp show ?thesis by (simp add: trm.inject) |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1769 |
qed (simp_all add: fresh_prod) |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1770 |
next |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1771 |
case (T_Sub \<Gamma> t S T t') |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1772 |
have "t \<longmapsto> t'" by fact |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1773 |
hence "\<Gamma> \<turnstile> t' : S" by (rule T_Sub) |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1774 |
moreover have "\<Gamma> \<turnstile> S <: T" by fact |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1775 |
ultimately show ?case by (rule typing.T_Sub) |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1776 |
qed (auto) |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1777 |
|
63167 | 1778 |
lemma Fun_canonical: \<comment> \<open>A.14(1)\<close> |
53015
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
50252
diff
changeset
|
1779 |
assumes ty: "[] \<turnstile> v : T\<^sub>1 \<rightarrow> T\<^sub>2" |
30091
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1780 |
shows "val v \<Longrightarrow> \<exists>x t S. v = (\<lambda>x:S. t)" using ty |
53015
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
50252
diff
changeset
|
1781 |
proof (induct "[]::env" v "T\<^sub>1 \<rightarrow> T\<^sub>2" arbitrary: T\<^sub>1 T\<^sub>2) |
34915 | 1782 |
case (T_Sub t S) |
63167 | 1783 |
from \<open>[] \<turnstile> S <: T\<^sub>1 \<rightarrow> T\<^sub>2\<close> |
53015
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
50252
diff
changeset
|
1784 |
obtain S\<^sub>1 S\<^sub>2 where S: "S = S\<^sub>1 \<rightarrow> S\<^sub>2" |
80142 | 1785 |
by cases (auto simp: T_Sub) |
63167 | 1786 |
then show ?case using \<open>val t\<close> by (rule T_Sub) |
30091
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1787 |
qed (auto) |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1788 |
|
63167 | 1789 |
lemma TyAll_canonical: \<comment> \<open>A.14(3)\<close> |
30091
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1790 |
fixes X::tyvrs |
53015
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
50252
diff
changeset
|
1791 |
assumes ty: "[] \<turnstile> v : (\<forall>X<:T\<^sub>1. T\<^sub>2)" |
30091
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1792 |
shows "val v \<Longrightarrow> \<exists>X t S. v = (\<lambda>X<:S. t)" using ty |
53015
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
50252
diff
changeset
|
1793 |
proof (induct "[]::env" v "\<forall>X<:T\<^sub>1. T\<^sub>2" arbitrary: X T\<^sub>1 T\<^sub>2) |
34915 | 1794 |
case (T_Sub t S) |
63167 | 1795 |
from \<open>[] \<turnstile> S <: (\<forall>X<:T\<^sub>1. T\<^sub>2)\<close> |
53015
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
50252
diff
changeset
|
1796 |
obtain X S\<^sub>1 S\<^sub>2 where S: "S = (\<forall>X<:S\<^sub>1. S\<^sub>2)" |
80142 | 1797 |
by cases (auto simp: T_Sub) |
30091
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1798 |
then show ?case using T_Sub by auto |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1799 |
qed (auto) |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1800 |
|
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1801 |
theorem progress: |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1802 |
assumes "[] \<turnstile> t : T" |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1803 |
shows "val t \<or> (\<exists>t'. t \<longmapsto> t')" |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1804 |
using assms |
34915 | 1805 |
proof (induct "[]::env" t T) |
53015
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
50252
diff
changeset
|
1806 |
case (T_App t\<^sub>1 T\<^sub>11 T\<^sub>12 t\<^sub>2) |
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
50252
diff
changeset
|
1807 |
hence "val t\<^sub>1 \<or> (\<exists>t'. t\<^sub>1 \<longmapsto> t')" by simp |
30091
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1808 |
thus ?case |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1809 |
proof |
53015
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
50252
diff
changeset
|
1810 |
assume t\<^sub>1_val: "val t\<^sub>1" |
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
50252
diff
changeset
|
1811 |
with T_App obtain x t3 S where t\<^sub>1: "t\<^sub>1 = (\<lambda>x:S. t3)" |
30091
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1812 |
by (auto dest!: Fun_canonical) |
53015
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
50252
diff
changeset
|
1813 |
from T_App have "val t\<^sub>2 \<or> (\<exists>t'. t\<^sub>2 \<longmapsto> t')" by simp |
30091
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1814 |
thus ?case |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1815 |
proof |
53015
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
50252
diff
changeset
|
1816 |
assume "val t\<^sub>2" |
81127 | 1817 |
with t\<^sub>1 have "t\<^sub>1 \<cdot> t\<^sub>2 \<longmapsto> t3[x \<leadsto> t\<^sub>2]" by auto |
30091
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1818 |
thus ?case by auto |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1819 |
next |
53015
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
50252
diff
changeset
|
1820 |
assume "\<exists>t'. t\<^sub>2 \<longmapsto> t'" |
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
50252
diff
changeset
|
1821 |
then obtain t' where "t\<^sub>2 \<longmapsto> t'" by auto |
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
50252
diff
changeset
|
1822 |
with t\<^sub>1_val have "t\<^sub>1 \<cdot> t\<^sub>2 \<longmapsto> t\<^sub>1 \<cdot> t'" by auto |
30091
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1823 |
thus ?case by auto |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1824 |
qed |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1825 |
next |
53015
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
50252
diff
changeset
|
1826 |
assume "\<exists>t'. t\<^sub>1 \<longmapsto> t'" |
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
50252
diff
changeset
|
1827 |
then obtain t' where "t\<^sub>1 \<longmapsto> t'" by auto |
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
50252
diff
changeset
|
1828 |
hence "t\<^sub>1 \<cdot> t\<^sub>2 \<longmapsto> t' \<cdot> t\<^sub>2" by auto |
30091
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1829 |
thus ?case by auto |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1830 |
qed |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1831 |
next |
53015
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
50252
diff
changeset
|
1832 |
case (T_TApp X t\<^sub>1 T\<^sub>2 T\<^sub>11 T\<^sub>12) |
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
50252
diff
changeset
|
1833 |
hence "val t\<^sub>1 \<or> (\<exists>t'. t\<^sub>1 \<longmapsto> t')" by simp |
30091
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1834 |
thus ?case |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1835 |
proof |
53015
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
50252
diff
changeset
|
1836 |
assume "val t\<^sub>1" |
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
50252
diff
changeset
|
1837 |
with T_TApp obtain x t S where "t\<^sub>1 = (\<lambda>x<:S. t)" |
30091
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1838 |
by (auto dest!: TyAll_canonical) |
81127 | 1839 |
hence "t\<^sub>1 \<cdot>\<^sub>\<tau> T\<^sub>2 \<longmapsto> t[x \<leadsto>\<^sub>\<tau> T\<^sub>2]" by auto |
30091
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1840 |
thus ?case by auto |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1841 |
next |
53015
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
50252
diff
changeset
|
1842 |
assume "\<exists>t'. t\<^sub>1 \<longmapsto> t'" thus ?case by auto |
30091
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1843 |
qed |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1844 |
qed (auto) |
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1845 |
|
2fb0b721e9c2
Added typing and evaluation relations, together with proofs of preservation
berghofe
parents:
29097
diff
changeset
|
1846 |
end |