# HG changeset patch # User paulson # Date 1737154813 0 # Node ID e4ff4a4ee4ec277373255efa18f117afd424af7f # Parent a4c0f9d124403b1a0b51e2b4f6c7383a25c98900# Parent 1c003b308c98c35ba8b4b805b3a4972d2537988e merged diff -r a4c0f9d12440 -r e4ff4a4ee4ec src/HOL/Library/Ramsey.thy --- a/src/HOL/Library/Ramsey.thy Fri Jan 17 23:15:47 2025 +0100 +++ b/src/HOL/Library/Ramsey.thy Fri Jan 17 23:00:13 2025 +0000 @@ -27,7 +27,7 @@ lemma nsets_Pi_contra: "A' \ A \ Pi ([A]\<^bsup>n\<^esup>) B \ Pi ([A']\<^bsup>n\<^esup>) B" by (auto simp: nsets_def) -lemma nsets_2_eq: "nsets A 2 = (\x\A. \y\A - {x}. {{x, y}})" +lemma nsets_2_eq: "[A]\<^bsup>2\<^esup> = (\x\A. \y\A - {x}. {{x, y}})" by (auto simp: nsets_def card_2_iff) lemma nsets2_E: @@ -41,7 +41,7 @@ lemma doubleton_in_nsets_2 [simp]: "{x,y} \ [A]\<^bsup>2\<^esup> \ x \ A \ y \ A \ x \ y" by (auto simp: nsets_2_eq Set.doubleton_eq_iff) -lemma nsets_3_eq: "nsets A 3 = (\x\A. \y\A - {x}. \z\A - {x,y}. {{x,y,z}})" +lemma nsets_3_eq: "[A]\<^bsup>3\<^esup> = (\x\A. \y\A - {x}. \z\A - {x,y}. {{x,y,z}})" by (simp add: eval_nat_numeral nsets_def card_Suc_eq) blast lemma nsets_4_eq: "[A]\<^bsup>4\<^esup> = (\u\A. \x\A - {u}. \y\A - {u,x}. \z\A - {u,x,y}. {{u,x,y,z}})" @@ -49,9 +49,10 @@ proof show "[A]\<^bsup>4\<^esup> \ ?rhs" by (clarsimp simp add: nsets_def eval_nat_numeral card_Suc_eq) blast - show "?rhs \ [A]\<^bsup>4\<^esup>" - apply (clarsimp simp add: nsets_def eval_nat_numeral card_Suc_eq) - by (metis insert_iff singletonD) + have "\X. X \ ?rhs \ card X = 4" + by (force simp: card_2_iff) + then show "?rhs \ [A]\<^bsup>4\<^esup>" + by (auto simp: nsets_def) qed lemma nsets_disjoint_2: @@ -60,76 +61,75 @@ lemma ordered_nsets_2_eq: fixes A :: "'a::linorder set" - shows "nsets A 2 = {{x,y} | x y. x \ A \ y \ A \ x2\<^esup> = {{x,y} | x y. x \ A \ y \ A \ x ?rhs" - unfolding numeral_nat - apply (clarsimp simp add: nsets_def card_Suc_eq Set.doubleton_eq_iff not_less) - by (metis antisym) - show "?rhs \ nsets A 2" + show "[A]\<^bsup>2\<^esup> \ ?rhs" + by (auto simp: nsets_def card_2_iff doubleton_eq_iff neq_iff) + show "?rhs \ [A]\<^bsup>2\<^esup>" unfolding numeral_nat by (auto simp: nsets_def card_Suc_eq) qed lemma ordered_nsets_3_eq: fixes A :: "'a::linorder set" - shows "nsets A 3 = {{x,y,z} | x y z. x \ A \ y \ A \ z \ A \ x y3\<^esup> = {{x,y,z} | x y z. x \ A \ y \ A \ z \ A \ x y ?rhs" - apply (clarsimp simp add: nsets_def card_Suc_eq eval_nat_numeral) - by (metis insert_commute linorder_cases) - show "?rhs \ nsets A 3" - apply (clarsimp simp add: nsets_def card_Suc_eq eval_nat_numeral) - by (metis empty_iff insert_iff not_less_iff_gr_or_eq) + show "[A]\<^bsup>3\<^esup> \ ?rhs" + unfolding nsets_def card_3_iff + by (smt (verit, del_insts) Collect_mono_iff insert_commute insert_subset + linorder_less_linear) + have "\X. X \ ?rhs \ card X = 3" + by (force simp: card_3_iff) + then show "?rhs \ [A]\<^bsup>3\<^esup>" + by (auto simp: nsets_def) qed lemma ordered_nsets_4_eq: fixes A :: "'a::linorder set" - shows "[A]\<^bsup>4\<^esup> = {U. \u x y z. U = {u,x,y,z} \ u \ A \ x \ A \ y \ A \ z \ A \ u < x \ x < y \ y < z}" - (is "_ = Collect ?RHS") + defines "rhs \ \U. \u x y z. U = {u,x,y,z} \ u \ A \ x \ A \ y \ A \ z \ A \ u < x \ x < y \ y < z" + shows "[A]\<^bsup>4\<^esup> = Collect rhs" proof - - have "?RHS U" if "U \ [A]\<^bsup>4\<^esup>" for U + have "rhs U" if "U \ [A]\<^bsup>4\<^esup>" for U proof - from that obtain l where "strict_sorted l" "List.set l = U" "length l = 4" "U \ A" by (simp add: nsets_def) (metis finite_set_strict_sorted) then show ?thesis - unfolding numeral_nat length_Suc_conv by auto blast + unfolding numeral_nat length_Suc_conv rhs_def by auto blast qed moreover - have "Collect ?RHS \ [A]\<^bsup>4\<^esup>" - apply (clarsimp simp add: nsets_def eval_nat_numeral) - apply (subst card_insert_disjoint, auto)+ - done + have "\X. X \ Collect rhs \ card X = 4 \ finite X \ X \ A" + by (auto simp: rhs_def card_insert_if) ultimately show ?thesis - by auto + unfolding nsets_def by blast qed lemma ordered_nsets_5_eq: fixes A :: "'a::linorder set" - shows "[A]\<^bsup>5\<^esup> = {U. \u v x y z. U = {u,v,x,y,z} \ u \ A \ v \ A \ x \ A \ y \ A \ z \ A \ u < v \ v < x \ x < y \ y < z}" - (is "_ = Collect ?RHS") + defines "rhs \ \U. \u v x y z. U = {u,v,x,y,z} \ u \ A \ v \ A \ x \ A \ y \ A \ z \ A \ u < v \ v < x \ x < y \ y < z" + shows "[A]\<^bsup>5\<^esup> = Collect rhs" proof - - have "?RHS U" if "U \ [A]\<^bsup>5\<^esup>" for U + have "rhs U" if "U \ [A]\<^bsup>5\<^esup>" for U proof - from that obtain l where "strict_sorted l" "List.set l = U" "length l = 5" "U \ A" - apply (simp add: nsets_def) - by (metis finite_set_strict_sorted) + by (simp add: nsets_def) (metis finite_set_strict_sorted) then show ?thesis - unfolding numeral_nat length_Suc_conv by auto blast + unfolding numeral_nat length_Suc_conv rhs_def by auto blast qed moreover - have "Collect ?RHS \ [A]\<^bsup>5\<^esup>" - apply (clarsimp simp add: nsets_def eval_nat_numeral) - apply (subst card_insert_disjoint, auto)+ - done + have "\X. X \ Collect rhs \ card X = 5 \ finite X \ X \ A" + by (auto simp: rhs_def card_insert_if) ultimately show ?thesis - by auto + unfolding nsets_def by blast qed lemma binomial_eq_nsets: "n choose k = card (nsets {0.. {0.. card K = k} = {N. N \ {0.. finite N \ card N = k}" + using infinite_super by blast + then show ?thesis + by (simp add: binomial_def nsets_def) +qed lemma nsets_eq_empty_iff: "nsets A r = {} \ finite A \ card A < r" unfolding nsets_def @@ -157,9 +157,10 @@ by (auto simp: nsets_def card_gt_0_iff subset_singleton_iff) lemma nsets_self [simp]: "nsets {..m\<^esup> \ {{..X. f ` X) ([A]\<^bsup>n\<^esup>)" - using assms unfolding nsets_def - by (metis (no_types, lifting) inj_on_inverseI inv_into_image_cancel mem_Collect_eq) + using assms by (simp add: nsets_def inj_on_def inj_on_image_eq_iff) lemma bij_betw_nsets: assumes "bij_betw f A B" shows "bij_betw (\X. f ` X) ([A]\<^bsup>n\<^esup>) ([B]\<^bsup>n\<^esup>)" proof - - have "(`) f ` [A]\<^bsup>n\<^esup> = [f ` A]\<^bsup>n\<^esup>" - using assms - apply (auto simp: nsets_def bij_betw_def image_iff card_image inj_on_subset) + have "\X. \X \ f ` A; finite X\ \ \Y\A. finite Y \ card Y = card X \ X = f ` Y" by (metis card_image inj_on_finite order_refl subset_image_inj) + then have "(`) f ` [A]\<^bsup>n\<^esup> = [f ` A]\<^bsup>n\<^esup>" + using assms by (auto simp: nsets_def bij_betw_def image_iff card_image inj_on_subset) with assms show ?thesis by (auto simp: bij_betw_def inj_on_nsets) qed @@ -188,9 +188,14 @@ lemma nset_image_obtains: assumes "X \ [f`A]\<^bsup>k\<^esup>" "inj_on f A" obtains Y where "Y \ [A]\<^bsup>k\<^esup>" "X = f ` Y" - using assms - apply (clarsimp simp add: nsets_def subset_image_iff) - by (metis card_image finite_imageD inj_on_subset) +proof + show "X = f ` (A \ f -` X)" + using assms by (auto simp: nsets_def) + then show "A Int (f -` X) \ [A]\<^bsup>k\<^esup>" + using assms + unfolding nsets_def mem_Collect_eq + by (metis card_image finite_image_iff inf_le1 subset_inj_on) +qed lemma nsets_image_funcset: assumes "g \ S \ T" and "inj_on g S" @@ -331,8 +336,12 @@ qed lemma partn_lst_eq_partn: "partn_lst {..i. i < 2 \ [m, m] ! i = m" + using less_2_cases_iff by force + then show ?thesis + by (auto simp: partn_lst_def partn_def numeral_2_eq_2 cong: conj_cong) +qed lemma partn_lstE: assumes "partn_lst \ \ \" "f \ nsets \ \ \ {.. = l" @@ -603,8 +612,7 @@ using V by simp then have "u ` V \ nsets {.. nsets {..p} q2" unfolding nsets_def using \q2 > 0\ card_insert_if by fastforce have invu_nsets: "inv_into {.. nsets V r" @@ -653,9 +661,9 @@ then have "u ` V \ nsets {..p} q1" using V u_nsets by auto moreover have "f ` nsets (u ` V) (Suc r) \ {j}" - using hj + using hj unfolding h_def image_subset_iff nsets_def apply (clarsimp simp add: h_def image_subset_iff nsets_def) - by (metis Zero_not_Suc card_eq_0_iff card_image subset_image_inj) + by (metis card_image finite_imageD subset_image_inj) ultimately show ?thesis using jzero not_less_eq by fastforce qed @@ -792,7 +800,7 @@ using Suc Suc.hyps(2) j by linarith have "nsets (u ` V) r \ (\x. (u ` x)) ` nsets V r" apply (clarsimp simp add: nsets_def image_iff) - by (metis card_eq_0_iff card_image image_is_empty subset_image_inj) + by (metis card_image finite_imageD subset_image_inj) then have "f ` nsets (u ` V) r \ h ` nsets V r" by (auto simp: h_def) then show "f ` nsets (u ` V) r \ {j}" @@ -866,9 +874,8 @@ show "card (v ` U) = m \ clique (v ` U) E \ card (v ` U) = n \ indep (v ` U) E" using i unfolding numeral_2_eq_2 using gi U u - apply (simp add: image_subset_iff nsets_2_eq clique_def indep_def less_Suc_eq) - apply (auto simp: f_def nsets_def card_image inj_on_subset split: if_split_asm) - done + unfolding image_subset_iff nsets_2_eq clique_def indep_def less_Suc_eq + by (auto simp: f_def nsets_def card_image inj_on_subset split: if_splits) qed qed then show ?thesis diff -r a4c0f9d12440 -r e4ff4a4ee4ec src/HOL/Transcendental.thy --- a/src/HOL/Transcendental.thy Fri Jan 17 23:15:47 2025 +0100 +++ b/src/HOL/Transcendental.thy Fri Jan 17 23:00:13 2025 +0000 @@ -1985,6 +1985,9 @@ finally show ?thesis . qed +lemma exp_gt_self: "x < exp (x::real)" + using exp_gt_zero ln_less_self by fastforce + lemma ln_one_plus_pos_lower_bound: fixes x :: real assumes a: "0 \ x" and b: "x \ 1"