diff -r 8c53bcd5c0ae -r c9a1c6f50ff5 Nominal/Nominal2_Base.thy --- a/Nominal/Nominal2_Base.thy Fri Aug 30 14:35:37 2013 +0100 +++ b/Nominal/Nominal2_Base.thy Fri Sep 06 10:06:41 2013 +0100 @@ -212,7 +212,7 @@ unfolding swap_def apply (rule Abs_perm_inverse) apply (rule permI) -apply (auto simp add: bij_def inj_on_def surj_def)[1] +apply (auto simp: bij_def inj_on_def surj_def)[1] apply (rule MOST_rev_mp [OF MOST_neq(1) [of a]]) apply (rule MOST_rev_mp [OF MOST_neq(1) [of b]]) apply (simp) @@ -254,7 +254,7 @@ shows "(a \ c) + (b \ c) + (a \ c) = (a \ b)" using assms by (rule_tac Rep_perm_ext) - (auto simp add: Rep_perm_simps fun_eq_iff) + (auto simp: Rep_perm_simps fun_eq_iff) section {* Permutation Types *} @@ -439,7 +439,7 @@ instance apply default -apply (auto simp add: permute_set_def) +apply (auto simp: permute_set_def) done end @@ -467,25 +467,25 @@ assumes a: "a \ S" "b \ S" shows "(a \ b) \ S = S" unfolding permute_set_def - using a by (auto simp add: swap_atom) + using a by (auto simp: swap_atom) lemma swap_set_in: assumes a: "a \ S" "b \ S" "sort_of a = sort_of b" shows "(a \ b) \ S \ S" unfolding permute_set_def - using a by (auto simp add: swap_atom) + using a by (auto simp: swap_atom) lemma swap_set_in_eq: assumes a: "a \ S" "b \ S" "sort_of a = sort_of b" shows "(a \ b) \ S = (S - {a}) \ {b}" unfolding permute_set_def - using a by (auto simp add: swap_atom) + using a by (auto simp: swap_atom) lemma swap_set_both_in: assumes a: "a \ S" "b \ S" shows "(a \ b) \ S = S" unfolding permute_set_def - using a by (auto simp add: swap_atom) + using a by (auto simp: swap_atom) lemma mem_permute_iff: shows "(p \ x) \ (p \ X) \ x \ X" @@ -864,7 +864,7 @@ lemma swap_eqvt [eqvt]: shows "p \ (a \ b) = (p \ a \ p \ b)" unfolding permute_perm_def - by (auto simp add: swap_atom perm_eq_iff) + by (auto simp: swap_atom perm_eq_iff) lemma uminus_eqvt [eqvt]: fixes p q::"perm" @@ -969,7 +969,7 @@ lemma Collect_eqvt [eqvt]: shows "p \ {x. P x} = {x. (p \ P) x}" unfolding permute_set_eq permute_fun_def - by (auto simp add: permute_bool_def) + by (auto simp: permute_bool_def) lemma inter_eqvt [eqvt]: shows "p \ (A \ B) = (p \ A) \ (p \ B)" @@ -1501,7 +1501,7 @@ apply (rule supports_perm) apply (rule finite_perm_lemma) apply (simp add: perm_swap_eq swap_eqvt) -apply (auto simp add: perm_eq_iff swap_atom) +apply (auto simp: perm_eq_iff swap_atom) done lemma fresh_perm: @@ -1511,7 +1511,7 @@ lemma supp_swap: shows "supp (a \ b) = (if a = b \ sort_of a \ sort_of b then {} else {a, b})" - by (auto simp add: supp_perm swap_atom) + by (auto simp: supp_perm swap_atom) lemma fresh_swap: shows "a \ (b \ c) \ (sort_of b \ sort_of c) \ b = c \ (a \ b \ a \ c)" @@ -1531,12 +1531,12 @@ shows "a \ (p + q)" using assms unfolding fresh_def - by (auto simp add: supp_perm) + by (auto simp: supp_perm) lemma supp_plus_perm: fixes p q::perm shows "supp (p + q) \ supp p \ supp q" - by (auto simp add: supp_perm) + by (auto simp: supp_perm) lemma fresh_minus_perm: fixes p::perm @@ -1725,7 +1725,7 @@ lemma supp_append: shows "supp (xs @ ys) = supp xs \ supp ys" - by (induct xs) (auto simp add: supp_Nil supp_Cons) + by (induct xs) (auto simp: supp_Nil supp_Cons) lemma fresh_append: shows "a \ (xs @ ys) \ a \ xs \ a \ ys" @@ -1733,17 +1733,17 @@ lemma supp_rev: shows "supp (rev xs) = supp xs" - by (induct xs) (auto simp add: supp_append supp_Cons supp_Nil) + by (induct xs) (auto simp: supp_append supp_Cons supp_Nil) lemma fresh_rev: shows "a \ rev xs \ a \ xs" - by (induct xs) (auto simp add: fresh_append fresh_Cons fresh_Nil) + by (induct xs) (auto simp: fresh_append fresh_Cons fresh_Nil) lemma supp_removeAll: fixes x::"atom" shows "supp (removeAll x xs) = supp xs - {x}" by (induct xs) - (auto simp add: supp_Nil supp_Cons supp_atom) + (auto simp: supp_Nil supp_Cons supp_atom) lemma supp_of_atom_list: fixes as::"atom list" @@ -2011,7 +2011,7 @@ assumes "finite S" shows "a \ S - T \ (a \ T \ a \ S)" unfolding fresh_def - by (auto simp add: supp_finite_atom_set assms) + by (auto simp: supp_finite_atom_set assms) lemma Union_supports_set: shows "(\x \ S. supp x) supports S" @@ -2029,7 +2029,7 @@ fixes S::"('a::fs set)" assumes fin: "finite S" shows "finite (\x\S. supp x)" - using fin by (induct) (auto simp add: finite_supp) + using fin by (induct) (auto simp: finite_supp) lemma Union_included_in_supp: fixes S::"('a::fs set)" @@ -2189,7 +2189,7 @@ lemma supp_of_multiset_union: fixes M N::"('a::fs) multiset" shows "supp (M + N) = supp M \ supp N" - by (auto simp add: supp_of_multisets) + by (auto simp: supp_of_multisets) lemma supp_empty_mset [simp]: shows "supp {#} = {}" @@ -2274,7 +2274,7 @@ lemma supp_finfun_update: shows "supp (finfun_update f x y) \ supp(f, x, y)" using fresh_finfun_update -by (auto simp add: fresh_def supp_Pair) +by (auto simp: fresh_def supp_Pair) instance finfun :: (fs, fs) fs apply(default) @@ -2326,7 +2326,7 @@ lemma fresh_star_supp_conv: shows "supp x \* y \ supp y \* x" -by (auto simp add: fresh_star_def fresh_def) +by (auto simp: fresh_star_def fresh_def) lemma fresh_star_perm_set_conv: fixes p::"perm" @@ -2343,25 +2343,25 @@ shows "bs \* as" using fresh unfolding fresh_star_def fresh_def -by (auto simp add: supp_finite_atom_set fin) +by (auto simp: supp_finite_atom_set fin) lemma atom_fresh_star_disjoint: assumes fin: "finite bs" shows "as \* bs \ (as \ bs = {})" unfolding fresh_star_def fresh_def -by (auto simp add: supp_finite_atom_set fin) +by (auto simp: supp_finite_atom_set fin) lemma fresh_star_Pair: shows "as \* (x, y) = (as \* x \ as \* y)" - by (auto simp add: fresh_star_def fresh_Pair) + by (auto simp: fresh_star_def fresh_Pair) lemma fresh_star_list: shows "as \* (xs @ ys) \ as \* xs \ as \* ys" and "as \* (x # xs) \ as \* x \ as \* xs" and "as \* []" -by (auto simp add: fresh_star_def fresh_Nil fresh_Cons fresh_append) +by (auto simp: fresh_star_def fresh_Nil fresh_Cons fresh_append) lemma fresh_star_set: fixes xs::"('a::fs) list" @@ -2381,11 +2381,11 @@ lemma fresh_star_Un: shows "(as \ bs) \* x = (as \* x \ bs \* x)" - by (auto simp add: fresh_star_def) + by (auto simp: fresh_star_def) lemma fresh_star_insert: shows "(insert a as) \* x = (a \ x \ as \* x)" - by (auto simp add: fresh_star_def) + by (auto simp: fresh_star_def) lemma fresh_star_Un_elim: "((as \ bs) \* x \ PROP C) \ (as \* x \ bs \* x \ PROP C)" @@ -2440,7 +2440,7 @@ shows "supp ((p \ a \ a) + p) \ supp p" proof - have "supp ((p \ a \ a) + p) \ supp p" - unfolding supp_perm by (auto simp add: swap_atom) + unfolding supp_perm by (auto simp: swap_atom) moreover have "a \ supp ((p \ a \ a) + p)" by (simp add: supp_perm) then have "supp ((p \ a \ a) + p) \ supp p" using a by auto @@ -2469,7 +2469,7 @@ { assume "supp p \ {}" then obtain a where a0: "a \ supp p" by blast then have a1: "p \ a \ S" "a \ S" "sort_of (p \ a) = sort_of a" "p \ a \ a" - using as by (auto simp add: supp_atom supp_perm swap_atom) + using as by (auto simp: supp_atom supp_perm swap_atom) let ?q = "(p \ a \ a) + p" have a2: "supp ?q \ supp p" using a0 smaller_supp by simp then have "P ?q" using ih by simp @@ -2517,7 +2517,7 @@ then have "p = 0" by (induct p rule: perm_struct_induct) (simp_all) } - then show "supp p \ {b} \ p = 0" by (auto simp add: supp_zero_perm) + then show "supp p \ {b} \ p = 0" by (auto simp: supp_zero_perm) qed lemma supp_perm_pair: @@ -2527,12 +2527,12 @@ { assume "supp p \ {a, b}" then have "p = 0 \ p = (b \ a)" apply (induct p rule: perm_struct_induct) - apply (auto simp add: swap_cancel supp_zero_perm supp_swap) + apply (auto simp: swap_cancel supp_zero_perm supp_swap) apply (simp add: swap_commute) done } then show "supp p \ {a, b} \ p = 0 \ p = (b \ a)" - by (auto simp add: supp_zero_perm supp_swap split: if_splits) + by (auto simp: supp_zero_perm supp_swap split: if_splits) qed lemma supp_perm_eq: @@ -2679,7 +2679,7 @@ hence y: "y \ As" "y \ p \ Xs" "y \ supp p" "sort_of y = sort_of x" by simp_all hence py: "p \ y = y" "x \ y" using `x \ As` - by (auto simp add: supp_perm) + by (auto simp: supp_perm) let ?q = "(x \ y) + p" have q: "?q \ insert x Xs = insert y (p \ Xs)" unfolding insert_eqvt @@ -2728,7 +2728,7 @@ apply(rule_tac x="p" in exI) apply(simp add: fresh_star_Pair) apply(rule fresh_star_supp_conv) -apply(auto simp add: fresh_star_def) +apply(auto simp: fresh_star_def) done lemma at_set_avoiding3: @@ -2742,7 +2742,7 @@ apply(rule_tac x="p" in exI) apply(simp add: fresh_star_Pair) apply(rule fresh_star_supp_conv) -apply(auto simp add: fresh_star_def) +apply(auto simp: fresh_star_def) done lemma at_set_avoiding2_atom: @@ -2781,7 +2781,7 @@ have "\b \ (insert a bs). q \ b = p \ b" using 1 * by simp moreover have "supp q \ insert a bs \ p \ insert a bs" - using ** by (auto simp add: insert_eqvt) + using ** by (auto simp: insert_eqvt) ultimately have "\q. (\b \ insert a bs. q \ b = p \ b) \ supp q \ insert a bs \ p \ insert a bs" by blast } @@ -2789,11 +2789,11 @@ { assume 2: "q \ a \ p \ a" def q' \ "((q \ a) \ (p \ a)) + q" have "\b \ insert a bs. q' \ b = p \ b" using 2 * `a \ bs` unfolding q'_def - by (auto simp add: swap_atom) + by (auto simp: swap_atom) moreover { have "{q \ a, p \ a} \ insert a bs \ p \ insert a bs" using ** - apply (auto simp add: supp_perm insert_eqvt) + apply (auto simp: supp_perm insert_eqvt) apply (subgoal_tac "q \ a \ bs \ p \ bs") apply(auto)[1] apply(subgoal_tac "q \ a \ {a. q \ a \ a}") @@ -2804,7 +2804,7 @@ unfolding supp_swap by auto moreover have "supp q \ insert a bs \ p \ insert a bs" - using ** by (auto simp add: insert_eqvt) + using ** by (auto simp: insert_eqvt) ultimately have "supp q' \ insert a bs \ p \ insert a bs" unfolding q'_def using supp_plus_perm by blast @@ -2823,7 +2823,7 @@ then obtain q where *: "\b \ bs \ supp p. q \ b = p \ b" and **: "supp q \ (bs \ supp p) \ (p \ (bs \ supp p))" using set_renaming_perm by blast - from ** have "supp q \ bs \ (p \ bs)" by (auto simp add: inter_eqvt) + from ** have "supp q \ bs \ (p \ bs)" by (auto simp: inter_eqvt) moreover have "\b \ bs - supp p. q \ b = p \ b" apply(auto) @@ -2850,7 +2850,7 @@ have "q \ a = p \ a" using * 1 by (induct bs) (auto) then have "\b \ set (a # bs). q \ b = p \ b" using * by simp moreover - have "supp q \ set (a # bs) \ p \ (set (a # bs))" using ** by (auto simp add: insert_eqvt) + have "supp q \ set (a # bs) \ p \ (set (a # bs))" using ** by (auto simp: insert_eqvt) ultimately have "\q. (\b \ set (a # bs). q \ b = p \ b) \ supp q \ set (a # bs) \ p \ (set (a # bs))" by blast } @@ -2858,11 +2858,11 @@ { assume 2: "a \ set bs" def q' \ "((q \ a) \ (p \ a)) + q" have "\b \ set (a # bs). q' \ b = p \ b" - unfolding q'_def using 2 * `a \ set bs` by (auto simp add: swap_atom) + unfolding q'_def using 2 * `a \ set bs` by (auto simp: swap_atom) moreover { have "{q \ a, p \ a} \ set (a # bs) \ p \ (set (a # bs))" using ** - apply (auto simp add: supp_perm insert_eqvt) + apply (auto simp: supp_perm insert_eqvt) apply (subgoal_tac "q \ a \ set bs \ p \ set bs") apply(auto)[1] apply(subgoal_tac "q \ a \ {a. q \ a \ a}") @@ -2873,7 +2873,7 @@ unfolding supp_swap by auto moreover have "supp q \ set (a # bs) \ p \ (set (a # bs))" - using ** by (auto simp add: insert_eqvt) + using ** by (auto simp: insert_eqvt) ultimately have "supp q' \ set (a # bs) \ p \ (set (a # bs))" unfolding q'_def using supp_plus_perm by blast @@ -2950,31 +2950,39 @@ simproc_setup fresh_ineq ("x \ (y::'a::at_base)") = {* fn _ => fn ctxt => fn ctrm => - let - fun first_is_neg lhs rhs [] = NONE - | first_is_neg lhs rhs (thm::thms) = + case term_of ctrm of @{term "HOL.Not"} $ (Const ("HOL.eq", _) $ lhs $ rhs) => + let + + fun first_is_neg lhs rhs [] = NONE + | first_is_neg lhs rhs (thm::thms) = (case Thm.prop_of thm of _ $ (@{term "HOL.Not"} $ (Const ("HOL.eq", _) $ l $ r)) => (if l = lhs andalso r = rhs then SOME(thm) else if r = lhs andalso l = rhs then SOME(thm RS @{thm not_sym}) else first_is_neg lhs rhs thms) - | _ => first_is_neg lhs rhs thms) - - val simp_thms = @{thms fresh_Pair fresh_at_base atom_eq_iff} - val prems = Simplifier.prems_of ctxt - |> filter (fn thm => case Thm.prop_of thm of - _ $ (Const (@{const_name fresh}, _) $ _ $ _) => true | _ => false) - |> map (simplify (put_simpset HOL_basic_ss ctxt addsimps simp_thms)) - |> map HOLogic.conj_elims - |> flat - in - case term_of ctrm of - @{term "HOL.Not"} $ (Const ("HOL.eq", _) $ lhs $ rhs) => - (case first_is_neg lhs rhs prems of - SOME(thm) => SOME(thm RS @{thm Eq_TrueI}) - | NONE => NONE) - | _ => NONE - end + | _ => first_is_neg lhs rhs thms) + + val simp_thms = @{thms fresh_Pair fresh_at_base atom_eq_iff} + val prems = Simplifier.prems_of ctxt + |> filter (fn thm => case Thm.prop_of thm of + _ $ (Const (@{const_name fresh}, ty) $ (_ $ a) $ b) => + (let + val atms = a :: HOLogic.strip_tuple b + in + member (op=) atms lhs andalso member (op=) atms rhs + end) + | _ => false) + |> map (simplify (put_simpset HOL_basic_ss ctxt addsimps simp_thms)) + |> map HOLogic.conj_elims + |> flat + + + in + case first_is_neg lhs rhs prems of + SOME(thm) => SOME(thm RS @{thm Eq_TrueI}) + | NONE => NONE + end + | _ => NONE *} @@ -3025,12 +3033,12 @@ assumes fin: "finite (supp x)" obtains a::"'a::at_base" where "atom a \ x" using obtain_at_base[where X="supp x"] -by (auto simp add: fresh_def fin) +by (auto simp: fresh_def fin) lemma obtain_fresh: fixes x::"'b::fs" obtains a::"'a::at_base" where "atom a \ x" - by (rule obtain_fresh') (auto simp add: finite_supp) + by (rule obtain_fresh') (auto simp: finite_supp) lemma supp_finite_set_at_base: assumes a: "finite S" @@ -3266,7 +3274,7 @@ shows "\x. \a. atom a \ h \ h a = x" proof - from a obtain b where a1: "atom b \ h" and a2: "atom b \ h b" - by (auto simp add: fresh_Pair) + by (auto simp: fresh_Pair) show "\x. \a. atom a \ h \ h a = x" proof (intro exI allI impI) fix a :: 'a @@ -3306,7 +3314,7 @@ assume x: "\a. atom a \ h \ h a = x" assume y: "\a. atom a \ h \ h a = y" from a x y show "x = y" - by (auto simp add: fresh_Pair) + by (auto simp: fresh_Pair) qed text {* packaging the freshness lemma into a function *} @@ -3341,7 +3349,7 @@ assumes a: "atom a \ h" "atom a \ h a" shows "Fresh h = h a" apply (rule Fresh_apply) - apply (auto simp add: fresh_Pair intro: a) + apply (auto simp: fresh_Pair intro: a) done simproc_setup Fresh_simproc ("Fresh (h::'a::at \ 'b::pt)") = {* fn _ => fn ctxt => fn ctrm =>