equal
deleted
inserted
replaced
2 |
2 |
3 theory Weakening |
3 theory Weakening |
4 imports "../Nominal" |
4 imports "../Nominal" |
5 begin |
5 begin |
6 |
6 |
7 section {* Weakening Example for the Simply-Typed Lambda-Calculus *} |
7 section {* Weakening Property in the Simply-Typed Lambda-Calculus *} |
8 |
8 |
9 atom_decl name |
9 atom_decl name |
10 |
10 |
11 text {* Terms and types *} |
11 text {* Terms and Types *} |
12 nominal_datatype lam = |
12 nominal_datatype lam = |
13 Var "name" |
13 Var "name" |
14 | App "lam" "lam" |
14 | App "lam" "lam" |
15 | Lam "\<guillemotleft>name\<guillemotright>lam" ("Lam [_]._" [100,100] 100) |
15 | Lam "\<guillemotleft>name\<guillemotright>lam" ("Lam [_]._" [100,100] 100) |
16 |
16 |
46 | t_Lam[intro]: "\<lbrakk>x\<sharp>\<Gamma>;(x,T1)#\<Gamma> \<turnstile> t : T2\<rbrakk> \<Longrightarrow> \<Gamma> \<turnstile> Lam [x].t : T1\<rightarrow>T2" |
46 | t_Lam[intro]: "\<lbrakk>x\<sharp>\<Gamma>;(x,T1)#\<Gamma> \<turnstile> t : T2\<rbrakk> \<Longrightarrow> \<Gamma> \<turnstile> Lam [x].t : T1\<rightarrow>T2" |
47 |
47 |
48 text {* |
48 text {* |
49 We derive the strong induction principle for the typing |
49 We derive the strong induction principle for the typing |
50 relation (this induction principle has the variable convention |
50 relation (this induction principle has the variable convention |
51 already built in). |
51 already built-in). |
52 *} |
52 *} |
53 equivariance typing |
53 equivariance typing |
54 nominal_inductive typing |
54 nominal_inductive typing |
55 by (simp_all add: abs_fresh ty_fresh) |
55 by (simp_all add: abs_fresh ty_fresh) |
56 |
56 |
142 moreover |
142 moreover |
143 have "valid ((x,T1)#\<Gamma>2)" using v2 (* fails *) |
143 have "valid ((x,T1)#\<Gamma>2)" using v2 (* fails *) |
144 oops |
144 oops |
145 |
145 |
146 text{* The complete proof without using the variable convention. *} |
146 text{* The complete proof without using the variable convention. *} |
|
147 |
147 lemma weakening_with_explicit_renaming: |
148 lemma weakening_with_explicit_renaming: |
148 fixes \<Gamma>1 \<Gamma>2::"(name\<times>ty) list" |
149 fixes \<Gamma>1 \<Gamma>2::"(name\<times>ty) list" |
149 assumes a: "\<Gamma>1 \<turnstile> t : T" |
150 assumes a: "\<Gamma>1 \<turnstile> t : T" |
150 and b: "valid \<Gamma>2" |
151 and b: "valid \<Gamma>2" |
151 and c: "\<Gamma>1 \<subseteq> \<Gamma>2" |
152 and c: "\<Gamma>1 \<subseteq> \<Gamma>2" |
187 qed |
188 qed |
188 ultimately show "\<Gamma>2 \<turnstile> Lam [x].t : T1 \<rightarrow> T2" by simp |
189 ultimately show "\<Gamma>2 \<turnstile> Lam [x].t : T1 \<rightarrow> T2" by simp |
189 qed (auto) |
190 qed (auto) |
190 |
191 |
191 text {* |
192 text {* |
192 Compare the proof with explicit renamings to version1 and version2, |
193 Moral: compare the proof with explicit renamings to version1 and version2, |
193 and imagine you are proving something more substantial than the |
194 and imagine you are proving something more substantial than the weakening |
194 weakening lemma. |
195 lemma. |
195 *} |
196 *} |
196 |
197 |
197 end |
198 end |