# HG changeset patch # User urbanc # Date 1178062943 -7200 # Node ID f1db55c7534dd70cdb9c2790eb13a7f28c6486c7 # Parent 2064f0fd20c92b40c79a811c72c23bdedbcd2ac2 tuned some proofs and changed variable names in some definitions of Nominal.thy diff -r 2064f0fd20c9 -r f1db55c7534d src/HOL/Nominal/Examples/CR_Takahashi.thy --- a/src/HOL/Nominal/Examples/CR_Takahashi.thy Mon Apr 30 22:43:33 2007 +0200 +++ b/src/HOL/Nominal/Examples/CR_Takahashi.thy Wed May 02 01:42:23 2007 +0200 @@ -4,15 +4,19 @@ imports Lam_Funs begin -text {* The Church-Rosser proof from a paper by Masako Takahashi; - our formalisation follows with some slight exceptions the one - done by Randy Pollack and James McKinna from their 1993 - TLCA-paper; the proof is simpler by using an auxiliary - reduction relation called complete development reduction. - - Authors: Mathilde Arnaud and Christian Urban - *} +text {* Authors: Mathilde Arnaud and Christian Urban + + The Church-Rosser proof from a paper by Masako Takahashi. + This formalisation follows with some very slight exceptions + the one given by Randy Pollack in his paper: + Polishing Up the Tait-Martin Löf Proof of the + Church-Rosser Theorem (1995). + + *} + +section {* Lemmas about Capture-Avoiding Substitution *} + lemma forget: assumes asm: "x\L" shows "L[x::=P] = L" @@ -43,6 +47,14 @@ by (nominal_induct M avoiding: x y N L rule: lam.induct) (auto simp add: fresh_fact forget) +lemma subst_rename: + assumes a: "c\t1" + shows "t1[a::=t2] = ([(c,a)]\t1)[c::=t2]" +using a +by (nominal_induct t1 avoiding: a c t2 rule: lam.induct) + (auto simp add: calc_atm fresh_atm abs_fresh) + + section {* Beta Reduction *} inductive2 @@ -58,10 +70,12 @@ nominal_inductive Beta by (simp_all add: abs_fresh fresh_fact') +section {* Transitive Closure of Beta *} + inductive2 "Beta_star" :: "lam\lam\bool" (" _ \\<^isub>\\<^sup>* _" [80,80] 80) where - bs1[intro, simp]: "M \\<^isub>\\<^sup>* M" + bs1[intro,simp]: "M \\<^isub>\\<^sup>* M" | bs2[intro]: "\M1\\<^isub>\\<^sup>* M2; M2 \\<^isub>\ M3\ \ M1 \\<^isub>\\<^sup>* M3" equivariance Beta_star @@ -103,6 +117,8 @@ by (nominal_induct M M' avoiding: N N' x rule: One.strong_induct) (auto simp add: one_subst_aux substitution_lemma fresh_atm fresh_fact) +section {* Transitive Closure of One *} + inductive2 "One_star" :: "lam\lam\bool" (" _ \\<^isub>1\<^sup>* _" [80,80] 80) where @@ -127,33 +143,22 @@ by (nominal_induct avoiding: a rule: One.strong_induct) (auto simp add: abs_fresh fresh_atm fresh_fact) -lemma subst_rename: - assumes a: "c\t1" - shows "t1[a::=t2] = ([(c,a)]\t1)[c::=t2]" -using a -by (nominal_induct t1 avoiding: a c t2 rule: lam.induct) - (auto simp add: calc_atm fresh_atm abs_fresh) +section {* Elimination Rules for One *} lemma one_var: assumes a: "Var x \\<^isub>1 t" shows "t = Var x" using a -by - (ind_cases2 "Var x \\<^isub>1 t", simp) +by (erule_tac One.cases) (simp_all) lemma one_abs: - fixes t :: "lam" - and t':: "lam" - and a :: "name" assumes a: "(Lam [a].t)\\<^isub>1t'" shows "\t''. t'=Lam [a].t'' \ t\\<^isub>1t''" - using a - apply - - apply(ind_cases2 "(Lam [a].t)\\<^isub>1t'") +using a + apply(erule_tac One.cases) apply(auto simp add: lam.inject alpha) apply(rule_tac x="[(a,aa)]\s2" in exI) - apply(rule conjI) - apply(perm_simp) - apply(simp add: fresh_left calc_atm) + apply(perm_simp add: fresh_left calc_atm) apply(simp add: One.eqvt) apply(simp add: one_fresh_preserv) done @@ -163,8 +168,7 @@ shows "(\s1 s2. t' = App s1 s2 \ t1 \\<^isub>1 s1 \ t2 \\<^isub>1 s2) \ (\a s s1 s2. t1 = Lam [a].s \ a\(t2,s2) \ t' = s1[a::=s2] \ s \\<^isub>1 s1 \ t2 \\<^isub>1 s2)" using a - apply - - apply(ind_cases2 "App t1 t2 \\<^isub>1 t'") + apply(erule_tac One.cases) apply(auto simp add: lam.distinct lam.inject) done @@ -173,8 +177,7 @@ shows "(\s1 s2. M = App (Lam [a].s1) s2 \ t1 \\<^isub>1 s1 \ t2 \\<^isub>1 s2) \ (\s1 s2. M = s1[a::=s2] \ t1 \\<^isub>1 s1 \ t2 \\<^isub>1 s2)" using a - apply - - apply(ind_cases2 "App (Lam [a].t1) t2 \\<^isub>1 M") + apply(erule_tac One.cases) apply(simp_all add: lam.inject) apply(force) apply(erule conjE) @@ -201,7 +204,7 @@ apply(simp add: One.eqvt) done -text {* complete development reduction *} +text {* Complete Development Reduction *} inductive2 cd1 :: "lam \ lam \ bool" (" _ >c _" [80,80]80) @@ -227,12 +230,9 @@ obtain c::"name" where fs: "c\(a,t1,s1,t2,s2)" by (rule exists_fresh, rule fin_supp,blast) have eq1: "Lam [a].t1 = Lam [c].([(c,a)]\t1)" using fs by (rule_tac sym, auto simp add: lam.inject alpha fresh_prod fresh_atm) - have "App (Lam [a].t1) s1 = App (Lam [c].([(c,a)]\t1)) s1" - using eq1 by simp - also have "\ >c ([(c,a)]\t2)[c::=s2]" using fs a b - by (rule_tac cd1r, simp_all add: cd1.eqvt) - also have "\ = t2[a::=s2]" using fs - by (rule_tac subst_rename[symmetric], simp) + have "App (Lam [a].t1) s1 = App (Lam [c].([(c,a)]\t1)) s1" using eq1 by simp + also have "\ >c ([(c,a)]\t2)[c::=s2]" using fs a b by (simp_all add: cd1.eqvt) + also have "\ = t2[a::=s2]" using fs by (rule_tac subst_rename[symmetric], simp) finally show "App (Lam [a].t1) s1 >c (t2[a::=s2])" by simp qed @@ -242,19 +242,15 @@ and b: "s1 >c s2" shows "a\s2" using b a -by (induct) (auto simp add: abs_fresh fresh_fact fresh_fact') - + by (induct) (auto simp add: abs_fresh fresh_fact fresh_fact') lemma cd1_lam: - fixes c::"'a::fs_name" assumes a: "Lam [a].t >c t'" shows "\s. t'=Lam [a].s \ t >c s" using a apply - apply(erule cd1.cases) -apply(simp_all) -apply(simp add: lam.inject) -apply(simp add: alpha) +apply(simp_all add: lam.inject alpha) apply(auto) apply(rule_tac x="[(a,aa)]\s2" in exI) apply(perm_simp add: fresh_left cd1.eqvt cd1_fresh_preserve) @@ -289,32 +285,19 @@ assumes a: "t1\\<^isub>\\<^sup>*t2" shows "(Lam [a].t1)\\<^isub>\\<^sup>*(Lam [a].t2)" using a -proof induct - case bs1 thus ?case by simp -next - case (bs2 y z) - thus ?case by (blast dest: b3) -qed +by (induct) (blast)+ lemma one_app_congL: assumes a: "t1\\<^isub>\\<^sup>*t2" shows "App t1 s\\<^isub>\\<^sup>* App t2 s" using a -proof induct - case bs1 thus ?case by simp -next - case bs2 thus ?case by (blast dest: b1) -qed +by (induct) (blast)+ lemma one_app_congR: assumes a: "t1\\<^isub>\\<^sup>*t2" shows "App s t1 \\<^isub>\\<^sup>* App s t2" using a -proof induct - case bs1 thus ?case by simp -next - case bs2 thus ?case by (blast dest: b2) -qed +by (induct) (blast)+ lemma one_app_cong: assumes a1: "t1\\<^isub>\\<^sup>*t2" @@ -324,7 +307,7 @@ have "App t1 s1 \\<^isub>\\<^sup>* App t2 s1" using a1 by (rule one_app_congL) moreover have "App t2 s1 \\<^isub>\\<^sup>* App t2 s2" using a2 by (rule one_app_congR) - ultimately show ?thesis by (rule beta_star_trans) + ultimately show "App t1 s1\\<^isub>\\<^sup>* App t2 s2" by (rule beta_star_trans) qed lemma one_beta_star: diff -r 2064f0fd20c9 -r f1db55c7534d src/HOL/Nominal/Examples/Compile.thy --- a/src/HOL/Nominal/Examples/Compile.thy Mon Apr 30 22:43:33 2007 +0200 +++ b/src/HOL/Nominal/Examples/Compile.thy Wed May 02 01:42:23 2007 +0200 @@ -1,6 +1,6 @@ (* $Id$ *) -(* A challenge suggested by Adam Chlipala *) +(* The definitions for a challenge suggested by Adam Chlipala *) theory Compile imports "../Nominal" @@ -8,51 +8,58 @@ atom_decl name -nominal_datatype data = DNat - | DProd "data" "data" - | DSum "data" "data" +nominal_datatype data = + DNat + | DProd "data" "data" + | DSum "data" "data" -nominal_datatype ty = Data "data" - | Arrow "ty" "ty" ("_\_" [100,100] 100) +nominal_datatype ty = + Data "data" + | Arrow "ty" "ty" ("_\_" [100,100] 100) -nominal_datatype trm = Var "name" - | Lam "\name\trm" ("Lam [_]._" [100,100] 100) - | App "trm" "trm" - | Const "nat" - | Pr "trm" "trm" - | Fst "trm" - | Snd "trm" - | InL "trm" - | InR "trm" - | Case "trm" "\name\trm" "\name\trm" - ("Case _ of inl _ \ _ | inr _ \ _" [100,100,100,100,100] 100) +nominal_datatype trm = + Var "name" + | Lam "\name\trm" ("Lam [_]._" [100,100] 100) + | App "trm" "trm" + | Const "nat" + | Pr "trm" "trm" + | Fst "trm" + | Snd "trm" + | InL "trm" + | InR "trm" + | Case "trm" "\name\trm" "\name\trm" + ("Case _ of inl _ \ _ | inr _ \ _" [100,100,100,100,100] 100) nominal_datatype dataI = OneI | NatI -nominal_datatype tyI = DataI "dataI" - | ArrowI "tyI" "tyI" ("_\_" [100,100] 100) +nominal_datatype tyI = + DataI "dataI" + | ArrowI "tyI" "tyI" ("_\_" [100,100] 100) -nominal_datatype trmI = IVar "name" - | ILam "\name\trmI" ("ILam [_]._" [100,100] 100) - | IApp "trmI" "trmI" - | IUnit - | INat "nat" - | ISucc "trmI" - | IAss "trmI" "trmI" ("_\_" [100,100] 100) - | IRef "trmI" - | ISeq "trmI" "trmI" ("_;;_" [100,100] 100) - | Iif "trmI" "trmI" "trmI" +nominal_datatype trmI = + IVar "name" + | ILam "\name\trmI" ("ILam [_]._" [100,100] 100) + | IApp "trmI" "trmI" + | IUnit + | INat "nat" + | ISucc "trmI" + | IAss "trmI" "trmI" ("_\_" [100,100] 100) + | IRef "trmI" + | ISeq "trmI" "trmI" ("_;;_" [100,100] 100) + | Iif "trmI" "trmI" "trmI" text {* valid contexts *} -inductive2 valid :: "(name\'a::pt_name) list \ bool" +inductive2 + valid :: "(name\'a::pt_name) list \ bool" where v1[intro]: "valid []" | v2[intro]: "\valid \;a\\\\ valid ((a,\)#\)" (* maybe dom of \ *) text {* typing judgements for trms *} -inductive2 typing :: "(name\ty) list\trm\ty\bool" (" _ \ _ : _ " [80,80,80] 80) +inductive2 + typing :: "(name\ty) list\trm\ty\bool" (" _ \ _ : _ " [80,80,80] 80) where t0[intro]: "\valid \; (x,\)\set \\\ \ \ Var x : \" | t1[intro]: "\\ \ e1 : \1\\2; \ \ e2 : \1\\ \ \ App e1 e2 : \2" @@ -69,7 +76,8 @@ text {* typing judgements for Itrms *} -inductive2 Ityping :: "(name\tyI) list\trmI\tyI\bool" (" _ I\ _ : _ " [80,80,80] 80) +inductive2 + Ityping :: "(name\tyI) list\trmI\tyI\bool" (" _ I\ _ : _ " [80,80,80] 80) where t0[intro]: "\valid \; (x,\)\set \\\ \ I\ IVar x : \" | t1[intro]: "\\ I\ e1 : \1\\2; \ I\ e2 : \1\\ \ I\ IApp e1 e2 : \2" @@ -159,7 +167,8 @@ text {* big-step evaluation for trms *} -inductive2 big :: "trm\trm\bool" ("_ \ _" [80,80] 80) +inductive2 + big :: "trm\trm\bool" ("_ \ _" [80,80] 80) where b0[intro]: "Lam [x].e \ Lam [x].e" | b1[intro]: "\e1\Lam [x].e; e2\e2'; e[x::=e2']\e'\ \ App e1 e2 \ e'" @@ -172,7 +181,8 @@ | b8[intro]: "\e\InL e'; e1[x::=e']\e''\ \ Case e of inl x1 \ e1 | inr x2 \ e2 \ e''" | b9[intro]: "\e\InR e'; e2[x::=e']\e''\ \ Case e of inl x1 \ e1 | inr x2 \ e2 \ e''" -inductive2 Ibig :: "((nat\nat)\trmI)\((nat\nat)\trmI)\bool" ("_ I\ _" [80,80] 80) +inductive2 + Ibig :: "((nat\nat)\trmI)\((nat\nat)\trmI)\bool" ("_ I\ _" [80,80] 80) where m0[intro]: "(m,ILam [x].e) I\ (m,ILam [x].e)" | m1[intro]: "\(m,e1)I\(m',ILam [x].e); (m',e2)I\(m'',e3); (m'',e[x::=e3])I\(m''',e4)\ diff -r 2064f0fd20c9 -r f1db55c7534d src/HOL/Nominal/Examples/Crary.thy --- a/src/HOL/Nominal/Examples/Crary.thy Mon Apr 30 22:43:33 2007 +0200 +++ b/src/HOL/Nominal/Examples/Crary.thy Wed May 02 01:42:23 2007 +0200 @@ -14,15 +14,17 @@ atom_decl name -nominal_datatype ty = TBase - | TUnit - | Arrow "ty" "ty" ("_\_" [100,100] 100) +nominal_datatype ty = + TBase + | TUnit + | Arrow "ty" "ty" ("_\_" [100,100] 100) -nominal_datatype trm = Unit - | Var "name" - | Lam "\name\trm" ("Lam [_]._" [100,100] 100) - | App "trm" "trm" - | Const "nat" +nominal_datatype trm = + Unit + | Var "name" + | Lam "\name\trm" ("Lam [_]._" [100,100] 100) + | App "trm" "trm" + | Const "nat" types Ctxt = "(name\ty) list" types Subst = "(name\trm) list" diff -r 2064f0fd20c9 -r f1db55c7534d src/HOL/Nominal/Examples/Height.thy --- a/src/HOL/Nominal/Examples/Height.thy Mon Apr 30 22:43:33 2007 +0200 +++ b/src/HOL/Nominal/Examples/Height.thy Wed May 02 01:42:23 2007 +0200 @@ -8,9 +8,10 @@ atom_decl name -nominal_datatype lam = Var "name" - | App "lam" "lam" - | Lam "\name\lam" ("Lam [_]._" [100,100] 100) +nominal_datatype lam = + Var "name" + | App "lam" "lam" + | Lam "\name\lam" ("Lam [_]._" [100,100] 100) text {* definition of the height-function on lambda-terms *} diff -r 2064f0fd20c9 -r f1db55c7534d src/HOL/Nominal/Examples/Lam_Funs.thy --- a/src/HOL/Nominal/Examples/Lam_Funs.thy Mon Apr 30 22:43:33 2007 +0200 +++ b/src/HOL/Nominal/Examples/Lam_Funs.thy Wed May 02 01:42:23 2007 +0200 @@ -6,9 +6,10 @@ atom_decl name -nominal_datatype lam = Var "name" - | App "lam" "lam" - | Lam "\name\lam" ("Lam [_]._" [100,100] 100) +nominal_datatype lam = + Var "name" + | App "lam" "lam" + | Lam "\name\lam" ("Lam [_]._" [100,100] 100) text {* depth of a lambda-term *} diff -r 2064f0fd20c9 -r f1db55c7534d src/HOL/Nominal/Examples/Lambda_mu.thy --- a/src/HOL/Nominal/Examples/Lambda_mu.thy Mon Apr 30 22:43:33 2007 +0200 +++ b/src/HOL/Nominal/Examples/Lambda_mu.thy Wed May 02 01:42:23 2007 +0200 @@ -8,10 +8,11 @@ atom_decl var mvar -nominal_datatype trm = Var "var" - | Lam "\var\trm" ("Lam [_]._" [100,100] 100) - | App "trm" "trm" - | Pss "mvar" "trm" - | Act "\mvar\trm" ("Act [_]._" [100,100] 100) +nominal_datatype trm = + Var "var" + | Lam "\var\trm" ("Lam [_]._" [100,100] 100) + | App "trm" "trm" + | Pss "mvar" "trm" + | Act "\mvar\trm" ("Act [_]._" [100,100] 100) end diff -r 2064f0fd20c9 -r f1db55c7534d src/HOL/Nominal/Nominal.thy --- a/src/HOL/Nominal/Nominal.thy Mon Apr 30 22:43:33 2007 +0200 +++ b/src/HOL/Nominal/Nominal.thy Wed May 02 01:42:23 2007 +0200 @@ -31,7 +31,7 @@ (* permutation on sets *) defs (unchecked overloaded) - perm_set_def: "pi\(X::'a set) \ {pi\a | a. a\X}" + perm_set_def: "pi\(X::'a set) \ {pi\x | x. x\X}" lemma empty_eqvt: shows "pi\{} = {}" @@ -50,7 +50,7 @@ "pi\() = ()" primrec (unchecked perm_prod) - "pi\(a,b) = (pi\a,pi\b)" + "pi\(x,y) = (pi\x,pi\y)" lemma fst_eqvt: "pi\(fst x) = fst (pi\x)" @@ -1171,7 +1171,7 @@ and y :: "'a" assumes pt: "pt TYPE('a) TYPE('x)" and at: "at TYPE('x)" - shows "pi \ (x=y) = (pi\x = pi\y)" + shows "pi\(x=y) = (pi\x = pi\y)" using assms by (auto simp add: pt_bij perm_bool) @@ -1309,9 +1309,18 @@ and pi::"'x prm" assumes pt: "pt TYPE('a) TYPE('x)" and at: "at TYPE('x)" - shows "pi \ (X - Y) = (pi \ X) - (pi \ Y)" + shows "pi\(X - Y) = (pi\X) - (pi\Y)" by (auto simp add: perm_set_def pt_bij[OF pt, OF at]) +lemma pt_Collect_eqvt: + fixes pi::"'x prm" + assumes pt: "pt TYPE('a) TYPE('x)" + and at: "at TYPE('x)" + shows "pi\{x::'a. P x} = {x. P ((rev pi)\x)}" +apply(auto simp add: perm_set_def pt_rev_pi[OF pt, OF at]) +apply(rule_tac x="(rev pi)\x" in exI) +apply(simp add: pt_pi_rev[OF pt, OF at]) +done -- "some helper lemmas for the pt_perm_supp_ineq lemma" lemma Collect_permI: @@ -1596,15 +1605,15 @@ and x :: "'y" assumes pt: "pt TYPE('y) TYPE('x)" and at: "at TYPE('x)" - and h1: "a \ pi" - and h2: "a \ x" - shows "a \ (pi \ x)" + and h1: "a\pi" + and h2: "a\x" + shows "a\(pi\x)" using assms proof - - have "a \ rev pi"using h1 by (simp add: fresh_list_rev) - then have "(rev pi) \ a = a" by (simp add: at_prm_fresh[OF at]) - then have "((rev pi) \ a) \ x" using h2 by simp - thus "a \ (pi \ x)" by (simp add: pt_fresh_right[OF pt, OF at]) + have "a\(rev pi)"using h1 by (simp add: fresh_list_rev) + then have "(rev pi)\a = a" by (simp add: at_prm_fresh[OF at]) + then have "((rev pi)\a)\x" using h2 by simp + thus "a\(pi\x)" by (simp add: pt_fresh_right[OF pt, OF at]) qed lemma pt_fresh_perm_app_ineq: @@ -2127,11 +2136,11 @@ case goal1 show "pi\(\x\X. f x) \ (\x\(pi\X). (pi\f) x)" apply(auto simp add: perm_set_def) - apply(rule_tac x="pi\xa" in exI) + apply(rule_tac x="pi\xb" in exI) apply(rule conjI) - apply(rule_tac x="xa" in exI) + apply(rule_tac x="xb" in exI) apply(simp) - apply(subgoal_tac "(pi\f) (pi\xa) = pi\(f xa)")(*A*) + apply(subgoal_tac "(pi\f) (pi\xb) = pi\(f xb)")(*A*) apply(simp) apply(rule pt_set_bij2[OF pt_x, OF at]) apply(assumption) @@ -2146,7 +2155,7 @@ apply(rule_tac x="(rev pi)\x" in exI) apply(rule conjI) apply(simp add: pt_pi_rev[OF pt_x, OF at]) - apply(rule_tac x="a" in bexI) + apply(rule_tac x="xb" in bexI) apply(simp add: pt_set_bij1[OF pt_x, OF at]) apply(simp add: pt_fun_app_eq[OF pt, OF at]) apply(assumption) @@ -2177,7 +2186,7 @@ apply(erule conjE) apply(simp add: perm_set_def) apply(auto) - apply(subgoal_tac "[(a,b)]\aa = aa")(*A*) + apply(subgoal_tac "[(a,b)]\xa = xa")(*A*) apply(simp) apply(rule pt_fresh_fresh[OF pt, OF at]) apply(force) @@ -2351,7 +2360,7 @@ apply(simp add: cp_def) apply(auto) apply(auto simp add: perm_set_def) -apply(rule_tac x="pi2\aa" in exI) +apply(rule_tac x="pi2\xc" in exI) apply(auto) done