(* Title: HOL/Nominal/Examples/Standardization.thy Author: Stefan Berghofer and Tobias Nipkow Copyright 2005, 2008 TU Muenchen
*)
section \<open>Standardization\<close>
theory Standardization imports"HOL-Nominal.Nominal" begin
text\<open>
The proof of the standardization theorem, as well as most of the theorems about
lambda calculus in the following sections, are taken from\<open>HOL/Lambda\<close>. \<close>
lemma subst_eqvt [eqvt]: "(pi::name prm) \ (t[x::=u]) = (pi \ t)[(pi \ x)::=(pi \ u)]" by (nominal_induct t avoiding: x u rule: lam.strong_induct)
(perm_simp add: fresh_bij)+
lemma subst_rename: "y \ t \ ([(y, x)] \ t)[y::=u] = t[x::=u]" by (nominal_induct t avoiding: x y u rule: lam.strong_induct)
(simp_all add: fresh_atm calc_atm abs_fresh)
lemma fresh_subst: "(x::name) \ t \ x \ u \ x \ t[y::=u]" by (nominal_induct t avoiding: x y u rule: lam.strong_induct)
(auto simp add: abs_fresh fresh_atm)
lemma fresh_subst': "(x::name) \ u \ x \ t[x::=u]" by (nominal_induct t avoiding: x u rule: lam.strong_induct)
(auto simp add: abs_fresh fresh_atm)
lemma subst_forget: "(x::name) \ t \ t[x::=u] = t" by (nominal_induct t avoiding: x u rule: lam.strong_induct)
(auto simp add: abs_fresh fresh_atm)
lemma subst_subst: "x \ y \ x \ v \ t[y::=v][x::=u[y::=v]] = t[x::=u][y::=v]" by (nominal_induct t avoiding: x y u v rule: lam.strong_induct)
(auto simp add: fresh_subst subst_forget)
lemma Var_eq_apps_conv [iff]: "(Var m = s \\ ss) = (Var m = s \ ss = [])" by (induct ss arbitrary: s) auto
lemma Var_apps_eq_Var_apps_conv [iff]: "(Var m \\ rs = Var n \\ ss) = (m = n \ rs = ss)" proof (induct rs arbitrary: ss rule: rev_induct) case Nil thenshow ?caseby (auto simp add: lam.inject) next case (snoc x xs) thenshow ?case by (induct ss rule: rev_induct) (auto simp add: lam.inject) qed
lemma App_eq_foldl_conv: "(r \ s = t \\ ts) =
(if ts = [] then r \<degree> s = t
else (\<exists>ss. ts = ss @ [s] \<and> r = t \<degree>\<degree> ss))" by (rule rev_exhaust [of ts]) (auto simp: lam.inject)
lemma Abs_eq_apps_conv [iff]: "((Lam [x].r) = s \\ ss) = ((Lam [x].r) = s \ ss = [])" by (induct ss rule: rev_induct) auto
lemma apps_eq_Abs_conv [iff]: "(s \\ ss = (Lam [x].r)) = (s = (Lam [x].r) \ ss = [])" by (induct ss rule: rev_induct) auto
lemma Abs_App_neq_Var_apps [iff]: "(Lam [x].s) \ t \ Var n \\ ss" by (induct ss arbitrary: s t rule: rev_induct) (auto simp add: lam.inject)
lemma Var_apps_neq_Abs_apps [iff]: "Var n \\ ts \ (Lam [x].r) \\ ss" proof (induct ss arbitrary: ts rule: rev_induct) case Nil thenshow ?caseby simp next case (snoc x xs) thenshow ?case by (induct ts rule: rev_induct) (auto simp add: lam.inject) qed
lemma ex_head_tail: "\ts h. t = h \\ ts \ ((\n. h = Var n) \ (\x u. h = (Lam [x].u)))" proof (induct t rule: lam.induct) case (App lam1 lam2) thenshow ?case by (metis foldl_Cons foldl_Nil foldl_append) qed auto
lemma size_apps [simp]: "size (r \\ rs) = size r + foldl (+) 0 (map size rs) + length rs" by (induct rs rule: rev_induct) auto
lemma lem0: "(0::nat) < k \ m \ n \ m < n + k" by simp
lemma fresh_apps [simp]: "(x::name) \ (t \\ ts) = (x \ t \ x \ ts)" by (induct ts rule: rev_induct)
(auto simp add: fresh_list_append fresh_list_nil fresh_list_cons)
text\<open>A customized induction schema for \<open>\<degree>\<degree>\<close>.\<close>
lemma Apps_lam_induct_aux: assumes"\n ts (z::'a::fs_name). (\z. \t \ set ts. P z t) \ P z (Var n \\ ts)" and"\x u ts z. x \ z \ (\z. P z u) \ (\z. \t \ set ts. P z t) \ P z ((Lam [x].u) \\ ts)" shows"size t = n \ P z t" proof (induct n arbitrary: t z rule: less_induct) case (less n) obtain ts h where t: "t = h \\ ts" and D: "(\a. h = Var a) \ (\x u. h = (Lam [x].u))" using ex_head_tail [of t] by metis show ?case using D proof (elim exE disjE) fix a :: name assume h: "h = Var a" have"P z t"if"t \ set ts" for z t proof - have"size t < length ts + fold (+) (map size ts) 0" using that by (fastforce simp add: sum_list_map_remove1 fold_plus_sum_list_rev) thenhave"size t < size (Var a \\ ts)" by simp (simp add: add.commute foldl_conv_fold) thenshow ?thesis using h less.hyps less.prems t by blast qed thenshow"P z t" unfolding t h by (blast intro: assms) next fix x u assume h: "h = (Lam [x].u)" obtain y::name where y: "y \ (x, u, z)" by (metis exists_fresh' fin_supp) thenhave eq: "(Lam [x].u) = (Lam [y].([(y, x)] \ u))" by (metis alpha' fresh_prod lam.inject(3) perm_fresh_fresh) show"P z t" unfolding t h eq proof (intro assms strip) show"y \ z" by (simp add: y) have"size ([(y, x)] \ u) < size ((Lam [x].u) \\ ts)" by (simp add: eq) thenshow"P z ([(y, x)] \ u)" for z using h less.hyps less.prems t by blast show"P z t"if"t\set ts" for z t proof - have 2: "size t < size ((Lam [x].u) \\ ts)" using that apply (simp add: eq) apply (simp only: foldl_conv_fold add.commute fold_plus_sum_list_rev) apply (fastforce simp add: sum_list_map_remove1) done thenshow ?thesis using h less.hyps less.prems t by blast qed qed qed qed
theorem Apps_lam_induct: assumes"\n ts (z::'a::fs_name). (\z. \t \ set ts. P z t) \ P z (Var n \\ ts)" and"\x u ts z. x \ z \ (\z. P z u) \ (\z. \t \ set ts. P z t) \ P z ((Lam [x].u) \\ ts)" shows"P z t" using Apps_lam_induct_aux [of P] assms by blast
subsection \<open>Congruence rules\<close>
lemma apps_preserves_beta [simp]: "r \\<^sub>\ s \ r \\ ss \\<^sub>\ s \\ ss" by (induct ss rule: rev_induct) auto
lemma rtrancl_beta_Abs [intro!]: "s \\<^sub>\\<^sup>* s' \ (Lam [x].s) \\<^sub>\\<^sup>* (Lam [x].s')" by (induct set: rtranclp) (blast intro: rtranclp.rtrancl_into_rtrancl)+
lemma rtrancl_beta_AppL: "s \\<^sub>\\<^sup>* s' \ s \ t \\<^sub>\\<^sup>* s' \ t" by (induct set: rtranclp) (blast intro: rtranclp.rtrancl_into_rtrancl)+
lemma rtrancl_beta_AppR: "t \\<^sub>\\<^sup>* t' \ s \ t \\<^sub>\\<^sup>* s \ t'" by (induct set: rtranclp) (blast intro: rtranclp.rtrancl_into_rtrancl)+
lemma rtrancl_beta_App [intro]: "s \\<^sub>\\<^sup>* s' \ t \\<^sub>\\<^sup>* t' \ s \ t \\<^sub>\\<^sup>* s' \ t'" by (blast intro!: rtrancl_beta_AppL rtrancl_beta_AppR intro: rtranclp_trans)
subsection \<open>Lifting an order to lists of elements\<close>
definition
step1 :: "('a \ 'a \ bool) \ 'a list \ 'a list \ bool" where "step1 r \
(\<lambda>ys xs. \<exists>us z z' vs. xs = us @ z # vs \<and> r z' z \<and> ys =
us @ z' # vs)"
lemma not_Nil_step1 [iff]: "\ step1 r [] xs" by (simp add: step1_def)
lemma not_step1_Nil [iff]: "\ step1 r xs []" by (simp add: step1_def)
lemma Cons_step1_Cons [iff]: "step1 r (y # ys) (x # xs) \ r y x \ xs = ys \ x = y \ step1 r ys xs" apply (rule ) apply (smt (verit, ccfv_SIG) append_eq_Cons_conv list.inject step1_def) by (metis append_Cons append_Nil step1_def)
lemma Cons_step1E [elim!]: assumes"step1 r ys (x # xs)" and"\y. ys = y # xs \ r y x \ R" and"\zs. ys = x # zs \ step1 r zs xs \ R" shows R by (metis Cons_step1_Cons assms list.exhaust not_Nil_step1)
lemma append_step1I: "step1 r ys xs \ vs = us \ ys = xs \ step1 r vs us \<Longrightarrow> step1 r (ys @ vs) (xs @ us)" by (smt (verit) append_Cons append_assoc step1_def)
lemma Snoc_step1_SnocD: assumes"step1 r (ys @ [y]) (xs @ [x])" shows"(step1 r ys xs \ y = x \ ys = xs \ r y x)" using assms apply (clarsimp simp: step1_def) by (metis butlast.simps(2) butlast_append butlast_snoc last.simps last_appendR list.simps(3))
subsection \<open>Lifting beta-reduction to lists\<close>
abbreviation
list_beta :: "lam list \ lam list \ bool" (infixl \[\\<^sub>\]\<^sub>1\ 50) where "rs [\\<^sub>\]\<^sub>1 ss \ step1 beta rs ss"
lemma head_Var_reduction: "Var n \\ rs \\<^sub>\ v \ \ss. rs [\\<^sub>\]\<^sub>1 ss \ v = Var n \\ ss" proof (induct u \<equiv> "Var n \<degree>\<degree> rs" v arbitrary: rs set: beta) case (appL s t u) thenshow ?case by (smt (verit, best) App_eq_foldl_conv app_last append_step1I lam.distinct(1)) next case (appR s t u) thenshow ?case by (smt (verit, ccfv_SIG) App_eq_foldl_conv Cons_step1_Cons app_last append_step1I lam.distinct(1)) qed auto
lemma apps_betasE [case_names appL appR beta, consumes 1]: assumes major: "r \\ rs \\<^sub>\ s" and cases: "\r'. r \\<^sub>\ r' \ s = r' \\ rs \ R" "\rs'. rs [\\<^sub>\]\<^sub>1 rs' \ s = r \\ rs' \ R" "\t u us. (x \ r \ r = (Lam [x].t) \ rs = u # us \ s = t[x::=u] \\ us) \ R" shows R proof - note [[simproc del: defined_all]] from major have "(\r'. r \\<^sub>\ r' \ s = r' \\ rs) \
(\<exists>rs'. rs [\<rightarrow>\<^sub>\<beta>]\<^sub>1 rs' \<and> s = r \<degree>\<degree> rs') \<or>
(\<exists>t u us. x \<sharp> r \<longrightarrow> r = (Lam [x].t) \<and> rs = u # us \<and> s = t[x::=u] \<degree>\<degree> us)" proof (nominal_induct u \<equiv> "r \<degree>\<degree> rs" s avoiding: x r rs rule: beta.strong_induct) case (beta y t s) thenshow ?case apply (simp add: App_eq_foldl_conv split: if_split_asm) apply blast by (metis (no_types, lifting) abs_fresh(1) alpha' lam.fresh(3) lam.inject(3) subst_rename) next case (appL s t u) thenshow ?case apply (simp add: App_eq_foldl_conv split: if_split_asm) apply blast by (smt (verit) append_Cons append_step1I snoc_eq_iff_butlast) next case (appR s t u) thenshow ?case apply (simp add: App_eq_foldl_conv step1_def split: if_split_asm) apply force by (metis snoc_eq_iff_butlast) next case (abs s t x) thenshow ?case by blast qed with cases show ?thesis by blast qed
lemma apps_preserves_betas [simp]: "rs [\\<^sub>\]\<^sub>1 ss \ r \\ rs \\<^sub>\ r \\ ss" proof (induct rs arbitrary: ss rule: rev_induct) case Nil thenshow ?caseby simp next case (snoc x ts) thenshow ?case apply (simp add: step1_def) by (smt (verit) appR app_last apps_preserves_beta foldl_Cons foldl_append) qed
lemma refl_listrelp: "\x\set xs. R x x \ listrelp R xs xs" by (induct xs) (auto intro: listrelp.intros)
lemma refl_sred: "t \\<^sub>s t" by (nominal_induct t rule: Apps_lam_induct) (auto intro: refl_listrelp better_sred_intros)
lemma listrelp_conj1: "listrelp (\x y. R x y \ S x y) x y \ listrelp R x y" by (erule listrelp.induct) (auto intro: listrelp.intros)
lemma listrelp_conj2: "listrelp (\x y. R x y \ S x y) x y \ listrelp S x y" by (erule listrelp.induct) (auto intro: listrelp.intros)
lemma listrelp_app: assumes xsys: "listrelp R xs ys" shows"listrelp R xs' ys' \ listrelp R (xs @ xs') (ys @ ys')" using xsys by (induct arbitrary: xs' ys') (auto intro: listrelp.intros)
lemma lemma1: assumes r: "r \\<^sub>s r'" and s: "s \\<^sub>s s'" shows"r \ s \\<^sub>s r' \ s'" using r proof induct case (Var rs rs' x) thenhave"rs [\\<^sub>s] rs'" by (rule listrelp_conj1) moreoverhave"[s] [\\<^sub>s] [s']" by (iprover intro: s listrelp.intros) ultimatelyhave"rs @ [s] [\\<^sub>s] rs' @ [s']" by (rule listrelp_app) hence"Var x \\ (rs @ [s]) \\<^sub>s Var x \\ (rs' @ [s'])" by (rule sred.Var) thus ?caseby (simp only: app_last) next case (Abs x ss ss' r r') from Abs(4) have"ss [\\<^sub>s] ss'" by (rule listrelp_conj1) moreoverhave"[s] [\\<^sub>s] [s']" by (iprover intro: s listrelp.intros) ultimatelyhave"ss @ [s] [\\<^sub>s] ss' @ [s']" by (rule listrelp_app) with\<open>r \<rightarrow>\<^sub>s r'\<close> have "(Lam [x].r) \<degree>\<degree> (ss @ [s]) \<rightarrow>\<^sub>s (Lam [x].r') \<degree>\<degree> (ss' @ [s'])" by (rule better_sred_Abs) thus ?caseby (simp only: app_last) next case (Beta x u ss t r) hence"r[x::=u] \\ (ss @ [s]) \\<^sub>s t \ s'" by (simp only: app_last) hence"(Lam [x].r) \ u \\ (ss @ [s]) \\<^sub>s t \ s'" by (rule better_sred_Beta) thus ?caseby (simp only: app_last) qed
lemma lemma1': assumes ts: "ts [\\<^sub>s] ts'" shows"r \\<^sub>s r' \ r \\ ts \\<^sub>s r' \\ ts'" using ts by (induct arbitrary: r r') (auto intro: lemma1)
lemma listrelp_betas: assumes ts: "listrelp (\\<^sub>\\<^sup>*) ts ts'" shows"\t t'. t \\<^sub>\\<^sup>* t' \ t \\ ts \\<^sub>\\<^sup>* t' \\ ts'" using ts by induct auto
lemma lemma2: assumes t: "t \\<^sub>s u" shows"t \\<^sub>\\<^sup>* u" using t by induct (auto dest: listrelp_conj2
intro: listrelp_betas apps_preserves_beta converse_rtranclp_into_rtranclp)
lemma lemma3: assumes r: "r \\<^sub>s r'" shows"s \\<^sub>s s' \ r[x::=s] \\<^sub>s r'[x::=s']" using r proof (nominal_induct avoiding: x s s' rule: sred.strong_induct) case (Var rs rs' y) hence"map (\t. t[x::=s]) rs [\\<^sub>s] map (\t. t[x::=s']) rs'" by induct (auto intro: listrelp.intros Var) moreoverhave"Var y[x::=s] \\<^sub>s Var y[x::=s']" by (cases "y = x") (auto simp add: Var intro: refl_sred) ultimatelyshow ?caseby simp (rule lemma1') next case (Abs y ss ss' r r') thenhave"r[x::=s] \\<^sub>s r'[x::=s']" by fast moreoverfrom Abs(8) \<open>s \<rightarrow>\<^sub>s s'\<close> have "map (\<lambda>t. t[x::=s]) ss [\<rightarrow>\<^sub>s] map (\<lambda>t. t[x::=s']) ss'" by induct (auto intro: listrelp.intros Abs) ultimatelyshow ?caseusing Abs(6) \<open>y \<sharp> x\<close> \<open>y \<sharp> s\<close> \<open>y \<sharp> s'\<close> by simp (rule better_sred_Abs) next case (Beta y u ss t r) thus ?caseby (auto simp add: subst_subst fresh_atm intro: better_sred_Beta) qed
lemma lemma4_aux: assumes rs: "listrelp (\t u. t \\<^sub>s u \ (\r. u \\<^sub>\ r \ t \\<^sub>s r)) rs rs'" shows"rs' [\\<^sub>\]\<^sub>1 ss \ rs [\\<^sub>s] ss" using rs proof (induct arbitrary: ss) case Nil thus ?caseby cases (auto intro: listrelp.Nil) next case (Cons x y xs ys) note Cons' = Cons show ?case proof (cases ss) case Nil with Cons show ?thesis by simp next case (Cons y' ys') hence ss: "ss = y' # ys'"by simp from Cons Cons' have "y \\<^sub>\ y' \ ys' = ys \ y' = y \ ys [\\<^sub>\]\<^sub>1 ys'" by simp hence"x # xs [\\<^sub>s] y' # ys'" proof assume H: "y \\<^sub>\ y' \ ys' = ys" with Cons' have "x \\<^sub>s y'" by blast moreoverfrom Cons' have "xs [\\<^sub>s] ys" by (iprover dest: listrelp_conj1) ultimatelyhave"x # xs [\\<^sub>s] y' # ys" by (rule listrelp.Cons) with H show ?thesis by simp next assume H: "y' = y \ ys [\\<^sub>\]\<^sub>1 ys'" with Cons' have "x \\<^sub>s y'" by blast moreoverfrom H have"xs [\\<^sub>s] ys'" by (blast intro: Cons') ultimatelyshow ?thesis by (rule listrelp.Cons) qed with ss show ?thesis by simp qed qed
lemma lemma4: assumes r: "r \\<^sub>s r'" shows"r' \\<^sub>\ r'' \ r \\<^sub>s r''" using r proof (nominal_induct avoiding: r'' rule: sred.strong_induct) case (Var rs rs' x) thenobtain ss where rs: "rs' [\\<^sub>\]\<^sub>1 ss" and r'': "r'' = Var x \\ ss" by (blast dest: head_Var_reduction) from Var(1) [simplified] rs have"rs [\\<^sub>s] ss" by (rule lemma4_aux) hence"Var x \\ rs \\<^sub>s Var x \\ ss" by (rule sred.Var) with r''show ?caseby simp next case (Abs x ss ss' r r') from\<open>(Lam [x].r') \<degree>\<degree> ss' \<rightarrow>\<^sub>\<beta> r''\<close> show ?case proof (cases rule: apps_betasE [where x=x]) case (appL s) thenobtain r''' where s: "s = (Lam [x].r''')" and r''': "r' \\<^sub>\ r'''" using \x \r''\ by (cases rule: beta.strong_cases) (auto simp add: abs_fresh lam.inject alpha) from r''' have "r \\<^sub>s r'''" by (blast intro: Abs) moreoverfrom Abs have"ss [\\<^sub>s] ss'" by (iprover dest: listrelp_conj1) ultimatelyhave"(Lam [x].r) \\ ss \\<^sub>s (Lam [x].r''') \\ ss'" by (rule better_sred_Abs) with appL s show"(Lam [x].r) \\ ss \\<^sub>s r''" by simp next case (appR rs') from Abs(6) [simplified] \<open>ss' [\<rightarrow>\<^sub>\<beta>]\<^sub>1 rs'\<close> have"ss [\\<^sub>s] rs'" by (rule lemma4_aux) with\<open>r \<rightarrow>\<^sub>s r'\<close> have "(Lam [x].r) \<degree>\<degree> ss \<rightarrow>\<^sub>s (Lam [x].r') \<degree>\<degree> rs'" by (rule better_sred_Abs) with appR show"(Lam [x].r) \\ ss \\<^sub>s r''" by simp next case (beta t u' us') thenhave Lam_eq: "(Lam [x].r') = (Lam [x].t)"and ss': "ss' = u' # us'" and r'': "r'' = t[x::=u'] \\ us'" by (simp_all add: abs_fresh) from Abs(6) ss' obtain u us where
ss: "ss = u # us"and u: "u \\<^sub>s u'" and us: "us [\\<^sub>s] us'" by cases (auto dest!: listrelp_conj1) have"r[x::=u] \\<^sub>s r'[x::=u']" using \r \\<^sub>s r'\ and u by (rule lemma3) with us have"r[x::=u] \\ us \\<^sub>s r'[x::=u'] \\ us'" by (rule lemma1') hence"(Lam [x].r) \ u \\ us \\<^sub>s r'[x::=u'] \\ us'" by (rule better_sred_Beta) with ss r'' Lam_eq show"(Lam [x].r) \\ ss \\<^sub>s r''" by (simp add: lam.inject alpha) qed next case (Beta x s ss t r) show ?case by (rule better_sred_Beta) (rule Beta)+ qed
lemma rtrancl_beta_sred: assumes r: "r \\<^sub>\\<^sup>* r'" shows"r \\<^sub>s r'" using r by induct (iprover intro: refl_sred lemma4)+
subsection \<open>Terms in normal form\<close>
lemma listsp_eqvt [eqvt]: assumes xs: "listsp p (xs::'a::pt_name list)" shows"listsp ((pi::name prm) \ p) (pi \ xs)" using xs byinduction (use perm_app in force)+
inductive NF :: "lam \ bool" where
App: "listsp NF ts \ NF (Var x \\ ts)"
| Abs: "NF t \ NF (Lam [x].t)"
equivariance NF nominal_inductive NF by (simp add: abs_fresh)
text\<open> \<^term>\<open>NF\<close> characterizes exactly the terms that are in normal form. \<close>
lemma NF_eq: "NF t = (\t'. \ t \\<^sub>\ t')" proof assume H: "NF t" show"\t'. \ t \\<^sub>\ t'" proof fix t' from H show"\ t \\<^sub>\ t'" proof (nominal_induct avoiding: t' rule: NF.strong_induct) case (App ts t) show ?case proof assume"Var t \\ ts \\<^sub>\ t'" thenobtain rs where"ts [\\<^sub>\]\<^sub>1 rs" by (iprover dest: head_Var_reduction) with App show False by (induct rs arbitrary: ts) (auto del: in_listspD) qed next case (Abs t x) show ?case proof assume"(Lam [x].t) \\<^sub>\ t'" thenshow False using Abs by (cases rule: beta.strong_cases) (auto simp add: abs_fresh lam.inject alpha) qed qed qed next assume H: "\t'. \ t \\<^sub>\ t'" thenshow"NF t" proof (nominal_induct t rule: Apps_lam_induct) case (1 n ts) thenhave"\ts'. \ ts [\\<^sub>\]\<^sub>1 ts'" by (iprover intro: apps_preserves_betas) with 1(1) have"listsp NF ts" by (induct ts) (auto simp add: in_listsp_conv_set) thenshow ?caseby (rule NF.App) next case (2 x u ts) show ?case proof (cases ts) case Nil thus ?thesis by (metis 2 NF.Abs abs foldl_Nil) next case (Cons r rs) have"(Lam [x].u) \ r \\<^sub>\ u[x::=r]" .. thenhave"(Lam [x].u) \ r \\ rs \\<^sub>\ u[x::=r] \\ rs" by (rule apps_preserves_beta) with Cons have"(Lam [x].u) \\ ts \\<^sub>\ u[x::=r] \\ rs" by simp with 2 show ?thesis by iprover qed qed qed
subsection \<open>Leftmost reduction and weakly normalizing terms\<close>
inductive
lred :: "lam \ lam \ bool" (infixl \\\<^sub>l\ 50) and lredlist :: "lam list \ lam list \ bool" (infixl \[\\<^sub>l]\ 50) where "s [\\<^sub>l] t \ listrelp (\\<^sub>l) s t"
| Var: "rs [\\<^sub>l] rs' \ Var x \\ rs \\<^sub>l Var x \\ rs'"
| Abs: "r \\<^sub>l r' \ (Lam [x].r) \\<^sub>l (Lam [x].r')"
| Beta: "r[x::=s] \\ ss \\<^sub>l t \ (Lam [x].r) \ s \\ ss \\<^sub>l t"
lemma lred_imp_sred: assumes lred: "s \\<^sub>l t" shows"s \\<^sub>s t" using lred proof induct case (Var rs rs' x) thenhave"rs [\\<^sub>s] rs'" by induct (iprover intro: listrelp.intros)+ thenshow ?caseby (rule sred.Var) next case (Abs r r' x) from\<open>r \<rightarrow>\<^sub>s r'\<close> have"(Lam [x].r) \\ [] \\<^sub>s (Lam [x].r') \\ []" using listrelp.Nil by (rule better_sred_Abs) thenshow ?caseby simp next case (Beta r x s ss t) from\<open>r[x::=s] \<degree>\<degree> ss \<rightarrow>\<^sub>s t\<close> show ?caseby (rule better_sred_Beta) qed
lemma lemma6: assumes wn: "WN r" shows"\r'. r \\<^sub>l r'" using wn proof induct case (Var rs n) thenhave"\rs'. rs [\\<^sub>l] rs'" by induct (iprover intro: listrelp.intros)+ thenshow ?caseby (iprover intro: lred.Var) qed (iprover intro: lred.intros)+
lemma lemma7: assumes r: "r \\<^sub>s r'" shows"NF r' \ r \\<^sub>l r'" using r proof induct case (Var rs rs' x) from\<open>NF (Var x \<degree>\<degree> rs')\<close> have "listsp NF rs'" by cases simp_all with Var(1) have"rs [\\<^sub>l] rs'" proof induct case Nil show ?caseby (rule listrelp.Nil) next case (Cons x y xs ys) hence"x \\<^sub>l y" and "xs [\\<^sub>l] ys" by (auto del: in_listspD) thus ?caseby (rule listrelp.Cons) qed thus ?caseby (rule lred.Var) next case (Abs x ss ss' r r') from\<open>NF ((Lam [x].r') \<degree>\<degree> ss')\<close> have ss': "ss' = []" by (rule Abs_NF) from Abs(4) have ss: "ss = []"using ss' by cases simp_all from ss' Abs have "NF (Lam [x].r')" by simp hence"NF r'"by (cases rule: NF.strong_cases) (auto simp add: abs_fresh lam.inject alpha) with Abs have"r \\<^sub>l r'" by simp hence"(Lam [x].r) \\<^sub>l (Lam [x].r')" by (rule lred.Abs) with ss ss' show ?case by simp next case (Beta x s ss t r) hence"r[x::=s] \\ ss \\<^sub>l t" by simp thus ?caseby (rule lred.Beta) qed
lemma WN_eq: "WN t = (\t'. t \\<^sub>\\<^sup>* t' \ NF t')" proof assume"WN t" thenhave"\t'. t \\<^sub>l t'" by (rule lemma6) thenobtain t' where t': "t \\<^sub>l t'" .. thenhave NF: "NF t'"by (rule lemma5) from t' have "t \\<^sub>s t'" by (rule lred_imp_sred) thenhave"t \\<^sub>\\<^sup>* t'" by (rule lemma2) with NF show"\t'. t \\<^sub>\\<^sup>* t' \ NF t'" by iprover next assume"\t'. t \\<^sub>\\<^sup>* t' \ NF t'" thenobtain t' where t': "t \\<^sub>\\<^sup>* t'" and NF: "NF t'" by iprover from t' have "t \\<^sub>s t'" by (rule rtrancl_beta_sred) thenhave"t \\<^sub>l t'" using NF by (rule lemma7) thenshow"WN t"by (rule lemma5) qed
end
¤ Dauer der Verarbeitung: 0.4 Sekunden
(vorverarbeitet)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.