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