# HG changeset patch # User haftmann # Date 1397294856 -7200 # Node ID 8f1e7596deb7db5943b24680a3583267ce190f80 # Parent b60d5d11948917a9a85ee35538a8449b2ac7dd43 more operations and lemmas diff -r b60d5d119489 -r 8f1e7596deb7 src/HOL/Groups_Big.thy --- a/src/HOL/Groups_Big.thy Sat Apr 12 17:26:27 2014 +0200 +++ b/src/HOL/Groups_Big.thy Sat Apr 12 11:27:36 2014 +0200 @@ -99,6 +99,23 @@ ultimately show ?thesis by simp qed +lemma setdiff_irrelevant: + assumes "finite A" + shows "F g (A - {x. g x = z}) = F g A" + using assms by (induct A) (simp_all add: insert_Diff_if) + +lemma not_neutral_contains_not_neutral: + assumes "F g A \ z" + obtains a where "a \ A" and "g a \ z" +proof - + from assms have "\a\A. g a \ z" + proof (induct A rule: infinite_finite_induct) + case (insert a A) + then show ?case by simp (rule, simp) + qed simp_all + with that show thesis by blast +qed + lemma reindex: assumes "inj_on h A" shows "F g (h ` A) = F (g \ h) A" diff -r b60d5d119489 -r 8f1e7596deb7 src/HOL/Library/Mapping.thy --- a/src/HOL/Library/Mapping.thy Sat Apr 12 17:26:27 2014 +0200 +++ b/src/HOL/Library/Mapping.thy Sat Apr 12 11:27:36 2014 +0200 @@ -292,6 +292,10 @@ "\ is_empty (map_default k v f m)" by (simp add: map_default_def) +lemma keys_dom_lookup: + "keys m = dom (Mapping.lookup m)" + by transfer rule + lemma keys_empty [simp]: "keys empty = {}" by transfer simp diff -r b60d5d119489 -r 8f1e7596deb7 src/HOL/Library/Permutations.thy --- a/src/HOL/Library/Permutations.thy Sat Apr 12 17:26:27 2014 +0200 +++ b/src/HOL/Library/Permutations.thy Sat Apr 12 11:27:36 2014 +0200 @@ -10,17 +10,17 @@ subsection {* Transpositions *} -lemma swapid_sym: "Fun.swap a b id = Fun.swap b a id" - by (auto simp add: fun_eq_iff swap_def fun_upd_def) - lemma swap_id_refl: "Fun.swap a a id = id" - by simp + by (fact swap_self) lemma swap_id_sym: "Fun.swap a b id = Fun.swap b a id" - by (rule ext, simp add: swap_def) + by (fact swap_commute) + +lemma swapid_sym: "Fun.swap a b id = Fun.swap b a id" + by (fact swap_commute) lemma swap_id_idempotent[simp]: "Fun.swap a b id \ Fun.swap a b id = id" - by (rule ext, auto simp add: swap_def) + by (rule ext, auto simp add: Fun.swap_def) lemma inv_unique_comp: assumes fg: "f \ g = id" @@ -32,7 +32,7 @@ by (rule inv_unique_comp) simp_all lemma swap_id_eq: "Fun.swap a b id x = (if x = a then b else if x = b then a else x)" - by (simp add: swap_def) + by (simp add: Fun.swap_def) subsection {* Basic consequences of the definition *} @@ -95,7 +95,7 @@ done lemma permutes_swap_id: "a \ S \ b \ S \ Fun.swap a b id permutes S" - unfolding permutes_def swap_def fun_upd_def by auto metis + unfolding permutes_def Fun.swap_def fun_upd_def by auto metis lemma permutes_superset: "p permutes S \ (\x \ S - T. p x = x) \ p permutes T" by (simp add: Ball_def permutes_def) metis @@ -131,7 +131,7 @@ apply (rule permutes_swap_id, simp) using permutes_in_image[OF pS, of a] apply simp - apply (auto simp add: Ball_def swap_def) + apply (auto simp add: Ball_def Fun.swap_def) done lemma permutes_insert: "{p. p permutes (insert a S)} = @@ -215,14 +215,14 @@ by auto from ths(4) `x \ F` eq have "b = ?g (b,p) x" unfolding permutes_def - by (auto simp add: swap_def fun_upd_def fun_eq_iff) + by (auto simp add: Fun.swap_def fun_upd_def fun_eq_iff) also have "\ = ?g (c,q) x" using ths(5) `x \ F` eq by (auto simp add: swap_def fun_upd_def fun_eq_iff) also have "\ = c" using ths(5) `x \ F` unfolding permutes_def - by (auto simp add: swap_def fun_upd_def fun_eq_iff) + by (auto simp add: Fun.swap_def fun_upd_def fun_eq_iff) finally have bc: "b = c" . then have "Fun.swap x b id = Fun.swap x c id" by simp @@ -310,15 +310,15 @@ lemma swap_id_common:" a \ c \ b \ c \ Fun.swap a b id \ Fun.swap a c id = Fun.swap b c id \ Fun.swap a b id" - by (simp add: fun_eq_iff swap_def) + by (simp add: fun_eq_iff Fun.swap_def) lemma swap_id_common': "a \ b \ a \ c \ Fun.swap a c id \ Fun.swap b c id = Fun.swap b c id \ Fun.swap a b id" - by (simp add: fun_eq_iff swap_def) + by (simp add: fun_eq_iff Fun.swap_def) lemma swap_id_independent: "a \ c \ a \ d \ b \ c \ b \ d \ Fun.swap a b id \ Fun.swap c d id = Fun.swap c d id \ Fun.swap a b id" - by (simp add: swap_def fun_eq_iff) + by (simp add: fun_eq_iff Fun.swap_def) subsection {* Permutations as transposition sequences *} @@ -437,7 +437,7 @@ (\x y z. x \ a \ y \ a \ z \ a \ x \ y \ Fun.swap a b id \ Fun.swap c d id = Fun.swap x y id \ Fun.swap a z id))" apply (rule symmetry_lemma[where a=a and b=b and c=c and d=d]) - apply (simp_all only: swapid_sym) + apply (simp_all only: swap_commute) apply (case_tac "a = c \ b = d") apply (clarsimp simp only: swapid_sym swap_id_idempotent) apply (case_tac "a = c \ b \ d") @@ -445,18 +445,18 @@ apply (rule_tac x="b" in exI) apply (rule_tac x="d" in exI) apply (rule_tac x="b" in exI) - apply (clarsimp simp add: fun_eq_iff swap_def) + apply (clarsimp simp add: fun_eq_iff Fun.swap_def) apply (case_tac "a \ c \ b = d") apply (rule disjI2) apply (rule_tac x="c" in exI) apply (rule_tac x="d" in exI) apply (rule_tac x="c" in exI) - apply (clarsimp simp add: fun_eq_iff swap_def) + apply (clarsimp simp add: fun_eq_iff Fun.swap_def) apply (rule disjI2) apply (rule_tac x="c" in exI) apply (rule_tac x="d" in exI) apply (rule_tac x="b" in exI) - apply (clarsimp simp add: fun_eq_iff swap_def) + apply (clarsimp simp add: fun_eq_iff Fun.swap_def) done with H show ?thesis by metis qed @@ -489,7 +489,7 @@ proof (induct n arbitrary: p a b) case 0 then show ?case - by (auto simp add: swap_def fun_upd_def) + by (auto simp add: Fun.swap_def fun_upd_def) next case (Suc n p a b) from Suc.prems(1) swapidseq_cases[of "Suc n" p] @@ -511,7 +511,7 @@ { fix h have "(Fun.swap x y id \ h) a = a \ h a = a" - using H by (simp add: swap_def) + using H by (simp add: Fun.swap_def) } note th3 = this from cdqm(2) have "Fun.swap a b id \ p = Fun.swap a b id \ (Fun.swap c d id \ q)" @@ -673,7 +673,7 @@ from comp_Suc.hyps(2) have fS: "finite ?S" by simp from `a \ b` have th: "{x. (Fun.swap a b id \ p) x \ x} \ ?S" - by (auto simp add: swap_def) + by (auto simp add: Fun.swap_def) from finite_subset[OF th fS] show ?case . qed qed @@ -685,7 +685,7 @@ assumes bp: "bij p" shows "Fun.swap a b id \ p = Fun.swap (inv p a) (inv p b) p" using surj_f_inv_f[OF bij_is_surj[OF bp]] - by (simp add: fun_eq_iff swap_def bij_inv_eq_iff[OF bp]) + by (simp add: fun_eq_iff Fun.swap_def bij_inv_eq_iff[OF bp]) lemma bij_swap_ompose_bij: "bij p \ bij (Fun.swap a b id \ p)" proof - @@ -709,12 +709,12 @@ let ?r = "Fun.swap a (p a) id \ p" let ?q = "Fun.swap a (p a) id \ ?r" have raa: "?r a = a" - by (simp add: swap_def) + by (simp add: Fun.swap_def) from bij_swap_ompose_bij[OF insert(4)] have br: "bij ?r" . from insert raa have th: "\x. x \ F \ ?r x = x" - apply (clarsimp simp add: swap_def) + apply (clarsimp simp add: Fun.swap_def) apply (erule_tac x="x" in allE) apply auto unfolding bij_iff @@ -1054,7 +1054,7 @@ from eq have "(Fun.swap a b id \ p) a = (Fun.swap a c id \ q) a" by simp then have bc: "b = c" - by (simp add: permutes_def pa qa o_def fun_upd_def swap_def id_def + by (simp add: permutes_def pa qa o_def fun_upd_def Fun.swap_def id_def cong del: if_weak_cong split: split_if_asm) from eq[unfolded bc] have "(\p. Fun.swap a c id \ p) (Fun.swap a c id \ p) = (\p. Fun.swap a c id \ p) (Fun.swap a c id \ q)" by simp diff -r b60d5d119489 -r 8f1e7596deb7 src/HOL/List.thy --- a/src/HOL/List.thy Sat Apr 12 17:26:27 2014 +0200 +++ b/src/HOL/List.thy Sat Apr 12 11:27:36 2014 +0200 @@ -5432,6 +5432,40 @@ apply (rule allI, case_tac x, simp, simp) by blast +lemma lexord_irrefl: + "irrefl R \ irrefl (lexord R)" + by (simp add: irrefl_def lexord_irreflexive) + +lemma lexord_asym: + assumes "asym R" + shows "asym (lexord R)" +proof + from assms obtain "irrefl R" by (blast elim: asym.cases) + then show "irrefl (lexord R)" by (rule lexord_irrefl) +next + fix xs ys + assume "(xs, ys) \ lexord R" + then show "(ys, xs) \ lexord R" + proof (induct xs arbitrary: ys) + case Nil + then show ?case by simp + next + case (Cons x xs) + then obtain z zs where ys: "ys = z # zs" by (cases ys) auto + with assms Cons show ?case by (auto elim: asym.cases) + qed +qed + +lemma lexord_asymmetric: + assumes "asym R" + assumes hyp: "(a, b) \ lexord R" + shows "(b, a) \ lexord R" +proof - + from `asym R` have "asym (lexord R)" by (rule lexord_asym) + then show ?thesis by (rule asym.cases) (auto simp add: hyp) +qed + + text {* Predicate version of lexicographic order integrated with Isabelle's order type classes. Author: Andreas Lochbihler diff -r b60d5d119489 -r 8f1e7596deb7 src/HOL/Map.thy --- a/src/HOL/Map.thy Sat Apr 12 17:26:27 2014 +0200 +++ b/src/HOL/Map.thy Sat Apr 12 11:27:36 2014 +0200 @@ -249,6 +249,10 @@ "dom (\k. map_option (f k) (m k)) = dom m" by (simp add: dom_def) +lemma dom_map_option_comp [simp]: + "dom (map_option g \ m) = dom m" + using dom_map_option [of "\_. g" m] by (simp add: comp_def) + subsection {* @{const map_option} related *} diff -r b60d5d119489 -r 8f1e7596deb7 src/HOL/Multivariate_Analysis/Brouwer_Fixpoint.thy --- a/src/HOL/Multivariate_Analysis/Brouwer_Fixpoint.thy Sat Apr 12 17:26:27 2014 +0200 +++ b/src/HOL/Multivariate_Analysis/Brouwer_Fixpoint.thy Sat Apr 12 11:27:36 2014 +0200 @@ -47,10 +47,10 @@ done lemma swap_apply1: "Fun.swap x y f x = f y" - by (simp add: swap_def) + by (simp add: Fun.swap_def) lemma swap_apply2: "Fun.swap x y f y = f x" - by (simp add: swap_def) + by (simp add: Fun.swap_def) lemma (in -) lessThan_empty_iff: "{..< n::nat} = {} \ n = 0" by auto diff -r b60d5d119489 -r 8f1e7596deb7 src/HOL/Multivariate_Analysis/Determinants.thy --- a/src/HOL/Multivariate_Analysis/Determinants.thy Sat Apr 12 17:26:27 2014 +0200 +++ b/src/HOL/Multivariate_Analysis/Determinants.thy Sat Apr 12 11:27:36 2014 +0200 @@ -359,7 +359,7 @@ have th1: "of_int (-1) = - 1" by simp let ?p = "Fun.swap i j id" let ?A = "\ i. A $ ?p i" - from r have "A = ?A" by (simp add: vec_eq_iff row_def swap_def) + from r have "A = ?A" by (simp add: vec_eq_iff row_def Fun.swap_def) then have "det A = det ?A" by simp moreover have "det A = - det ?A" by (simp add: det_permute_rows[OF permutes_swap_id] sign_swap_id ij th1) diff -r b60d5d119489 -r 8f1e7596deb7 src/HOL/Orderings.thy --- a/src/HOL/Orderings.thy Sat Apr 12 17:26:27 2014 +0200 +++ b/src/HOL/Orderings.thy Sat Apr 12 11:27:36 2014 +0200 @@ -270,6 +270,35 @@ end +text {* Alternative introduction rule with bias towards strict order *} + +lemma order_strictI: + fixes less (infix "\" 50) + and less_eq (infix "\" 50) + assumes less_eq_less: "\a b. a \ b \ a \ b \ a = b" + assumes asym: "\a b. a \ b \ \ b \ a" + assumes irrefl: "\a. \ a \ a" + assumes trans: "\a b c. a \ b \ b \ c \ a \ c" + shows "class.order less_eq less" +proof + fix a b + show "a \ b \ a \ b \ \ b \ a" + by (auto simp add: less_eq_less asym irrefl) +next + fix a + show "a \ a" + by (auto simp add: less_eq_less) +next + fix a b c + assume "a \ b" and "b \ c" then show "a \ c" + by (auto simp add: less_eq_less intro: trans) +next + fix a b + assume "a \ b" and "b \ a" then show "a = b" + by (auto simp add: less_eq_less asym) +qed + + subsection {* Linear (total) orders *} class linorder = order + @@ -341,6 +370,26 @@ end +text {* Alternative introduction rule with bias towards strict order *} + +lemma linorder_strictI: + fixes less (infix "\" 50) + and less_eq (infix "\" 50) + assumes "class.order less_eq less" + assumes trichotomy: "\a b. a \ b \ a = b \ b \ a" + shows "class.linorder less_eq less" +proof - + interpret order less_eq less + by (fact `class.order less_eq less`) + show ?thesis + proof + fix a b + show "a \ b \ b \ a" + using trichotomy by (auto simp add: le_less) + qed +qed + + subsection {* Reasoning tools setup *} ML {* diff -r b60d5d119489 -r 8f1e7596deb7 src/HOL/Product_Type.thy --- a/src/HOL/Product_Type.thy Sat Apr 12 17:26:27 2014 +0200 +++ b/src/HOL/Product_Type.thy Sat Apr 12 11:27:36 2014 +0200 @@ -954,6 +954,26 @@ "apsnd f (apfst g p) = apfst g (apsnd f p)" by simp +definition swap :: "'a \ 'b \ 'b \ 'a" +where + "swap p = (snd p, fst p)" + +lemma swap_simp [simp]: + "swap (x, y) = (y, x)" + by (simp add: swap_def) + +lemma pair_in_swap_image [simp]: + "(y, x) \ swap ` A \ (x, y) \ A" + by (auto intro!: image_eqI) + +lemma inj_swap [simp]: + "inj_on swap A" + by (rule inj_onI) (auto simp add: swap_def) + +lemma case_swap [simp]: + "(case swap p of (y, x) \ f x y) = (case p of (x, y) \ f x y)" + by (cases p) simp + text {* Disjoint union of a family of sets -- Sigma. *} @@ -1085,13 +1105,13 @@ *} lemma Times_Un_distrib1: "(A Un B) <*> C = (A <*> C) Un (B <*> C)" -by blast + by (fact Sigma_Un_distrib1) lemma Times_Int_distrib1: "(A Int B) <*> C = (A <*> C) Int (B <*> C)" -by blast + by (fact Sigma_Int_distrib1) lemma Times_Diff_distrib1: "(A - B) <*> C = (A <*> C) - (B <*> C)" -by blast + by (fact Sigma_Diff_distrib1) lemma Times_empty[simp]: "A \ B = {} \ A = {} \ B = {}" by auto @@ -1105,6 +1125,14 @@ lemma snd_image_times[simp]: "snd ` (A \ B) = (if A = {} then {} else B)" by force +lemma vimage_fst: + "fst -` A = A \ UNIV" + by auto + +lemma vimage_snd: + "snd -` A = UNIV \ A" + by auto + lemma insert_times_insert[simp]: "insert a A \ insert b B = insert (a,b) (A \ insert b B \ insert a A \ B)" diff -r b60d5d119489 -r 8f1e7596deb7 src/HOL/Relation.thy --- a/src/HOL/Relation.thy Sat Apr 12 17:26:27 2014 +0200 +++ b/src/HOL/Relation.thy Sat Apr 12 11:27:36 2014 +0200 @@ -211,13 +211,44 @@ definition irrefl :: "'a rel \ bool" where - "irrefl r \ (\x. (x, x) \ r)" + "irrefl r \ (\a. (a, a) \ r)" + +definition irreflp :: "('a \ 'a \ bool) \ bool" +where + "irreflp R \ (\a. \ R a a)" + +lemma irreflp_irrefl_eq [pred_set_conv]: + "irreflp (\a b. (a, b) \ R) \ irrefl R" + by (simp add: irrefl_def irreflp_def) + +lemma irreflI: + "(\a. (a, a) \ R) \ irrefl R" + by (simp add: irrefl_def) + +lemma irreflpI: + "(\a. \ R a a) \ irreflp R" + by (fact irreflI [to_pred]) lemma irrefl_distinct [code]: - "irrefl r \ (\(x, y) \ r. x \ y)" + "irrefl r \ (\(a, b) \ r. a \ b)" by (auto simp add: irrefl_def) +subsubsection {* Asymmetry *} + +inductive asym :: "'a rel \ bool" +where + asymI: "irrefl R \ (\a b. (a, b) \ R \ (b, a) \ R) \ asym R" + +inductive asymp :: "('a \ 'a \ bool) \ bool" +where + asympI: "irreflp R \ (\a b. R a b \ \ R b a) \ asymp R" + +lemma asymp_asym_eq [pred_set_conv]: + "asymp (\a b. (a, b) \ R) \ asym R" + by (auto intro!: asymI asympI elim: asym.cases asymp.cases simp add: irreflp_irrefl_eq) + + subsubsection {* Symmetry *} definition sym :: "'a rel \ bool"