diff -r faeac3ae43e5 -r 25d813c5042d Nominal/Ex/BetaCR.thy --- a/Nominal/Ex/BetaCR.thy Tue Dec 20 18:07:48 2011 +0900 +++ b/Nominal/Ex/BetaCR.thy Wed Dec 21 13:06:09 2011 +0900 @@ -1,90 +1,16 @@ theory BetaCR -imports - "../Nominal2" +imports CR begin -atom_decl name - -nominal_datatype lam = - Var "name" -| App "lam" "lam" -| Lam x::"name" l::"lam" binds x in l ("Lam [_]. _" [100, 100] 100) - -nominal_primrec - subst :: "lam \ name \ lam \ lam" ("_ [_ ::= _]" [90, 90, 90] 90) -where - "(Var x)[y ::= s] = (if x = y then s else (Var x))" -| "(App t1 t2)[y ::= s] = App (t1[y ::= s]) (t2[y ::= s])" -| "atom x \ (y, s) \ (Lam [x]. t)[y ::= s] = Lam [x].(t[y ::= s])" - unfolding eqvt_def subst_graph_def - apply (rule, perm_simp, rule) - apply(rule TrueI) - apply(auto simp add: lam.distinct lam.eq_iff) - apply(rule_tac y="a" and c="(aa, b)" in lam.strong_exhaust) - apply(blast)+ - apply(simp_all add: fresh_star_def fresh_Pair_elim) - apply (erule_tac c="(ya,sa)" in Abs_lst1_fcb2) - apply(simp_all add: Abs_fresh_iff) - apply(simp add: fresh_star_def fresh_Pair) - apply(simp add: eqvt_at_def atom_eqvt fresh_star_Pair perm_supp_eq) - apply(simp add: eqvt_at_def atom_eqvt fresh_star_Pair perm_supp_eq) -done - -termination (eqvt) - by lexicographic_order - -lemma fresh_fact: - fixes z::"name" - assumes a: "atom z \ s" - and b: "z = y \ atom z \ t" - shows "atom z \ t[y ::= s]" - using a b - by (nominal_induct t avoiding: z y s rule: lam.strong_induct) - (auto simp add: lam.fresh fresh_at_base) - -inductive - beta :: "lam \ lam \ bool" (" _ \b _" [80,80] 80) -where - b1[intro]: "t1 \b t2 \ App t1 s \b App t2 s" -| b2[intro]: "s1 \b s2 \ App t s1 \b App t s2" -| b3[intro]: "t1 \b t2 \ Lam [x]. t1 \b Lam [x]. t2" -| b4[intro]: "atom x \ s \ App (Lam [x]. t) s \b t[x ::= s]" - -equivariance beta - -nominal_inductive beta - avoids b3: x - | b4: x - by (simp_all add: fresh_star_def fresh_Pair lam.fresh fresh_fact) - - - -(* The combination should look like this: *) - -inductive - beta_star :: "lam \ lam \ bool" (" _ \b* _" [80,80] 80) -where - bs1[intro, simp]: "M \b* M" -| bs2[intro]: "\M1\b* M2; M2 \b M3\ \ M1 \b* M3" - -lemma beta_star_trans: - assumes "A \b* B" - and "B \b* C" - shows "A \b* C" - using assms(2) assms(1) - by induct auto - -(* HERE 2: Does not work:*) +(* TODO1: Does not work:*) (* equivariance beta_star *) (* proved manually below. *) lemma eqvt_helper: "x1 \b* x2 \ (p \ x1) \b* (p \ x2)" - apply (erule beta_star.induct) - apply auto - using eqvt(1) bs2 - by blast + by (erule beta_star.induct) + (metis beta.eqvt bs2 bs1)+ lemma [eqvt]: "p \ (x1 \b* x2) = ((p \ x1) \b* (p \ x2))" apply rule @@ -109,11 +35,6 @@ using assms unfolding equ_def by auto -(* can be ported from nominal1 *) -lemma cr: - assumes "t \b* t1" and "t \b* t2" shows "\t3. t1 \b* t3 \ t2 \b* t3" - sorry - lemma equ_trans: assumes "A \ B" "B \ C" shows "A \ C" @@ -121,8 +42,8 @@ proof (elim exE conjE) fix D E assume a: "A \b* D" "B \b* D" "B \b* E" "C \b* E" - then obtain F where "D \b* F" "E \b* F" using cr by blast - then have "A \b* F \ C \b* F" using a beta_star_trans by blast + then obtain F where "D \b* F" "E \b* F" using CR_for_Beta_star by blast + then have "A \b* F \ C \b* F" using a bs3 by blast then show "\F. A \b* F \ C \b* F" by blast qed @@ -146,7 +67,7 @@ lemma [quot_respect]: shows "(op = ===> equ) Var Var" and "(equ ===> equ ===> equ) App App" - and "(op = ===> equ ===> equ) BetaCR.Lam BetaCR.Lam" + and "(op = ===> equ ===> equ) CR.Lam CR.Lam" unfolding fun_rel_def equ_def apply auto apply (rule_tac x="App r ra" in exI) @@ -164,23 +85,11 @@ apply auto apply (subgoal_tac "A [x ::= M2] \b* A [x ::= M3]") apply (rotate_tac 1) - apply (erule beta_star_trans) + apply (erule bs3) apply assumption apply (simp add: beta_subst1_pre) done -lemma forget: - shows "atom x \ t \ t[x ::= s] = t" - by (nominal_induct t avoiding: x s rule: lam.strong_induct) - (auto simp add: lam.fresh fresh_at_base) - -lemma substitution_lemma: - assumes a: "x \ y" "atom x \ u" - shows "t[x ::= s][y ::= u] = t[y ::= u][x ::= s[y ::= u]]" - using a - by (nominal_induct t avoiding: x y s u rule: lam.strong_induct) - (auto simp add: fresh_fact forget) - lemma beta_subst2_pre: assumes "A \b B" shows "A [x ::= C] \b* B [x ::= C]" using assms @@ -200,13 +109,13 @@ apply auto apply (subgoal_tac "M2[x ::= C] \b* M3[x ::= C]") apply (rotate_tac 1) - apply (erule beta_star_trans) + apply (erule bs3) apply assumption apply (simp add: beta_subst2_pre) done lemma beta_subst: "A \b* B \ C \b* D \ A [x ::= C] \b* B [x ::= D]" - using beta_subst1 beta_subst2 beta_star_trans by metis + using beta_subst1 beta_subst2 bs3 by metis lemma subst_rsp_pre: "x \ y \ xb \ ya \ x [xa ::= xb] \ y [xa ::= ya]" @@ -234,7 +143,7 @@ quotient_definition "QVar::name \ qlam" is Var quotient_definition "QApp::qlam \ qlam \ qlam" is App quotient_definition QLam ("QLam [_]._") - where "QLam::name \ qlam \ qlam" is BetaCR.Lam + where "QLam::name \ qlam \ qlam" is CR.Lam lemmas qlam_strong_induct = lam.strong_induct[quot_lifted] lemmas qlam_induct = lam.induct[quot_lifted]