diff -r 0f289a52edbe -r b136721eedb2 Nominal/Ex/Foo2.thy --- a/Nominal/Ex/Foo2.thy Tue Dec 07 14:27:21 2010 +0000 +++ b/Nominal/Ex/Foo2.thy Tue Dec 07 14:27:39 2010 +0000 @@ -24,6 +24,8 @@ "bn (As x y t a) = [atom x] @ bn a" | "bn (As_Nil) = []" +thm foo.bn_defs +thm foo.permute_bn thm foo.perm_bn_alpha thm foo.perm_bn_simps thm foo.bn_finite @@ -43,57 +45,61 @@ thm foo.supp thm foo.fresh -lemma tt1: - shows "(p \ bn as) = bn (permute_bn p as)" -apply(induct as rule: foo.inducts(2)) -apply(auto)[5] -apply(simp only: foo.perm_bn_simps foo.bn_defs) -apply(perm_simp) -apply(simp only:) -apply(simp only: foo.perm_bn_simps foo.bn_defs) -apply(perm_simp add: foo.fv_bn_eqvt) -apply(simp only:) -done - text {* tests by cu *} -lemma yy: +lemma set_renaming_perm: assumes a: "p \ bs \ bs = {}" and b: "finite bs" shows "\q. q \ bs = p \ bs \ supp q \ bs \ (p \ bs)" using b a -apply(induct) -apply(simp add: permute_set_eq) -apply(rule_tac x="0" in exI) -apply(simp add: supp_perm) -apply(perm_simp) -apply(drule meta_mp) -apply(auto simp add: fresh_star_def fresh_finite_insert)[1] -apply(erule exE) -apply(simp) -apply(case_tac "q \ x = p \ x") -apply(rule_tac x="q" in exI) -apply(auto)[1] -apply(rule_tac x="((q \ x) \ (p \ x)) + q" in exI) -apply(subgoal_tac "p \ x \ p \ F") -apply(subgoal_tac "q \ x \ p \ F") -apply(simp add: swap_set_not_in) -apply(rule subset_trans) -apply(rule supp_plus_perm) -apply(simp) -apply(rule conjI) -apply(simp add: supp_swap) -apply(simp add: supp_perm) -apply(auto)[1] -apply(auto)[1] -apply(erule conjE)+ -apply(drule sym) -apply(simp add: mem_permute_iff) -apply(simp add: mem_permute_iff) -done - +proof (induct) + case empty + have "0 \ {} = p \ {} \ supp (0::perm) \ {} \ p \ {}" + by (simp add: permute_set_eq supp_perm) + then show "\q. q \ {} = p \ {} \ supp q \ {} \ p \ {}" by blast +next + case (insert a bs) + then have " \q. q \ bs = p \ bs \ supp q \ bs \ p \ bs" + by (perm_simp) (auto) + then obtain q where *: "q \ bs = p \ bs" and **: "supp q \ bs \ p \ bs" by blast + { assume 1: "q \ a = p \ a" + have "q \ insert a bs = p \ insert a bs" using 1 * by (simp add: insert_eqvt) + moreover + have "supp q \ insert a bs \ p \ insert a bs" + using ** by (auto simp add: insert_eqvt) + ultimately + have "\q. q \ insert a bs = p \ insert a bs \ supp q \ insert a bs \ p \ insert a bs" by blast + } + moreover + { assume 2: "q \ a \ p \ a" + def q' \ "((q \ a) \ (p \ a)) + q" + { have "(q \ a) \ (p \ bs)" using `a \ bs` *[symmetric] by (simp add: mem_permute_iff) + moreover + have "(p \ a) \ (p \ bs)" using `a \ bs` by (simp add: mem_permute_iff) + ultimately + have "q' \ insert a bs = p \ insert a bs" using 2 * unfolding q'_def + by (simp add: insert_eqvt swap_set_not_in) + } + moreover + { have "{q \ a, p \ a} \ insert a bs \ p \ insert a bs" + using ** `a \ bs` `p \ insert a bs \ insert a bs = {}` + by (auto simp add: supp_perm insert_eqvt) + then have "supp (q \ a \ p \ a) \ insert a bs \ p \ insert a bs" by (simp add: supp_swap) + moreover + have "supp q \ insert a bs \ p \ insert a bs" + using ** by (auto simp add: insert_eqvt) + ultimately + have "supp q' \ insert a bs \ p \ insert a bs" + unfolding q'_def using supp_plus_perm by blast + } + ultimately + have "\q. q \ insert a bs = p \ insert a bs \ supp q \ insert a bs \ p \ insert a bs" by blast + } + ultimately show "\q. q \ insert a bs = p \ insert a bs \ supp q \ insert a bs \ p \ insert a bs" + by blast +qed lemma Abs_rename_set: @@ -103,7 +109,8 @@ shows "\y. [bs]set. x = [p \ bs]set. y" proof - from a b have "p \ bs \ bs = {}" using at_fresh_star_inter by (auto simp add: fresh_star_Pair) - with yy obtain q where *: "q \ bs = p \ bs" and **: "supp q \ bs \ (p \ bs)" using b by metis + with set_renaming_perm + obtain q where *: "q \ bs = p \ bs" and **: "supp q \ bs \ (p \ bs)" using b by metis have "[bs]set. x = q \ ([bs]set. x)" apply(rule perm_supp_eq[symmetric]) using a ** @@ -124,7 +131,8 @@ shows "\y. [bs]res. x = [p \ bs]res. y" proof - from a b have "p \ bs \ bs = {}" using at_fresh_star_inter by (simp add: fresh_star_Pair) - with yy obtain q where *: "q \ bs = p \ bs" and **: "supp q \ bs \ (p \ bs)" using b by metis + with set_renaming_perm + obtain q where *: "q \ bs = p \ bs" and **: "supp q \ bs \ (p \ bs)" using b by metis have "[bs]res. x = q \ ([bs]res. x)" apply(rule perm_supp_eq[symmetric]) using a ** @@ -138,54 +146,60 @@ then show "\y. [bs]res. x = [p \ bs]res. y" by blast qed -lemma zz0: - assumes "p \ bs = q \ bs" - and a: "a \ set bs" - shows "p \ a = q \ a" -using assms -by (induct bs) (auto) - -lemma zz: +lemma list_renaming_perm: fixes bs::"atom list" - assumes "(p \ (set bs)) \ (set bs) = {}" + assumes a: "(p \ (set bs)) \ (set bs) = {}" shows "\q. q \ bs = p \ bs \ supp q \ (set bs) \ (p \ (set bs))" -using assms -apply(induct bs) -apply(simp add: permute_set_eq) -apply(rule_tac x="0" in exI) -apply(simp add: supp_perm) -apply(drule meta_mp) -apply(perm_simp) -apply(auto)[1] -apply(erule exE) -apply(simp) -apply(case_tac "a \ set bs") -apply(rule_tac x="q" in exI) -apply(perm_simp) -apply(auto dest: zz0)[1] -apply(subgoal_tac "q \ a \ p \ bs") -apply(subgoal_tac "p \ a \ p \ bs") -apply(rule_tac x="((q \ a) \ (p \ a)) + q" in exI) -apply(simp add: swap_fresh_fresh) -apply(rule subset_trans) -apply(rule supp_plus_perm) -apply(simp) -apply(rule conjI) -apply(simp add: supp_swap) -apply(simp add: supp_perm) -apply(perm_simp) -apply(auto simp add: fresh_def supp_of_atom_list)[1] -apply(perm_simp) -apply(auto)[1] -apply(simp add: fresh_permute_iff) -apply(simp add: fresh_def supp_of_atom_list) -apply(erule conjE)+ -apply(drule sym) -apply(drule sym) -apply(simp) -apply(simp add: fresh_permute_iff) -apply(auto simp add: fresh_def supp_of_atom_list)[1] -done +using a +proof (induct bs) + case Nil + have "0 \ [] = p \ [] \ supp (0::perm) \ set [] \ p \ set []" + by (simp add: permute_set_eq supp_perm) + then show "\q. q \ [] = p \ [] \ supp q \ set [] \ p \ (set [])" by blast +next + case (Cons a bs) + then have " \q. q \ bs = p \ bs \ supp q \ set bs \ p \ (set bs)" + by (perm_simp) (auto) + then obtain q where *: "q \ bs = p \ bs" and **: "supp q \ set bs \ p \ (set bs)" by blast + { assume 1: "a \ set bs" + have "q \ a = p \ a" using * 1 by (induct bs) (auto) + then have "q \ (a # bs) = p \ (a # bs)" using * by simp + moreover + have "supp q \ set (a # bs) \ p \ (set (a # bs))" using ** by (auto simp add: insert_eqvt) + ultimately + have "\q. q \ (a # bs) = p \ (a # bs) \ supp q \ set (a # bs) \ p \ (set (a # bs))" by blast + } + moreover + { assume 2: "a \ set bs" + def q' \ "((q \ a) \ (p \ a)) + q" + { have "(q \ a) \ (p \ bs)" using `a \ set bs` *[symmetric] + by (simp add: fresh_permute_iff) (simp add: fresh_def supp_of_atom_list) + moreover + have "(p \ a) \ (p \ bs)" using `a \ set bs` + by (simp add: fresh_permute_iff) (simp add: fresh_def supp_of_atom_list) + ultimately + have "q' \ (a # bs) = p \ (a # bs)" using 2 * unfolding q'_def + by (simp add: swap_fresh_fresh) + } + moreover + { have "{q \ a, p \ a} \ set (a # bs) \ p \ (set (a # bs))" + using ** `a \ set bs` `p \ (set (a # bs)) \ set (a # bs) = {}` + by (auto simp add: supp_perm insert_eqvt) + then have "supp (q \ a \ p \ a) \ set (a # bs) \ p \ set (a # bs)" by (simp add: supp_swap) + moreover + have "supp q \ set (a # bs) \ p \ (set (a # bs))" + using ** by (auto simp add: insert_eqvt) + ultimately + have "supp q' \ set (a # bs) \ p \ (set (a # bs))" + unfolding q'_def using supp_plus_perm by blast + } + ultimately + have "\q. q \ (a # bs) = p \ (a # bs) \ supp q \ set (a # bs) \ p \ (set (a # bs))" by blast + } + ultimately show "\q. q \ (a # bs) = p \ (a # bs) \ supp q \ set (a # bs) \ p \ (set (a # bs))" + by blast +qed + lemma Abs_rename_list: fixes x::"'a::fs" @@ -194,7 +208,8 @@ proof - from a have "p \ (set bs) \ (set bs) = {}" using at_fresh_star_inter by (simp add: fresh_star_Pair fresh_star_set) - with zz obtain q where *: "q \ bs = p \ bs" and **: "supp q \ set bs \ (p \ set bs)" by metis + with list_renaming_perm + obtain q where *: "q \ bs = p \ bs" and **: "supp q \ set bs \ (p \ set bs)" by metis have "[bs]lst. x = q \ ([bs]lst. x)" apply(rule perm_supp_eq[symmetric]) using a ** @@ -208,6 +223,23 @@ then show "\y. [bs]lst. x = [p \ bs]lst. y" by blast qed +(* +thm at_set_avoiding1[THEN exE] + + +lemma Let1_rename: + fixes c::"'a::fs" + shows "\name' trm'. {atom name'} \* c \ Lam name trm = Lam name' trm'" +apply(simp only: foo.eq_iff) +apply(rule at_set_avoiding1[where c="(c, atom name, trm)" and xs="set [atom name]", THEN exE]) +apply(simp) +apply(simp add: finite_supp) +apply(perm_simp) +apply(rule Abs_rename_list[THEN exE]) +apply(simp only: set_eqvt) +apply +sorry +*) lemma test6: fixes c::"'a::fs" @@ -224,6 +256,14 @@ apply(rule assms(2)) apply(rule exI)+ apply(assumption) +(* lam case *) +(* +apply(rule Let1_rename) +apply(rule assms(3)) +apply(assumption) +apply(simp) +*) + apply(subgoal_tac "\p. (p \ {atom name}) \* (c, [atom name], trm)") apply(erule exE) apply(insert Abs_rename_list)[1] @@ -245,10 +285,10 @@ apply(rule at_set_avoiding1) apply(simp) apply(simp add: finite_supp) +(* let1 case *) apply(subgoal_tac "\p. (p \ ((set (bn assg1)) \ (set (bn assg2)))) \* (c, bn assg1, bn assg2, trm1, trm2)") apply(erule exE) apply(rule assms(4)) -apply(simp only:) apply(simp only: foo.eq_iff) apply(insert Abs_rename_list)[1] apply(drule_tac x="p" in meta_spec) @@ -264,7 +304,7 @@ apply(simp only: union_eqvt fresh_star_Pair set.simps fresh_star_Un, simp) apply(erule exE)+ apply(rule exI)+ -apply(perm_simp add: tt1) +apply(perm_simp add: foo.permute_bn) apply(rule conjI) apply(simp add: fresh_star_Pair fresh_star_Un) apply(erule conjE)+ @@ -282,6 +322,7 @@ apply(rule at_set_avoiding1) apply(simp) apply(simp add: finite_supp) +(* let2 case *) apply(subgoal_tac "\p. (p \ ({atom name1} \ {atom name2})) \* (c, atom name1, atom name2, trm1, trm2)") apply(erule exE) apply(rule assms(5)) @@ -309,7 +350,7 @@ apply(auto simp add: fresh_star_def fresh_Pair fresh_Nil fresh_Cons)[1] apply(erule exE)+ apply(rule exI)+ -apply(perm_simp add: tt1) +apply(perm_simp add: foo.permute_bn) apply(rule conjI) prefer 2 apply(rule conjI)