# HG changeset patch # User paulson # Date 1636363886 0 # Node ID 25f5f1fa31bb7a9a1e4b8da3d65ee0c15670dad3 # Parent 58ae06d382ee5a1867d402550dbc69d2d1275c27# Parent 64b3d8d9bd105ee4bd2fe070e6a78fc07dc4ac8c merged diff -r 58ae06d382ee -r 25f5f1fa31bb src/HOL/Analysis/Convex.thy --- a/src/HOL/Analysis/Convex.thy Sun Nov 07 23:35:11 2021 +0100 +++ b/src/HOL/Analysis/Convex.thy Mon Nov 08 09:31:26 2021 +0000 @@ -344,6 +344,14 @@ where "convex_on S f \ (\x\S. \y\S. \u\0. \v\0. u + v = 1 \ f (u *\<^sub>R x + v *\<^sub>R y) \ u * f x + v * f y)" +definition\<^marker>\tag important\ concave_on :: "'a::real_vector set \ ('a \ real) \ bool" + where "concave_on S f \ convex_on S (\x. - f x)" + +lemma concave_on_iff: + "concave_on S f \ + (\x\S. \y\S. \u\0. \v\0. u + v = 1 \ f (u *\<^sub>R x + v *\<^sub>R y) \ u * f x + v * f y)" + by (auto simp: concave_on_def convex_on_def algebra_simps) + lemma convex_onI [intro?]: assumes "\t x y. t > 0 \ t < 1 \ x \ A \ y \ A \ f ((1 - t) *\<^sub>R x + t *\<^sub>R y) \ (1 - t) * f x + t * f y" @@ -865,35 +873,44 @@ assumes conv: "convex C" and f': "\x. x \ C \ DERIV f x :> (f' x)" and f'': "\x. x \ C \ DERIV f' x :> (f'' x)" - and pos: "\x. x \ C \ f'' x \ 0" + and 0: "\x. x \ C \ f'' x \ 0" shows "convex_on C f" - using f''_imp_f'[OF conv f' f'' pos] assms pos_convex_function + using f''_imp_f'[OF conv f' f'' 0] assms pos_convex_function by fastforce +lemma f''_le0_imp_concave: + fixes f :: "real \ real" + assumes "convex C" + and "\x. x \ C \ DERIV f x :> (f' x)" + and "\x. x \ C \ DERIV f' x :> (f'' x)" + and "\x. x \ C \ f'' x \ 0" + shows "concave_on C f" + unfolding concave_on_def + by (rule assms f''_ge0_imp_convex derivative_eq_intros | simp)+ + +lemma log_concave: + fixes b :: real + assumes "b > 1" + shows "concave_on {0<..} (\ x. log b x)" + using assms + by (intro f''_le0_imp_concave derivative_eq_intros | simp)+ + +lemma ln_concave: "concave_on {0<..} ln" + unfolding log_ln by (simp add: log_concave) + lemma minus_log_convex: fixes b :: real assumes "b > 1" shows "convex_on {0 <..} (\ x. - log b x)" -proof - - have "\z. z > 0 \ DERIV (log b) z :> 1 / (ln b * z)" - using DERIV_log by auto - then have f': "\z. z > 0 \ DERIV (\ z. - log b z) z :> - 1 / (ln b * z)" - by (auto simp: DERIV_minus) - have "\z::real. z > 0 \ DERIV inverse z :> - (inverse z ^ Suc (Suc 0))" - using less_imp_neq[THEN not_sym, THEN DERIV_inverse] by auto - from this[THEN DERIV_cmult, of _ "- 1 / ln b"] - have "\z::real. z > 0 \ - DERIV (\ z. (- 1 / ln b) * inverse z) z :> (- 1 / ln b) * (- (inverse z ^ Suc (Suc 0)))" - by auto - then have f''0: "\z::real. z > 0 \ - DERIV (\ z. - 1 / (ln b * z)) z :> 1 / (ln b * z * z)" - unfolding inverse_eq_divide by (auto simp: mult.assoc) - have f''_ge0: "\z::real. z > 0 \ 1 / (ln b * z * z) \ 0" - using \b > 1\ by (auto intro!: less_imp_le) - from f''_ge0_imp_convex[OF convex_real_interval(3), unfolded greaterThan_iff, OF f' f''0 f''_ge0] - show ?thesis - by auto -qed + using assms concave_on_def log_concave by blast + +lemma powr_convex: + assumes "p \ 1" shows "convex_on {0<..} (\x. x powr p)" + using assms + by (intro f''_ge0_imp_convex derivative_eq_intros | simp)+ + +lemma exp_convex: "convex_on UNIV exp" + by (intro f''_ge0_imp_convex derivative_eq_intros | simp)+ subsection\<^marker>\tag unimportant\ \Convexity of real functions\ @@ -1003,6 +1020,63 @@ finally show ?thesis . qed (insert assms(2), simp_all) +subsection \Some inequalities\ + +lemma Youngs_inequality_0: + fixes a::real + assumes "0 \ \" "0 \ \" "\+\ = 1" "a>0" "b>0" + shows "a powr \ * b powr \ \ \*a + \*b" +proof - + have "\ * ln a + \ * ln b \ ln (\ * a + \ * b)" + using assms ln_concave by (simp add: concave_on_iff) + moreover have "0 < \ * a + \ * b" + using assms by (smt (verit) mult_pos_pos split_mult_pos_le) + ultimately show ?thesis + using assms by (simp add: powr_def mult_exp_exp flip: ln_ge_iff) +qed + +lemma Youngs_inequality: + fixes p::real + assumes "p>1" "q>1" "1/p + 1/q = 1" "a\0" "b\0" + shows "a * b \ a powr p / p + b powr q / q" +proof (cases "a=0 \ b=0") + case False + then show ?thesis + using Youngs_inequality_0 [of "1/p" "1/q" "a powr p" "b powr q"] assms + by (simp add: powr_powr) +qed (use assms in auto) + +lemma Cauchy_Schwarz_ineq_sum: + fixes a :: "'a \ 'b::linordered_field" + shows "(\i\I. a i * b i)\<^sup>2 \ (\i\I. (a i)\<^sup>2) * (\i\I. (b i)\<^sup>2)" +proof (cases "(\i\I. (b i)\<^sup>2) > 0") + case False + then consider "\i. i\I \ b i = 0" | "infinite I" + by (metis (mono_tags, lifting) sum_pos2 zero_le_power2 zero_less_power2) + thus ?thesis + by fastforce +next + case True + define r where "r \ (\i\I. a i * b i) / (\i\I. (b i)\<^sup>2)" + with True have *: "(\i\I. a i * b i) = r * (\i\I. (b i)\<^sup>2)" + by simp + have "0 \ (\i\I. (a i - r * b i)\<^sup>2)" + by (meson sum_nonneg zero_le_power2) + also have "... = (\i\I. (a i)\<^sup>2) - 2 * r * (\i\I. a i * b i) + r\<^sup>2 * (\i\I. (b i)\<^sup>2)" + by (simp add: algebra_simps power2_eq_square sum_distrib_left flip: sum.distrib) + also have "\ = (\i\I. (a i)\<^sup>2) - (\i\I. a i * b i) * r" + by (simp add: * power2_eq_square) + also have "\ = (\i\I. (a i)\<^sup>2) - ((\i\I. a i * b i))\<^sup>2 / (\i\I. (b i)\<^sup>2)" + by (simp add: r_def power2_eq_square) + finally have "0 \ (\i\I. (a i)\<^sup>2) - ((\i\I. a i * b i))\<^sup>2 / (\i\I. (b i)\<^sup>2)" . + hence "((\i\I. a i * b i))\<^sup>2 / (\i\I. (b i)\<^sup>2) \ (\i\I. (a i)\<^sup>2)" + by (simp add: le_diff_eq) + thus "((\i\I. a i * b i))\<^sup>2 \ (\i\I. (a i)\<^sup>2) * (\i\I. (b i)\<^sup>2)" + by (simp add: pos_divide_le_eq True) +qed + +subsection \Misc related lemmas\ + lemma convex_translation_eq [simp]: "convex ((+) a ` s) \ convex s" by (metis convex_translation translation_galois) @@ -1016,9 +1090,6 @@ shows "\linear f; inj f\ \ convex (f ` s) \ convex s" by (metis (no_types) convex_linear_image convex_linear_vimage inj_vimage_image_eq) -lemma fst_snd_linear: "linear (\(x,y). x + y)" - unfolding linear_iff by (simp add: algebra_simps) - lemma vector_choose_size: assumes "0 \ c" obtains x :: "'a::{real_normed_vector, perfect_space}" where "norm x = c" @@ -1045,18 +1116,6 @@ unfolding * using sum.delta[OF assms, of y "\x. f x *\<^sub>R x"] by auto qed -lemma dist_triangle_eq: - fixes x y z :: "'a::real_inner" - shows "dist x z = dist x y + dist y z \ - norm (x - y) *\<^sub>R (y - z) = norm (y - z) *\<^sub>R (x - y)" -proof - - have *: "x - y + (y - z) = x - z" by auto - show ?thesis unfolding dist_norm norm_triangle_eq[of "x - y" "y - z", unfolded *] - by (auto simp:norm_minus_commute) -qed - - - subsection \Cones\ diff -r 58ae06d382ee -r 25f5f1fa31bb src/HOL/Analysis/Linear_Algebra.thy --- a/src/HOL/Analysis/Linear_Algebra.thy Sun Nov 07 23:35:11 2021 +0100 +++ b/src/HOL/Analysis/Linear_Algebra.thy Mon Nov 08 09:31:26 2021 +0000 @@ -1143,6 +1143,15 @@ finally show ?thesis . qed +lemma dist_triangle_eq: + fixes x y z :: "'a::real_inner" + shows "dist x z = dist x y + dist y z \ + norm (x - y) *\<^sub>R (y - z) = norm (y - z) *\<^sub>R (x - y)" +proof - + have *: "x - y + (y - z) = x - z" by auto + show ?thesis unfolding dist_norm norm_triangle_eq[of "x - y" "y - z", unfolded *] + by (auto simp:norm_minus_commute) +qed subsection \Collinearity\ diff -r 58ae06d382ee -r 25f5f1fa31bb src/HOL/Analysis/Starlike.thy --- a/src/HOL/Analysis/Starlike.thy Sun Nov 07 23:35:11 2021 +0100 +++ b/src/HOL/Analysis/Starlike.thy Mon Nov 08 09:31:26 2021 +0000 @@ -2398,6 +2398,9 @@ by (intro closure_bounded_linear_image_subset bounded_linear_add bounded_linear_fst bounded_linear_snd) +lemma fst_snd_linear: "linear (\(x,y). x + y)" + unfolding linear_iff by (simp add: algebra_simps) + lemma rel_interior_sum: fixes S T :: "'n::euclidean_space set" assumes "convex S"