# HG changeset patch # User paulson # Date 1708351949 0 # Node ID 1d0cb3f003d409f740e74b785b28175dd268f2b0 # Parent a3e7a323780f6b3cc3b3da8455e85e7d7fcdb694# Parent f471e1715fc4c5656bed7c854a89eadd1e4f25c0 merged diff -r a3e7a323780f -r 1d0cb3f003d4 src/HOL/Analysis/Complex_Transcendental.thy --- a/src/HOL/Analysis/Complex_Transcendental.thy Mon Feb 19 14:31:26 2024 +0100 +++ b/src/HOL/Analysis/Complex_Transcendental.thy Mon Feb 19 14:12:29 2024 +0000 @@ -2379,8 +2379,7 @@ by (auto simp: powr_def algebra_simps Reals_def Ln_of_real) lemma powr_times_real: - "\x \ \; y \ \; 0 \ Re x; 0 \ Re y\ - \ (x * y) powr z = x powr z * y powr z" + "\x \ \; y \ \; 0 \ Re x; 0 \ Re y\ \ (x * y) powr z = x powr z * y powr z" by (auto simp: Reals_def powr_def Ln_times exp_add algebra_simps less_eq_real_def Ln_of_real) lemma Re_powr_le: "r \ \\<^sub>\\<^sub>0 \ Re (r powr z) \ Re r powr Re z" @@ -2392,6 +2391,12 @@ shows Reals_powr [simp]: "w powr z \ \" and nonneg_Reals_powr [simp]: "w powr z \ \\<^sub>\\<^sub>0" using assms by (auto simp: nonneg_Reals_def Reals_def powr_of_real) +lemma exp_powr_complex: + fixes x::complex + assumes "-pi < Im(x)" "Im(x) \ pi" + shows "exp x powr y = exp (x*y)" + using assms by (simp add: powr_def mult.commute) + lemma powr_neg_real_complex: fixes w::complex shows "(- of_real x) powr w = (-1) powr (of_real (sgn x) * w) * of_real x powr w" diff -r a3e7a323780f -r 1d0cb3f003d4 src/HOL/Analysis/Convex.thy --- a/src/HOL/Analysis/Convex.thy Mon Feb 19 14:31:26 2024 +0100 +++ b/src/HOL/Analysis/Convex.thy Mon Feb 19 14:12:29 2024 +0000 @@ -583,7 +583,6 @@ and f :: "'b \ real" assumes "finite S" "S \ {}" and "convex_on C f" - and "convex C" and "(\ i \ S. a i) = 1" and "\i. i \ S \ a i \ 0" and "\i. i \ S \ y i \ C" @@ -624,6 +623,8 @@ using i0 by auto then have a1: "(\ j \ S. ?a j) = 1" unfolding sum_divide_distrib by simp + have "convex C" + using \convex_on C f\ by (simp add: convex_on_def) have asum: "(\ j \ S. ?a j *\<^sub>R y j) \ C" using insert convex_sum [OF \finite S\ \convex C\ a1 a_nonneg] by auto have asum_le: "f (\ j \ S. ?a j *\<^sub>R y j) \ (\ j \ S. ?a j * f (y j))" @@ -648,6 +649,26 @@ qed qed +lemma concave_on_sum: + fixes a :: "'a \ real" + and y :: "'a \ 'b::real_vector" + and f :: "'b \ real" + assumes "finite S" "S \ {}" + and "concave_on C f" + and "(\i \ S. a i) = 1" + and "\i. i \ S \ a i \ 0" + and "\i. i \ S \ y i \ C" + shows "f (\i \ S. a i *\<^sub>R y i) \ (\i \ S. a i * f (y i))" +proof - + have "(uminus \ f) (\i\S. a i *\<^sub>R y i) \ (\i\S. a i * (uminus \ f) (y i))" + proof (intro convex_on_sum) + show "convex_on C (uminus \ f)" + by (simp add: assms convex_on_iff_concave) + qed (use assms in auto) + then show ?thesis + by (simp add: sum_negf o_def) +qed + lemma convex_on_alt: fixes C :: "'a::real_vector set" shows "convex_on C f \ convex C \ @@ -865,6 +886,39 @@ lemma exp_convex: "convex_on UNIV exp" by (intro f''_ge0_imp_convex derivative_eq_intros | simp)+ +text \The AM-GM inequality: the arithmetic mean exceeds the geometric mean.\ +lemma arith_geom_mean: + fixes x :: "'a \ real" + assumes "finite S" "S \ {}" + and x: "\i. i \ S \ x i \ 0" + shows "(\i \ S. x i / card S) \ (\i \ S. x i) powr (1 / card S)" +proof (cases "\i\S. x i = 0") + case True + then have "(\i \ S. x i) = 0" + by (simp add: \finite S\) + moreover have "(\i \ S. x i / card S) \ 0" + by (simp add: sum_nonneg x) + ultimately show ?thesis + by simp +next + case False + have "ln (\i \ S. (1 / card S) *\<^sub>R x i) \ (\i \ S. (1 / card S) * ln (x i))" + proof (intro concave_on_sum) + show "concave_on {0<..} ln" + by (simp add: ln_concave) + show "\i. i\S \ x i \ {0<..}" + using False x by fastforce + qed (use assms False in auto) + moreover have "(\i \ S. (1 / card S) *\<^sub>R x i) > 0" + using False assms by (simp add: card_gt_0_iff less_eq_real_def sum_pos) + ultimately have "(\i \ S. (1 / card S) *\<^sub>R x i) \ exp (\i \ S. (1 / card S) * ln (x i))" + using ln_ge_iff by blast + then have "(\i \ S. x i / card S) \ exp (\i \ S. ln (x i) / card S)" + by (simp add: divide_simps) + then show ?thesis + using assms False + by (smt (verit, ccfv_SIG) divide_inverse exp_ln exp_powr_real exp_sum inverse_eq_divide prod.cong prod_powr_distrib) +qed subsection\<^marker>\tag unimportant\ \Convexity of real functions\ diff -r a3e7a323780f -r 1d0cb3f003d4 src/HOL/Groups_Big.thy --- a/src/HOL/Groups_Big.thy Mon Feb 19 14:31:26 2024 +0100 +++ b/src/HOL/Groups_Big.thy Mon Feb 19 14:12:29 2024 +0000 @@ -1596,10 +1596,10 @@ context linordered_semidom begin -lemma prod_nonneg: "(\a\A. 0 \ f a) \ 0 \ prod f A" +lemma prod_nonneg: "(\a. a\A \ 0 \ f a) \ 0 \ prod f A" by (induct A rule: infinite_finite_induct) simp_all -lemma prod_pos: "(\a\A. 0 < f a) \ 0 < prod f A" +lemma prod_pos: "(\a. a\A \ 0 < f a) \ 0 < prod f A" by (induct A rule: infinite_finite_induct) simp_all lemma prod_mono: @@ -1738,14 +1738,13 @@ case empty then show ?case by auto next - case (insert x F) - from insertI1 have "0 \ g (f x)" by (rule insert) - hence 1: "sum g (f ` F) \ g (f x) + sum g (f ` F)" using add_increasing by blast - have 2: "sum g (f ` F) \ sum (g \ f) F" using insert by blast - have "sum g (f ` insert x F) = sum g (insert (f x) (f ` F))" by simp - also have "\ \ g (f x) + sum g (f ` F)" by (simp add: 1 insert sum.insert_if) - also from 2 have "\ \ g (f x) + sum (g \ f) F" by (rule add_left_mono) - also from insert(1, 2) have "\ = sum (g \ f) (insert x F)" by (simp add: sum.insert_if) + case (insert i I) + hence *: "sum g (f ` I) \ g (f i) + sum g (f ` I)" + "sum g (f ` I) \ sum (g \ f) I" using add_increasing by blast+ + have "sum g (f ` insert i I) = sum g (insert (f i) (f ` I))" by simp + also have "\ \ g (f i) + sum g (f ` I)" by (simp add: * insert sum.insert_if) + also from * have "\ \ g (f i) + sum (g \ f) I" by (intro add_left_mono) + also from insert have "\ = sum (g \ f) (insert i I)" by (simp add: sum.insert_if) finally show ?case . qed diff -r a3e7a323780f -r 1d0cb3f003d4 src/HOL/Transcendental.thy --- a/src/HOL/Transcendental.thy Mon Feb 19 14:31:26 2024 +0100 +++ b/src/HOL/Transcendental.thy Mon Feb 19 14:12:29 2024 +0000 @@ -2450,6 +2450,10 @@ shows "continuous_on s (\x. log (f x) (g x))" using assms unfolding continuous_on_def by (fast intro: tendsto_log) +lemma exp_powr_real: + fixes x::real shows "exp x powr y = exp (x*y)" + by (simp add: powr_def) + lemma powr_one_eq_one [simp]: "1 powr a = 1" by (simp add: powr_def) @@ -2469,6 +2473,13 @@ for a x y :: real by (simp add: powr_def exp_add [symmetric] ln_mult distrib_left) +lemma prod_powr_distrib: + fixes x :: "'a \ real" + assumes "\i. i\I \ x i \ 0" + shows "(prod x I) powr r = (\i\I. x i powr r)" + using assms + by (induction I rule: infinite_finite_induct) (auto simp add: powr_mult prod_nonneg) + lemma powr_ge_pzero [simp]: "0 \ x powr y" for x y :: real by (simp add: powr_def) @@ -2546,6 +2557,14 @@ shows "x powr real_of_int n = power_int x n" by (metis assms exp_ln_iff exp_power_int nless_le power_int_eq_0_iff powr_def) +lemma exp_minus_ge: + fixes x::real shows "1 - x \ exp (-x)" + by (smt (verit) exp_ge_add_one_self) + +lemma exp_minus_greater: + fixes x::real shows "1 - x < exp (-x) \ x \ 0" + by (smt (verit) exp_minus_ge exp_eq_one_iff exp_gt_zero ln_eq_minus_one ln_exp) + lemma log_ln: "ln x = log (exp(1)) x" by (simp add: log_def) @@ -2945,6 +2964,17 @@ for x :: real using less_eq_real_def powr_less_mono2 that by auto +lemma powr01_less_one: + fixes a::real + assumes "0 < a" "a < 1" + shows "a powr e < 1 \ e>0" +proof + show "a powr e < 1 \ e>0" + using assms not_less_iff_gr_or_eq powr_less_mono2_neg by fastforce + show "e>0 \ a powr e < 1" + by (metis assms less_eq_real_def powr_less_mono2 powr_one_eq_one) +qed + lemma powr_le1: "0 \ a \ 0 \ x \ x \ 1 \ x powr a \ 1" for x :: real using powr_mono2 by fastforce @@ -2973,6 +3003,9 @@ lemma powr_half_sqrt: "0 \ x \ x powr (1/2) = sqrt x" by (simp add: powr_def root_powr_inverse sqrt_def) +lemma powr_half_sqrt_powr: "0 \ x \ x powr (a/2) = sqrt(x powr a)" + by (metis divide_inverse mult.left_neutral powr_ge_pzero powr_half_sqrt powr_powr) + lemma square_powr_half [simp]: fixes x::real shows "x\<^sup>2 powr (1/2) = \x\" by (simp add: powr_half_sqrt) @@ -3108,6 +3141,23 @@ by (rule has_derivative_transform_within[OF _ \d > 0\ \x \ X\]) (auto simp: powr_def dest: pos') qed +lemma has_derivative_const_powr [derivative_intros]: + assumes "\x. (f has_derivative f') (at x)" "a \ (0::real)" + shows "((\x. a powr (f x)) has_derivative (\y. f' y * ln a * a powr (f x))) (at x)" + using assms + apply (simp add: powr_def) + apply (rule assms derivative_eq_intros refl)+ + done + +lemma has_real_derivative_const_powr [derivative_intros]: + assumes "\x. (f has_real_derivative f' x) (at x)" + "a \ (0::real)" + shows "((\x. a powr (f x)) has_real_derivative (f' x * ln a * a powr (f x))) (at x)" + using assms + apply (simp add: powr_def) + apply (rule assms derivative_eq_intros refl | simp)+ + done + lemma DERIV_powr: fixes r :: real assumes g: "DERIV g x :> m"