src/HOL/Analysis/Convex.thy
changeset 71244 38457af660bc
parent 71242 ec5090faf541
child 72385 4a2c0eb482aa
equal deleted inserted replaced
71243:5b7c85586eb1 71244:38457af660bc
   558 proof -
   558 proof -
   559   have "(\<lambda>x. a + c *\<^sub>R x) ` S = (+) a ` (*\<^sub>R) c ` S"
   559   have "(\<lambda>x. a + c *\<^sub>R x) ` S = (+) a ` (*\<^sub>R) c ` S"
   560     by auto
   560     by auto
   561   then show ?thesis
   561   then show ?thesis
   562     using convex_translation[OF convex_scaling[OF assms], of a c] by auto
   562     using convex_translation[OF convex_scaling[OF assms], of a c] by auto
   563 qed
       
   564 
       
   565 lemma pos_is_convex: "convex {0 :: real <..}"
       
   566   unfolding convex_alt
       
   567 proof safe
       
   568   fix y x \<mu> :: real
       
   569   assume *: "y > 0" "x > 0" "\<mu> \<ge> 0" "\<mu> \<le> 1"
       
   570   {
       
   571     assume "\<mu> = 0"
       
   572     then have "\<mu> *\<^sub>R x + (1 - \<mu>) *\<^sub>R y = y"
       
   573       by simp
       
   574     then have "\<mu> *\<^sub>R x + (1 - \<mu>) *\<^sub>R y > 0"
       
   575       using * by simp
       
   576   }
       
   577   moreover
       
   578   {
       
   579     assume "\<mu> = 1"
       
   580     then have "\<mu> *\<^sub>R x + (1 - \<mu>) *\<^sub>R y > 0"
       
   581       using * by simp
       
   582   }
       
   583   moreover
       
   584   {
       
   585     assume "\<mu> \<noteq> 1" "\<mu> \<noteq> 0"
       
   586     then have "\<mu> > 0" "(1 - \<mu>) > 0"
       
   587       using * by auto
       
   588     then have "\<mu> *\<^sub>R x + (1 - \<mu>) *\<^sub>R y > 0"
       
   589       using * by (auto simp: add_pos_pos)
       
   590   }
       
   591   ultimately show "(1 - \<mu>) *\<^sub>R y + \<mu> *\<^sub>R x > 0"
       
   592     by fastforce
       
   593 qed
   563 qed
   594 
   564 
   595 lemma convex_on_sum:
   565 lemma convex_on_sum:
   596   fixes a :: "'a \<Rightarrow> real"
   566   fixes a :: "'a \<Rightarrow> real"
   597     and y :: "'a \<Rightarrow> 'b::real_vector"
   567     and y :: "'a \<Rightarrow> 'b::real_vector"
   921   then have f''0: "\<And>z::real. z > 0 \<Longrightarrow>
   891   then have f''0: "\<And>z::real. z > 0 \<Longrightarrow>
   922     DERIV (\<lambda> z. - 1 / (ln b * z)) z :> 1 / (ln b * z * z)"
   892     DERIV (\<lambda> z. - 1 / (ln b * z)) z :> 1 / (ln b * z * z)"
   923     unfolding inverse_eq_divide by (auto simp: mult.assoc)
   893     unfolding inverse_eq_divide by (auto simp: mult.assoc)
   924   have f''_ge0: "\<And>z::real. z > 0 \<Longrightarrow> 1 / (ln b * z * z) \<ge> 0"
   894   have f''_ge0: "\<And>z::real. z > 0 \<Longrightarrow> 1 / (ln b * z * z) \<ge> 0"
   925     using \<open>b > 1\<close> by (auto intro!: less_imp_le)
   895     using \<open>b > 1\<close> by (auto intro!: less_imp_le)
   926   from f''_ge0_imp_convex[OF pos_is_convex, unfolded greaterThan_iff, OF f' f''0 f''_ge0]
   896   from f''_ge0_imp_convex[OF convex_real_interval(3), unfolded greaterThan_iff, OF f' f''0 f''_ge0]
   927   show ?thesis
   897   show ?thesis
   928     by auto
   898     by auto
   929 qed
   899 qed
   930 
   900 
   931 
   901 
  1046 
  1016 
  1047 lemma convex_linear_image_eq [simp]:
  1017 lemma convex_linear_image_eq [simp]:
  1048     fixes f :: "'a::real_vector \<Rightarrow> 'b::real_vector"
  1018     fixes f :: "'a::real_vector \<Rightarrow> 'b::real_vector"
  1049     shows "\<lbrakk>linear f; inj f\<rbrakk> \<Longrightarrow> convex (f ` s) \<longleftrightarrow> convex s"
  1019     shows "\<lbrakk>linear f; inj f\<rbrakk> \<Longrightarrow> convex (f ` s) \<longleftrightarrow> convex s"
  1050     by (metis (no_types) convex_linear_image convex_linear_vimage inj_vimage_image_eq)
  1020     by (metis (no_types) convex_linear_image convex_linear_vimage inj_vimage_image_eq)
  1051 
       
  1052 lemma fst_linear: "linear fst"
       
  1053   unfolding linear_iff by (simp add: algebra_simps)
       
  1054 
       
  1055 lemma snd_linear: "linear snd"
       
  1056   unfolding linear_iff by (simp add: algebra_simps)
       
  1057 
  1021 
  1058 lemma fst_snd_linear: "linear (\<lambda>(x,y). x + y)"
  1022 lemma fst_snd_linear: "linear (\<lambda>(x,y). x + y)"
  1059   unfolding linear_iff by (simp add: algebra_simps)
  1023   unfolding linear_iff by (simp add: algebra_simps)
  1060 
  1024 
  1061 lemma vector_choose_size:
  1025 lemma vector_choose_size:
  1281     unfolding convex_def cone_def by blast
  1245     unfolding convex_def cone_def by blast
  1282 qed
  1246 qed
  1283 
  1247 
  1284 
  1248 
  1285 subsection\<^marker>\<open>tag unimportant\<close> \<open>Connectedness of convex sets\<close>
  1249 subsection\<^marker>\<open>tag unimportant\<close> \<open>Connectedness of convex sets\<close>
  1286 
       
  1287 lemma connectedD:
       
  1288   "connected S \<Longrightarrow> open A \<Longrightarrow> open B \<Longrightarrow> S \<subseteq> A \<union> B \<Longrightarrow> A \<inter> B \<inter> S = {} \<Longrightarrow> A \<inter> S = {} \<or> B \<inter> S = {}"
       
  1289   by (rule Topological_Spaces.topological_space_class.connectedD)
       
  1290 
  1250 
  1291 lemma convex_connected:
  1251 lemma convex_connected:
  1292   fixes S :: "'a::real_normed_vector set"
  1252   fixes S :: "'a::real_normed_vector set"
  1293   assumes "convex S"
  1253   assumes "convex S"
  1294   shows "connected S"
  1254   shows "connected S"