diff -r 263aaf988d44 -r c24395ea4e71 src/HOL/Nominal/Examples/SN.thy --- a/src/HOL/Nominal/Examples/SN.thy Tue Jan 08 11:37:37 2008 +0100 +++ b/src/HOL/Nominal/Examples/SN.thy Tue Jan 08 23:11:08 2008 +0100 @@ -1,7 +1,7 @@ (* $Id$ *) theory SN -imports Lam_Funs + imports Lam_Funs begin text {* Strong Normalisation proof from the Proofs and Types book *} @@ -104,27 +104,12 @@ TVar "nat" | TArr "ty" "ty" (infix "\" 200) -lemma perm_ty: - fixes pi ::"name prm" - and \ ::"ty" - shows "pi\\ = \" -by (nominal_induct \ rule: ty.induct) - (simp_all add: perm_nat_def) - lemma fresh_ty: fixes a ::"name" and \ ::"ty" shows "a\\" - by (simp add: fresh_def perm_ty supp_def) - -(* domain of a typing context *) - -fun - "dom_ty" :: "(name\ty) list \ (name list)" -where - "dom_ty [] = []" -| "dom_ty ((x,\)#\) = (x)#(dom_ty \)" - +by (nominal_induct \ rule: ty.induct) + (auto simp add: fresh_nat) (* valid contexts *) @@ -136,8 +121,6 @@ equivariance valid -inductive_cases valid_elim[elim]: "valid ((a,\)#\)" - (* typing judgements *) lemma fresh_context: @@ -161,12 +144,7 @@ nominal_inductive typing by (simp_all add: abs_fresh fresh_ty) -abbreviation - "sub" :: "(name\ty) list \ (name\ty) list \ bool" ("_ \ _" [60,60] 60) -where - "\1 \ \2 \ \a \. (a,\)\set \1 \ (a,\)\set \2" - -subsection {* some facts about beta *} +subsection {* a fact about beta *} constdefs "NORMAL" :: "lam \ bool" @@ -177,11 +155,12 @@ proof - { assume "\t'. (Var a) \\<^isub>\ t'" then obtain t' where "(Var a) \\<^isub>\ t'" by blast - hence False by (cases, auto) + hence False by (cases) (auto) } - thus "NORMAL (Var a)" by (force simp add: NORMAL_def) + thus "NORMAL (Var a)" by (auto simp add: NORMAL_def) qed +text {* Inductive version of Strong Normalisation *} inductive SN :: "lam \ bool" where @@ -249,7 +228,7 @@ "RED (\\\) = {t. \u. (u\RED \ \ (App t u)\RED \)}" by (rule TrueI)+ -(* neutral terms *) +text {* neutral terms *} constdefs NEUT :: "lam \ bool" "NEUT t \ (\a. t = Var a) \ (\t1 t2. t = App t1 t2)" @@ -358,7 +337,7 @@ ultimately show "App t u \ RED \" using c3 by (simp add: CR3_def) qed -(* properties of the candiadates *) +text {* properties of the candiadates *} lemma RED_props: shows "CR1 \" and "CR2 \" and "CR3 \" proof (nominal_induct \ rule: ty.induct) @@ -374,10 +353,11 @@ { case 1 have ih_CR3_\1: "CR3 \1" by fact have ih_CR1_\2: "CR1 \2" by fact - show "CR1 (\1 \ \2)" unfolding CR1_def - proof (simp, intro strip) + have "\t. t \ RED (\1 \ \2) \ SN t" + proof - fix t - assume a: "\u. u \ RED \1 \ App t u \ RED \2" + assume "t \ RED (\1 \ \2)" + then have a: "\u. u \ RED \1 \ App t u \ RED \2" by simp from ih_CR3_\1 have "CR4 \1" by (simp add: CR3_implies_CR4) moreover have "NEUT (Var a)" by (force simp add: NEUT_def) @@ -386,20 +366,13 @@ ultimately have "(Var a)\ RED \1" by (simp add: CR4_def) with a have "App t (Var a) \ RED \2" by simp hence "SN (App t (Var a))" using ih_CR1_\2 by (simp add: CR1_def) - thus "SN(t)" by (auto dest: SN_of_FST_of_App) + thus "SN t" by (auto dest: SN_of_FST_of_App) qed + then show "CR1 (\1 \ \2)" unfolding CR1_def by simp next case 2 - have ih_CR1_\1: "CR1 \1" by fact have ih_CR2_\2: "CR2 \2" by fact - show "CR2 (\1 \ \2)" unfolding CR2_def - proof (simp, intro strip) - fix t1 t2 u - assume "(\u. u \ RED \1 \ App t1 u \ RED \2) \ t1 \\<^isub>\ t2" - and "u \ RED \1" - hence "t1 \\<^isub>\ t2" and "App t1 u \ RED \2" by simp_all - thus "App t2 u \ RED \2" using ih_CR2_\2 by (auto simp add: CR2_def) - qed + then show "CR2 (\1 \ \2)" unfolding CR2_def by auto next case 3 have ih_CR1_\1: "CR1 \1" by fact @@ -416,7 +389,10 @@ } qed -(* not as simple as on paper, because of the stronger double_SN induction *) +text {* + the next lemma not as simple as on paper, probably because of + the stronger double_SN induction +*} lemma abs_RED: assumes asm: "\s\RED \. t[x::=s]\RED \" shows "Lam [x].t\RED (\\\)" @@ -462,14 +438,17 @@ apply(drule_tac x="t'" in meta_spec) apply(simp) apply(drule meta_mp) - apply(auto) + prefer 2 + apply(auto)[1] + apply(rule ballI) apply(drule_tac x="s" in bspec) apply(simp) - apply(subgoal_tac "CR2 \") + apply(subgoal_tac "CR2 \")(*A*) apply(unfold CR2_def)[1] apply(drule_tac x="t[x::=s]" in spec) apply(drule_tac x="t'[x::=s]" in spec) apply(simp add: beta_subst) + (*A*) apply(simp add: RED_props) done then have "r\RED \" using a2 by simp @@ -497,9 +476,12 @@ then have "r\RED \" using as1 as2 by auto } ultimately show "r \ RED \" + (* one wants to use the strong elimination principle; for this one + has to know that x\u *) apply(cases) apply(auto simp add: lam.inject) apply(drule beta_abs) + apply(auto)[1] apply(auto simp add: alpha subst_rename) done qed @@ -513,7 +495,7 @@ abbreviation mapsto :: "(name\lam) list \ name \ lam \ bool" ("_ maps _ to _" [55,55,55] 55) where - "\ maps x to e\ (lookup \ x) = e" + "\ maps x to e \ (lookup \ x) = e" abbreviation closes :: "(name\lam) list \ (name\ty) list \ bool" ("_ closes _" [55,55] 55)