24 |
24 |
25 theorem listall_nil: "listall P []" |
25 theorem listall_nil: "listall P []" |
26 by (simp add: listall_def) |
26 by (simp add: listall_def) |
27 |
27 |
28 theorem listall_nil_eq [simp]: "listall P [] = True" |
28 theorem listall_nil_eq [simp]: "listall P [] = True" |
29 by (rules intro: listall_nil) |
29 by (iprover intro: listall_nil) |
30 |
30 |
31 theorem listall_cons: "P x \<Longrightarrow> listall P xs \<Longrightarrow> listall P (x # xs)" |
31 theorem listall_cons: "P x \<Longrightarrow> listall P xs \<Longrightarrow> listall P (x # xs)" |
32 apply (simp add: listall_def) |
32 apply (simp add: listall_def) |
33 apply (rule allI impI)+ |
33 apply (rule allI impI)+ |
34 apply (case_tac i) |
34 apply (case_tac i) |
82 |
82 |
83 lemma nat_eq_dec: "\<And>n::nat. m = n \<or> m \<noteq> n" |
83 lemma nat_eq_dec: "\<And>n::nat. m = n \<or> m \<noteq> n" |
84 apply (induct m) |
84 apply (induct m) |
85 apply (case_tac n) |
85 apply (case_tac n) |
86 apply (case_tac [3] n) |
86 apply (case_tac [3] n) |
87 apply (simp only: nat.simps, rules?)+ |
87 apply (simp only: nat.simps, iprover?)+ |
88 done |
88 done |
89 |
89 |
90 lemma nat_le_dec: "\<And>n::nat. m < n \<or> \<not> (m < n)" |
90 lemma nat_le_dec: "\<And>n::nat. m < n \<or> \<not> (m < n)" |
91 apply (induct m) |
91 apply (induct m) |
92 apply (case_tac n) |
92 apply (case_tac n) |
93 apply (case_tac [3] n) |
93 apply (case_tac [3] n) |
94 apply (simp del: simp_thms, rules?)+ |
94 apply (simp del: simp_thms, iprover?)+ |
95 done |
95 done |
96 |
96 |
97 lemma App_NF_D: assumes NF: "Var n \<degree>\<degree> ts \<in> NF" |
97 lemma App_NF_D: assumes NF: "Var n \<degree>\<degree> ts \<in> NF" |
98 shows "listall (\<lambda>t. t \<in> NF) ts" using NF |
98 shows "listall (\<lambda>t. t \<in> NF) ts" using NF |
99 by cases simp_all |
99 by cases simp_all |
123 apply (rule_tac m=x and n=j in nat_eq_dec [THEN disjE, standard]) |
123 apply (rule_tac m=x and n=j in nat_eq_dec [THEN disjE, standard]) |
124 apply simp |
124 apply simp |
125 apply (erule NF.App) |
125 apply (erule NF.App) |
126 apply (rule_tac m=j and n=x in nat_le_dec [THEN disjE, standard]) |
126 apply (rule_tac m=j and n=x in nat_le_dec [THEN disjE, standard]) |
127 apply simp |
127 apply simp |
128 apply (rules intro: NF.App) |
128 apply (iprover intro: NF.App) |
129 apply simp |
129 apply simp |
130 apply (rules intro: NF.App) |
130 apply (iprover intro: NF.App) |
131 apply simp |
131 apply simp |
132 apply (rules intro: NF.Abs) |
132 apply (iprover intro: NF.Abs) |
133 done |
133 done |
134 |
134 |
135 lemma app_Var_NF: "t \<in> NF \<Longrightarrow> \<exists>t'. t \<degree> Var i \<rightarrow>\<^sub>\<beta>\<^sup>* t' \<and> t' \<in> NF" |
135 lemma app_Var_NF: "t \<in> NF \<Longrightarrow> \<exists>t'. t \<degree> Var i \<rightarrow>\<^sub>\<beta>\<^sup>* t' \<and> t' \<in> NF" |
136 apply (induct set: NF) |
136 apply (induct set: NF) |
137 apply (simplesubst app_last) --{*Using @{text subst} makes extraction fail*} |
137 apply (simplesubst app_last) --{*Using @{text subst} makes extraction fail*} |
233 from snoc have "listall ?R bs" by simp |
233 from snoc have "listall ?R bs" by simp |
234 with bs have "\<exists>bs'. ?ex Vs bs bs'" by (rule snoc) |
234 with bs have "\<exists>bs'. ?ex Vs bs bs'" by (rule snoc) |
235 then obtain bs' where |
235 then obtain bs' where |
236 bsred: "Var 0 \<degree>\<degree> map (\<lambda>t. lift (t[u/i]) 0) bs \<rightarrow>\<^sub>\<beta>\<^sup>* |
236 bsred: "Var 0 \<degree>\<degree> map (\<lambda>t. lift (t[u/i]) 0) bs \<rightarrow>\<^sub>\<beta>\<^sup>* |
237 Var 0 \<degree>\<degree> map (\<lambda>t. lift t 0) bs'" |
237 Var 0 \<degree>\<degree> map (\<lambda>t. lift t 0) bs'" |
238 and bsNF: "Var 0 \<degree>\<degree> map (\<lambda>t. lift t 0) bs' \<in> NF" by rules |
238 and bsNF: "Var 0 \<degree>\<degree> map (\<lambda>t. lift t 0) bs' \<in> NF" by iprover |
239 from snoc have "?R b" by simp |
239 from snoc have "?R b" by simp |
240 with bT and uNF and uT have "\<exists>b'. b[u/i] \<rightarrow>\<^sub>\<beta>\<^sup>* b' \<and> b' \<in> NF" by rules |
240 with bT and uNF and uT have "\<exists>b'. b[u/i] \<rightarrow>\<^sub>\<beta>\<^sup>* b' \<and> b' \<in> NF" by iprover |
241 then obtain b' where bred: "b[u/i] \<rightarrow>\<^sub>\<beta>\<^sup>* b'" and bNF: "b' \<in> NF" by rules |
241 then obtain b' where bred: "b[u/i] \<rightarrow>\<^sub>\<beta>\<^sup>* b'" and bNF: "b' \<in> NF" by iprover |
242 from bsNF have "listall (\<lambda>t. t \<in> NF) (map (\<lambda>t. lift t 0) bs')" |
242 from bsNF have "listall (\<lambda>t. t \<in> NF) (map (\<lambda>t. lift t 0) bs')" |
243 by (rule App_NF_D) |
243 by (rule App_NF_D) |
244 moreover have "lift b' 0 \<in> NF" by (rule lift_NF) |
244 moreover have "lift b' 0 \<in> NF" by (rule lift_NF) |
245 ultimately have "listall (\<lambda>t. t \<in> NF) (map (\<lambda>t. lift t 0) (bs' @ [b']))" |
245 ultimately have "listall (\<lambda>t. t \<in> NF) (map (\<lambda>t. lift t 0) (bs' @ [b']))" |
246 by simp |
246 by simp |
251 "(Var 0 \<degree>\<degree> map (\<lambda>t. lift (t[u/i]) 0) bs) \<degree> lift (b[u/i]) 0 \<rightarrow>\<^sub>\<beta>\<^sup>* |
251 "(Var 0 \<degree>\<degree> map (\<lambda>t. lift (t[u/i]) 0) bs) \<degree> lift (b[u/i]) 0 \<rightarrow>\<^sub>\<beta>\<^sup>* |
252 (Var 0 \<degree>\<degree> map (\<lambda>t. lift t 0) bs') \<degree> lift b' 0" by (rule rtrancl_beta_App) |
252 (Var 0 \<degree>\<degree> map (\<lambda>t. lift t 0) bs') \<degree> lift b' 0" by (rule rtrancl_beta_App) |
253 ultimately have "?ex Us (bs @ [b]) (bs' @ [b'])" by simp |
253 ultimately have "?ex Us (bs @ [b]) (bs' @ [b'])" by simp |
254 thus ?case .. |
254 thus ?case .. |
255 qed |
255 qed |
256 from App and Cons have "listall ?R as" by simp (rules dest: listall_conj2) |
256 from App and Cons have "listall ?R as" by simp (iprover dest: listall_conj2) |
257 with argsT have "\<exists>as'. ?ex Ts as as'" by (rule as) |
257 with argsT have "\<exists>as'. ?ex Ts as as'" by (rule as) |
258 then obtain as' where |
258 then obtain as' where |
259 asred: "Var 0 \<degree>\<degree> map (\<lambda>t. lift (t[u/i]) 0) as \<rightarrow>\<^sub>\<beta>\<^sup>* |
259 asred: "Var 0 \<degree>\<degree> map (\<lambda>t. lift (t[u/i]) 0) as \<rightarrow>\<^sub>\<beta>\<^sup>* |
260 Var 0 \<degree>\<degree> map (\<lambda>t. lift t 0) as'" |
260 Var 0 \<degree>\<degree> map (\<lambda>t. lift t 0) as'" |
261 and asNF: "Var 0 \<degree>\<degree> map (\<lambda>t. lift t 0) as' \<in> NF" by rules |
261 and asNF: "Var 0 \<degree>\<degree> map (\<lambda>t. lift t 0) as' \<in> NF" by iprover |
262 from App and Cons have "?R a" by simp |
262 from App and Cons have "?R a" by simp |
263 with argT and uNF and uT have "\<exists>a'. a[u/i] \<rightarrow>\<^sub>\<beta>\<^sup>* a' \<and> a' \<in> NF" |
263 with argT and uNF and uT have "\<exists>a'. a[u/i] \<rightarrow>\<^sub>\<beta>\<^sup>* a' \<and> a' \<in> NF" |
264 by rules |
264 by iprover |
265 then obtain a' where ared: "a[u/i] \<rightarrow>\<^sub>\<beta>\<^sup>* a'" and aNF: "a' \<in> NF" by rules |
265 then obtain a' where ared: "a[u/i] \<rightarrow>\<^sub>\<beta>\<^sup>* a'" and aNF: "a' \<in> NF" by iprover |
266 from uNF have "lift u 0 \<in> NF" by (rule lift_NF) |
266 from uNF have "lift u 0 \<in> NF" by (rule lift_NF) |
267 hence "\<exists>u'. lift u 0 \<degree> Var 0 \<rightarrow>\<^sub>\<beta>\<^sup>* u' \<and> u' \<in> NF" by (rule app_Var_NF) |
267 hence "\<exists>u'. lift u 0 \<degree> Var 0 \<rightarrow>\<^sub>\<beta>\<^sup>* u' \<and> u' \<in> NF" by (rule app_Var_NF) |
268 then obtain u' where ured: "lift u 0 \<degree> Var 0 \<rightarrow>\<^sub>\<beta>\<^sup>* u'" and u'NF: "u' \<in> NF" |
268 then obtain u' where ured: "lift u 0 \<degree> Var 0 \<rightarrow>\<^sub>\<beta>\<^sup>* u'" and u'NF: "u' \<in> NF" |
269 by rules |
269 by iprover |
270 from T and u'NF have "\<exists>ua. u'[a'/0] \<rightarrow>\<^sub>\<beta>\<^sup>* ua \<and> ua \<in> NF" |
270 from T and u'NF have "\<exists>ua. u'[a'/0] \<rightarrow>\<^sub>\<beta>\<^sup>* ua \<and> ua \<in> NF" |
271 proof (rule MI1) |
271 proof (rule MI1) |
272 have "e\<langle>0:T''\<rangle> \<turnstile> lift u 0 \<degree> Var 0 : Ts \<Rrightarrow> T'" |
272 have "e\<langle>0:T''\<rangle> \<turnstile> lift u 0 \<degree> Var 0 : Ts \<Rrightarrow> T'" |
273 proof (rule typing.App) |
273 proof (rule typing.App) |
274 from uT' show "e\<langle>0:T''\<rangle> \<turnstile> lift u 0 : T'' \<Rightarrow> Ts \<Rrightarrow> T'" by (rule lift_type) |
274 from uT' show "e\<langle>0:T''\<rangle> \<turnstile> lift u 0 : T'' \<Rightarrow> Ts \<Rrightarrow> T'" by (rule lift_type) |
276 qed |
276 qed |
277 with ured show "e\<langle>0:T''\<rangle> \<turnstile> u' : Ts \<Rrightarrow> T'" by (rule subject_reduction') |
277 with ured show "e\<langle>0:T''\<rangle> \<turnstile> u' : Ts \<Rrightarrow> T'" by (rule subject_reduction') |
278 from ared aT show "e \<turnstile> a' : T''" by (rule subject_reduction') |
278 from ared aT show "e \<turnstile> a' : T''" by (rule subject_reduction') |
279 qed |
279 qed |
280 then obtain ua where uared: "u'[a'/0] \<rightarrow>\<^sub>\<beta>\<^sup>* ua" and uaNF: "ua \<in> NF" |
280 then obtain ua where uared: "u'[a'/0] \<rightarrow>\<^sub>\<beta>\<^sup>* ua" and uaNF: "ua \<in> NF" |
281 by rules |
281 by iprover |
282 from ared have "(lift u 0 \<degree> Var 0)[a[u/i]/0] \<rightarrow>\<^sub>\<beta>\<^sup>* (lift u 0 \<degree> Var 0)[a'/0]" |
282 from ared have "(lift u 0 \<degree> Var 0)[a[u/i]/0] \<rightarrow>\<^sub>\<beta>\<^sup>* (lift u 0 \<degree> Var 0)[a'/0]" |
283 by (rule subst_preserves_beta2') |
283 by (rule subst_preserves_beta2') |
284 also from ured have "(lift u 0 \<degree> Var 0)[a'/0] \<rightarrow>\<^sub>\<beta>\<^sup>* u'[a'/0]" |
284 also from ured have "(lift u 0 \<degree> Var 0)[a'/0] \<rightarrow>\<^sub>\<beta>\<^sup>* u'[a'/0]" |
285 by (rule subst_preserves_beta') |
285 by (rule subst_preserves_beta') |
286 also note uared |
286 also note uared |
303 from argT uT refl have "e \<turnstile> a[u/i] : T''" by (rule subst_lemma) |
303 from argT uT refl have "e \<turnstile> a[u/i] : T''" by (rule subst_lemma) |
304 with uT' have "e \<turnstile> u \<degree> a[u/i] : Ts \<Rrightarrow> T'" by (rule typing.App) |
304 with uT' have "e \<turnstile> u \<degree> a[u/i] : Ts \<Rrightarrow> T'" by (rule typing.App) |
305 with uared' show "e \<turnstile> ua : Ts \<Rrightarrow> T'" by (rule subject_reduction') |
305 with uared' show "e \<turnstile> ua : Ts \<Rrightarrow> T'" by (rule subject_reduction') |
306 qed |
306 qed |
307 then obtain r where rred: "(Var 0 \<degree>\<degree> map (\<lambda>t. lift t 0) as')[ua/0] \<rightarrow>\<^sub>\<beta>\<^sup>* r" |
307 then obtain r where rred: "(Var 0 \<degree>\<degree> map (\<lambda>t. lift t 0) as')[ua/0] \<rightarrow>\<^sub>\<beta>\<^sup>* r" |
308 and rnf: "r \<in> NF" by rules |
308 and rnf: "r \<in> NF" by iprover |
309 from asred have |
309 from asred have |
310 "(Var 0 \<degree>\<degree> map (\<lambda>t. lift (t[u/i]) 0) as)[u \<degree> a[u/i]/0] \<rightarrow>\<^sub>\<beta>\<^sup>* |
310 "(Var 0 \<degree>\<degree> map (\<lambda>t. lift (t[u/i]) 0) as)[u \<degree> a[u/i]/0] \<rightarrow>\<^sub>\<beta>\<^sup>* |
311 (Var 0 \<degree>\<degree> map (\<lambda>t. lift t 0) as')[u \<degree> a[u/i]/0]" |
311 (Var 0 \<degree>\<degree> map (\<lambda>t. lift t 0) as')[u \<degree> a[u/i]/0]" |
312 by (rule subst_preserves_beta') |
312 by (rule subst_preserves_beta') |
313 also from uared' have "(Var 0 \<degree>\<degree> map (\<lambda>t. lift t 0) as')[u \<degree> a[u/i]/0] \<rightarrow>\<^sub>\<beta>\<^sup>* |
313 also from uared' have "(Var 0 \<degree>\<degree> map (\<lambda>t. lift t 0) as')[u \<degree> a[u/i]/0] \<rightarrow>\<^sub>\<beta>\<^sup>* |
314 (Var 0 \<degree>\<degree> map (\<lambda>t. lift t 0) as')[ua/0]" by (rule subst_preserves_beta2') |
314 (Var 0 \<degree>\<degree> map (\<lambda>t. lift t 0) as')[ua/0]" by (rule subst_preserves_beta2') |
315 also note rred |
315 also note rred |
316 finally have "(Var 0 \<degree>\<degree> map (\<lambda>t. lift (t[u/i]) 0) as)[u \<degree> a[u/i]/0] \<rightarrow>\<^sub>\<beta>\<^sup>* r" . |
316 finally have "(Var 0 \<degree>\<degree> map (\<lambda>t. lift (t[u/i]) 0) as)[u \<degree> a[u/i]/0] \<rightarrow>\<^sub>\<beta>\<^sup>* r" . |
317 with rnf Cons eq show ?thesis |
317 with rnf Cons eq show ?thesis |
318 by (simp add: map_compose [symmetric] o_def) rules |
318 by (simp add: map_compose [symmetric] o_def) iprover |
319 qed |
319 qed |
320 next |
320 next |
321 assume neq: "x \<noteq> i" |
321 assume neq: "x \<noteq> i" |
322 show ?thesis |
322 show ?thesis |
323 proof - |
323 proof - |
340 and bs: "e\<langle>i:T\<rangle> \<tturnstile> bs : Vs" and bT: "e\<langle>i:T\<rangle> \<turnstile> b : W" by (rule types_snocE) |
340 and bs: "e\<langle>i:T\<rangle> \<tturnstile> bs : Vs" and bT: "e\<langle>i:T\<rangle> \<turnstile> b : W" by (rule types_snocE) |
341 from snoc have "listall ?R bs" by simp |
341 from snoc have "listall ?R bs" by simp |
342 with bs have "\<exists>bs'. ?ex Vs bs bs'" by (rule snoc) |
342 with bs have "\<exists>bs'. ?ex Vs bs bs'" by (rule snoc) |
343 then obtain bs' where |
343 then obtain bs' where |
344 bsred: "\<And>x'. Var x' \<degree>\<degree> map (\<lambda>t. t[u/i]) bs \<rightarrow>\<^sub>\<beta>\<^sup>* Var x' \<degree>\<degree> bs'" |
344 bsred: "\<And>x'. Var x' \<degree>\<degree> map (\<lambda>t. t[u/i]) bs \<rightarrow>\<^sub>\<beta>\<^sup>* Var x' \<degree>\<degree> bs'" |
345 and bsNF: "\<And>x'. Var x' \<degree>\<degree> bs' \<in> NF" by rules |
345 and bsNF: "\<And>x'. Var x' \<degree>\<degree> bs' \<in> NF" by iprover |
346 from snoc have "?R b" by simp |
346 from snoc have "?R b" by simp |
347 with bT and uNF and uT have "\<exists>b'. b[u/i] \<rightarrow>\<^sub>\<beta>\<^sup>* b' \<and> b' \<in> NF" by rules |
347 with bT and uNF and uT have "\<exists>b'. b[u/i] \<rightarrow>\<^sub>\<beta>\<^sup>* b' \<and> b' \<in> NF" by iprover |
348 then obtain b' where bred: "b[u/i] \<rightarrow>\<^sub>\<beta>\<^sup>* b'" and bNF: "b' \<in> NF" by rules |
348 then obtain b' where bred: "b[u/i] \<rightarrow>\<^sub>\<beta>\<^sup>* b'" and bNF: "b' \<in> NF" by iprover |
349 from bsred bred have "\<And>x'. (Var x' \<degree>\<degree> map (\<lambda>t. t[u/i]) bs) \<degree> b[u/i] \<rightarrow>\<^sub>\<beta>\<^sup>* |
349 from bsred bred have "\<And>x'. (Var x' \<degree>\<degree> map (\<lambda>t. t[u/i]) bs) \<degree> b[u/i] \<rightarrow>\<^sub>\<beta>\<^sup>* |
350 (Var x' \<degree>\<degree> bs') \<degree> b'" by (rule rtrancl_beta_App) |
350 (Var x' \<degree>\<degree> bs') \<degree> b'" by (rule rtrancl_beta_App) |
351 moreover from bsNF [of 0] have "listall (\<lambda>t. t \<in> NF) bs'" |
351 moreover from bsNF [of 0] have "listall (\<lambda>t. t \<in> NF) bs'" |
352 by (rule App_NF_D) |
352 by (rule App_NF_D) |
353 with bNF have "listall (\<lambda>t. t \<in> NF) (bs' @ [b'])" by simp |
353 with bNF have "listall (\<lambda>t. t \<in> NF) (bs' @ [b'])" by simp |
354 hence "\<And>x'. Var x' \<degree>\<degree> (bs' @ [b']) \<in> NF" by (rule NF.App) |
354 hence "\<And>x'. Var x' \<degree>\<degree> (bs' @ [b']) \<in> NF" by (rule NF.App) |
355 ultimately have "?ex Us (bs @ [b]) (bs' @ [b'])" by simp |
355 ultimately have "?ex Us (bs @ [b]) (bs' @ [b'])" by simp |
356 thus ?case .. |
356 thus ?case .. |
357 qed |
357 qed |
358 from App have "listall ?R ts" by (rules dest: listall_conj2) |
358 from App have "listall ?R ts" by (iprover dest: listall_conj2) |
359 with argsT have "\<exists>ts'. ?ex Ts ts ts'" by (rule ts) |
359 with argsT have "\<exists>ts'. ?ex Ts ts ts'" by (rule ts) |
360 then obtain ts' where NF: "?ex Ts ts ts'" .. |
360 then obtain ts' where NF: "?ex Ts ts ts'" .. |
361 from nat_le_dec show ?thesis |
361 from nat_le_dec show ?thesis |
362 proof |
362 proof |
363 assume "i < x" |
363 assume "i < x" |
364 with NF show ?thesis by simp rules |
364 with NF show ?thesis by simp iprover |
365 next |
365 next |
366 assume "\<not> (i < x)" |
366 assume "\<not> (i < x)" |
367 with NF neq show ?thesis by (simp add: subst_Var) rules |
367 with NF neq show ?thesis by (simp add: subst_Var) iprover |
368 qed |
368 qed |
369 qed |
369 qed |
370 qed |
370 qed |
371 next |
371 next |
372 case (Abs r e_ T'_ u_ i_) |
372 case (Abs r e_ T'_ u_ i_) |
374 then obtain R S where "e\<langle>0:R\<rangle>\<langle>Suc i:T\<rangle> \<turnstile> r : S" by (rule abs_typeE) simp |
374 then obtain R S where "e\<langle>0:R\<rangle>\<langle>Suc i:T\<rangle> \<turnstile> r : S" by (rule abs_typeE) simp |
375 moreover have "lift u 0 \<in> NF" by (rule lift_NF) |
375 moreover have "lift u 0 \<in> NF" by (rule lift_NF) |
376 moreover have "e\<langle>0:R\<rangle> \<turnstile> lift u 0 : T" by (rule lift_type) |
376 moreover have "e\<langle>0:R\<rangle> \<turnstile> lift u 0 : T" by (rule lift_type) |
377 ultimately have "\<exists>t'. r[lift u 0/Suc i] \<rightarrow>\<^sub>\<beta>\<^sup>* t' \<and> t' \<in> NF" by (rule Abs) |
377 ultimately have "\<exists>t'. r[lift u 0/Suc i] \<rightarrow>\<^sub>\<beta>\<^sup>* t' \<and> t' \<in> NF" by (rule Abs) |
378 thus "\<exists>t'. Abs r[u/i] \<rightarrow>\<^sub>\<beta>\<^sup>* t' \<and> t' \<in> NF" |
378 thus "\<exists>t'. Abs r[u/i] \<rightarrow>\<^sub>\<beta>\<^sup>* t' \<and> t' \<in> NF" |
379 by simp (rules intro: rtrancl_beta_Abs NF.Abs) |
379 by simp (iprover intro: rtrancl_beta_Abs NF.Abs) |
380 } |
380 } |
381 qed |
381 qed |
382 qed |
382 qed |
383 |
383 |
384 |
384 |
409 |
409 |
410 theorem type_NF: assumes T: "e \<turnstile>\<^sub>R t : T" |
410 theorem type_NF: assumes T: "e \<turnstile>\<^sub>R t : T" |
411 shows "\<exists>t'. t \<rightarrow>\<^sub>\<beta>\<^sup>* t' \<and> t' \<in> NF" using T |
411 shows "\<exists>t'. t \<rightarrow>\<^sub>\<beta>\<^sup>* t' \<and> t' \<in> NF" using T |
412 proof induct |
412 proof induct |
413 case Var |
413 case Var |
414 show ?case by (rules intro: Var_NF) |
414 show ?case by (iprover intro: Var_NF) |
415 next |
415 next |
416 case Abs |
416 case Abs |
417 thus ?case by (rules intro: rtrancl_beta_Abs NF.Abs) |
417 thus ?case by (iprover intro: rtrancl_beta_Abs NF.Abs) |
418 next |
418 next |
419 case (App T U e s t) |
419 case (App T U e s t) |
420 from App obtain s' t' where |
420 from App obtain s' t' where |
421 sred: "s \<rightarrow>\<^sub>\<beta>\<^sup>* s'" and sNF: "s' \<in> NF" |
421 sred: "s \<rightarrow>\<^sub>\<beta>\<^sup>* s'" and sNF: "s' \<in> NF" |
422 and tred: "t \<rightarrow>\<^sub>\<beta>\<^sup>* t'" and tNF: "t' \<in> NF" by rules |
422 and tred: "t \<rightarrow>\<^sub>\<beta>\<^sup>* t'" and tNF: "t' \<in> NF" by iprover |
423 have "\<exists>u. (Var 0 \<degree> lift t' 0)[s'/0] \<rightarrow>\<^sub>\<beta>\<^sup>* u \<and> u \<in> NF" |
423 have "\<exists>u. (Var 0 \<degree> lift t' 0)[s'/0] \<rightarrow>\<^sub>\<beta>\<^sup>* u \<and> u \<in> NF" |
424 proof (rule subst_type_NF) |
424 proof (rule subst_type_NF) |
425 have "lift t' 0 \<in> NF" by (rule lift_NF) |
425 have "lift t' 0 \<in> NF" by (rule lift_NF) |
426 hence "listall (\<lambda>t. t \<in> NF) [lift t' 0]" by (rule listall_cons) (rule listall_nil) |
426 hence "listall (\<lambda>t. t \<in> NF) [lift t' 0]" by (rule listall_cons) (rule listall_nil) |
427 hence "Var 0 \<degree>\<degree> [lift t' 0] \<in> NF" by (rule NF.App) |
427 hence "Var 0 \<degree>\<degree> [lift t' 0] \<in> NF" by (rule NF.App) |
436 by (rule lift_type) |
436 by (rule lift_type) |
437 qed |
437 qed |
438 from sred show "e \<turnstile> s' : T \<Rightarrow> U" |
438 from sred show "e \<turnstile> s' : T \<Rightarrow> U" |
439 by (rule subject_reduction') (rule rtyping_imp_typing) |
439 by (rule subject_reduction') (rule rtyping_imp_typing) |
440 qed |
440 qed |
441 then obtain u where ured: "s' \<degree> t' \<rightarrow>\<^sub>\<beta>\<^sup>* u" and unf: "u \<in> NF" by simp rules |
441 then obtain u where ured: "s' \<degree> t' \<rightarrow>\<^sub>\<beta>\<^sup>* u" and unf: "u \<in> NF" by simp iprover |
442 from sred tred have "s \<degree> t \<rightarrow>\<^sub>\<beta>\<^sup>* s' \<degree> t'" by (rule rtrancl_beta_App) |
442 from sred tred have "s \<degree> t \<rightarrow>\<^sub>\<beta>\<^sup>* s' \<degree> t'" by (rule rtrancl_beta_App) |
443 hence "s \<degree> t \<rightarrow>\<^sub>\<beta>\<^sup>* u" using ured by (rule rtrancl_trans) |
443 hence "s \<degree> t \<rightarrow>\<^sub>\<beta>\<^sup>* u" using ured by (rule rtrancl_trans) |
444 with unf show ?case by rules |
444 with unf show ?case by iprover |
445 qed |
445 qed |
446 |
446 |
447 |
447 |
448 subsection {* Extracting the program *} |
448 subsection {* Extracting the program *} |
449 |
449 |