diff -r 5335c0ea743a -r 313e6f2cdd89 Nominal/Nominal2_Base.thy --- a/Nominal/Nominal2_Base.thy Thu May 31 12:01:13 2012 +0100 +++ b/Nominal/Nominal2_Base.thy Mon Jun 04 21:39:51 2012 +0100 @@ -799,6 +799,21 @@ {* Nominal_Permeq.args_parser >> Nominal_Permeq.perm_strict_simp_meth *} {* pushes permutations inside, raises an error if it cannot solve all permutations. *} +simproc_setup perm_simproc ("p \ t") = {* fn _ => fn ss => fn ctrm => + case term_of (Thm.dest_arg ctrm) of + Free _ => NONE + | Var _ => NONE + | Const (@{const_name permute}, _) $ _ $ _ => NONE + | _ => + let + val ctxt = Simplifier.the_context ss + val thm = Nominal_Permeq.eqvt_conv ctxt Nominal_Permeq.eqvt_strict_config ctrm + handle ERROR _ => Thm.reflexive ctrm + in + if Thm.is_reflexive thm then NONE else SOME(thm) + end +*} + subsubsection {* Equivariance for permutations and swapping *} @@ -876,10 +891,6 @@ shows "p \ (if b then x else y) = (if p \ b then p \ x else p \ y)" by (simp add: permute_fun_def permute_bool_def) -lemma Let_eqvt [eqvt]: - shows "p \ Let x y = Let (p \ x) (p \ y)" - unfolding Let_def permute_fun_app_eq .. - lemma True_eqvt [eqvt]: shows "p \ True = True" unfolding permute_bool_def .. @@ -920,7 +931,7 @@ assumes unique: "\!x. P x" shows "(p \ (THE x. P x)) = (THE x. p \ P (- p \ x))" apply(rule the1_equality [symmetric]) - apply(simp add: ex1_eqvt2[symmetric]) + apply(simp only: ex1_eqvt2[symmetric]) apply(simp add: permute_bool_def unique) apply(simp add: permute_bool_def) apply(rule theI'[OF unique]) @@ -940,84 +951,76 @@ lemma inter_eqvt [eqvt]: shows "p \ (A \ B) = (p \ A) \ (p \ B)" - unfolding Int_def - by (perm_simp) (rule refl) + unfolding Int_def by simp lemma Bex_eqvt [eqvt]: shows "p \ (\x \ S. P x) = (\x \ (p \ S). (p \ P) x)" - unfolding Bex_def - by (perm_simp) (rule refl) + unfolding Bex_def by simp lemma Ball_eqvt [eqvt]: shows "p \ (\x \ S. P x) = (\x \ (p \ S). (p \ P) x)" - unfolding Ball_def - by (perm_simp) (rule refl) + unfolding Ball_def by simp lemma image_eqvt [eqvt]: shows "p \ (f ` A) = (p \ f) ` (p \ A)" - unfolding image_def - by (perm_simp) (rule refl) + unfolding image_def by simp lemma Image_eqvt [eqvt]: shows "p \ (R `` A) = (p \ R) `` (p \ A)" - unfolding Image_def - by (perm_simp) (rule refl) + unfolding Image_def by simp lemma UNIV_eqvt [eqvt]: shows "p \ UNIV = UNIV" - unfolding UNIV_def + unfolding UNIV_def by (perm_simp) (rule refl) lemma union_eqvt [eqvt]: shows "p \ (A \ B) = (p \ A) \ (p \ B)" - unfolding Un_def - by (perm_simp) (rule refl) + unfolding Un_def by simp lemma Diff_eqvt [eqvt]: fixes A B :: "'a::pt set" shows "p \ (A - B) = (p \ A) - (p \ B)" - unfolding set_diff_eq - by (perm_simp) (rule refl) + unfolding set_diff_eq by simp lemma Compl_eqvt [eqvt]: fixes A :: "'a::pt set" shows "p \ (- A) = - (p \ A)" - unfolding Compl_eq_Diff_UNIV - by (perm_simp) (rule refl) + unfolding Compl_eq_Diff_UNIV by simp lemma subset_eqvt [eqvt]: shows "p \ (S \ T) \ (p \ S) \ (p \ T)" - unfolding subset_eq - by (perm_simp) (rule refl) + unfolding subset_eq by simp lemma psubset_eqvt [eqvt]: shows "p \ (S \ T) \ (p \ S) \ (p \ T)" - unfolding psubset_eq - by (perm_simp) (rule refl) + unfolding psubset_eq by simp lemma vimage_eqvt [eqvt]: shows "p \ (f -` A) = (p \ f) -` (p \ A)" - unfolding vimage_def - by (perm_simp) (rule refl) + unfolding vimage_def by simp lemma Union_eqvt [eqvt]: shows "p \ (\ S) = \ (p \ S)" - unfolding Union_eq - by (perm_simp) (rule refl) + unfolding Union_eq by simp lemma Inter_eqvt [eqvt]: shows "p \ (\ S) = \ (p \ S)" - unfolding Inter_eq - by (perm_simp) (rule refl) + unfolding Inter_eq by simp + +thm foldr.simps lemma foldr_eqvt[eqvt]: - "p \ foldr a b c = foldr (p \ a) (p \ b) (p \ c)" - apply (induct b) - apply simp_all - apply (perm_simp) - apply simp + "p \ foldr f xs = foldr (p \ f) (p \ xs)" + apply(induct xs) + apply(simp_all) + apply(perm_simp exclude: foldr) + apply(simp) done +thm eqvts_raw + + (* FIXME: eqvt attribute *) lemma Sigma_eqvt: shows "(p \ (X \ Y)) = (p \ X) \ (p \ Y)" @@ -1090,12 +1093,12 @@ fixes F::"('a \ 'b) \ ('a::pt \ 'b::{inf_eqvt, le_eqvt})" shows "p \ (lfp F) = lfp (p \ F)" unfolding lfp_def -by (perm_simp) (rule refl) +by simp lemma finite_eqvt [eqvt]: shows "p \ finite A = finite (p \ A)" unfolding finite_def -by (perm_simp) (rule refl) +by simp subsubsection {* Equivariance for product operations *} @@ -1111,7 +1114,7 @@ lemma split_eqvt [eqvt]: shows "p \ (split P x) = split (p \ P) (p \ x)" unfolding split_def - by (perm_simp) (rule refl) + by simp subsubsection {* Equivariance for list operations *} @@ -1126,7 +1129,7 @@ lemma map_eqvt [eqvt]: shows "p \ (map f xs) = map (p \ f) (p \ xs)" - by (induct xs) (simp_all, simp only: permute_fun_app_eq) + by (induct xs) (simp_all) lemma removeAll_eqvt [eqvt]: shows "p \ (removeAll x xs) = removeAll (p \ x) (p \ xs)" @@ -1156,15 +1159,14 @@ lemma option_map_eqvt[eqvt]: shows "p \ (Option.map f x) = Option.map (p \ f) (p \ x)" - by (cases x) (simp_all, simp add: permute_fun_app_eq) + by (cases x) (simp_all) subsubsection {* Equivariance for @{typ "'a fset"} *} lemma in_fset_eqvt [eqvt]: shows "(p \ (x |\| S)) = ((p \ x) |\| (p \ S))" -unfolding in_fset -by (perm_simp) (simp) +unfolding in_fset by simp lemma union_fset_eqvt [eqvt]: shows "(p \ (S |\| T)) = ((p \ S) |\| (p \ T))" @@ -1174,7 +1176,6 @@ shows "(p \ (S |\| T)) = ((p \ S) |\| (p \ T))" apply(descending) unfolding list_eq_def inter_list_def - apply(perm_simp) apply(simp) done @@ -1182,7 +1183,6 @@ shows "(p \ (S |\| T)) = ((p \ S) |\| (p \ T))" apply(descending) unfolding sub_list_def - apply(perm_simp) apply(simp) done @@ -1254,14 +1254,11 @@ lemma supp_eqvt [eqvt]: shows "p \ (supp x) = supp (p \ x)" - unfolding supp_def - by (perm_simp) - (simp only: permute_eqvt[symmetric]) + unfolding supp_def by simp lemma fresh_eqvt [eqvt]: shows "p \ (a \ x) = (p \ a) \ (p \ x)" - unfolding fresh_def - by (perm_simp) (rule refl) + unfolding fresh_def by simp lemma fresh_permute_iff: shows "(p \ a) \ (p \ x) \ a \ x" @@ -1751,7 +1748,7 @@ using assms by (simp add: eqvt_at_def) also have "\ = (p + q) \ (f x)" by simp also have "\ = f ((p + q) \ x)" - using assms by (simp add: eqvt_at_def) + using assms by (simp only: eqvt_at_def) finally have "p \ (f (q \ x)) = f (p \ q \ x)" by simp } then show "eqvt_at f (q \ x)" unfolding eqvt_at_def by simp @@ -1978,7 +1975,7 @@ shows "(\x\S. supp x) \ supp S" proof - have eqvt: "eqvt (\S. \ supp ` S)" - unfolding eqvt_def + unfolding eqvt_def by (perm_simp) (simp) have "(\x\S. supp x) = supp (\x\S. supp x)" by (rule supp_finite_atom_set[symmetric]) (rule Union_of_finite_supp_sets[OF fin]) @@ -2334,9 +2331,7 @@ lemma fresh_star_eqvt [eqvt]: shows "p \ (as \* x) \ (p \ as) \* (p \ x)" -unfolding fresh_star_def -by (perm_simp) (rule refl) - +unfolding fresh_star_def by simp section {* Induction principle for permutations *} @@ -2709,7 +2704,8 @@ apply(blast) apply(simp) done - then have "supp (q \ a \ p \ a) \ insert a bs \ p \ insert a bs" by (simp add: supp_swap) + then have "supp (q \ a \ p \ a) \ insert a bs \ p \ insert a bs" + unfolding supp_swap by auto moreover have "supp q \ insert a bs \ p \ insert a bs" using ** by (auto simp add: insert_eqvt) @@ -2777,7 +2773,8 @@ apply(blast) apply(simp) done - then have "supp (q \ a \ p \ a) \ set (a # bs) \ p \ set (a # bs)" by (simp add: supp_swap) + then have "supp (q \ a \ p \ a) \ set (a # bs) \ p \ set (a # bs)" + unfolding supp_swap by auto moreover have "supp q \ set (a # bs) \ p \ (set (a # bs))" using ** by (auto simp add: insert_eqvt) @@ -2961,7 +2958,7 @@ fixes a::"'a::at_base" shows "atom (p \ a) \ p \ x \ atom a \ x" unfolding atom_eqvt[symmetric] - by (simp add: fresh_permute_iff) + by (simp only: fresh_permute_iff) section {* Infrastructure for concrete atom types *}