author | wenzelm |
Tue, 10 Jul 2007 23:29:43 +0200 | |
changeset 23719 | ccd9cb15c062 |
parent 22730 | 8bcc8809ed3b |
child 23760 | aca2c7f80e2f |
permissions | -rw-r--r-- |
18269 | 1 |
(* $Id$ *) |
18105 | 2 |
|
19496 | 3 |
theory Weakening |
22418
49e2d9744ae1
major update of the nominal package; there is now an infrastructure
urbanc
parents:
22231
diff
changeset
|
4 |
imports "../Nominal" |
18105 | 5 |
begin |
6 |
||
21052
ec5531061ed6
adapted to Stefan's new inductive package and cleaning up
urbanc
parents:
20955
diff
changeset
|
7 |
section {* Weakening Example for the Simply-Typed Lambda-Calculus *} |
ec5531061ed6
adapted to Stefan's new inductive package and cleaning up
urbanc
parents:
20955
diff
changeset
|
8 |
(*================================================================*) |
18105 | 9 |
|
10 |
atom_decl name |
|
11 |
||
21052
ec5531061ed6
adapted to Stefan's new inductive package and cleaning up
urbanc
parents:
20955
diff
changeset
|
12 |
nominal_datatype lam = |
ec5531061ed6
adapted to Stefan's new inductive package and cleaning up
urbanc
parents:
20955
diff
changeset
|
13 |
Var "name" |
ec5531061ed6
adapted to Stefan's new inductive package and cleaning up
urbanc
parents:
20955
diff
changeset
|
14 |
| App "lam" "lam" |
ec5531061ed6
adapted to Stefan's new inductive package and cleaning up
urbanc
parents:
20955
diff
changeset
|
15 |
| Lam "\<guillemotleft>name\<guillemotright>lam" ("Lam [_]._" [100,100] 100) |
18105 | 16 |
|
18352 | 17 |
nominal_datatype ty = |
18 |
TVar "nat" |
|
18105 | 19 |
| TArr "ty" "ty" (infix "\<rightarrow>" 200) |
20 |
||
22533 | 21 |
lemma ty_fresh: |
22 |
fixes x::"name" |
|
23 |
and T::"ty" |
|
24 |
shows "x\<sharp>T" |
|
25 |
by (nominal_induct T rule: ty.induct) |
|
26 |
(auto simp add: fresh_nat) |
|
18105 | 27 |
|
21052
ec5531061ed6
adapted to Stefan's new inductive package and cleaning up
urbanc
parents:
20955
diff
changeset
|
28 |
text {* valid contexts *} |
22533 | 29 |
|
21052
ec5531061ed6
adapted to Stefan's new inductive package and cleaning up
urbanc
parents:
20955
diff
changeset
|
30 |
inductive2 |
18105 | 31 |
valid :: "(name\<times>ty) list \<Rightarrow> bool" |
21364 | 32 |
where |
33 |
v1[intro]: "valid []" |
|
34 |
| v2[intro]: "\<lbrakk>valid \<Gamma>;a\<sharp>\<Gamma>\<rbrakk>\<Longrightarrow> valid ((a,\<sigma>)#\<Gamma>)" |
|
18105 | 35 |
|
22533 | 36 |
equivariance valid |
22231
f76f187c91f9
added an infrastructure that allows the user to declare lemmas to be equivariance lemmas; the intention is to use these lemmas in automated tools but also can be employed by the user
urbanc
parents:
21488
diff
changeset
|
37 |
|
21052
ec5531061ed6
adapted to Stefan's new inductive package and cleaning up
urbanc
parents:
20955
diff
changeset
|
38 |
text{* typing judgements *} |
ec5531061ed6
adapted to Stefan's new inductive package and cleaning up
urbanc
parents:
20955
diff
changeset
|
39 |
inductive2 |
22650
0c5b22076fb3
tuned the proof of lemma pt_list_set_fresh (as suggested by Randy Pollack) and tuned the syntax for sub_contexts
urbanc
parents:
22533
diff
changeset
|
40 |
typing :: "(name\<times>ty) list\<Rightarrow>lam\<Rightarrow>ty\<Rightarrow>bool" ("_ \<turnstile> _ : _" [60,60,60] 60) |
21364 | 41 |
where |
22650
0c5b22076fb3
tuned the proof of lemma pt_list_set_fresh (as suggested by Randy Pollack) and tuned the syntax for sub_contexts
urbanc
parents:
22533
diff
changeset
|
42 |
t_Var[intro]: "\<lbrakk>valid \<Gamma>; (x,T)\<in>set \<Gamma>\<rbrakk> \<Longrightarrow> \<Gamma> \<turnstile> Var x : T" |
0c5b22076fb3
tuned the proof of lemma pt_list_set_fresh (as suggested by Randy Pollack) and tuned the syntax for sub_contexts
urbanc
parents:
22533
diff
changeset
|
43 |
| t_App[intro]: "\<lbrakk>\<Gamma> \<turnstile> t1 : T1\<rightarrow>T2; \<Gamma> \<turnstile> t2 : T1\<rbrakk> \<Longrightarrow> \<Gamma> \<turnstile> App t1 t2 : T2" |
22533 | 44 |
| t_Lam[intro]: "\<lbrakk>x\<sharp>\<Gamma>;((x,T1)#\<Gamma>) \<turnstile> t : T2\<rbrakk> \<Longrightarrow> \<Gamma> \<turnstile> Lam [x].t : T1\<rightarrow>T2" |
21052
ec5531061ed6
adapted to Stefan's new inductive package and cleaning up
urbanc
parents:
20955
diff
changeset
|
45 |
|
22730
8bcc8809ed3b
nominal_inductive no longer proves equivariance.
berghofe
parents:
22650
diff
changeset
|
46 |
equivariance typing |
8bcc8809ed3b
nominal_inductive no longer proves equivariance.
berghofe
parents:
22650
diff
changeset
|
47 |
|
22533 | 48 |
(* automatically deriving the strong induction principle *) |
49 |
nominal_inductive typing |
|
50 |
by (simp_all add: abs_fresh ty_fresh) |
|
18105 | 51 |
|
21052
ec5531061ed6
adapted to Stefan's new inductive package and cleaning up
urbanc
parents:
20955
diff
changeset
|
52 |
text {* definition of a subcontext *} |
18105 | 53 |
|
21052
ec5531061ed6
adapted to Stefan's new inductive package and cleaning up
urbanc
parents:
20955
diff
changeset
|
54 |
abbreviation |
22650
0c5b22076fb3
tuned the proof of lemma pt_list_set_fresh (as suggested by Randy Pollack) and tuned the syntax for sub_contexts
urbanc
parents:
22533
diff
changeset
|
55 |
"sub_context" :: "(name\<times>ty) list \<Rightarrow> (name\<times>ty) list \<Rightarrow> bool" ("_ \<subseteq> _" [60,60] 60) |
22533 | 56 |
where |
22650
0c5b22076fb3
tuned the proof of lemma pt_list_set_fresh (as suggested by Randy Pollack) and tuned the syntax for sub_contexts
urbanc
parents:
22533
diff
changeset
|
57 |
"\<Gamma>1 \<subseteq> \<Gamma>2 \<equiv> \<forall>x T. (x,T)\<in>set \<Gamma>1 \<longrightarrow> (x,T)\<in>set \<Gamma>2" |
21052
ec5531061ed6
adapted to Stefan's new inductive package and cleaning up
urbanc
parents:
20955
diff
changeset
|
58 |
|
22533 | 59 |
text {* Now it comes: The Weakening Lemma *} |
18105 | 60 |
|
18311
b83b00cbaecf
changed "fresh:" to "avoiding:" and cleaned up the weakening example
urbanc
parents:
18296
diff
changeset
|
61 |
lemma weakening_version1: |
22418
49e2d9744ae1
major update of the nominal package; there is now an infrastructure
urbanc
parents:
22231
diff
changeset
|
62 |
assumes a: "\<Gamma>1 \<turnstile> t : T" |
18311
b83b00cbaecf
changed "fresh:" to "avoiding:" and cleaned up the weakening example
urbanc
parents:
18296
diff
changeset
|
63 |
and b: "valid \<Gamma>2" |
22650
0c5b22076fb3
tuned the proof of lemma pt_list_set_fresh (as suggested by Randy Pollack) and tuned the syntax for sub_contexts
urbanc
parents:
22533
diff
changeset
|
64 |
and c: "\<Gamma>1 \<subseteq> \<Gamma>2" |
22418
49e2d9744ae1
major update of the nominal package; there is now an infrastructure
urbanc
parents:
22231
diff
changeset
|
65 |
shows "\<Gamma>2 \<turnstile> t : T" |
18311
b83b00cbaecf
changed "fresh:" to "avoiding:" and cleaned up the weakening example
urbanc
parents:
18296
diff
changeset
|
66 |
using a b c |
22533 | 67 |
by (nominal_induct \<Gamma>1 t T avoiding: \<Gamma>2 rule: typing.strong_induct) |
22418
49e2d9744ae1
major update of the nominal package; there is now an infrastructure
urbanc
parents:
22231
diff
changeset
|
68 |
(auto | atomize)+ |
18105 | 69 |
|
18311
b83b00cbaecf
changed "fresh:" to "avoiding:" and cleaned up the weakening example
urbanc
parents:
18296
diff
changeset
|
70 |
lemma weakening_version2: |
18105 | 71 |
fixes \<Gamma>1::"(name\<times>ty) list" |
72 |
and t ::"lam" |
|
73 |
and \<tau> ::"ty" |
|
22650
0c5b22076fb3
tuned the proof of lemma pt_list_set_fresh (as suggested by Randy Pollack) and tuned the syntax for sub_contexts
urbanc
parents:
22533
diff
changeset
|
74 |
assumes a: "\<Gamma>1 \<turnstile> t : T" |
18311
b83b00cbaecf
changed "fresh:" to "avoiding:" and cleaned up the weakening example
urbanc
parents:
18296
diff
changeset
|
75 |
and b: "valid \<Gamma>2" |
22650
0c5b22076fb3
tuned the proof of lemma pt_list_set_fresh (as suggested by Randy Pollack) and tuned the syntax for sub_contexts
urbanc
parents:
22533
diff
changeset
|
76 |
and c: "\<Gamma>1 \<subseteq> \<Gamma>2" |
0c5b22076fb3
tuned the proof of lemma pt_list_set_fresh (as suggested by Randy Pollack) and tuned the syntax for sub_contexts
urbanc
parents:
22533
diff
changeset
|
77 |
shows "\<Gamma>2 \<turnstile> t : T" |
18311
b83b00cbaecf
changed "fresh:" to "avoiding:" and cleaned up the weakening example
urbanc
parents:
18296
diff
changeset
|
78 |
using a b c |
22533 | 79 |
proof (nominal_induct \<Gamma>1 t T avoiding: \<Gamma>2 rule: typing.strong_induct) |
80 |
case (t_Var \<Gamma>1 x T) (* variable case *) |
|
22650
0c5b22076fb3
tuned the proof of lemma pt_list_set_fresh (as suggested by Randy Pollack) and tuned the syntax for sub_contexts
urbanc
parents:
22533
diff
changeset
|
81 |
have "\<Gamma>1 \<subseteq> \<Gamma>2" by fact |
21052
ec5531061ed6
adapted to Stefan's new inductive package and cleaning up
urbanc
parents:
20955
diff
changeset
|
82 |
moreover |
ec5531061ed6
adapted to Stefan's new inductive package and cleaning up
urbanc
parents:
20955
diff
changeset
|
83 |
have "valid \<Gamma>2" by fact |
ec5531061ed6
adapted to Stefan's new inductive package and cleaning up
urbanc
parents:
20955
diff
changeset
|
84 |
moreover |
22533 | 85 |
have "(x,T)\<in> set \<Gamma>1" by fact |
86 |
ultimately show "\<Gamma>2 \<turnstile> Var x : T" by auto |
|
18105 | 87 |
next |
22533 | 88 |
case (t_Lam x \<Gamma>1 T1 t T2) (* lambda case *) |
89 |
have vc: "x\<sharp>\<Gamma>2" by fact (* variable convention *) |
|
22650
0c5b22076fb3
tuned the proof of lemma pt_list_set_fresh (as suggested by Randy Pollack) and tuned the syntax for sub_contexts
urbanc
parents:
22533
diff
changeset
|
90 |
have ih: "\<lbrakk>valid ((x,T1)#\<Gamma>2); (x,T1)#\<Gamma>1 \<subseteq> (x,T1)#\<Gamma>2\<rbrakk> \<Longrightarrow> (x,T1)#\<Gamma>2 \<turnstile> t:T2" by fact |
0c5b22076fb3
tuned the proof of lemma pt_list_set_fresh (as suggested by Randy Pollack) and tuned the syntax for sub_contexts
urbanc
parents:
22533
diff
changeset
|
91 |
have "\<Gamma>1 \<subseteq> \<Gamma>2" by fact |
0c5b22076fb3
tuned the proof of lemma pt_list_set_fresh (as suggested by Randy Pollack) and tuned the syntax for sub_contexts
urbanc
parents:
22533
diff
changeset
|
92 |
then have "(x,T1)#\<Gamma>1 \<subseteq> (x,T1)#\<Gamma>2" by simp |
18105 | 93 |
moreover |
21052
ec5531061ed6
adapted to Stefan's new inductive package and cleaning up
urbanc
parents:
20955
diff
changeset
|
94 |
have "valid \<Gamma>2" by fact |
22533 | 95 |
then have "valid ((x,T1)#\<Gamma>2)" using vc by (simp add: v2) |
22650
0c5b22076fb3
tuned the proof of lemma pt_list_set_fresh (as suggested by Randy Pollack) and tuned the syntax for sub_contexts
urbanc
parents:
22533
diff
changeset
|
96 |
ultimately have "(x,T1)#\<Gamma>2 \<turnstile> t : T2" using ih by simp |
0c5b22076fb3
tuned the proof of lemma pt_list_set_fresh (as suggested by Randy Pollack) and tuned the syntax for sub_contexts
urbanc
parents:
22533
diff
changeset
|
97 |
with vc show "\<Gamma>2 \<turnstile> Lam [x].t : T1\<rightarrow>T2" by auto |
21488 | 98 |
qed (auto) (* app case *) |
18105 | 99 |
|
18311
b83b00cbaecf
changed "fresh:" to "avoiding:" and cleaned up the weakening example
urbanc
parents:
18296
diff
changeset
|
100 |
lemma weakening_version3: |
22418
49e2d9744ae1
major update of the nominal package; there is now an infrastructure
urbanc
parents:
22231
diff
changeset
|
101 |
assumes a: "\<Gamma>1 \<turnstile> t : T" |
18311
b83b00cbaecf
changed "fresh:" to "avoiding:" and cleaned up the weakening example
urbanc
parents:
18296
diff
changeset
|
102 |
and b: "valid \<Gamma>2" |
22650
0c5b22076fb3
tuned the proof of lemma pt_list_set_fresh (as suggested by Randy Pollack) and tuned the syntax for sub_contexts
urbanc
parents:
22533
diff
changeset
|
103 |
and c: "\<Gamma>1 \<subseteq> \<Gamma>2" |
22418
49e2d9744ae1
major update of the nominal package; there is now an infrastructure
urbanc
parents:
22231
diff
changeset
|
104 |
shows "\<Gamma>2 \<turnstile> t : T" |
18311
b83b00cbaecf
changed "fresh:" to "avoiding:" and cleaned up the weakening example
urbanc
parents:
18296
diff
changeset
|
105 |
using a b c |
22533 | 106 |
proof (nominal_induct \<Gamma>1 t T avoiding: \<Gamma>2 rule: typing.strong_induct) |
107 |
case (t_Lam x \<Gamma>1 T1 t T2) (* lambda case *) |
|
108 |
have vc: "x\<sharp>\<Gamma>2" by fact (* variable convention *) |
|
22650
0c5b22076fb3
tuned the proof of lemma pt_list_set_fresh (as suggested by Randy Pollack) and tuned the syntax for sub_contexts
urbanc
parents:
22533
diff
changeset
|
109 |
have ih: "\<And>\<Gamma>3. \<lbrakk>valid \<Gamma>3; (x,T1)#\<Gamma>1 \<subseteq> \<Gamma>3\<rbrakk> \<Longrightarrow> \<Gamma>3 \<turnstile> t : T2" by fact |
0c5b22076fb3
tuned the proof of lemma pt_list_set_fresh (as suggested by Randy Pollack) and tuned the syntax for sub_contexts
urbanc
parents:
22533
diff
changeset
|
110 |
have "\<Gamma>1 \<subseteq> \<Gamma>2" by fact |
0c5b22076fb3
tuned the proof of lemma pt_list_set_fresh (as suggested by Randy Pollack) and tuned the syntax for sub_contexts
urbanc
parents:
22533
diff
changeset
|
111 |
then have "(x,T1)#\<Gamma>1 \<subseteq> (x,T1)#\<Gamma>2" by simp |
18311
b83b00cbaecf
changed "fresh:" to "avoiding:" and cleaned up the weakening example
urbanc
parents:
18296
diff
changeset
|
112 |
moreover |
21052
ec5531061ed6
adapted to Stefan's new inductive package and cleaning up
urbanc
parents:
20955
diff
changeset
|
113 |
have "valid \<Gamma>2" by fact |
22533 | 114 |
then have "valid ((x,T1)#\<Gamma>2)" using vc by (simp add: v2) |
22650
0c5b22076fb3
tuned the proof of lemma pt_list_set_fresh (as suggested by Randy Pollack) and tuned the syntax for sub_contexts
urbanc
parents:
22533
diff
changeset
|
115 |
ultimately have "(x,T1)#\<Gamma>2 \<turnstile> t : T2" using ih by simp |
0c5b22076fb3
tuned the proof of lemma pt_list_set_fresh (as suggested by Randy Pollack) and tuned the syntax for sub_contexts
urbanc
parents:
22533
diff
changeset
|
116 |
with vc show "\<Gamma>2 \<turnstile> Lam [x].t : T1 \<rightarrow> T2" by auto |
21052
ec5531061ed6
adapted to Stefan's new inductive package and cleaning up
urbanc
parents:
20955
diff
changeset
|
117 |
qed (auto) (* app and var case *) |
18105 | 118 |
|
21052
ec5531061ed6
adapted to Stefan's new inductive package and cleaning up
urbanc
parents:
20955
diff
changeset
|
119 |
text{* The original induction principle for the typing relation |
22650
0c5b22076fb3
tuned the proof of lemma pt_list_set_fresh (as suggested by Randy Pollack) and tuned the syntax for sub_contexts
urbanc
parents:
22533
diff
changeset
|
120 |
is not strong enough - even this simple lemma fails to be simple ;o) *} |
0c5b22076fb3
tuned the proof of lemma pt_list_set_fresh (as suggested by Randy Pollack) and tuned the syntax for sub_contexts
urbanc
parents:
22533
diff
changeset
|
121 |
|
18311
b83b00cbaecf
changed "fresh:" to "avoiding:" and cleaned up the weakening example
urbanc
parents:
18296
diff
changeset
|
122 |
lemma weakening_too_weak: |
22418
49e2d9744ae1
major update of the nominal package; there is now an infrastructure
urbanc
parents:
22231
diff
changeset
|
123 |
assumes a: "\<Gamma>1 \<turnstile> t : T" |
18311
b83b00cbaecf
changed "fresh:" to "avoiding:" and cleaned up the weakening example
urbanc
parents:
18296
diff
changeset
|
124 |
and b: "valid \<Gamma>2" |
22650
0c5b22076fb3
tuned the proof of lemma pt_list_set_fresh (as suggested by Randy Pollack) and tuned the syntax for sub_contexts
urbanc
parents:
22533
diff
changeset
|
125 |
and c: "\<Gamma>1 \<subseteq> \<Gamma>2" |
22418
49e2d9744ae1
major update of the nominal package; there is now an infrastructure
urbanc
parents:
22231
diff
changeset
|
126 |
shows "\<Gamma>2 \<turnstile> t : T" |
18311
b83b00cbaecf
changed "fresh:" to "avoiding:" and cleaned up the weakening example
urbanc
parents:
18296
diff
changeset
|
127 |
using a b c |
20503 | 128 |
proof (induct arbitrary: \<Gamma>2) |
22650
0c5b22076fb3
tuned the proof of lemma pt_list_set_fresh (as suggested by Randy Pollack) and tuned the syntax for sub_contexts
urbanc
parents:
22533
diff
changeset
|
129 |
case (t_Var \<Gamma>1 x T) (* variable case works *) |
0c5b22076fb3
tuned the proof of lemma pt_list_set_fresh (as suggested by Randy Pollack) and tuned the syntax for sub_contexts
urbanc
parents:
22533
diff
changeset
|
130 |
have "\<Gamma>1 \<subseteq> \<Gamma>2" by fact |
21052
ec5531061ed6
adapted to Stefan's new inductive package and cleaning up
urbanc
parents:
20955
diff
changeset
|
131 |
moreover |
ec5531061ed6
adapted to Stefan's new inductive package and cleaning up
urbanc
parents:
20955
diff
changeset
|
132 |
have "valid \<Gamma>2" by fact |
ec5531061ed6
adapted to Stefan's new inductive package and cleaning up
urbanc
parents:
20955
diff
changeset
|
133 |
moreover |
22533 | 134 |
have "(x,T) \<in> (set \<Gamma>1)" by fact |
135 |
ultimately show "\<Gamma>2 \<turnstile> Var x : T" by auto |
|
18105 | 136 |
next |
22533 | 137 |
case (t_Lam x \<Gamma>1 T1 t T2) (* lambda case *) |
21488 | 138 |
(* all assumptions available in this case*) |
22533 | 139 |
have a0: "x\<sharp>\<Gamma>1" by fact |
22650
0c5b22076fb3
tuned the proof of lemma pt_list_set_fresh (as suggested by Randy Pollack) and tuned the syntax for sub_contexts
urbanc
parents:
22533
diff
changeset
|
140 |
have a1: "(x,T1)#\<Gamma>1 \<turnstile> t : T2" by fact |
0c5b22076fb3
tuned the proof of lemma pt_list_set_fresh (as suggested by Randy Pollack) and tuned the syntax for sub_contexts
urbanc
parents:
22533
diff
changeset
|
141 |
have a2: "\<Gamma>1 \<subseteq> \<Gamma>2" by fact |
18311
b83b00cbaecf
changed "fresh:" to "avoiding:" and cleaned up the weakening example
urbanc
parents:
18296
diff
changeset
|
142 |
have a3: "valid \<Gamma>2" by fact |
22650
0c5b22076fb3
tuned the proof of lemma pt_list_set_fresh (as suggested by Randy Pollack) and tuned the syntax for sub_contexts
urbanc
parents:
22533
diff
changeset
|
143 |
have ih: "\<And>\<Gamma>3. \<lbrakk>valid \<Gamma>3; (x,T1)#\<Gamma>1 \<subseteq> \<Gamma>3\<rbrakk> \<Longrightarrow> \<Gamma>3 \<turnstile> t : T2" by fact |
0c5b22076fb3
tuned the proof of lemma pt_list_set_fresh (as suggested by Randy Pollack) and tuned the syntax for sub_contexts
urbanc
parents:
22533
diff
changeset
|
144 |
have "(x,T1)#\<Gamma>1 \<subseteq> (x,T1)#\<Gamma>2" using a2 by simp |
18105 | 145 |
moreover |
22533 | 146 |
have "valid ((x,T1)#\<Gamma>2)" using v2 (* fails *) |
19496 | 147 |
oops |
18105 | 148 |
|
19496 | 149 |
end |