diff -r a9f3600c9ae6 -r 589b1a0c75e6 Nominal/Ex/SFT/Lambda.thy --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Nominal/Ex/SFT/Lambda.thy Fri Jun 24 10:30:06 2011 +0900 @@ -0,0 +1,85 @@ +header {* Definition of Lambda terms and convertibility *} + +theory Lambda imports Nominal2 begin + +lemma [simp]: "supp x = {} \ y \ x" + unfolding fresh_def by blast + +atom_decl var + +nominal_datatype lam = + V "var" +| Ap "lam" "lam" (infixl "\" 98) +| Lm x::"var" l::"lam" bind x in l ("\ _. _" [97, 97] 99) + +nominal_primrec + subst :: "lam \ var \ lam \ lam" ("_ [_ ::= _]" [90, 90, 90] 90) +where + "(V x)[y ::= s] = (if x = y then s else (V x))" +| "(t1 \ t2)[y ::= s] = (t1[y ::= s]) \ (t2[y ::= s])" +| "atom x \ (y, s) \ (\x. t)[y ::= s] = \x.(t[y ::= s])" +proof auto + fix a b :: lam and aa :: var and P + assume "\x y s. a = V x \ aa = y \ b = s \ P" + "\t1 t2 y s. a = t1 \ t2 \ aa = y \ b = s \ P" + "\x y s t. \atom x \ (y, s); a = \ x. t \ aa = y \ b = s\ \ P" + then show "P" + by (rule_tac y="a" and c="(aa, b)" in lam.strong_exhaust) + (blast, blast, simp add: fresh_star_def) +next + fix x :: var and t and xa :: var and ya sa ta + assume *: "eqvt_at subst_sumC (t, ya, sa)" + "atom x \ (ya, sa)" "atom xa \ (ya, sa)" + "[[atom x]]lst. t = [[atom xa]]lst. ta" + then show "[[atom x]]lst. subst_sumC (t, ya, sa) = [[atom xa]]lst. subst_sumC (ta, ya, sa)" + apply - + apply (erule Abs_lst1_fcb) + apply(simp (no_asm) add: Abs_fresh_iff) + apply(drule_tac a="atom xa" in fresh_eqvt_at) + apply(simp add: finite_supp) + apply(simp_all add: fresh_Pair_elim Abs_fresh_iff Abs1_eq_iff) + apply(subgoal_tac "(atom x \ atom xa) \ ya = ya") + apply(subgoal_tac "(atom x \ atom xa) \ sa = sa") + apply(simp add: atom_eqvt eqvt_at_def) + apply(rule perm_supp_eq, simp add: supp_swap fresh_star_def fresh_Pair)+ + done +next + show "eqvt subst_graph" unfolding eqvt_def subst_graph_def + by (rule, perm_simp, rule) +qed + +termination + by (relation "measure (\(t,_,_). size t)") + (simp_all add: lam.size) + +lemma subst4[eqvt]: + shows "(p \ t[x ::= s]) = (p \ t)[(p \ x) ::= (p \ s)]" + by (induct t x s rule: subst.induct) (simp_all) + +lemma subst1[simp]: + 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 subst2[simp]: "supp t = {} \ t[x ::= s] = t" + by (simp add: fresh_def) + +lemma subst3[simp]: "M [x ::= V x] = M" + by (rule_tac lam="M" and c="x" in lam.strong_induct) + (simp_all add: fresh_star_def lam.fresh fresh_Pair) + +inductive + beta :: "lam \ lam \ bool" (infix "\" 80) +where + bI: "(\x. M) \ N \ M[x ::= N]" +| b1: "M \ M" +| b2: "M \ N \ N \ M" +| b3: "M \ N \ N \ L \ M \ L" +| b4: "M \ N \ Z \ M \ Z \ N" +| b5: "M \ N \ M \ Z \ N \ Z" +| b6: "M \ N \ \x. M \ \x. N" + +lemmas [trans] = b3 +equivariance beta + +end