69 using h |
69 using h |
70 by (nominal_induct t avoiding: \<theta> c s rule: lam.strong_induct) |
70 by (nominal_induct t avoiding: \<theta> c s rule: lam.strong_induct) |
71 (auto simp add: fresh_list_cons fresh_atm forget lookup_fresh lookup_fresh') |
71 (auto simp add: fresh_list_cons fresh_atm forget lookup_fresh lookup_fresh') |
72 |
72 |
73 inductive |
73 inductive |
74 Beta :: "lam\<Rightarrow>lam\<Rightarrow>bool" (" _ \<longrightarrow>\<^isub>\<beta> _" [80,80] 80) |
74 Beta :: "lam\<Rightarrow>lam\<Rightarrow>bool" (" _ \<longrightarrow>\<^sub>\<beta> _" [80,80] 80) |
75 where |
75 where |
76 b1[intro!]: "s1 \<longrightarrow>\<^isub>\<beta> s2 \<Longrightarrow> App s1 t \<longrightarrow>\<^isub>\<beta> App s2 t" |
76 b1[intro!]: "s1 \<longrightarrow>\<^sub>\<beta> s2 \<Longrightarrow> App s1 t \<longrightarrow>\<^sub>\<beta> App s2 t" |
77 | b2[intro!]: "s1\<longrightarrow>\<^isub>\<beta>s2 \<Longrightarrow> App t s1 \<longrightarrow>\<^isub>\<beta> App t s2" |
77 | b2[intro!]: "s1\<longrightarrow>\<^sub>\<beta>s2 \<Longrightarrow> App t s1 \<longrightarrow>\<^sub>\<beta> App t s2" |
78 | b3[intro!]: "s1\<longrightarrow>\<^isub>\<beta>s2 \<Longrightarrow> Lam [a].s1 \<longrightarrow>\<^isub>\<beta> Lam [a].s2" |
78 | b3[intro!]: "s1\<longrightarrow>\<^sub>\<beta>s2 \<Longrightarrow> Lam [a].s1 \<longrightarrow>\<^sub>\<beta> Lam [a].s2" |
79 | b4[intro!]: "a\<sharp>s2 \<Longrightarrow> App (Lam [a].s1) s2\<longrightarrow>\<^isub>\<beta> (s1[a::=s2])" |
79 | b4[intro!]: "a\<sharp>s2 \<Longrightarrow> App (Lam [a].s1) s2\<longrightarrow>\<^sub>\<beta> (s1[a::=s2])" |
80 |
80 |
81 equivariance Beta |
81 equivariance Beta |
82 |
82 |
83 nominal_inductive Beta |
83 nominal_inductive Beta |
84 by (simp_all add: abs_fresh fresh_fact') |
84 by (simp_all add: abs_fresh fresh_fact') |
85 |
85 |
86 lemma beta_preserves_fresh: |
86 lemma beta_preserves_fresh: |
87 fixes a::"name" |
87 fixes a::"name" |
88 assumes a: "t\<longrightarrow>\<^isub>\<beta> s" |
88 assumes a: "t\<longrightarrow>\<^sub>\<beta> s" |
89 shows "a\<sharp>t \<Longrightarrow> a\<sharp>s" |
89 shows "a\<sharp>t \<Longrightarrow> a\<sharp>s" |
90 using a |
90 using a |
91 apply(nominal_induct t s avoiding: a rule: Beta.strong_induct) |
91 apply(nominal_induct t s avoiding: a rule: Beta.strong_induct) |
92 apply(auto simp add: abs_fresh fresh_fact fresh_atm) |
92 apply(auto simp add: abs_fresh fresh_fact fresh_atm) |
93 done |
93 done |
94 |
94 |
95 lemma beta_abs: |
95 lemma beta_abs: |
96 assumes a: "Lam [a].t\<longrightarrow>\<^isub>\<beta> t'" |
96 assumes a: "Lam [a].t\<longrightarrow>\<^sub>\<beta> t'" |
97 shows "\<exists>t''. t'=Lam [a].t'' \<and> t\<longrightarrow>\<^isub>\<beta> t''" |
97 shows "\<exists>t''. t'=Lam [a].t'' \<and> t\<longrightarrow>\<^sub>\<beta> t''" |
98 proof - |
98 proof - |
99 have "a\<sharp>Lam [a].t" by (simp add: abs_fresh) |
99 have "a\<sharp>Lam [a].t" by (simp add: abs_fresh) |
100 with a have "a\<sharp>t'" by (simp add: beta_preserves_fresh) |
100 with a have "a\<sharp>t'" by (simp add: beta_preserves_fresh) |
101 with a show ?thesis |
101 with a show ?thesis |
102 by (cases rule: Beta.strong_cases[where a="a" and aa="a"]) |
102 by (cases rule: Beta.strong_cases[where a="a" and aa="a"]) |
103 (auto simp add: lam.inject abs_fresh alpha) |
103 (auto simp add: lam.inject abs_fresh alpha) |
104 qed |
104 qed |
105 |
105 |
106 lemma beta_subst: |
106 lemma beta_subst: |
107 assumes a: "M \<longrightarrow>\<^isub>\<beta> M'" |
107 assumes a: "M \<longrightarrow>\<^sub>\<beta> M'" |
108 shows "M[x::=N]\<longrightarrow>\<^isub>\<beta> M'[x::=N]" |
108 shows "M[x::=N]\<longrightarrow>\<^sub>\<beta> M'[x::=N]" |
109 using a |
109 using a |
110 by (nominal_induct M M' avoiding: x N rule: Beta.strong_induct) |
110 by (nominal_induct M M' avoiding: x N rule: Beta.strong_induct) |
111 (auto simp add: fresh_atm subst_lemma fresh_fact) |
111 (auto simp add: fresh_atm subst_lemma fresh_fact) |
112 |
112 |
113 section {* types *} |
113 section {* types *} |
157 by (simp_all add: abs_fresh fresh_ty) |
157 by (simp_all add: abs_fresh fresh_ty) |
158 |
158 |
159 subsection {* a fact about beta *} |
159 subsection {* a fact about beta *} |
160 |
160 |
161 definition "NORMAL" :: "lam \<Rightarrow> bool" where |
161 definition "NORMAL" :: "lam \<Rightarrow> bool" where |
162 "NORMAL t \<equiv> \<not>(\<exists>t'. t\<longrightarrow>\<^isub>\<beta> t')" |
162 "NORMAL t \<equiv> \<not>(\<exists>t'. t\<longrightarrow>\<^sub>\<beta> t')" |
163 |
163 |
164 lemma NORMAL_Var: |
164 lemma NORMAL_Var: |
165 shows "NORMAL (Var a)" |
165 shows "NORMAL (Var a)" |
166 proof - |
166 proof - |
167 { assume "\<exists>t'. (Var a) \<longrightarrow>\<^isub>\<beta> t'" |
167 { assume "\<exists>t'. (Var a) \<longrightarrow>\<^sub>\<beta> t'" |
168 then obtain t' where "(Var a) \<longrightarrow>\<^isub>\<beta> t'" by blast |
168 then obtain t' where "(Var a) \<longrightarrow>\<^sub>\<beta> t'" by blast |
169 hence False by (cases) (auto) |
169 hence False by (cases) (auto) |
170 } |
170 } |
171 thus "NORMAL (Var a)" by (auto simp add: NORMAL_def) |
171 thus "NORMAL (Var a)" by (auto simp add: NORMAL_def) |
172 qed |
172 qed |
173 |
173 |
174 text {* Inductive version of Strong Normalisation *} |
174 text {* Inductive version of Strong Normalisation *} |
175 inductive |
175 inductive |
176 SN :: "lam \<Rightarrow> bool" |
176 SN :: "lam \<Rightarrow> bool" |
177 where |
177 where |
178 SN_intro: "(\<And>t'. t \<longrightarrow>\<^isub>\<beta> t' \<Longrightarrow> SN t') \<Longrightarrow> SN t" |
178 SN_intro: "(\<And>t'. t \<longrightarrow>\<^sub>\<beta> t' \<Longrightarrow> SN t') \<Longrightarrow> SN t" |
179 |
179 |
180 lemma SN_preserved: |
180 lemma SN_preserved: |
181 assumes a: "SN t1" "t1\<longrightarrow>\<^isub>\<beta> t2" |
181 assumes a: "SN t1" "t1\<longrightarrow>\<^sub>\<beta> t2" |
182 shows "SN t2" |
182 shows "SN t2" |
183 using a |
183 using a |
184 by (cases) (auto) |
184 by (cases) (auto) |
185 |
185 |
186 lemma double_SN_aux: |
186 lemma double_SN_aux: |
187 assumes a: "SN a" |
187 assumes a: "SN a" |
188 and b: "SN b" |
188 and b: "SN b" |
189 and hyp: "\<And>x z. |
189 and hyp: "\<And>x z. |
190 \<lbrakk>\<And>y. x \<longrightarrow>\<^isub>\<beta> y \<Longrightarrow> SN y; \<And>y. x \<longrightarrow>\<^isub>\<beta> y \<Longrightarrow> P y z; |
190 \<lbrakk>\<And>y. x \<longrightarrow>\<^sub>\<beta> y \<Longrightarrow> SN y; \<And>y. x \<longrightarrow>\<^sub>\<beta> y \<Longrightarrow> P y z; |
191 \<And>u. z \<longrightarrow>\<^isub>\<beta> u \<Longrightarrow> SN u; \<And>u. z \<longrightarrow>\<^isub>\<beta> u \<Longrightarrow> P x u\<rbrakk> \<Longrightarrow> P x z" |
191 \<And>u. z \<longrightarrow>\<^sub>\<beta> u \<Longrightarrow> SN u; \<And>u. z \<longrightarrow>\<^sub>\<beta> u \<Longrightarrow> P x u\<rbrakk> \<Longrightarrow> P x z" |
192 shows "P a b" |
192 shows "P a b" |
193 proof - |
193 proof - |
194 from a |
194 from a |
195 have r: "\<And>b. SN b \<Longrightarrow> P a b" |
195 have r: "\<And>b. SN b \<Longrightarrow> P a b" |
196 proof (induct a rule: SN.SN.induct) |
196 proof (induct a rule: SN.SN.induct) |
274 |
274 |
275 definition "CR1" :: "ty \<Rightarrow> bool" where |
275 definition "CR1" :: "ty \<Rightarrow> bool" where |
276 "CR1 \<tau> \<equiv> \<forall>t. (t\<in>RED \<tau> \<longrightarrow> SN t)" |
276 "CR1 \<tau> \<equiv> \<forall>t. (t\<in>RED \<tau> \<longrightarrow> SN t)" |
277 |
277 |
278 definition "CR2" :: "ty \<Rightarrow> bool" where |
278 definition "CR2" :: "ty \<Rightarrow> bool" where |
279 "CR2 \<tau> \<equiv> \<forall>t t'. (t\<in>RED \<tau> \<and> t \<longrightarrow>\<^isub>\<beta> t') \<longrightarrow> t'\<in>RED \<tau>" |
279 "CR2 \<tau> \<equiv> \<forall>t t'. (t\<in>RED \<tau> \<and> t \<longrightarrow>\<^sub>\<beta> t') \<longrightarrow> t'\<in>RED \<tau>" |
280 |
280 |
281 definition "CR3_RED" :: "lam \<Rightarrow> ty \<Rightarrow> bool" where |
281 definition "CR3_RED" :: "lam \<Rightarrow> ty \<Rightarrow> bool" where |
282 "CR3_RED t \<tau> \<equiv> \<forall>t'. t\<longrightarrow>\<^isub>\<beta> t' \<longrightarrow> t'\<in>RED \<tau>" |
282 "CR3_RED t \<tau> \<equiv> \<forall>t'. t\<longrightarrow>\<^sub>\<beta> t' \<longrightarrow> t'\<in>RED \<tau>" |
283 |
283 |
284 definition "CR3" :: "ty \<Rightarrow> bool" where |
284 definition "CR3" :: "ty \<Rightarrow> bool" where |
285 "CR3 \<tau> \<equiv> \<forall>t. (NEUT t \<and> CR3_RED t \<tau>) \<longrightarrow> t\<in>RED \<tau>" |
285 "CR3 \<tau> \<equiv> \<forall>t. (NEUT t \<and> CR3_RED t \<tau>) \<longrightarrow> t\<in>RED \<tau>" |
286 |
286 |
287 definition "CR4" :: "ty \<Rightarrow> bool" where |
287 definition "CR4" :: "ty \<Rightarrow> bool" where |
303 shows "(App t u)\<in>RED \<sigma>" |
303 shows "(App t u)\<in>RED \<sigma>" |
304 using a b |
304 using a b |
305 proof (induct) |
305 proof (induct) |
306 fix u |
306 fix u |
307 assume as: "u\<in>RED \<tau>" |
307 assume as: "u\<in>RED \<tau>" |
308 assume ih: " \<And>u'. \<lbrakk>u \<longrightarrow>\<^isub>\<beta> u'; u' \<in> RED \<tau>\<rbrakk> \<Longrightarrow> App t u' \<in> RED \<sigma>" |
308 assume ih: " \<And>u'. \<lbrakk>u \<longrightarrow>\<^sub>\<beta> u'; u' \<in> RED \<tau>\<rbrakk> \<Longrightarrow> App t u' \<in> RED \<sigma>" |
309 have "NEUT (App t u)" using c1 by (auto simp add: NEUT_def) |
309 have "NEUT (App t u)" using c1 by (auto simp add: NEUT_def) |
310 moreover |
310 moreover |
311 have "CR3_RED (App t u) \<sigma>" unfolding CR3_RED_def |
311 have "CR3_RED (App t u) \<sigma>" unfolding CR3_RED_def |
312 proof (intro strip) |
312 proof (intro strip) |
313 fix r |
313 fix r |
314 assume red: "App t u \<longrightarrow>\<^isub>\<beta> r" |
314 assume red: "App t u \<longrightarrow>\<^sub>\<beta> r" |
315 moreover |
315 moreover |
316 { assume "\<exists>t'. t \<longrightarrow>\<^isub>\<beta> t' \<and> r = App t' u" |
316 { assume "\<exists>t'. t \<longrightarrow>\<^sub>\<beta> t' \<and> r = App t' u" |
317 then obtain t' where a1: "t \<longrightarrow>\<^isub>\<beta> t'" and a2: "r = App t' u" by blast |
317 then obtain t' where a1: "t \<longrightarrow>\<^sub>\<beta> t'" and a2: "r = App t' u" by blast |
318 have "t'\<in>RED (\<tau>\<rightarrow>\<sigma>)" using c4 a1 by (simp add: CR3_RED_def) |
318 have "t'\<in>RED (\<tau>\<rightarrow>\<sigma>)" using c4 a1 by (simp add: CR3_RED_def) |
319 then have "App t' u\<in>RED \<sigma>" using as by simp |
319 then have "App t' u\<in>RED \<sigma>" using as by simp |
320 then have "r\<in>RED \<sigma>" using a2 by simp |
320 then have "r\<in>RED \<sigma>" using a2 by simp |
321 } |
321 } |
322 moreover |
322 moreover |
323 { assume "\<exists>u'. u \<longrightarrow>\<^isub>\<beta> u' \<and> r = App t u'" |
323 { assume "\<exists>u'. u \<longrightarrow>\<^sub>\<beta> u' \<and> r = App t u'" |
324 then obtain u' where b1: "u \<longrightarrow>\<^isub>\<beta> u'" and b2: "r = App t u'" by blast |
324 then obtain u' where b1: "u \<longrightarrow>\<^sub>\<beta> u'" and b2: "r = App t u'" by blast |
325 have "u'\<in>RED \<tau>" using as b1 c2 by (auto simp add: CR2_def) |
325 have "u'\<in>RED \<tau>" using as b1 c2 by (auto simp add: CR2_def) |
326 with ih have "App t u' \<in> RED \<sigma>" using b1 by simp |
326 with ih have "App t u' \<in> RED \<sigma>" using b1 by simp |
327 then have "r\<in>RED \<sigma>" using b2 by simp |
327 then have "r\<in>RED \<sigma>" using b2 by simp |
328 } |
328 } |
329 moreover |
329 moreover |
421 assume b2: "u\<in>RED \<tau>" |
421 assume b2: "u\<in>RED \<tau>" |
422 then have b3: "SN u" using RED_props by (auto simp add: CR1_def) |
422 then have b3: "SN u" using RED_props by (auto simp add: CR1_def) |
423 show "App (Lam [x].t) u \<in> RED \<sigma>" using b1 b3 b2 asm |
423 show "App (Lam [x].t) u \<in> RED \<sigma>" using b1 b3 b2 asm |
424 proof(induct t u rule: double_SN) |
424 proof(induct t u rule: double_SN) |
425 fix t u |
425 fix t u |
426 assume ih1: "\<And>t'. \<lbrakk>t \<longrightarrow>\<^isub>\<beta> t'; u\<in>RED \<tau>; \<forall>s\<in>RED \<tau>. t'[x::=s]\<in>RED \<sigma>\<rbrakk> \<Longrightarrow> App (Lam [x].t') u \<in> RED \<sigma>" |
426 assume ih1: "\<And>t'. \<lbrakk>t \<longrightarrow>\<^sub>\<beta> t'; u\<in>RED \<tau>; \<forall>s\<in>RED \<tau>. t'[x::=s]\<in>RED \<sigma>\<rbrakk> \<Longrightarrow> App (Lam [x].t') u \<in> RED \<sigma>" |
427 assume ih2: "\<And>u'. \<lbrakk>u \<longrightarrow>\<^isub>\<beta> u'; u'\<in>RED \<tau>; \<forall>s\<in>RED \<tau>. t[x::=s]\<in>RED \<sigma>\<rbrakk> \<Longrightarrow> App (Lam [x].t) u' \<in> RED \<sigma>" |
427 assume ih2: "\<And>u'. \<lbrakk>u \<longrightarrow>\<^sub>\<beta> u'; u'\<in>RED \<tau>; \<forall>s\<in>RED \<tau>. t[x::=s]\<in>RED \<sigma>\<rbrakk> \<Longrightarrow> App (Lam [x].t) u' \<in> RED \<sigma>" |
428 assume as1: "u \<in> RED \<tau>" |
428 assume as1: "u \<in> RED \<tau>" |
429 assume as2: "\<forall>s\<in>RED \<tau>. t[x::=s]\<in>RED \<sigma>" |
429 assume as2: "\<forall>s\<in>RED \<tau>. t[x::=s]\<in>RED \<sigma>" |
430 have "CR3_RED (App (Lam [x].t) u) \<sigma>" unfolding CR3_RED_def |
430 have "CR3_RED (App (Lam [x].t) u) \<sigma>" unfolding CR3_RED_def |
431 proof(intro strip) |
431 proof(intro strip) |
432 fix r |
432 fix r |
433 assume red: "App (Lam [x].t) u \<longrightarrow>\<^isub>\<beta> r" |
433 assume red: "App (Lam [x].t) u \<longrightarrow>\<^sub>\<beta> r" |
434 moreover |
434 moreover |
435 { assume "\<exists>t'. t \<longrightarrow>\<^isub>\<beta> t' \<and> r = App (Lam [x].t') u" |
435 { assume "\<exists>t'. t \<longrightarrow>\<^sub>\<beta> t' \<and> r = App (Lam [x].t') u" |
436 then obtain t' where a1: "t \<longrightarrow>\<^isub>\<beta> t'" and a2: "r = App (Lam [x].t') u" by blast |
436 then obtain t' where a1: "t \<longrightarrow>\<^sub>\<beta> t'" and a2: "r = App (Lam [x].t') u" by blast |
437 have "App (Lam [x].t') u\<in>RED \<sigma>" using ih1 a1 as1 as2 |
437 have "App (Lam [x].t') u\<in>RED \<sigma>" using ih1 a1 as1 as2 |
438 apply(auto) |
438 apply(auto) |
439 apply(drule_tac x="t'" in meta_spec) |
439 apply(drule_tac x="t'" in meta_spec) |
440 apply(simp) |
440 apply(simp) |
441 apply(drule meta_mp) |
441 apply(drule meta_mp) |
453 apply(simp add: RED_props) |
453 apply(simp add: RED_props) |
454 done |
454 done |
455 then have "r\<in>RED \<sigma>" using a2 by simp |
455 then have "r\<in>RED \<sigma>" using a2 by simp |
456 } |
456 } |
457 moreover |
457 moreover |
458 { assume "\<exists>u'. u \<longrightarrow>\<^isub>\<beta> u' \<and> r = App (Lam [x].t) u'" |
458 { assume "\<exists>u'. u \<longrightarrow>\<^sub>\<beta> u' \<and> r = App (Lam [x].t) u'" |
459 then obtain u' where b1: "u \<longrightarrow>\<^isub>\<beta> u'" and b2: "r = App (Lam [x].t) u'" by blast |
459 then obtain u' where b1: "u \<longrightarrow>\<^sub>\<beta> u'" and b2: "r = App (Lam [x].t) u'" by blast |
460 have "App (Lam [x].t) u'\<in>RED \<sigma>" using ih2 b1 as1 as2 |
460 have "App (Lam [x].t) u'\<in>RED \<sigma>" using ih2 b1 as1 as2 |
461 apply(auto) |
461 apply(auto) |
462 apply(drule_tac x="u'" in meta_spec) |
462 apply(drule_tac x="u'" in meta_spec) |
463 apply(simp) |
463 apply(simp) |
464 apply(drule meta_mp) |
464 apply(drule meta_mp) |