| author | wenzelm | 
| Sun, 24 Sep 2023 15:07:40 +0200 | |
| changeset 78688 | ff7db9055002 | 
| parent 78656 | 4da1e18a9633 | 
| child 79532 | bb5d036f3523 | 
| permissions | -rw-r--r-- | 
| 70086 
72c52a897de2
First tranche of the Homology development: Simplices
 paulson <lp15@cam.ac.uk> parents: 
69802diff
changeset | 1 | (* Title: HOL/Analysis/Convex.thy | 
| 69619 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 2 | Author: L C Paulson, University of Cambridge | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 3 | Author: Robert Himmelmann, TU Muenchen | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 4 | Author: Bogdan Grechuk, University of Edinburgh | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 5 | Author: Armin Heller, TU Muenchen | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 6 | Author: Johannes Hoelzl, TU Muenchen | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 7 | *) | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 8 | |
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 9 | section \<open>Convex Sets and Functions\<close> | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 10 | |
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 11 | theory Convex | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 12 | imports | 
| 71242 | 13 | Affine | 
| 69619 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 14 | "HOL-Library.Set_Algebras" | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 15 | begin | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 16 | |
| 71044 | 17 | subsection \<open>Convex Sets\<close> | 
| 69619 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 18 | |
| 70136 | 19 | definition\<^marker>\<open>tag important\<close> convex :: "'a::real_vector set \<Rightarrow> bool" | 
| 69619 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 20 | where "convex s \<longleftrightarrow> (\<forall>x\<in>s. \<forall>y\<in>s. \<forall>u\<ge>0. \<forall>v\<ge>0. u + v = 1 \<longrightarrow> u *\<^sub>R x + v *\<^sub>R y \<in> s)" | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 21 | |
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 22 | lemma convexI: | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 23 | assumes "\<And>x y u v. x \<in> s \<Longrightarrow> y \<in> s \<Longrightarrow> 0 \<le> u \<Longrightarrow> 0 \<le> v \<Longrightarrow> u + v = 1 \<Longrightarrow> u *\<^sub>R x + v *\<^sub>R y \<in> s" | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 24 | shows "convex s" | 
| 78475 | 25 | by (simp add: assms convex_def) | 
| 69619 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 26 | |
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 27 | lemma convexD: | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 28 | assumes "convex s" and "x \<in> s" and "y \<in> s" and "0 \<le> u" and "0 \<le> v" and "u + v = 1" | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 29 | shows "u *\<^sub>R x + v *\<^sub>R y \<in> s" | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 30 | using assms unfolding convex_def by fast | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 31 | |
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 32 | lemma convex_alt: "convex s \<longleftrightarrow> (\<forall>x\<in>s. \<forall>y\<in>s. \<forall>u. 0 \<le> u \<and> u \<le> 1 \<longrightarrow> ((1 - u) *\<^sub>R x + u *\<^sub>R y) \<in> s)" | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 33 | (is "_ \<longleftrightarrow> ?alt") | 
| 78475 | 34 | by (smt (verit) convexD convexI) | 
| 69619 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 35 | |
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 36 | lemma convexD_alt: | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 37 | assumes "convex s" "a \<in> s" "b \<in> s" "0 \<le> u" "u \<le> 1" | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 38 | shows "((1 - u) *\<^sub>R a + u *\<^sub>R b) \<in> s" | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 39 | using assms unfolding convex_alt by auto | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 40 | |
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 41 | lemma mem_convex_alt: | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 42 | assumes "convex S" "x \<in> S" "y \<in> S" "u \<ge> 0" "v \<ge> 0" "u + v > 0" | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 43 | shows "((u/(u+v)) *\<^sub>R x + (v/(u+v)) *\<^sub>R y) \<in> S" | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 44 | using assms | 
| 72385 | 45 | by (simp add: convex_def zero_le_divide_iff add_divide_distrib [symmetric]) | 
| 69619 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 46 | |
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 47 | lemma convex_empty[intro,simp]: "convex {}"
 | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 48 | unfolding convex_def by simp | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 49 | |
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 50 | lemma convex_singleton[intro,simp]: "convex {a}"
 | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 51 | unfolding convex_def by (auto simp: scaleR_left_distrib[symmetric]) | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 52 | |
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 53 | lemma convex_UNIV[intro,simp]: "convex UNIV" | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 54 | unfolding convex_def by auto | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 55 | |
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 56 | lemma convex_Inter: "(\<And>s. s\<in>f \<Longrightarrow> convex s) \<Longrightarrow> convex(\<Inter>f)" | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 57 | unfolding convex_def by auto | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 58 | |
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 59 | lemma convex_Int: "convex s \<Longrightarrow> convex t \<Longrightarrow> convex (s \<inter> t)" | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 60 | unfolding convex_def by auto | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 61 | |
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 62 | lemma convex_INT: "(\<And>i. i \<in> A \<Longrightarrow> convex (B i)) \<Longrightarrow> convex (\<Inter>i\<in>A. B i)" | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 63 | unfolding convex_def by auto | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 64 | |
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 65 | lemma convex_Times: "convex s \<Longrightarrow> convex t \<Longrightarrow> convex (s \<times> t)" | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 66 | unfolding convex_def by auto | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 67 | |
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 68 | lemma convex_halfspace_le: "convex {x. inner a x \<le> b}"
 | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 69 | unfolding convex_def | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 70 | by (auto simp: inner_add intro!: convex_bound_le) | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 71 | |
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 72 | lemma convex_halfspace_ge: "convex {x. inner a x \<ge> b}"
 | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 73 | proof - | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 74 |   have *: "{x. inner a x \<ge> b} = {x. inner (-a) x \<le> -b}"
 | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 75 | by auto | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 76 | show ?thesis | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 77 | unfolding * using convex_halfspace_le[of "-a" "-b"] by auto | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 78 | qed | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 79 | |
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 80 | lemma convex_halfspace_abs_le: "convex {x. \<bar>inner a x\<bar> \<le> b}"
 | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 81 | proof - | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 82 |   have *: "{x. \<bar>inner a x\<bar> \<le> b} = {x. inner a x \<le> b} \<inter> {x. -b \<le> inner a x}"
 | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 83 | by auto | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 84 | show ?thesis | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 85 | unfolding * by (simp add: convex_Int convex_halfspace_ge convex_halfspace_le) | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 86 | qed | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 87 | |
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 88 | lemma convex_hyperplane: "convex {x. inner a x = b}"
 | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 89 | proof - | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 90 |   have *: "{x. inner a x = b} = {x. inner a x \<le> b} \<inter> {x. inner a x \<ge> b}"
 | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 91 | by auto | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 92 | show ?thesis using convex_halfspace_le convex_halfspace_ge | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 93 | by (auto intro!: convex_Int simp: *) | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 94 | qed | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 95 | |
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 96 | lemma convex_halfspace_lt: "convex {x. inner a x < b}"
 | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 97 | unfolding convex_def | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 98 | by (auto simp: convex_bound_lt inner_add) | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 99 | |
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 100 | lemma convex_halfspace_gt: "convex {x. inner a x > b}"
 | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 101 | using convex_halfspace_lt[of "-a" "-b"] by auto | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 102 | |
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 103 | lemma convex_halfspace_Re_ge: "convex {x. Re x \<ge> b}"
 | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 104 | using convex_halfspace_ge[of b "1::complex"] by simp | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 105 | |
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 106 | lemma convex_halfspace_Re_le: "convex {x. Re x \<le> b}"
 | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 107 | using convex_halfspace_le[of "1::complex" b] by simp | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 108 | |
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 109 | lemma convex_halfspace_Im_ge: "convex {x. Im x \<ge> b}"
 | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 110 | using convex_halfspace_ge[of b \<i>] by simp | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 111 | |
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 112 | lemma convex_halfspace_Im_le: "convex {x. Im x \<le> b}"
 | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 113 | using convex_halfspace_le[of \<i> b] by simp | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 114 | |
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 115 | lemma convex_halfspace_Re_gt: "convex {x. Re x > b}"
 | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 116 | using convex_halfspace_gt[of b "1::complex"] by simp | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 117 | |
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 118 | lemma convex_halfspace_Re_lt: "convex {x. Re x < b}"
 | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 119 | using convex_halfspace_lt[of "1::complex" b] by simp | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 120 | |
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 121 | lemma convex_halfspace_Im_gt: "convex {x. Im x > b}"
 | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 122 | using convex_halfspace_gt[of b \<i>] by simp | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 123 | |
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 124 | lemma convex_halfspace_Im_lt: "convex {x. Im x < b}"
 | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 125 | using convex_halfspace_lt[of \<i> b] by simp | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 126 | |
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 127 | lemma convex_real_interval [iff]: | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 128 | fixes a b :: "real" | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 129 |   shows "convex {a..}" and "convex {..b}"
 | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 130 |     and "convex {a<..}" and "convex {..<b}"
 | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 131 |     and "convex {a..b}" and "convex {a<..b}"
 | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 132 |     and "convex {a..<b}" and "convex {a<..<b}"
 | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 133 | proof - | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 134 |   have "{a..} = {x. a \<le> inner 1 x}"
 | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 135 | by auto | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 136 |   then show 1: "convex {a..}"
 | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 137 | by (simp only: convex_halfspace_ge) | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 138 |   have "{..b} = {x. inner 1 x \<le> b}"
 | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 139 | by auto | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 140 |   then show 2: "convex {..b}"
 | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 141 | by (simp only: convex_halfspace_le) | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 142 |   have "{a<..} = {x. a < inner 1 x}"
 | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 143 | by auto | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 144 |   then show 3: "convex {a<..}"
 | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 145 | by (simp only: convex_halfspace_gt) | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 146 |   have "{..<b} = {x. inner 1 x < b}"
 | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 147 | by auto | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 148 |   then show 4: "convex {..<b}"
 | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 149 | by (simp only: convex_halfspace_lt) | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 150 |   have "{a..b} = {a..} \<inter> {..b}"
 | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 151 | by auto | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 152 |   then show "convex {a..b}"
 | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 153 | by (simp only: convex_Int 1 2) | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 154 |   have "{a<..b} = {a<..} \<inter> {..b}"
 | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 155 | by auto | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 156 |   then show "convex {a<..b}"
 | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 157 | by (simp only: convex_Int 3 2) | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 158 |   have "{a..<b} = {a..} \<inter> {..<b}"
 | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 159 | by auto | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 160 |   then show "convex {a..<b}"
 | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 161 | by (simp only: convex_Int 1 4) | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 162 |   have "{a<..<b} = {a<..} \<inter> {..<b}"
 | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 163 | by auto | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 164 |   then show "convex {a<..<b}"
 | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 165 | by (simp only: convex_Int 3 4) | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 166 | qed | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 167 | |
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 168 | lemma convex_Reals: "convex \<real>" | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 169 | by (simp add: convex_def scaleR_conv_of_real) | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 170 | |
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 171 | |
| 70136 | 172 | subsection\<^marker>\<open>tag unimportant\<close> \<open>Explicit expressions for convexity in terms of arbitrary sums\<close> | 
| 69619 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 173 | |
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 174 | lemma convex_sum: | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 175 | fixes C :: "'a::real_vector set" | 
| 72385 | 176 | assumes "finite S" | 
| 69619 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 177 | and "convex C" | 
| 78475 | 178 | and a: "(\<Sum> i \<in> S. a i) = 1" "\<And>i. i \<in> S \<Longrightarrow> a i \<ge> 0" | 
| 179 | and C: "\<And>i. i \<in> S \<Longrightarrow> y i \<in> C" | |
| 72385 | 180 | shows "(\<Sum> j \<in> S. a j *\<^sub>R y j) \<in> C" | 
| 78475 | 181 | using \<open>finite S\<close> a C | 
| 182 | proof (induction arbitrary: a set: finite) | |
| 69619 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 183 | case empty | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 184 | then show ?case by simp | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 185 | next | 
| 78475 | 186 | case (insert i S) | 
| 72385 | 187 | then have "0 \<le> sum a S" | 
| 69619 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 188 | by (simp add: sum_nonneg) | 
| 72385 | 189 | have "a i *\<^sub>R y i + (\<Sum>j\<in>S. a j *\<^sub>R y j) \<in> C" | 
| 190 | proof (cases "sum a S = 0") | |
| 78475 | 191 | case True with insert show ?thesis | 
| 192 | by (simp add: sum_nonneg_eq_0_iff) | |
| 69619 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 193 | next | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 194 | case False | 
| 72385 | 195 | with \<open>0 \<le> sum a S\<close> have "0 < sum a S" | 
| 69619 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 196 | by simp | 
| 72385 | 197 | then have "(\<Sum>j\<in>S. (a j / sum a S) *\<^sub>R y j) \<in> C" | 
| 78475 | 198 | using insert | 
| 199 | by (simp add: insert.IH flip: sum_divide_distrib) | |
| 200 | with \<open>convex C\<close> insert \<open>0 \<le> sum a S\<close> | |
| 72385 | 201 | have "a i *\<^sub>R y i + sum a S *\<^sub>R (\<Sum>j\<in>S. (a j / sum a S) *\<^sub>R y j) \<in> C" | 
| 78475 | 202 | by (simp add: convex_def) | 
| 69619 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 203 | then show ?thesis | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 204 | by (simp add: scaleR_sum_right False) | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 205 | qed | 
| 72385 | 206 | then show ?case using \<open>finite S\<close> and \<open>i \<notin> S\<close> | 
| 69619 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 207 | by simp | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 208 | qed | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 209 | |
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 210 | lemma convex: | 
| 78475 | 211 | "convex S \<longleftrightarrow> | 
| 212 |     (\<forall>(k::nat) u x. (\<forall>i. 1\<le>i \<and> i\<le>k \<longrightarrow> 0 \<le> u i \<and> x i \<in>S) \<and> (sum u {1..k} = 1)
 | |
| 213 |       \<longrightarrow> sum (\<lambda>i. u i *\<^sub>R x i) {1..k} \<in> S)"  
 | |
| 214 | (is "?lhs = ?rhs") | |
| 215 | proof | |
| 216 | show "?lhs \<Longrightarrow> ?rhs" | |
| 217 | by (metis (full_types) atLeastAtMost_iff convex_sum finite_atLeastAtMost) | |
| 72385 | 218 |   assume *: "\<forall>k u x. (\<forall> i :: nat. 1 \<le> i \<and> i \<le> k \<longrightarrow> 0 \<le> u i \<and> x i \<in> S) \<and> sum u {1..k} = 1
 | 
| 219 | \<longrightarrow> (\<Sum>i = 1..k. u i *\<^sub>R (x i :: 'a)) \<in> S" | |
| 69619 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 220 |   {
 | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 221 | fix \<mu> :: real | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 222 | fix x y :: 'a | 
| 72385 | 223 | assume xy: "x \<in> S" "y \<in> S" | 
| 69619 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 224 | assume mu: "\<mu> \<ge> 0" "\<mu> \<le> 1" | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 225 | let ?u = "\<lambda>i. if (i :: nat) = 1 then \<mu> else 1 - \<mu>" | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 226 | let ?x = "\<lambda>i. if (i :: nat) = 1 then x else y" | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 227 |     have "{1 :: nat .. 2} \<inter> - {x. x = 1} = {2}"
 | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 228 | by auto | 
| 78475 | 229 |     then have S: "(\<Sum>j \<in> {1..2}. ?u j *\<^sub>R ?x j) \<in> S"
 | 
| 230 |       using sum.If_cases[of "{(1 :: nat) .. 2}" "\<lambda>x. x = 1" "\<lambda>x. \<mu>" "\<lambda>x. 1 - \<mu>"]
 | |
| 231 | using mu xy "*" by auto | |
| 69619 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 232 |     have grarr: "(\<Sum>j \<in> {Suc (Suc 0)..2}. ?u j *\<^sub>R ?x j) = (1 - \<mu>) *\<^sub>R y"
 | 
| 70097 
4005298550a6
The last big tranche of Homology material: invariance of domain; renamings to use generic sum/prod lemmas from their locale
 paulson <lp15@cam.ac.uk> parents: 
70086diff
changeset | 233 | using sum.atLeast_Suc_atMost[of "Suc (Suc 0)" 2 "\<lambda> j. (1 - \<mu>) *\<^sub>R y"] by auto | 
| 78475 | 234 | with sum.atLeast_Suc_atMost | 
| 69619 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 235 |     have "(\<Sum>j \<in> {1..2}. ?u j *\<^sub>R ?x j) = \<mu> *\<^sub>R x + (1 - \<mu>) *\<^sub>R y"
 | 
| 78475 | 236 | by (smt (verit, best) Suc_1 Suc_eq_plus1 add_0 le_add1) | 
| 72385 | 237 | then have "(1 - \<mu>) *\<^sub>R y + \<mu> *\<^sub>R x \<in> S" | 
| 238 | using S by (auto simp: add.commute) | |
| 69619 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 239 | } | 
| 72385 | 240 | then show "convex S" | 
| 69619 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 241 | unfolding convex_alt by auto | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 242 | qed | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 243 | |
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 244 | |
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 245 | lemma convex_explicit: | 
| 72385 | 246 | fixes S :: "'a::real_vector set" | 
| 247 | shows "convex S \<longleftrightarrow> | |
| 248 | (\<forall>t u. finite t \<and> t \<subseteq> S \<and> (\<forall>x\<in>t. 0 \<le> u x) \<and> sum u t = 1 \<longrightarrow> sum (\<lambda>x. u x *\<^sub>R x) t \<in> S)" | |
| 69619 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 249 | proof safe | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 250 | fix t | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 251 | fix u :: "'a \<Rightarrow> real" | 
| 72385 | 252 | assume "convex S" | 
| 69619 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 253 | and "finite t" | 
| 72385 | 254 | and "t \<subseteq> S" "\<forall>x\<in>t. 0 \<le> u x" "sum u t = 1" | 
| 255 | then show "(\<Sum>x\<in>t. u x *\<^sub>R x) \<in> S" | |
| 78475 | 256 | by (simp add: convex_sum subsetD) | 
| 69619 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 257 | next | 
| 72385 | 258 | assume *: "\<forall>t. \<forall> u. finite t \<and> t \<subseteq> S \<and> (\<forall>x\<in>t. 0 \<le> u x) \<and> | 
| 259 | sum u t = 1 \<longrightarrow> (\<Sum>x\<in>t. u x *\<^sub>R x) \<in> S" | |
| 260 | show "convex S" | |
| 69619 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 261 | unfolding convex_alt | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 262 | proof safe | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 263 | fix x y | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 264 | fix \<mu> :: real | 
| 72385 | 265 | assume **: "x \<in> S" "y \<in> S" "0 \<le> \<mu>" "\<mu> \<le> 1" | 
| 266 | show "(1 - \<mu>) *\<^sub>R x + \<mu> *\<^sub>R y \<in> S" | |
| 69619 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 267 | proof (cases "x = y") | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 268 | case False | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 269 | then show ?thesis | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 270 |         using *[rule_format, of "{x, y}" "\<lambda> z. if z = x then 1 - \<mu> else \<mu>"] **
 | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 271 | by auto | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 272 | next | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 273 | case True | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 274 | then show ?thesis | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 275 |         using *[rule_format, of "{x, y}" "\<lambda> z. 1"] **
 | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 276 | by (auto simp: field_simps real_vector.scale_left_diff_distrib) | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 277 | qed | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 278 | qed | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 279 | qed | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 280 | |
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 281 | lemma convex_finite: | 
| 72385 | 282 | assumes "finite S" | 
| 283 | shows "convex S \<longleftrightarrow> (\<forall>u. (\<forall>x\<in>S. 0 \<le> u x) \<and> sum u S = 1 \<longrightarrow> sum (\<lambda>x. u x *\<^sub>R x) S \<in> S)" | |
| 284 | (is "?lhs = ?rhs") | |
| 285 | proof | |
| 286 |   { have if_distrib_arg: "\<And>P f g x. (if P then f else g) x = (if P then f x else g x)"
 | |
| 69619 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 287 | by simp | 
| 72385 | 288 | fix T :: "'a set" and u :: "'a \<Rightarrow> real" | 
| 289 | assume sum: "\<forall>u. (\<forall>x\<in>S. 0 \<le> u x) \<and> sum u S = 1 \<longrightarrow> (\<Sum>x\<in>S. u x *\<^sub>R x) \<in> S" | |
| 290 | assume *: "\<forall>x\<in>T. 0 \<le> u x" "sum u T = 1" | |
| 291 | assume "T \<subseteq> S" | |
| 292 | then have "S \<inter> T = T" by auto | |
| 78475 | 293 | with sum[THEN spec[where x="\<lambda>x. if x\<in>T then u x else 0"]] * | 
| 294 | have "(\<Sum>x\<in>T. u x *\<^sub>R x) \<in> S" | |
| 72385 | 295 | by (auto simp: assms sum.If_cases if_distrib if_distrib_arg) } | 
| 296 | moreover assume ?rhs | |
| 297 | ultimately show ?lhs | |
| 298 | unfolding convex_explicit by auto | |
| 299 | qed (auto simp: convex_explicit assms) | |
| 69619 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 300 | |
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 301 | |
| 71044 | 302 | subsection \<open>Convex Functions on a Set\<close> | 
| 69619 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 303 | |
| 70136 | 304 | definition\<^marker>\<open>tag important\<close> convex_on :: "'a::real_vector set \<Rightarrow> ('a \<Rightarrow> real) \<Rightarrow> bool"
 | 
| 72385 | 305 | where "convex_on S f \<longleftrightarrow> | 
| 306 | (\<forall>x\<in>S. \<forall>y\<in>S. \<forall>u\<ge>0. \<forall>v\<ge>0. u + v = 1 \<longrightarrow> f (u *\<^sub>R x + v *\<^sub>R y) \<le> u * f x + v * f y)" | |
| 69619 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 307 | |
| 74729 
64b3d8d9bd10
new lemmas about convex, concave functions, + tidying
 paulson <lp15@cam.ac.uk> parents: 
72385diff
changeset | 308 | definition\<^marker>\<open>tag important\<close> concave_on :: "'a::real_vector set \<Rightarrow> ('a \<Rightarrow> real) \<Rightarrow> bool"
 | 
| 
64b3d8d9bd10
new lemmas about convex, concave functions, + tidying
 paulson <lp15@cam.ac.uk> parents: 
72385diff
changeset | 309 | where "concave_on S f \<equiv> convex_on S (\<lambda>x. - f x)" | 
| 
64b3d8d9bd10
new lemmas about convex, concave functions, + tidying
 paulson <lp15@cam.ac.uk> parents: 
72385diff
changeset | 310 | |
| 
64b3d8d9bd10
new lemmas about convex, concave functions, + tidying
 paulson <lp15@cam.ac.uk> parents: 
72385diff
changeset | 311 | lemma concave_on_iff: | 
| 
64b3d8d9bd10
new lemmas about convex, concave functions, + tidying
 paulson <lp15@cam.ac.uk> parents: 
72385diff
changeset | 312 | "concave_on S f \<longleftrightarrow> | 
| 
64b3d8d9bd10
new lemmas about convex, concave functions, + tidying
 paulson <lp15@cam.ac.uk> parents: 
72385diff
changeset | 313 | (\<forall>x\<in>S. \<forall>y\<in>S. \<forall>u\<ge>0. \<forall>v\<ge>0. u + v = 1 \<longrightarrow> f (u *\<^sub>R x + v *\<^sub>R y) \<ge> u * f x + v * f y)" | 
| 
64b3d8d9bd10
new lemmas about convex, concave functions, + tidying
 paulson <lp15@cam.ac.uk> parents: 
72385diff
changeset | 314 | by (auto simp: concave_on_def convex_on_def algebra_simps) | 
| 
64b3d8d9bd10
new lemmas about convex, concave functions, + tidying
 paulson <lp15@cam.ac.uk> parents: 
72385diff
changeset | 315 | |
| 69619 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 316 | lemma convex_onI [intro?]: | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 317 | assumes "\<And>t x y. t > 0 \<Longrightarrow> t < 1 \<Longrightarrow> x \<in> A \<Longrightarrow> y \<in> A \<Longrightarrow> | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 318 | f ((1 - t) *\<^sub>R x + t *\<^sub>R y) \<le> (1 - t) * f x + t * f y" | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 319 | shows "convex_on A f" | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 320 | unfolding convex_on_def | 
| 78475 | 321 | by (smt (verit, del_insts) assms mult_cancel_right1 mult_eq_0_iff scaleR_collapse scaleR_eq_0_iff) | 
| 69619 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 322 | |
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 323 | lemma convex_on_linorderI [intro?]: | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 324 |   fixes A :: "('a::{linorder,real_vector}) set"
 | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 325 | assumes "\<And>t x y. t > 0 \<Longrightarrow> t < 1 \<Longrightarrow> x \<in> A \<Longrightarrow> y \<in> A \<Longrightarrow> x < y \<Longrightarrow> | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 326 | f ((1 - t) *\<^sub>R x + t *\<^sub>R y) \<le> (1 - t) * f x + t * f y" | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 327 | shows "convex_on A f" | 
| 78475 | 328 | by (smt (verit, best) add.commute assms convex_onI distrib_left linorder_cases mult.commute mult_cancel_left2 scaleR_collapse) | 
| 69619 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 329 | |
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 330 | lemma convex_onD: | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 331 | assumes "convex_on A f" | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 332 | shows "\<And>t x y. t \<ge> 0 \<Longrightarrow> t \<le> 1 \<Longrightarrow> x \<in> A \<Longrightarrow> y \<in> A \<Longrightarrow> | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 333 | f ((1 - t) *\<^sub>R x + t *\<^sub>R y) \<le> (1 - t) * f x + t * f y" | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 334 | using assms by (auto simp: convex_on_def) | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 335 | |
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 336 | lemma convex_onD_Icc: | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 337 |   assumes "convex_on {x..y} f" "x \<le> (y :: _ :: {real_vector,preorder})"
 | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 338 | shows "\<And>t. t \<ge> 0 \<Longrightarrow> t \<le> 1 \<Longrightarrow> | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 339 | f ((1 - t) *\<^sub>R x + t *\<^sub>R y) \<le> (1 - t) * f x + t * f y" | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 340 | using assms(2) by (intro convex_onD [OF assms(1)]) simp_all | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 341 | |
| 72385 | 342 | lemma convex_on_subset: "convex_on t f \<Longrightarrow> S \<subseteq> t \<Longrightarrow> convex_on S f" | 
| 69619 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 343 | unfolding convex_on_def by auto | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 344 | |
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 345 | lemma convex_on_add [intro]: | 
| 72385 | 346 | assumes "convex_on S f" | 
| 347 | and "convex_on S g" | |
| 348 | shows "convex_on S (\<lambda>x. f x + g x)" | |
| 69619 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 349 | proof - | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 350 |   {
 | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 351 | fix x y | 
| 72385 | 352 | assume "x \<in> S" "y \<in> S" | 
| 69619 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 353 | moreover | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 354 | fix u v :: real | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 355 | assume "0 \<le> u" "0 \<le> v" "u + v = 1" | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 356 | ultimately | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 357 | have "f (u *\<^sub>R x + v *\<^sub>R y) + g (u *\<^sub>R x + v *\<^sub>R y) \<le> (u * f x + v * f y) + (u * g x + v * g y)" | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 358 | using assms unfolding convex_on_def by (auto simp: add_mono) | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 359 | then have "f (u *\<^sub>R x + v *\<^sub>R y) + g (u *\<^sub>R x + v *\<^sub>R y) \<le> u * (f x + g x) + v * (f y + g y)" | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 360 | by (simp add: field_simps) | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 361 | } | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 362 | then show ?thesis | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 363 | unfolding convex_on_def by auto | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 364 | qed | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 365 | |
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 366 | lemma convex_on_cmul [intro]: | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 367 | fixes c :: real | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 368 | assumes "0 \<le> c" | 
| 72385 | 369 | and "convex_on S f" | 
| 370 | shows "convex_on S (\<lambda>x. c * f x)" | |
| 69619 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 371 | proof - | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 372 | have *: "u * (c * fx) + v * (c * fy) = c * (u * fx + v * fy)" | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 373 | for u c fx v fy :: real | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 374 | by (simp add: field_simps) | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 375 | show ?thesis using assms(2) and mult_left_mono [OF _ assms(1)] | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 376 | unfolding convex_on_def and * by auto | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 377 | qed | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 378 | |
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 379 | lemma convex_lower: | 
| 72385 | 380 | assumes "convex_on S f" | 
| 381 | and "x \<in> S" | |
| 382 | and "y \<in> S" | |
| 69619 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 383 | and "0 \<le> u" | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 384 | and "0 \<le> v" | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 385 | and "u + v = 1" | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 386 | shows "f (u *\<^sub>R x + v *\<^sub>R y) \<le> max (f x) (f y)" | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 387 | proof - | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 388 | let ?m = "max (f x) (f y)" | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 389 | have "u * f x + v * f y \<le> u * max (f x) (f y) + v * max (f x) (f y)" | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 390 | using assms(4,5) by (auto simp: mult_left_mono add_mono) | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 391 | also have "\<dots> = max (f x) (f y)" | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 392 | using assms(6) by (simp add: distrib_right [symmetric]) | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 393 | finally show ?thesis | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 394 | using assms unfolding convex_on_def by fastforce | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 395 | qed | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 396 | |
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 397 | lemma convex_on_dist [intro]: | 
| 72385 | 398 | fixes S :: "'a::real_normed_vector set" | 
| 399 | shows "convex_on S (\<lambda>x. dist a x)" | |
| 78475 | 400 | proof (clarsimp simp: convex_on_def dist_norm) | 
| 69619 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 401 | fix x y | 
| 72385 | 402 | assume "x \<in> S" "y \<in> S" | 
| 69619 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 403 | fix u v :: real | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 404 | assume "0 \<le> u" | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 405 | assume "0 \<le> v" | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 406 | assume "u + v = 1" | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 407 | have "a = u *\<^sub>R a + v *\<^sub>R a" | 
| 78475 | 408 | by (metis \<open>u + v = 1\<close> scaleR_left.add scaleR_one) | 
| 409 | then have "a - (u *\<^sub>R x + v *\<^sub>R y) = (u *\<^sub>R (a - x)) + (v *\<^sub>R (a - y))" | |
| 69619 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 410 | by (auto simp: algebra_simps) | 
| 78475 | 411 | then show "norm (a - (u *\<^sub>R x + v *\<^sub>R y)) \<le> u * norm (a - x) + v * norm (a - y)" | 
| 412 | by (smt (verit, best) \<open>0 \<le> u\<close> \<open>0 \<le> v\<close> norm_scaleR norm_triangle_ineq) | |
| 69619 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 413 | qed | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 414 | |
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 415 | |
| 70136 | 416 | subsection\<^marker>\<open>tag unimportant\<close> \<open>Arithmetic operations on sets preserve convexity\<close> | 
| 69619 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 417 | |
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 418 | lemma convex_linear_image: | 
| 78475 | 419 | assumes "linear f" and "convex S" | 
| 72385 | 420 | shows "convex (f ` S)" | 
| 69619 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 421 | proof - | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 422 | interpret f: linear f by fact | 
| 72385 | 423 | from \<open>convex S\<close> show "convex (f ` S)" | 
| 69619 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 424 | by (simp add: convex_def f.scaleR [symmetric] f.add [symmetric]) | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 425 | qed | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 426 | |
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 427 | lemma convex_linear_vimage: | 
| 78475 | 428 | assumes "linear f" and "convex S" | 
| 72385 | 429 | shows "convex (f -` S)" | 
| 69619 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 430 | proof - | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 431 | interpret f: linear f by fact | 
| 72385 | 432 | from \<open>convex S\<close> show "convex (f -` S)" | 
| 69619 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 433 | by (simp add: convex_def f.add f.scaleR) | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 434 | qed | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 435 | |
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 436 | lemma convex_scaling: | 
| 72385 | 437 | assumes "convex S" | 
| 438 | shows "convex ((\<lambda>x. c *\<^sub>R x) ` S)" | |
| 78475 | 439 | by (simp add: assms convex_linear_image) | 
| 69619 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 440 | |
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 441 | lemma convex_scaled: | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 442 | assumes "convex S" | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 443 | shows "convex ((\<lambda>x. x *\<^sub>R c) ` S)" | 
| 78475 | 444 | by (simp add: assms convex_linear_image) | 
| 69619 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 445 | |
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 446 | lemma convex_negations: | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 447 | assumes "convex S" | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 448 | shows "convex ((\<lambda>x. - x) ` S)" | 
| 78475 | 449 | by (simp add: assms convex_linear_image module_hom_uminus) | 
| 69619 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 450 | |
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 451 | lemma convex_sums: | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 452 | assumes "convex S" | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 453 | and "convex T" | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 454 |   shows "convex (\<Union>x\<in> S. \<Union>y \<in> T. {x + y})"
 | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 455 | proof - | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 456 | have "linear (\<lambda>(x, y). x + y)" | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 457 | by (auto intro: linearI simp: scaleR_add_right) | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 458 | with assms have "convex ((\<lambda>(x, y). x + y) ` (S \<times> T))" | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 459 | by (intro convex_linear_image convex_Times) | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 460 |   also have "((\<lambda>(x, y). x + y) ` (S \<times> T)) = (\<Union>x\<in> S. \<Union>y \<in> T. {x + y})"
 | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 461 | by auto | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 462 | finally show ?thesis . | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 463 | qed | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 464 | |
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 465 | lemma convex_differences: | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 466 | assumes "convex S" "convex T" | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 467 |   shows "convex (\<Union>x\<in> S. \<Union>y \<in> T. {x - y})"
 | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 468 | proof - | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 469 |   have "{x - y| x y. x \<in> S \<and> y \<in> T} = {x + y |x y. x \<in> S \<and> y \<in> uminus ` T}"
 | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 470 | by (auto simp: diff_conv_add_uminus simp del: add_uminus_conv_diff) | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 471 | then show ?thesis | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 472 | using convex_sums[OF assms(1) convex_negations[OF assms(2)]] by auto | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 473 | qed | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 474 | |
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 475 | lemma convex_translation: | 
| 69661 | 476 | "convex ((+) a ` S)" if "convex S" | 
| 69619 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 477 | proof - | 
| 69661 | 478 |   have "(\<Union> x\<in> {a}. \<Union>y \<in> S. {x + y}) = (+) a ` S"
 | 
| 69619 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 479 | by auto | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 480 | then show ?thesis | 
| 69661 | 481 | using convex_sums [OF convex_singleton [of a] that] by auto | 
| 69619 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 482 | qed | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 483 | |
| 69661 | 484 | lemma convex_translation_subtract: | 
| 485 | "convex ((\<lambda>b. b - a) ` S)" if "convex S" | |
| 486 | using convex_translation [of S "- a"] that by (simp cong: image_cong_simp) | |
| 487 | ||
| 69619 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 488 | lemma convex_affinity: | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 489 | assumes "convex S" | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 490 | shows "convex ((\<lambda>x. a + c *\<^sub>R x) ` S)" | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 491 | proof - | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 492 | have "(\<lambda>x. a + c *\<^sub>R x) ` S = (+) a ` (*\<^sub>R) c ` S" | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 493 | by auto | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 494 | then show ?thesis | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 495 | using convex_translation[OF convex_scaling[OF assms], of a c] by auto | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 496 | qed | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 497 | |
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 498 | lemma convex_on_sum: | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 499 | fixes a :: "'a \<Rightarrow> real" | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 500 | and y :: "'a \<Rightarrow> 'b::real_vector" | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 501 | and f :: "'b \<Rightarrow> real" | 
| 78475 | 502 |   assumes "finite S" "S \<noteq> {}"
 | 
| 69619 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 503 | and "convex_on C f" | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 504 | and "convex C" | 
| 78475 | 505 | and "(\<Sum> i \<in> S. a i) = 1" | 
| 506 | and "\<And>i. i \<in> S \<Longrightarrow> a i \<ge> 0" | |
| 507 | and "\<And>i. i \<in> S \<Longrightarrow> y i \<in> C" | |
| 508 | shows "f (\<Sum> i \<in> S. a i *\<^sub>R y i) \<le> (\<Sum> i \<in> S. a i * f (y i))" | |
| 69619 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 509 | using assms | 
| 78475 | 510 | proof (induct S arbitrary: a rule: finite_ne_induct) | 
| 69619 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 511 | case (singleton i) | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 512 | then show ?case | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 513 | by auto | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 514 | next | 
| 78475 | 515 | case (insert i S) | 
| 516 | then have yai: "y i \<in> C" "a i \<ge> 0" | |
| 517 | by auto | |
| 518 | with insert have conv: "\<And>x y \<mu>. x \<in> C \<Longrightarrow> y \<in> C \<Longrightarrow> 0 \<le> \<mu> \<Longrightarrow> \<mu> \<le> 1 \<Longrightarrow> | |
| 69619 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 519 | f (\<mu> *\<^sub>R x + (1 - \<mu>) *\<^sub>R y) \<le> \<mu> * f x + (1 - \<mu>) * f y" | 
| 78475 | 520 | by (simp add: convex_on_def) | 
| 69619 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 521 | show ?case | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 522 | proof (cases "a i = 1") | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 523 | case True | 
| 78475 | 524 | with insert have "(\<Sum> j \<in> S. a j) = 0" | 
| 525 | by auto | |
| 526 | with insert show ?thesis | |
| 527 | by (simp add: sum_nonneg_eq_0_iff) | |
| 69619 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 528 | next | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 529 | case False | 
| 78475 | 530 | then have ai1: "a i < 1" | 
| 531 | using sum_nonneg_leq_bound[of "insert i S" a] insert by force | |
| 69619 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 532 | then have i0: "1 - a i > 0" | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 533 | by auto | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 534 | let ?a = "\<lambda>j. a j / (1 - a i)" | 
| 78475 | 535 | have a_nonneg: "?a j \<ge> 0" if "j \<in> S" for j | 
| 69619 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 536 | using i0 insert that by fastforce | 
| 78475 | 537 | have "(\<Sum> j \<in> insert i S. a j) = 1" | 
| 69619 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 538 | using insert by auto | 
| 78475 | 539 | then have "(\<Sum> j \<in> S. a j) = 1 - a i" | 
| 69619 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 540 | using sum.insert insert by fastforce | 
| 78475 | 541 | then have "(\<Sum> j \<in> S. a j) / (1 - a i) = 1" | 
| 69619 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 542 | using i0 by auto | 
| 78475 | 543 | then have a1: "(\<Sum> j \<in> S. ?a j) = 1" | 
| 544 | unfolding sum_divide_distrib by simp | |
| 545 | have asum: "(\<Sum> j \<in> S. ?a j *\<^sub>R y j) \<in> C" | |
| 546 | using insert convex_sum [OF \<open>finite S\<close> \<open>convex C\<close> a1 a_nonneg] by auto | |
| 547 | have asum_le: "f (\<Sum> j \<in> S. ?a j *\<^sub>R y j) \<le> (\<Sum> j \<in> S. ?a j * f (y j))" | |
| 548 | using a_nonneg a1 insert by blast | |
| 549 | have "f (\<Sum> j \<in> insert i S. a j *\<^sub>R y j) = f ((\<Sum> j \<in> S. a j *\<^sub>R y j) + a i *\<^sub>R y i)" | |
| 550 | by (simp add: add.commute insert.hyps) | |
| 551 | also have "\<dots> = f (((1 - a i) * inverse (1 - a i)) *\<^sub>R (\<Sum> j \<in> S. a j *\<^sub>R y j) + a i *\<^sub>R y i)" | |
| 552 | using i0 by auto | |
| 553 | also have "\<dots> = f ((1 - a i) *\<^sub>R (\<Sum> j \<in> S. (a j * inverse (1 - a i)) *\<^sub>R y j) + a i *\<^sub>R y i)" | |
| 554 | using scaleR_right.sum[of "inverse (1 - a i)" "\<lambda> j. a j *\<^sub>R y j" S, symmetric] | |
| 69619 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 555 | by (auto simp: algebra_simps) | 
| 78475 | 556 | also have "\<dots> = f ((1 - a i) *\<^sub>R (\<Sum> j \<in> S. ?a j *\<^sub>R y j) + a i *\<^sub>R y i)" | 
| 69619 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 557 | by (auto simp: divide_inverse) | 
| 78475 | 558 | also have "\<dots> \<le> (1 - a i) *\<^sub>R f ((\<Sum> j \<in> S. ?a j *\<^sub>R y j)) + a i * f (y i)" | 
| 559 | using ai1 by (smt (verit) asum conv real_scaleR_def yai) | |
| 560 | also have "\<dots> \<le> (1 - a i) * (\<Sum> j \<in> S. ?a j * f (y j)) + a i * f (y i)" | |
| 561 | using asum_le i0 by fastforce | |
| 562 | also have "\<dots> = (\<Sum> j \<in> S. a j * f (y j)) + a i * f (y i)" | |
| 563 | using i0 by (auto simp: sum_distrib_left) | |
| 564 | finally show ?thesis | |
| 69619 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 565 | using insert by auto | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 566 | qed | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 567 | qed | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 568 | |
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 569 | lemma convex_on_alt: | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 570 | fixes C :: "'a::real_vector set" | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 571 | shows "convex_on C f \<longleftrightarrow> | 
| 78475 | 572 | (\<forall>x \<in> C. \<forall>y \<in> C. \<forall> \<mu> :: real. \<mu> \<ge> 0 \<and> \<mu> \<le> 1 \<longrightarrow> | 
| 573 | f (\<mu> *\<^sub>R x + (1 - \<mu>) *\<^sub>R y) \<le> \<mu> * f x + (1 - \<mu>) * f y)" | |
| 574 | by (smt (verit) convex_on_def) | |
| 69619 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 575 | |
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 576 | lemma convex_on_diff: | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 577 | fixes f :: "real \<Rightarrow> real" | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 578 | assumes f: "convex_on I f" | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 579 | and I: "x \<in> I" "y \<in> I" | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 580 | and t: "x < t" "t < y" | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 581 | shows "(f x - f t) / (x - t) \<le> (f x - f y) / (x - y)" | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 582 | and "(f x - f y) / (x - y) \<le> (f t - f y) / (t - y)" | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 583 | proof - | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 584 | define a where "a \<equiv> (t - y) / (x - y)" | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 585 | with t have "0 \<le> a" "0 \<le> 1 - a" | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 586 | by (auto simp: field_simps) | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 587 | with f \<open>x \<in> I\<close> \<open>y \<in> I\<close> have cvx: "f (a * x + (1 - a) * y) \<le> a * f x + (1 - a) * f y" | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 588 | by (auto simp: convex_on_def) | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 589 | have "a * x + (1 - a) * y = a * (x - y) + y" | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 590 | by (simp add: field_simps) | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 591 | also have "\<dots> = t" | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 592 | unfolding a_def using \<open>x < t\<close> \<open>t < y\<close> by simp | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 593 | finally have "f t \<le> a * f x + (1 - a) * f y" | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 594 | using cvx by simp | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 595 | also have "\<dots> = a * (f x - f y) + f y" | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 596 | by (simp add: field_simps) | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 597 | finally have "f t - f y \<le> a * (f x - f y)" | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 598 | by simp | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 599 | with t show "(f x - f t) / (x - t) \<le> (f x - f y) / (x - y)" | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 600 | by (simp add: le_divide_eq divide_le_eq field_simps a_def) | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 601 | with t show "(f x - f y) / (x - y) \<le> (f t - f y) / (t - y)" | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 602 | by (simp add: le_divide_eq divide_le_eq field_simps) | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 603 | qed | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 604 | |
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 605 | lemma pos_convex_function: | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 606 | fixes f :: "real \<Rightarrow> real" | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 607 | assumes "convex C" | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 608 | and leq: "\<And>x y. x \<in> C \<Longrightarrow> y \<in> C \<Longrightarrow> f' x * (y - x) \<le> f y - f x" | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 609 | shows "convex_on C f" | 
| 72385 | 610 | unfolding convex_on_alt | 
| 69619 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 611 | using assms | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 612 | proof safe | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 613 | fix x y \<mu> :: real | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 614 | let ?x = "\<mu> *\<^sub>R x + (1 - \<mu>) *\<^sub>R y" | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 615 | assume *: "convex C" "x \<in> C" "y \<in> C" "\<mu> \<ge> 0" "\<mu> \<le> 1" | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 616 | then have "1 - \<mu> \<ge> 0" by auto | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 617 | then have xpos: "?x \<in> C" | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 618 | using * unfolding convex_alt by fastforce | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 619 | have geq: "\<mu> * (f x - f ?x) + (1 - \<mu>) * (f y - f ?x) \<ge> | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 620 | \<mu> * f' ?x * (x - ?x) + (1 - \<mu>) * f' ?x * (y - ?x)" | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 621 | using add_mono [OF mult_left_mono [OF leq [OF xpos *(2)] \<open>\<mu> \<ge> 0\<close>] | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 622 | mult_left_mono [OF leq [OF xpos *(3)] \<open>1 - \<mu> \<ge> 0\<close>]] | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 623 | by auto | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 624 | then have "\<mu> * f x + (1 - \<mu>) * f y - f ?x \<ge> 0" | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 625 | by (auto simp: field_simps) | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 626 | then show "f (\<mu> *\<^sub>R x + (1 - \<mu>) *\<^sub>R y) \<le> \<mu> * f x + (1 - \<mu>) * f y" | 
| 72385 | 627 | by auto | 
| 69619 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 628 | qed | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 629 | |
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 630 | lemma atMostAtLeast_subset_convex: | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 631 | fixes C :: "real set" | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 632 | assumes "convex C" | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 633 | and "x \<in> C" "y \<in> C" "x < y" | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 634 |   shows "{x .. y} \<subseteq> C"
 | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 635 | proof safe | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 636 |   fix z assume z: "z \<in> {x .. y}"
 | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 637 | have less: "z \<in> C" if *: "x < z" "z < y" | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 638 | proof - | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 639 | let ?\<mu> = "(y - z) / (y - x)" | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 640 | have "0 \<le> ?\<mu>" "?\<mu> \<le> 1" | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 641 | using assms * by (auto simp: field_simps) | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 642 | then have comb: "?\<mu> * x + (1 - ?\<mu>) * y \<in> C" | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 643 | using assms iffD1[OF convex_alt, rule_format, of C y x ?\<mu>] | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 644 | by (simp add: algebra_simps) | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 645 | have "?\<mu> * x + (1 - ?\<mu>) * y = (y - z) * x / (y - x) + (1 - (y - z) / (y - x)) * y" | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 646 | by (auto simp: field_simps) | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 647 | also have "\<dots> = ((y - z) * x + (y - x - (y - z)) * y) / (y - x)" | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 648 | using assms by (simp only: add_divide_distrib) (auto simp: field_simps) | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 649 | also have "\<dots> = z" | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 650 | using assms by (auto simp: field_simps) | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 651 | finally show ?thesis | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 652 | using comb by auto | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 653 | qed | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 654 | show "z \<in> C" | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 655 | using z less assms by (auto simp: le_less) | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 656 | qed | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 657 | |
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 658 | lemma f''_imp_f': | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 659 | fixes f :: "real \<Rightarrow> real" | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 660 | assumes "convex C" | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 661 | and f': "\<And>x. x \<in> C \<Longrightarrow> DERIV f x :> (f' x)" | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 662 | and f'': "\<And>x. x \<in> C \<Longrightarrow> DERIV f' x :> (f'' x)" | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 663 | and pos: "\<And>x. x \<in> C \<Longrightarrow> f'' x \<ge> 0" | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 664 | and x: "x \<in> C" | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 665 | and y: "y \<in> C" | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 666 | shows "f' x * (y - x) \<le> f y - f x" | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 667 | using assms | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 668 | proof - | 
| 78475 | 669 | have "f y - f x \<ge> f' x * (y - x)" "f' y * (x - y) \<le> f x - f y" | 
| 69619 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 670 | if *: "x \<in> C" "y \<in> C" "y > x" for x y :: real | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 671 | proof - | 
| 78475 | 672 | from * have ge: "y - x > 0" "y - x \<ge> 0" and le: "x - y < 0" "x - y \<le> 0" | 
| 69619 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 673 | by auto | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 674 | then obtain z1 where z1: "z1 > x" "z1 < y" "f y - f x = (y - x) * f' z1" | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 675 | using subsetD[OF atMostAtLeast_subset_convex[OF \<open>convex C\<close> \<open>x \<in> C\<close> \<open>y \<in> C\<close> \<open>x < y\<close>], | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 676 | THEN f', THEN MVT2[OF \<open>x < y\<close>, rule_format, unfolded atLeastAtMost_iff[symmetric]]] | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 677 | by auto | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 678 | then have "z1 \<in> C" | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 679 | using atMostAtLeast_subset_convex \<open>convex C\<close> \<open>x \<in> C\<close> \<open>y \<in> C\<close> \<open>x < y\<close> | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 680 | by fastforce | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 681 | obtain z2 where z2: "z2 > x" "z2 < z1" "f' z1 - f' x = (z1 - x) * f'' z2" | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 682 | using subsetD[OF atMostAtLeast_subset_convex[OF \<open>convex C\<close> \<open>x \<in> C\<close> \<open>z1 \<in> C\<close> \<open>x < z1\<close>], | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 683 | THEN f'', THEN MVT2[OF \<open>x < z1\<close>, rule_format, unfolded atLeastAtMost_iff[symmetric]]] z1 | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 684 | by auto | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 685 | obtain z3 where z3: "z3 > z1" "z3 < y" "f' y - f' z1 = (y - z1) * f'' z3" | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 686 | using subsetD[OF atMostAtLeast_subset_convex[OF \<open>convex C\<close> \<open>z1 \<in> C\<close> \<open>y \<in> C\<close> \<open>z1 < y\<close>], | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 687 | THEN f'', THEN MVT2[OF \<open>z1 < y\<close>, rule_format, unfolded atLeastAtMost_iff[symmetric]]] z1 | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 688 | by auto | 
| 78475 | 689 | from z1 have "f x - f y = (x - y) * f' z1" | 
| 690 | by (simp add: field_simps) | |
| 691 | then have cool': "f' y - (f x - f y) / (x - y) = (y - z1) * f'' z3" | |
| 692 | using le(1) z3(3) by auto | |
| 69619 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 693 | have "z3 \<in> C" | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 694 | using z3 * atMostAtLeast_subset_convex \<open>convex C\<close> \<open>x \<in> C\<close> \<open>z1 \<in> C\<close> \<open>x < z1\<close> | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 695 | by fastforce | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 696 | then have B': "f'' z3 \<ge> 0" | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 697 | using assms by auto | 
| 78475 | 698 | with cool' have "f' y - (f x - f y) / (x - y) \<ge> 0" | 
| 699 | using z1 by auto | |
| 69619 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 700 | then have res: "f' y * (x - y) \<le> f x - f y" | 
| 78475 | 701 | by (meson diff_ge_0_iff_ge le(1) neg_divide_le_eq) | 
| 702 | have cool: "(f y - f x) / (y - x) - f' x = (z1 - x) * f'' z2" | |
| 703 | using le(1) z1(3) z2(3) by auto | |
| 69619 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 704 | have "z2 \<in> C" | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 705 | using z2 z1 * atMostAtLeast_subset_convex \<open>convex C\<close> \<open>z1 \<in> C\<close> \<open>y \<in> C\<close> \<open>z1 < y\<close> | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 706 | by fastforce | 
| 78475 | 707 | with z1 assms have "(z1 - x) * f'' z2 \<ge> 0" | 
| 69619 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 708 | by auto | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 709 | then show "f y - f x \<ge> f' x * (y - x)" "f' y * (x - y) \<le> f x - f y" | 
| 78475 | 710 | using that(3) z1(3) res cool by auto | 
| 69619 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 711 | qed | 
| 78475 | 712 | then show ?thesis | 
| 713 | using x y by fastforce | |
| 69619 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 714 | qed | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 715 | |
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 716 | lemma f''_ge0_imp_convex: | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 717 | fixes f :: "real \<Rightarrow> real" | 
| 78475 | 718 | assumes "convex C" | 
| 719 | and "\<And>x. x \<in> C \<Longrightarrow> DERIV f x :> (f' x)" | |
| 720 | and "\<And>x. x \<in> C \<Longrightarrow> DERIV f' x :> (f'' x)" | |
| 721 | and "\<And>x. x \<in> C \<Longrightarrow> f'' x \<ge> 0" | |
| 69619 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 722 | shows "convex_on C f" | 
| 78475 | 723 | by (metis assms f''_imp_f' pos_convex_function) | 
| 69619 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 724 | |
| 74729 
64b3d8d9bd10
new lemmas about convex, concave functions, + tidying
 paulson <lp15@cam.ac.uk> parents: 
72385diff
changeset | 725 | lemma f''_le0_imp_concave: | 
| 
64b3d8d9bd10
new lemmas about convex, concave functions, + tidying
 paulson <lp15@cam.ac.uk> parents: 
72385diff
changeset | 726 | fixes f :: "real \<Rightarrow> real" | 
| 
64b3d8d9bd10
new lemmas about convex, concave functions, + tidying
 paulson <lp15@cam.ac.uk> parents: 
72385diff
changeset | 727 | assumes "convex C" | 
| 
64b3d8d9bd10
new lemmas about convex, concave functions, + tidying
 paulson <lp15@cam.ac.uk> parents: 
72385diff
changeset | 728 | and "\<And>x. x \<in> C \<Longrightarrow> DERIV f x :> (f' x)" | 
| 
64b3d8d9bd10
new lemmas about convex, concave functions, + tidying
 paulson <lp15@cam.ac.uk> parents: 
72385diff
changeset | 729 | and "\<And>x. x \<in> C \<Longrightarrow> DERIV f' x :> (f'' x)" | 
| 
64b3d8d9bd10
new lemmas about convex, concave functions, + tidying
 paulson <lp15@cam.ac.uk> parents: 
72385diff
changeset | 730 | and "\<And>x. x \<in> C \<Longrightarrow> f'' x \<le> 0" | 
| 
64b3d8d9bd10
new lemmas about convex, concave functions, + tidying
 paulson <lp15@cam.ac.uk> parents: 
72385diff
changeset | 731 | shows "concave_on C f" | 
| 
64b3d8d9bd10
new lemmas about convex, concave functions, + tidying
 paulson <lp15@cam.ac.uk> parents: 
72385diff
changeset | 732 | unfolding concave_on_def | 
| 
64b3d8d9bd10
new lemmas about convex, concave functions, + tidying
 paulson <lp15@cam.ac.uk> parents: 
72385diff
changeset | 733 | by (rule assms f''_ge0_imp_convex derivative_eq_intros | simp)+ | 
| 
64b3d8d9bd10
new lemmas about convex, concave functions, + tidying
 paulson <lp15@cam.ac.uk> parents: 
72385diff
changeset | 734 | |
| 
64b3d8d9bd10
new lemmas about convex, concave functions, + tidying
 paulson <lp15@cam.ac.uk> parents: 
72385diff
changeset | 735 | lemma log_concave: | 
| 
64b3d8d9bd10
new lemmas about convex, concave functions, + tidying
 paulson <lp15@cam.ac.uk> parents: 
72385diff
changeset | 736 | fixes b :: real | 
| 
64b3d8d9bd10
new lemmas about convex, concave functions, + tidying
 paulson <lp15@cam.ac.uk> parents: 
72385diff
changeset | 737 | assumes "b > 1" | 
| 
64b3d8d9bd10
new lemmas about convex, concave functions, + tidying
 paulson <lp15@cam.ac.uk> parents: 
72385diff
changeset | 738 |   shows "concave_on {0<..} (\<lambda> x. log b x)"
 | 
| 
64b3d8d9bd10
new lemmas about convex, concave functions, + tidying
 paulson <lp15@cam.ac.uk> parents: 
72385diff
changeset | 739 | using assms | 
| 
64b3d8d9bd10
new lemmas about convex, concave functions, + tidying
 paulson <lp15@cam.ac.uk> parents: 
72385diff
changeset | 740 | by (intro f''_le0_imp_concave derivative_eq_intros | simp)+ | 
| 
64b3d8d9bd10
new lemmas about convex, concave functions, + tidying
 paulson <lp15@cam.ac.uk> parents: 
72385diff
changeset | 741 | |
| 
64b3d8d9bd10
new lemmas about convex, concave functions, + tidying
 paulson <lp15@cam.ac.uk> parents: 
72385diff
changeset | 742 | lemma ln_concave: "concave_on {0<..} ln"
 | 
| 
64b3d8d9bd10
new lemmas about convex, concave functions, + tidying
 paulson <lp15@cam.ac.uk> parents: 
72385diff
changeset | 743 | unfolding log_ln by (simp add: log_concave) | 
| 
64b3d8d9bd10
new lemmas about convex, concave functions, + tidying
 paulson <lp15@cam.ac.uk> parents: 
72385diff
changeset | 744 | |
| 69619 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 745 | lemma minus_log_convex: | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 746 | fixes b :: real | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 747 | assumes "b > 1" | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 748 |   shows "convex_on {0 <..} (\<lambda> x. - log b x)"
 | 
| 74729 
64b3d8d9bd10
new lemmas about convex, concave functions, + tidying
 paulson <lp15@cam.ac.uk> parents: 
72385diff
changeset | 749 | using assms concave_on_def log_concave by blast | 
| 
64b3d8d9bd10
new lemmas about convex, concave functions, + tidying
 paulson <lp15@cam.ac.uk> parents: 
72385diff
changeset | 750 | |
| 
64b3d8d9bd10
new lemmas about convex, concave functions, + tidying
 paulson <lp15@cam.ac.uk> parents: 
72385diff
changeset | 751 | lemma powr_convex: | 
| 
64b3d8d9bd10
new lemmas about convex, concave functions, + tidying
 paulson <lp15@cam.ac.uk> parents: 
72385diff
changeset | 752 |   assumes "p \<ge> 1" shows "convex_on {0<..} (\<lambda>x. x powr p)"
 | 
| 
64b3d8d9bd10
new lemmas about convex, concave functions, + tidying
 paulson <lp15@cam.ac.uk> parents: 
72385diff
changeset | 753 | using assms | 
| 
64b3d8d9bd10
new lemmas about convex, concave functions, + tidying
 paulson <lp15@cam.ac.uk> parents: 
72385diff
changeset | 754 | by (intro f''_ge0_imp_convex derivative_eq_intros | simp)+ | 
| 
64b3d8d9bd10
new lemmas about convex, concave functions, + tidying
 paulson <lp15@cam.ac.uk> parents: 
72385diff
changeset | 755 | |
| 
64b3d8d9bd10
new lemmas about convex, concave functions, + tidying
 paulson <lp15@cam.ac.uk> parents: 
72385diff
changeset | 756 | lemma exp_convex: "convex_on UNIV exp" | 
| 
64b3d8d9bd10
new lemmas about convex, concave functions, + tidying
 paulson <lp15@cam.ac.uk> parents: 
72385diff
changeset | 757 | by (intro f''_ge0_imp_convex derivative_eq_intros | simp)+ | 
| 69619 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 758 | |
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 759 | |
| 70136 | 760 | subsection\<^marker>\<open>tag unimportant\<close> \<open>Convexity of real functions\<close> | 
| 69619 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 761 | |
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 762 | lemma convex_on_realI: | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 763 | assumes "connected A" | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 764 | and "\<And>x. x \<in> A \<Longrightarrow> (f has_real_derivative f' x) (at x)" | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 765 | and "\<And>x y. x \<in> A \<Longrightarrow> y \<in> A \<Longrightarrow> x \<le> y \<Longrightarrow> f' x \<le> f' y" | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 766 | shows "convex_on A f" | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 767 | proof (rule convex_on_linorderI) | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 768 | fix t x y :: real | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 769 | assume t: "t > 0" "t < 1" | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 770 | assume xy: "x \<in> A" "y \<in> A" "x < y" | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 771 | define z where "z = (1 - t) * x + t * y" | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 772 |   with \<open>connected A\<close> and xy have ivl: "{x..y} \<subseteq> A"
 | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 773 | using connected_contains_Icc by blast | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 774 | |
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 775 | from xy t have xz: "z > x" | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 776 | by (simp add: z_def algebra_simps) | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 777 | have "y - z = (1 - t) * (y - x)" | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 778 | by (simp add: z_def algebra_simps) | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 779 | also from xy t have "\<dots> > 0" | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 780 | by (intro mult_pos_pos) simp_all | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 781 | finally have yz: "z < y" | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 782 | by simp | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 783 | |
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 784 | from assms xz yz ivl t have "\<exists>\<xi>. \<xi> > x \<and> \<xi> < z \<and> f z - f x = (z - x) * f' \<xi>" | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 785 | by (intro MVT2) (auto intro!: assms(2)) | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 786 | then obtain \<xi> where \<xi>: "\<xi> > x" "\<xi> < z" "f' \<xi> = (f z - f x) / (z - x)" | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 787 | by auto | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 788 | from assms xz yz ivl t have "\<exists>\<eta>. \<eta> > z \<and> \<eta> < y \<and> f y - f z = (y - z) * f' \<eta>" | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 789 | by (intro MVT2) (auto intro!: assms(2)) | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 790 | then obtain \<eta> where \<eta>: "\<eta> > z" "\<eta> < y" "f' \<eta> = (f y - f z) / (y - z)" | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 791 | by auto | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 792 | |
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 793 | from \<eta>(3) have "(f y - f z) / (y - z) = f' \<eta>" .. | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 794 | also from \<xi> \<eta> ivl have "\<xi> \<in> A" "\<eta> \<in> A" | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 795 | by auto | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 796 | with \<xi> \<eta> have "f' \<eta> \<ge> f' \<xi>" | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 797 | by (intro assms(3)) auto | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 798 | also from \<xi>(3) have "f' \<xi> = (f z - f x) / (z - x)" . | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 799 | finally have "(f y - f z) * (z - x) \<ge> (f z - f x) * (y - z)" | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 800 | using xz yz by (simp add: field_simps) | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 801 | also have "z - x = t * (y - x)" | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 802 | by (simp add: z_def algebra_simps) | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 803 | also have "y - z = (1 - t) * (y - x)" | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 804 | by (simp add: z_def algebra_simps) | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 805 | finally have "(f y - f z) * t \<ge> (f z - f x) * (1 - t)" | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 806 | using xy by simp | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 807 | then show "(1 - t) * f x + t * f y \<ge> f ((1 - t) *\<^sub>R x + t *\<^sub>R y)" | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 808 | by (simp add: z_def algebra_simps) | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 809 | qed | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 810 | |
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 811 | lemma convex_on_inverse: | 
| 78475 | 812 | fixes A :: "real set" | 
| 69619 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 813 |   assumes "A \<subseteq> {0<..}"
 | 
| 78475 | 814 | shows "convex_on A inverse" | 
| 815 | proof - | |
| 816 |   have "convex_on {0::real<..} inverse"
 | |
| 817 | proof (intro convex_on_realI) | |
| 818 | fix u v :: real | |
| 819 |     assume "u \<in> {0<..}" "v \<in> {0<..}" "u \<le> v"
 | |
| 820 | with assms show "-inverse (u^2) \<le> -inverse (v^2)" | |
| 821 | by simp | |
| 822 | next | |
| 823 |     show "\<And>x. x \<in> {0<..} \<Longrightarrow> (inverse has_real_derivative - inverse (x\<^sup>2)) (at x)"
 | |
| 824 | by (rule derivative_eq_intros | simp add: power2_eq_square)+ | |
| 825 | qed auto | |
| 826 | then show ?thesis | |
| 827 | using assms convex_on_subset by blast | |
| 828 | qed | |
| 69619 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 829 | |
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 830 | lemma convex_onD_Icc': | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 831 |   assumes "convex_on {x..y} f" "c \<in> {x..y}"
 | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 832 | defines "d \<equiv> y - x" | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 833 | shows "f c \<le> (f y - f x) / d * (c - x) + f x" | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 834 | proof (cases x y rule: linorder_cases) | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 835 | case less | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 836 | then have d: "d > 0" | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 837 | by (simp add: d_def) | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 838 | from assms(2) less have A: "0 \<le> (c - x) / d" "(c - x) / d \<le> 1" | 
| 70817 
dd675800469d
dedicated fact collections for algebraic simplification rules potentially splitting goals
 haftmann parents: 
70136diff
changeset | 839 | by (simp_all add: d_def field_split_simps) | 
| 69619 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 840 | have "f c = f (x + (c - x) * 1)" | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 841 | by simp | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 842 | also from less have "1 = ((y - x) / d)" | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 843 | by (simp add: d_def) | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 844 | also from d have "x + (c - x) * \<dots> = (1 - (c - x) / d) *\<^sub>R x + ((c - x) / d) *\<^sub>R y" | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 845 | by (simp add: field_simps) | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 846 | also have "f \<dots> \<le> (1 - (c - x) / d) * f x + (c - x) / d * f y" | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 847 | using assms less by (intro convex_onD_Icc) simp_all | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 848 | also from d have "\<dots> = (f y - f x) / d * (c - x) + f x" | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 849 | by (simp add: field_simps) | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 850 | finally show ?thesis . | 
| 78475 | 851 | qed (use assms in auto) | 
| 69619 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 852 | |
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 853 | lemma convex_onD_Icc'': | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 854 |   assumes "convex_on {x..y} f" "c \<in> {x..y}"
 | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 855 | defines "d \<equiv> y - x" | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 856 | shows "f c \<le> (f x - f y) / d * (y - c) + f y" | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 857 | proof (cases x y rule: linorder_cases) | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 858 | case less | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 859 | then have d: "d > 0" | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 860 | by (simp add: d_def) | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 861 | from assms(2) less have A: "0 \<le> (y - c) / d" "(y - c) / d \<le> 1" | 
| 70817 
dd675800469d
dedicated fact collections for algebraic simplification rules potentially splitting goals
 haftmann parents: 
70136diff
changeset | 862 | by (simp_all add: d_def field_split_simps) | 
| 69619 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 863 | have "f c = f (y - (y - c) * 1)" | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 864 | by simp | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 865 | also from less have "1 = ((y - x) / d)" | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 866 | by (simp add: d_def) | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 867 | also from d have "y - (y - c) * \<dots> = (1 - (1 - (y - c) / d)) *\<^sub>R x + (1 - (y - c) / d) *\<^sub>R y" | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 868 | by (simp add: field_simps) | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 869 | also have "f \<dots> \<le> (1 - (1 - (y - c) / d)) * f x + (1 - (y - c) / d) * f y" | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 870 | using assms less by (intro convex_onD_Icc) (simp_all add: field_simps) | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 871 | also from d have "\<dots> = (f x - f y) / d * (y - c) + f y" | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 872 | by (simp add: field_simps) | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 873 | finally show ?thesis . | 
| 78475 | 874 | qed (use assms in auto) | 
| 69619 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 875 | |
| 74729 
64b3d8d9bd10
new lemmas about convex, concave functions, + tidying
 paulson <lp15@cam.ac.uk> parents: 
72385diff
changeset | 876 | subsection \<open>Some inequalities\<close> | 
| 
64b3d8d9bd10
new lemmas about convex, concave functions, + tidying
 paulson <lp15@cam.ac.uk> parents: 
72385diff
changeset | 877 | |
| 
64b3d8d9bd10
new lemmas about convex, concave functions, + tidying
 paulson <lp15@cam.ac.uk> parents: 
72385diff
changeset | 878 | lemma Youngs_inequality_0: | 
| 
64b3d8d9bd10
new lemmas about convex, concave functions, + tidying
 paulson <lp15@cam.ac.uk> parents: 
72385diff
changeset | 879 | fixes a::real | 
| 
64b3d8d9bd10
new lemmas about convex, concave functions, + tidying
 paulson <lp15@cam.ac.uk> parents: 
72385diff
changeset | 880 | assumes "0 \<le> \<alpha>" "0 \<le> \<beta>" "\<alpha>+\<beta> = 1" "a>0" "b>0" | 
| 
64b3d8d9bd10
new lemmas about convex, concave functions, + tidying
 paulson <lp15@cam.ac.uk> parents: 
72385diff
changeset | 881 | shows "a powr \<alpha> * b powr \<beta> \<le> \<alpha>*a + \<beta>*b" | 
| 
64b3d8d9bd10
new lemmas about convex, concave functions, + tidying
 paulson <lp15@cam.ac.uk> parents: 
72385diff
changeset | 882 | proof - | 
| 
64b3d8d9bd10
new lemmas about convex, concave functions, + tidying
 paulson <lp15@cam.ac.uk> parents: 
72385diff
changeset | 883 | have "\<alpha> * ln a + \<beta> * ln b \<le> ln (\<alpha> * a + \<beta> * b)" | 
| 
64b3d8d9bd10
new lemmas about convex, concave functions, + tidying
 paulson <lp15@cam.ac.uk> parents: 
72385diff
changeset | 884 | using assms ln_concave by (simp add: concave_on_iff) | 
| 
64b3d8d9bd10
new lemmas about convex, concave functions, + tidying
 paulson <lp15@cam.ac.uk> parents: 
72385diff
changeset | 885 | moreover have "0 < \<alpha> * a + \<beta> * b" | 
| 
64b3d8d9bd10
new lemmas about convex, concave functions, + tidying
 paulson <lp15@cam.ac.uk> parents: 
72385diff
changeset | 886 | using assms by (smt (verit) mult_pos_pos split_mult_pos_le) | 
| 
64b3d8d9bd10
new lemmas about convex, concave functions, + tidying
 paulson <lp15@cam.ac.uk> parents: 
72385diff
changeset | 887 | ultimately show ?thesis | 
| 
64b3d8d9bd10
new lemmas about convex, concave functions, + tidying
 paulson <lp15@cam.ac.uk> parents: 
72385diff
changeset | 888 | using assms by (simp add: powr_def mult_exp_exp flip: ln_ge_iff) | 
| 
64b3d8d9bd10
new lemmas about convex, concave functions, + tidying
 paulson <lp15@cam.ac.uk> parents: 
72385diff
changeset | 889 | qed | 
| 
64b3d8d9bd10
new lemmas about convex, concave functions, + tidying
 paulson <lp15@cam.ac.uk> parents: 
72385diff
changeset | 890 | |
| 
64b3d8d9bd10
new lemmas about convex, concave functions, + tidying
 paulson <lp15@cam.ac.uk> parents: 
72385diff
changeset | 891 | lemma Youngs_inequality: | 
| 
64b3d8d9bd10
new lemmas about convex, concave functions, + tidying
 paulson <lp15@cam.ac.uk> parents: 
72385diff
changeset | 892 | fixes p::real | 
| 
64b3d8d9bd10
new lemmas about convex, concave functions, + tidying
 paulson <lp15@cam.ac.uk> parents: 
72385diff
changeset | 893 | assumes "p>1" "q>1" "1/p + 1/q = 1" "a\<ge>0" "b\<ge>0" | 
| 
64b3d8d9bd10
new lemmas about convex, concave functions, + tidying
 paulson <lp15@cam.ac.uk> parents: 
72385diff
changeset | 894 | shows "a * b \<le> a powr p / p + b powr q / q" | 
| 
64b3d8d9bd10
new lemmas about convex, concave functions, + tidying
 paulson <lp15@cam.ac.uk> parents: 
72385diff
changeset | 895 | proof (cases "a=0 \<or> b=0") | 
| 
64b3d8d9bd10
new lemmas about convex, concave functions, + tidying
 paulson <lp15@cam.ac.uk> parents: 
72385diff
changeset | 896 | case False | 
| 
64b3d8d9bd10
new lemmas about convex, concave functions, + tidying
 paulson <lp15@cam.ac.uk> parents: 
72385diff
changeset | 897 | then show ?thesis | 
| 
64b3d8d9bd10
new lemmas about convex, concave functions, + tidying
 paulson <lp15@cam.ac.uk> parents: 
72385diff
changeset | 898 | using Youngs_inequality_0 [of "1/p" "1/q" "a powr p" "b powr q"] assms | 
| 
64b3d8d9bd10
new lemmas about convex, concave functions, + tidying
 paulson <lp15@cam.ac.uk> parents: 
72385diff
changeset | 899 | by (simp add: powr_powr) | 
| 
64b3d8d9bd10
new lemmas about convex, concave functions, + tidying
 paulson <lp15@cam.ac.uk> parents: 
72385diff
changeset | 900 | qed (use assms in auto) | 
| 
64b3d8d9bd10
new lemmas about convex, concave functions, + tidying
 paulson <lp15@cam.ac.uk> parents: 
72385diff
changeset | 901 | |
| 
64b3d8d9bd10
new lemmas about convex, concave functions, + tidying
 paulson <lp15@cam.ac.uk> parents: 
72385diff
changeset | 902 | lemma Cauchy_Schwarz_ineq_sum: | 
| 
64b3d8d9bd10
new lemmas about convex, concave functions, + tidying
 paulson <lp15@cam.ac.uk> parents: 
72385diff
changeset | 903 | fixes a :: "'a \<Rightarrow> 'b::linordered_field" | 
| 
64b3d8d9bd10
new lemmas about convex, concave functions, + tidying
 paulson <lp15@cam.ac.uk> parents: 
72385diff
changeset | 904 | shows "(\<Sum>i\<in>I. a i * b i)\<^sup>2 \<le> (\<Sum>i\<in>I. (a i)\<^sup>2) * (\<Sum>i\<in>I. (b i)\<^sup>2)" | 
| 
64b3d8d9bd10
new lemmas about convex, concave functions, + tidying
 paulson <lp15@cam.ac.uk> parents: 
72385diff
changeset | 905 | proof (cases "(\<Sum>i\<in>I. (b i)\<^sup>2) > 0") | 
| 
64b3d8d9bd10
new lemmas about convex, concave functions, + tidying
 paulson <lp15@cam.ac.uk> parents: 
72385diff
changeset | 906 | case False | 
| 
64b3d8d9bd10
new lemmas about convex, concave functions, + tidying
 paulson <lp15@cam.ac.uk> parents: 
72385diff
changeset | 907 | then consider "\<And>i. i\<in>I \<Longrightarrow> b i = 0" | "infinite I" | 
| 
64b3d8d9bd10
new lemmas about convex, concave functions, + tidying
 paulson <lp15@cam.ac.uk> parents: 
72385diff
changeset | 908 | by (metis (mono_tags, lifting) sum_pos2 zero_le_power2 zero_less_power2) | 
| 
64b3d8d9bd10
new lemmas about convex, concave functions, + tidying
 paulson <lp15@cam.ac.uk> parents: 
72385diff
changeset | 909 | thus ?thesis | 
| 
64b3d8d9bd10
new lemmas about convex, concave functions, + tidying
 paulson <lp15@cam.ac.uk> parents: 
72385diff
changeset | 910 | by fastforce | 
| 
64b3d8d9bd10
new lemmas about convex, concave functions, + tidying
 paulson <lp15@cam.ac.uk> parents: 
72385diff
changeset | 911 | next | 
| 
64b3d8d9bd10
new lemmas about convex, concave functions, + tidying
 paulson <lp15@cam.ac.uk> parents: 
72385diff
changeset | 912 | case True | 
| 
64b3d8d9bd10
new lemmas about convex, concave functions, + tidying
 paulson <lp15@cam.ac.uk> parents: 
72385diff
changeset | 913 | define r where "r \<equiv> (\<Sum>i\<in>I. a i * b i) / (\<Sum>i\<in>I. (b i)\<^sup>2)" | 
| 
64b3d8d9bd10
new lemmas about convex, concave functions, + tidying
 paulson <lp15@cam.ac.uk> parents: 
72385diff
changeset | 914 | with True have *: "(\<Sum>i\<in>I. a i * b i) = r * (\<Sum>i\<in>I. (b i)\<^sup>2)" | 
| 
64b3d8d9bd10
new lemmas about convex, concave functions, + tidying
 paulson <lp15@cam.ac.uk> parents: 
72385diff
changeset | 915 | by simp | 
| 
64b3d8d9bd10
new lemmas about convex, concave functions, + tidying
 paulson <lp15@cam.ac.uk> parents: 
72385diff
changeset | 916 | have "0 \<le> (\<Sum>i\<in>I. (a i - r * b i)\<^sup>2)" | 
| 
64b3d8d9bd10
new lemmas about convex, concave functions, + tidying
 paulson <lp15@cam.ac.uk> parents: 
72385diff
changeset | 917 | by (meson sum_nonneg zero_le_power2) | 
| 
64b3d8d9bd10
new lemmas about convex, concave functions, + tidying
 paulson <lp15@cam.ac.uk> parents: 
72385diff
changeset | 918 | also have "... = (\<Sum>i\<in>I. (a i)\<^sup>2) - 2 * r * (\<Sum>i\<in>I. a i * b i) + r\<^sup>2 * (\<Sum>i\<in>I. (b i)\<^sup>2)" | 
| 
64b3d8d9bd10
new lemmas about convex, concave functions, + tidying
 paulson <lp15@cam.ac.uk> parents: 
72385diff
changeset | 919 | by (simp add: algebra_simps power2_eq_square sum_distrib_left flip: sum.distrib) | 
| 
64b3d8d9bd10
new lemmas about convex, concave functions, + tidying
 paulson <lp15@cam.ac.uk> parents: 
72385diff
changeset | 920 | also have "\<dots> = (\<Sum>i\<in>I. (a i)\<^sup>2) - (\<Sum>i\<in>I. a i * b i) * r" | 
| 
64b3d8d9bd10
new lemmas about convex, concave functions, + tidying
 paulson <lp15@cam.ac.uk> parents: 
72385diff
changeset | 921 | by (simp add: * power2_eq_square) | 
| 
64b3d8d9bd10
new lemmas about convex, concave functions, + tidying
 paulson <lp15@cam.ac.uk> parents: 
72385diff
changeset | 922 | also have "\<dots> = (\<Sum>i\<in>I. (a i)\<^sup>2) - ((\<Sum>i\<in>I. a i * b i))\<^sup>2 / (\<Sum>i\<in>I. (b i)\<^sup>2)" | 
| 
64b3d8d9bd10
new lemmas about convex, concave functions, + tidying
 paulson <lp15@cam.ac.uk> parents: 
72385diff
changeset | 923 | by (simp add: r_def power2_eq_square) | 
| 
64b3d8d9bd10
new lemmas about convex, concave functions, + tidying
 paulson <lp15@cam.ac.uk> parents: 
72385diff
changeset | 924 | finally have "0 \<le> (\<Sum>i\<in>I. (a i)\<^sup>2) - ((\<Sum>i\<in>I. a i * b i))\<^sup>2 / (\<Sum>i\<in>I. (b i)\<^sup>2)" . | 
| 
64b3d8d9bd10
new lemmas about convex, concave functions, + tidying
 paulson <lp15@cam.ac.uk> parents: 
72385diff
changeset | 925 | hence "((\<Sum>i\<in>I. a i * b i))\<^sup>2 / (\<Sum>i\<in>I. (b i)\<^sup>2) \<le> (\<Sum>i\<in>I. (a i)\<^sup>2)" | 
| 
64b3d8d9bd10
new lemmas about convex, concave functions, + tidying
 paulson <lp15@cam.ac.uk> parents: 
72385diff
changeset | 926 | by (simp add: le_diff_eq) | 
| 
64b3d8d9bd10
new lemmas about convex, concave functions, + tidying
 paulson <lp15@cam.ac.uk> parents: 
72385diff
changeset | 927 | thus "((\<Sum>i\<in>I. a i * b i))\<^sup>2 \<le> (\<Sum>i\<in>I. (a i)\<^sup>2) * (\<Sum>i\<in>I. (b i)\<^sup>2)" | 
| 
64b3d8d9bd10
new lemmas about convex, concave functions, + tidying
 paulson <lp15@cam.ac.uk> parents: 
72385diff
changeset | 928 | by (simp add: pos_divide_le_eq True) | 
| 
64b3d8d9bd10
new lemmas about convex, concave functions, + tidying
 paulson <lp15@cam.ac.uk> parents: 
72385diff
changeset | 929 | qed | 
| 
64b3d8d9bd10
new lemmas about convex, concave functions, + tidying
 paulson <lp15@cam.ac.uk> parents: 
72385diff
changeset | 930 | |
| 
64b3d8d9bd10
new lemmas about convex, concave functions, + tidying
 paulson <lp15@cam.ac.uk> parents: 
72385diff
changeset | 931 | subsection \<open>Misc related lemmas\<close> | 
| 
64b3d8d9bd10
new lemmas about convex, concave functions, + tidying
 paulson <lp15@cam.ac.uk> parents: 
72385diff
changeset | 932 | |
| 69661 | 933 | lemma convex_translation_eq [simp]: | 
| 934 | "convex ((+) a ` s) \<longleftrightarrow> convex s" | |
| 69619 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 935 | by (metis convex_translation translation_galois) | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 936 | |
| 69661 | 937 | lemma convex_translation_subtract_eq [simp]: | 
| 938 | "convex ((\<lambda>b. b - a) ` s) \<longleftrightarrow> convex s" | |
| 939 | using convex_translation_eq [of "- a"] by (simp cong: image_cong_simp) | |
| 940 | ||
| 69619 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 941 | lemma convex_linear_image_eq [simp]: | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 942 | fixes f :: "'a::real_vector \<Rightarrow> 'b::real_vector" | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 943 | shows "\<lbrakk>linear f; inj f\<rbrakk> \<Longrightarrow> convex (f ` s) \<longleftrightarrow> convex s" | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 944 | by (metis (no_types) convex_linear_image convex_linear_vimage inj_vimage_image_eq) | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 945 | |
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 946 | lemma vector_choose_size: | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 947 | assumes "0 \<le> c" | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 948 |   obtains x :: "'a::{real_normed_vector, perfect_space}" where "norm x = c"
 | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 949 | proof - | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 950 | obtain a::'a where "a \<noteq> 0" | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 951 | using UNIV_not_singleton UNIV_eq_I set_zero singletonI by fastforce | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 952 | then show ?thesis | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 953 | by (rule_tac x="scaleR (c / norm a) a" in that) (simp add: assms) | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 954 | qed | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 955 | |
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 956 | lemma vector_choose_dist: | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 957 | assumes "0 \<le> c" | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 958 |   obtains y :: "'a::{real_normed_vector, perfect_space}" where "dist x y = c"
 | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 959 | by (metis add_diff_cancel_left' assms dist_commute dist_norm vector_choose_size) | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 960 | |
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 961 | lemma sum_delta'': | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 962 | fixes s::"'a::real_vector set" | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 963 | assumes "finite s" | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 964 | shows "(\<Sum>x\<in>s. (if y = x then f x else 0) *\<^sub>R x) = (if y\<in>s then (f y) *\<^sub>R y else 0)" | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 965 | proof - | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 966 | have *: "\<And>x y. (if y = x then f x else (0::real)) *\<^sub>R x = (if x=y then (f x) *\<^sub>R x else 0)" | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 967 | by auto | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 968 | show ?thesis | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 969 | unfolding * using sum.delta[OF assms, of y "\<lambda>x. f x *\<^sub>R x"] by auto | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 970 | qed | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 971 | |
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 972 | |
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 973 | subsection \<open>Cones\<close> | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 974 | |
| 70136 | 975 | definition\<^marker>\<open>tag important\<close> cone :: "'a::real_vector set \<Rightarrow> bool" | 
| 69619 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 976 | where "cone s \<longleftrightarrow> (\<forall>x\<in>s. \<forall>c\<ge>0. c *\<^sub>R x \<in> s)" | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 977 | |
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 978 | lemma cone_empty[intro, simp]: "cone {}"
 | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 979 | unfolding cone_def by auto | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 980 | |
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 981 | lemma cone_univ[intro, simp]: "cone UNIV" | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 982 | unfolding cone_def by auto | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 983 | |
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 984 | lemma cone_Inter[intro]: "\<forall>s\<in>f. cone s \<Longrightarrow> cone (\<Inter>f)" | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 985 | unfolding cone_def by auto | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 986 | |
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 987 | lemma subspace_imp_cone: "subspace S \<Longrightarrow> cone S" | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 988 | by (simp add: cone_def subspace_scale) | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 989 | |
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 990 | |
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 991 | subsubsection \<open>Conic hull\<close> | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 992 | |
| 72385 | 993 | lemma cone_cone_hull: "cone (cone hull S)" | 
| 69619 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 994 | unfolding hull_def by auto | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 995 | |
| 72385 | 996 | lemma cone_hull_eq: "cone hull S = S \<longleftrightarrow> cone S" | 
| 997 | by (metis cone_cone_hull hull_same) | |
| 69619 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 998 | |
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 999 | lemma mem_cone: | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1000 | assumes "cone S" "x \<in> S" "c \<ge> 0" | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1001 | shows "c *\<^sub>R x \<in> S" | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1002 | using assms cone_def[of S] by auto | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1003 | |
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1004 | lemma cone_contains_0: | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1005 | assumes "cone S" | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1006 |   shows "S \<noteq> {} \<longleftrightarrow> 0 \<in> S"
 | 
| 72385 | 1007 | using assms mem_cone by fastforce | 
| 69619 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1008 | |
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1009 | lemma cone_0: "cone {0}"
 | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1010 | unfolding cone_def by auto | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1011 | |
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1012 | lemma cone_Union[intro]: "(\<forall>s\<in>f. cone s) \<longrightarrow> cone (\<Union>f)" | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1013 | unfolding cone_def by blast | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1014 | |
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1015 | lemma cone_iff: | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1016 |   assumes "S \<noteq> {}"
 | 
| 78475 | 1017 | shows "cone S \<longleftrightarrow> 0 \<in> S \<and> (\<forall>c. c > 0 \<longrightarrow> ((*\<^sub>R) c) ` S = S)" (is "_ = ?rhs") | 
| 1018 | proof | |
| 1019 | assume "cone S" | |
| 69619 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1020 |   {
 | 
| 78475 | 1021 | fix c :: real | 
| 1022 | assume "c > 0" | |
| 1023 | have "x \<in> ((*\<^sub>R) c) ` S" if "x \<in> S" for x | |
| 1024 | using \<open>cone S\<close> \<open>c>0\<close> mem_cone[of S x "1/c"] that | |
| 1025 | exI[of "(\<lambda>t. t \<in> S \<and> x = c *\<^sub>R t)" "(1 / c) *\<^sub>R x"] | |
| 1026 | by auto | |
| 1027 | then have "((*\<^sub>R) c) ` S = S" | |
| 1028 | using \<open>0 < c\<close> \<open>cone S\<close> mem_cone by fastforce | |
| 69619 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1029 | } | 
| 78475 | 1030 | then show "0 \<in> S \<and> (\<forall>c. c > 0 \<longrightarrow> ((*\<^sub>R) c) ` S = S)" | 
| 1031 | using \<open>cone S\<close> cone_contains_0[of S] assms by auto | |
| 1032 | next | |
| 1033 | show "?rhs \<Longrightarrow> cone S" | |
| 1034 | by (metis Convex.cone_def imageI order_neq_le_trans scaleR_zero_left) | |
| 69619 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1035 | qed | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1036 | |
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1037 | lemma cone_hull_empty: "cone hull {} = {}"
 | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1038 | by (metis cone_empty cone_hull_eq) | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1039 | |
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1040 | lemma cone_hull_empty_iff: "S = {} \<longleftrightarrow> cone hull S = {}"
 | 
| 78475 | 1041 | by (metis cone_hull_empty hull_subset subset_empty) | 
| 69619 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1042 | |
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1043 | lemma cone_hull_contains_0: "S \<noteq> {} \<longleftrightarrow> 0 \<in> cone hull S"
 | 
| 78475 | 1044 | by (metis cone_cone_hull cone_contains_0 cone_hull_empty_iff) | 
| 69619 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1045 | |
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1046 | lemma mem_cone_hull: | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1047 | assumes "x \<in> S" "c \<ge> 0" | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1048 | shows "c *\<^sub>R x \<in> cone hull S" | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1049 | by (metis assms cone_cone_hull hull_inc mem_cone) | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1050 | |
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1051 | proposition cone_hull_expl: "cone hull S = {c *\<^sub>R x | c x. c \<ge> 0 \<and> x \<in> S}"
 | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1052 | (is "?lhs = ?rhs") | 
| 78475 | 1053 | proof | 
| 1054 | have "?rhs \<in> Collect cone" | |
| 1055 | using Convex.cone_def by fastforce | |
| 1056 | moreover have "S \<subseteq> ?rhs" | |
| 1057 | by (smt (verit) mem_Collect_eq scaleR_one subsetI) | |
| 1058 | ultimately show "?lhs \<subseteq> ?rhs" | |
| 1059 | using hull_minimal by blast | |
| 1060 | qed (use mem_cone_hull in auto) | |
| 69619 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1061 | |
| 71242 | 1062 | lemma convex_cone: | 
| 78475 | 1063 | "convex S \<and> cone S \<longleftrightarrow> (\<forall>x\<in>S. \<forall>y\<in>S. (x + y) \<in> S) \<and> (\<forall>x\<in>S. \<forall>c\<ge>0. (c *\<^sub>R x) \<in> S)" | 
| 71242 | 1064 | (is "?lhs = ?rhs") | 
| 69619 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1065 | proof - | 
| 71242 | 1066 |   {
 | 
| 1067 | fix x y | |
| 78475 | 1068 | assume "x\<in>S" "y\<in>S" and ?lhs | 
| 1069 | then have "2 *\<^sub>R x \<in>S" "2 *\<^sub>R y \<in> S" "convex S" | |
| 71242 | 1070 | unfolding cone_def by auto | 
| 78475 | 1071 | then have "x + y \<in> S" | 
| 1072 | using convexD [OF \<open>convex S\<close>, of "2*\<^sub>R x" "2*\<^sub>R y"] | |
| 1073 | by (smt (verit, ccfv_threshold) field_sum_of_halves scaleR_2 scaleR_half_double) | |
| 71242 | 1074 | } | 
| 1075 | then show ?thesis | |
| 1076 | unfolding convex_def cone_def by blast | |
| 69619 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1077 | qed | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1078 | |
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1079 | |
| 70136 | 1080 | subsection\<^marker>\<open>tag unimportant\<close> \<open>Connectedness of convex sets\<close> | 
| 69619 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1081 | |
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1082 | lemma convex_connected: | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1083 | fixes S :: "'a::real_normed_vector set" | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1084 | assumes "convex S" | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1085 | shows "connected S" | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1086 | proof (rule connectedI) | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1087 | fix A B | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1088 |   assume "open A" "open B" "A \<inter> B \<inter> S = {}" "S \<subseteq> A \<union> B"
 | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1089 | moreover | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1090 |   assume "A \<inter> S \<noteq> {}" "B \<inter> S \<noteq> {}"
 | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1091 | then obtain a b where a: "a \<in> A" "a \<in> S" and b: "b \<in> B" "b \<in> S" by auto | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1092 | define f where [abs_def]: "f u = u *\<^sub>R a + (1 - u) *\<^sub>R b" for u | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1093 |   then have "continuous_on {0 .. 1} f"
 | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1094 | by (auto intro!: continuous_intros) | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1095 |   then have "connected (f ` {0 .. 1})"
 | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1096 | by (auto intro!: connected_continuous_image) | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1097 | note connectedD[OF this, of A B] | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1098 |   moreover have "a \<in> A \<inter> f ` {0 .. 1}"
 | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1099 | using a by (auto intro!: image_eqI[of _ _ 1] simp: f_def) | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1100 |   moreover have "b \<in> B \<inter> f ` {0 .. 1}"
 | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1101 | using b by (auto intro!: image_eqI[of _ _ 0] simp: f_def) | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1102 |   moreover have "f ` {0 .. 1} \<subseteq> S"
 | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1103 | using \<open>convex S\<close> a b unfolding convex_def f_def by auto | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1104 | ultimately show False by auto | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1105 | qed | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1106 | |
| 71136 | 1107 | corollary%unimportant connected_UNIV[intro]: "connected (UNIV :: 'a::real_normed_vector set)" | 
| 78475 | 1108 | by (simp add: convex_connected) | 
| 69619 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1109 | |
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1110 | lemma convex_prod: | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1111 |   assumes "\<And>i. i \<in> Basis \<Longrightarrow> convex {x. P i x}"
 | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1112 |   shows "convex {x. \<forall>i\<in>Basis. P i (x\<bullet>i)}"
 | 
| 78475 | 1113 | using assms by (auto simp: inner_add_left convex_def) | 
| 69619 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1114 | |
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1115 | lemma convex_positive_orthant: "convex {x::'a::euclidean_space. (\<forall>i\<in>Basis. 0 \<le> x\<bullet>i)}"
 | 
| 71136 | 1116 | by (rule convex_prod) (simp flip: atLeast_def) | 
| 69619 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1117 | |
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1118 | subsection \<open>Convex hull\<close> | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1119 | |
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1120 | lemma convex_convex_hull [iff]: "convex (convex hull s)" | 
| 78475 | 1121 | by (metis (mono_tags) convex_Inter hull_def mem_Collect_eq) | 
| 69619 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1122 | |
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1123 | lemma convex_hull_subset: | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1124 | "s \<subseteq> convex hull t \<Longrightarrow> convex hull s \<subseteq> convex hull t" | 
| 71174 | 1125 | by (simp add: subset_hull) | 
| 69619 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1126 | |
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1127 | lemma convex_hull_eq: "convex hull s = s \<longleftrightarrow> convex s" | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1128 | by (metis convex_convex_hull hull_same) | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1129 | |
| 70136 | 1130 | subsubsection\<^marker>\<open>tag unimportant\<close> \<open>Convex hull is "preserved" by a linear function\<close> | 
| 69619 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1131 | |
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1132 | lemma convex_hull_linear_image: | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1133 | assumes f: "linear f" | 
| 78475 | 1134 | shows "f ` (convex hull S) = convex hull (f ` S)" | 
| 69619 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1135 | proof | 
| 78475 | 1136 | show "convex hull (f ` S) \<subseteq> f ` (convex hull S)" | 
| 69619 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1137 | by (intro hull_minimal image_mono hull_subset convex_linear_image assms convex_convex_hull) | 
| 78475 | 1138 | show "f ` (convex hull S) \<subseteq> convex hull (f ` S)" | 
| 1139 | by (meson convex_convex_hull convex_linear_vimage f hull_minimal hull_subset image_subset_iff_subset_vimage) | |
| 69619 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1140 | qed | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1141 | |
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1142 | lemma in_convex_hull_linear_image: | 
| 78475 | 1143 | assumes "linear f" "x \<in> convex hull S" | 
| 1144 | shows "f x \<in> convex hull (f ` S)" | |
| 1145 | using assms convex_hull_linear_image image_eqI by blast | |
| 69619 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1146 | |
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1147 | lemma convex_hull_Times: | 
| 78475 | 1148 | "convex hull (S \<times> T) = (convex hull S) \<times> (convex hull T)" | 
| 69619 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1149 | proof | 
| 78475 | 1150 | show "convex hull (S \<times> T) \<subseteq> (convex hull S) \<times> (convex hull T)" | 
| 69619 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1151 | by (intro hull_minimal Sigma_mono hull_subset convex_Times convex_convex_hull) | 
| 78475 | 1152 | have "(x, y) \<in> convex hull (S \<times> T)" if x: "x \<in> convex hull S" and y: "y \<in> convex hull T" for x y | 
| 69619 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1153 | proof (rule hull_induct [OF x], rule hull_induct [OF y]) | 
| 78475 | 1154 | fix x y assume "x \<in> S" and "y \<in> T" | 
| 1155 | then show "(x, y) \<in> convex hull (S \<times> T)" | |
| 69619 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1156 | by (simp add: hull_inc) | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1157 | next | 
| 78475 | 1158 | fix x let ?S = "((\<lambda>y. (0, y)) -` (\<lambda>p. (- x, 0) + p) ` (convex hull S \<times> T))" | 
| 69619 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1159 | have "convex ?S" | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1160 | by (intro convex_linear_vimage convex_translation convex_convex_hull, | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1161 | simp add: linear_iff) | 
| 78475 | 1162 |     also have "?S = {y. (x, y) \<in> convex hull (S \<times> T)}"
 | 
| 69619 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1163 | by (auto simp: image_def Bex_def) | 
| 78475 | 1164 |     finally show "convex {y. (x, y) \<in> convex hull (S \<times> T)}" .
 | 
| 69619 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1165 | next | 
| 78475 | 1166 |     show "convex {x. (x, y) \<in> convex hull S \<times> T}"
 | 
| 69619 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1167 | proof - | 
| 78475 | 1168 | fix y let ?S = "((\<lambda>x. (x, 0)) -` (\<lambda>p. (0, - y) + p) ` (convex hull S \<times> T))" | 
| 69619 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1169 | have "convex ?S" | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1170 | by (intro convex_linear_vimage convex_translation convex_convex_hull, | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1171 | simp add: linear_iff) | 
| 78475 | 1172 |       also have "?S = {x. (x, y) \<in> convex hull (S \<times> T)}"
 | 
| 69619 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1173 | by (auto simp: image_def Bex_def) | 
| 78475 | 1174 |       finally show "convex {x. (x, y) \<in> convex hull (S \<times> T)}" .
 | 
| 69619 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1175 | qed | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1176 | qed | 
| 78475 | 1177 | then show "(convex hull S) \<times> (convex hull T) \<subseteq> convex hull (S \<times> T)" | 
| 69619 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1178 | unfolding subset_eq split_paired_Ball_Sigma by blast | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1179 | qed | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1180 | |
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1181 | |
| 70136 | 1182 | subsubsection\<^marker>\<open>tag unimportant\<close> \<open>Stepping theorems for convex hulls of finite sets\<close> | 
| 69619 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1183 | |
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1184 | lemma convex_hull_empty[simp]: "convex hull {} = {}"
 | 
| 78475 | 1185 | by (simp add: hull_same) | 
| 69619 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1186 | |
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1187 | lemma convex_hull_singleton[simp]: "convex hull {a} = {a}"
 | 
| 78475 | 1188 | by (simp add: hull_same) | 
| 69619 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1189 | |
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1190 | lemma convex_hull_insert: | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1191 | fixes S :: "'a::real_vector set" | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1192 |   assumes "S \<noteq> {}"
 | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1193 | shows "convex hull (insert a S) = | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1194 |          {x. \<exists>u\<ge>0. \<exists>v\<ge>0. \<exists>b. (u + v = 1) \<and> b \<in> (convex hull S) \<and> (x = u *\<^sub>R a + v *\<^sub>R b)}"
 | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1195 | (is "_ = ?hull") | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1196 | proof (intro equalityI hull_minimal subsetI) | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1197 | fix x | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1198 | assume "x \<in> insert a S" | 
| 78475 | 1199 | then show "x \<in> ?hull" | 
| 69619 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1200 | unfolding insert_iff | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1201 | proof | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1202 | assume "x = a" | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1203 | then show ?thesis | 
| 78475 | 1204 | by (smt (verit, del_insts) add.right_neutral assms ex_in_conv hull_inc mem_Collect_eq scaleR_one scaleR_zero_left) | 
| 69619 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1205 | next | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1206 | assume "x \<in> S" | 
| 78475 | 1207 | with hull_subset show ?thesis | 
| 69619 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1208 | by force | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1209 | qed | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1210 | next | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1211 | fix x | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1212 | assume "x \<in> ?hull" | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1213 | then obtain u v b where obt: "u\<ge>0" "v\<ge>0" "u + v = 1" "b \<in> convex hull S" "x = u *\<^sub>R a + v *\<^sub>R b" | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1214 | by auto | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1215 | have "a \<in> convex hull insert a S" "b \<in> convex hull insert a S" | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1216 |     using hull_mono[of S "insert a S" convex] hull_mono[of "{a}" "insert a S" convex] and obt(4)
 | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1217 | by auto | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1218 | then show "x \<in> convex hull insert a S" | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1219 | unfolding obt(5) using obt(1-3) | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1220 | by (rule convexD [OF convex_convex_hull]) | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1221 | next | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1222 | show "convex ?hull" | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1223 | proof (rule convexI) | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1224 | fix x y u v | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1225 | assume as: "(0::real) \<le> u" "0 \<le> v" "u + v = 1" and x: "x \<in> ?hull" and y: "y \<in> ?hull" | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1226 | from x obtain u1 v1 b1 where | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1227 | obt1: "u1\<ge>0" "v1\<ge>0" "u1 + v1 = 1" "b1 \<in> convex hull S" and xeq: "x = u1 *\<^sub>R a + v1 *\<^sub>R b1" | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1228 | by auto | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1229 | from y obtain u2 v2 b2 where | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1230 | obt2: "u2\<ge>0" "v2\<ge>0" "u2 + v2 = 1" "b2 \<in> convex hull S" and yeq: "y = u2 *\<^sub>R a + v2 *\<^sub>R b2" | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1231 | by auto | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1232 | have *: "\<And>(x::'a) s1 s2. x - s1 *\<^sub>R x - s2 *\<^sub>R x = ((1::real) - (s1 + s2)) *\<^sub>R x" | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1233 | by (auto simp: algebra_simps) | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1234 | have "\<exists>b \<in> convex hull S. u *\<^sub>R x + v *\<^sub>R y = | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1235 | (u * u1) *\<^sub>R a + (v * u2) *\<^sub>R a + (b - (u * u1) *\<^sub>R b - (v * u2) *\<^sub>R b)" | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1236 | proof (cases "u * v1 + v * v2 = 0") | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1237 | case True | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1238 | have *: "\<And>(x::'a) s1 s2. x - s1 *\<^sub>R x - s2 *\<^sub>R x = ((1::real) - (s1 + s2)) *\<^sub>R x" | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1239 | by (auto simp: algebra_simps) | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1240 | have eq0: "u * v1 = 0" "v * v2 = 0" | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1241 | using True mult_nonneg_nonneg[OF \<open>u\<ge>0\<close> \<open>v1\<ge>0\<close>] mult_nonneg_nonneg[OF \<open>v\<ge>0\<close> \<open>v2\<ge>0\<close>] | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1242 | by arith+ | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1243 | then have "u * u1 + v * u2 = 1" | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1244 | using as(3) obt1(3) obt2(3) by auto | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1245 | then show ?thesis | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1246 | using "*" eq0 as obt1(4) xeq yeq by auto | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1247 | next | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1248 | case False | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1249 | have "1 - (u * u1 + v * u2) = (u + v) - (u * u1 + v * u2)" | 
| 78475 | 1250 | by (simp add: as(3)) | 
| 69619 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1251 | also have "\<dots> = u * v1 + v * v2" | 
| 78475 | 1252 | by (smt (verit, ccfv_SIG) distrib_left mult_cancel_left1 obt1(3) obt2(3)) | 
| 1253 | finally have **:"1 - (u * u1 + v * u2) = u * v1 + v * v2" . | |
| 69619 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1254 | let ?b = "((u * v1) / (u * v1 + v * v2)) *\<^sub>R b1 + ((v * v2) / (u * v1 + v * v2)) *\<^sub>R b2" | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1255 | have zeroes: "0 \<le> u * v1 + v * v2" "0 \<le> u * v1" "0 \<le> u * v1 + v * v2" "0 \<le> v * v2" | 
| 78475 | 1256 | using as obt1 obt2 by auto | 
| 69619 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1257 | show ?thesis | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1258 | proof | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1259 | show "u *\<^sub>R x + v *\<^sub>R y = (u * u1) *\<^sub>R a + (v * u2) *\<^sub>R a + (?b - (u * u1) *\<^sub>R ?b - (v * u2) *\<^sub>R ?b)" | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1260 | unfolding xeq yeq * ** | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1261 | using False by (auto simp: scaleR_left_distrib scaleR_right_distrib) | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1262 | show "?b \<in> convex hull S" | 
| 78475 | 1263 | using False mem_convex_alt obt1(4) obt2(4) zeroes(2) zeroes(4) by fastforce | 
| 69619 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1264 | qed | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1265 | qed | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1266 | then obtain b where b: "b \<in> convex hull S" | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1267 | "u *\<^sub>R x + v *\<^sub>R y = (u * u1) *\<^sub>R a + (v * u2) *\<^sub>R a + (b - (u * u1) *\<^sub>R b - (v * u2) *\<^sub>R b)" .. | 
| 78475 | 1268 | obtain u1: "u1 \<le> 1" and u2: "u2 \<le> 1" | 
| 1269 | using obt1 obt2 by auto | |
| 69619 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1270 | have "u1 * u + u2 * v \<le> max u1 u2 * u + max u1 u2 * v" | 
| 78475 | 1271 | by (smt (verit, ccfv_SIG) as mult_right_mono) | 
| 69619 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1272 | also have "\<dots> \<le> 1" | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1273 | unfolding distrib_left[symmetric] and as(3) using u1 u2 by auto | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1274 | finally have le1: "u1 * u + u2 * v \<le> 1" . | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1275 | show "u *\<^sub>R x + v *\<^sub>R y \<in> ?hull" | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1276 | proof (intro CollectI exI conjI) | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1277 | show "0 \<le> u * u1 + v * u2" | 
| 78475 | 1278 | by (simp add: as obt1(1) obt2(1)) | 
| 69619 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1279 | show "0 \<le> 1 - u * u1 - v * u2" | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1280 | by (simp add: le1 diff_diff_add mult.commute) | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1281 | qed (use b in \<open>auto simp: algebra_simps\<close>) | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1282 | qed | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1283 | qed | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1284 | |
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1285 | lemma convex_hull_insert_alt: | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1286 | "convex hull (insert a S) = | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1287 |      (if S = {} then {a}
 | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1288 |       else {(1 - u) *\<^sub>R a + u *\<^sub>R x |x u. 0 \<le> u \<and> u \<le> 1 \<and> x \<in> convex hull S})"
 | 
| 78475 | 1289 | apply (simp add: convex_hull_insert) | 
| 1290 | using diff_add_cancel diff_ge_0_iff_ge | |
| 1291 | by (smt (verit, del_insts) Collect_cong) | |
| 69619 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1292 | |
| 70136 | 1293 | subsubsection\<^marker>\<open>tag unimportant\<close> \<open>Explicit expression for convex hull\<close> | 
| 69619 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1294 | |
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1295 | proposition convex_hull_indexed: | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1296 | fixes S :: "'a::real_vector set" | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1297 | shows "convex hull S = | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1298 |     {y. \<exists>k u x. (\<forall>i\<in>{1::nat .. k}. 0 \<le> u i \<and> x i \<in> S) \<and>
 | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1299 |                 (sum u {1..k} = 1) \<and> (\<Sum>i = 1..k. u i *\<^sub>R x i) = y}"
 | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1300 | (is "?xyz = ?hull") | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1301 | proof (rule hull_unique [OF _ convexI]) | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1302 | show "S \<subseteq> ?hull" | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1303 | by (clarsimp, rule_tac x=1 in exI, rule_tac x="\<lambda>x. 1" in exI, auto) | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1304 | next | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1305 | fix T | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1306 | assume "S \<subseteq> T" "convex T" | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1307 | then show "?hull \<subseteq> T" | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1308 | by (blast intro: convex_sum) | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1309 | next | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1310 | fix x y u v | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1311 | assume uv: "0 \<le> u" "0 \<le> v" "u + v = (1::real)" | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1312 | assume xy: "x \<in> ?hull" "y \<in> ?hull" | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1313 | from xy obtain k1 u1 x1 where | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1314 |     x [rule_format]: "\<forall>i\<in>{1::nat..k1}. 0\<le>u1 i \<and> x1 i \<in> S" 
 | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1315 |                       "sum u1 {Suc 0..k1} = 1" "(\<Sum>i = Suc 0..k1. u1 i *\<^sub>R x1 i) = x"
 | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1316 | by auto | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1317 | from xy obtain k2 u2 x2 where | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1318 |     y [rule_format]: "\<forall>i\<in>{1::nat..k2}. 0\<le>u2 i \<and> x2 i \<in> S" 
 | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1319 |                      "sum u2 {Suc 0..k2} = 1" "(\<Sum>i = Suc 0..k2. u2 i *\<^sub>R x2 i) = y"
 | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1320 | by auto | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1321 | have *: "\<And>P (x::'a) y s t i. (if P i then s else t) *\<^sub>R (if P i then x else y) = (if P i then s *\<^sub>R x else t *\<^sub>R y)" | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1322 |           "{1..k1 + k2} \<inter> {1..k1} = {1..k1}" "{1..k1 + k2} \<inter> - {1..k1} = (\<lambda>i. i + k1) ` {1..k2}"
 | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1323 | by auto | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1324 |   have inj: "inj_on (\<lambda>i. i + k1) {1..k2}"
 | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1325 | unfolding inj_on_def by auto | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1326 |   let ?uu = "\<lambda>i. if i \<in> {1..k1} then u * u1 i else v * u2 (i - k1)"
 | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1327 |   let ?xx = "\<lambda>i. if i \<in> {1..k1} then x1 i else x2 (i - k1)"
 | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1328 | show "u *\<^sub>R x + v *\<^sub>R y \<in> ?hull" | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1329 | proof (intro CollectI exI conjI ballI) | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1330 |     show "0 \<le> ?uu i" "?xx i \<in> S" if "i \<in> {1..k1+k2}" for i
 | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1331 | using that by (auto simp add: le_diff_conv uv(1) x(1) uv(2) y(1)) | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1332 | show "(\<Sum>i = 1..k1 + k2. ?uu i) = 1" "(\<Sum>i = 1..k1 + k2. ?uu i *\<^sub>R ?xx i) = u *\<^sub>R x + v *\<^sub>R y" | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1333 | unfolding * sum.If_cases[OF finite_atLeastAtMost[of 1 "k1 + k2"]] | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1334 | sum.reindex[OF inj] Collect_mem_eq o_def | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1335 | unfolding scaleR_scaleR[symmetric] scaleR_right.sum [symmetric] sum_distrib_left[symmetric] | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1336 | by (simp_all add: sum_distrib_left[symmetric] x(2,3) y(2,3) uv(3)) | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1337 | qed | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1338 | qed | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1339 | |
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1340 | lemma convex_hull_finite: | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1341 | fixes S :: "'a::real_vector set" | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1342 | assumes "finite S" | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1343 |   shows "convex hull S = {y. \<exists>u. (\<forall>x\<in>S. 0 \<le> u x) \<and> sum u S = 1 \<and> sum (\<lambda>x. u x *\<^sub>R x) S = y}"
 | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1344 | (is "?HULL = _") | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1345 | proof (rule hull_unique [OF _ convexI]; clarify) | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1346 | fix x | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1347 | assume "x \<in> S" | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1348 | then show "\<exists>u. (\<forall>x\<in>S. 0 \<le> u x) \<and> sum u S = 1 \<and> (\<Sum>x\<in>S. u x *\<^sub>R x) = x" | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1349 | by (rule_tac x="\<lambda>y. if x=y then 1 else 0" in exI) (auto simp: sum.delta'[OF assms] sum_delta''[OF assms]) | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1350 | next | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1351 | fix u v :: real | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1352 | assume uv: "0 \<le> u" "0 \<le> v" "u + v = 1" | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1353 | fix ux assume ux [rule_format]: "\<forall>x\<in>S. 0 \<le> ux x" "sum ux S = (1::real)" | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1354 | fix uy assume uy [rule_format]: "\<forall>x\<in>S. 0 \<le> uy x" "sum uy S = (1::real)" | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1355 | have "0 \<le> u * ux x + v * uy x" if "x\<in>S" for x | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1356 | by (simp add: that uv ux(1) uy(1)) | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1357 | moreover | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1358 | have "(\<Sum>x\<in>S. u * ux x + v * uy x) = 1" | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1359 | unfolding sum.distrib and sum_distrib_left[symmetric] ux(2) uy(2) | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1360 | using uv(3) by auto | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1361 | moreover | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1362 | have "(\<Sum>x\<in>S. (u * ux x + v * uy x) *\<^sub>R x) = u *\<^sub>R (\<Sum>x\<in>S. ux x *\<^sub>R x) + v *\<^sub>R (\<Sum>x\<in>S. uy x *\<^sub>R x)" | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1363 | unfolding scaleR_left_distrib sum.distrib scaleR_scaleR[symmetric] scaleR_right.sum [symmetric] | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1364 | by auto | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1365 | ultimately | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1366 | show "\<exists>uc. (\<forall>x\<in>S. 0 \<le> uc x) \<and> sum uc S = 1 \<and> | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1367 | (\<Sum>x\<in>S. uc x *\<^sub>R x) = u *\<^sub>R (\<Sum>x\<in>S. ux x *\<^sub>R x) + v *\<^sub>R (\<Sum>x\<in>S. uy x *\<^sub>R x)" | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1368 | by (rule_tac x="\<lambda>x. u * ux x + v * uy x" in exI, auto) | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1369 | qed (use assms in \<open>auto simp: convex_explicit\<close>) | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1370 | |
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1371 | |
| 70136 | 1372 | subsubsection\<^marker>\<open>tag unimportant\<close> \<open>Another formulation\<close> | 
| 69619 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1373 | |
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1374 | text "Formalized by Lars Schewe." | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1375 | |
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1376 | lemma convex_hull_explicit: | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1377 | fixes p :: "'a::real_vector set" | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1378 | shows "convex hull p = | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1379 |     {y. \<exists>S u. finite S \<and> S \<subseteq> p \<and> (\<forall>x\<in>S. 0 \<le> u x) \<and> sum u S = 1 \<and> sum (\<lambda>v. u v *\<^sub>R v) S = y}"
 | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1380 | (is "?lhs = ?rhs") | 
| 78475 | 1381 | proof (intro subset_antisym subsetI) | 
| 1382 | fix x | |
| 1383 | assume "x \<in> convex hull p" | |
| 1384 | then obtain k u y where | |
| 1385 |     obt: "\<forall>i\<in>{1::nat..k}. 0 \<le> u i \<and> y i \<in> p" "sum u {1..k} = 1" "(\<Sum>i = 1..k. u i *\<^sub>R y i) = x"
 | |
| 1386 | unfolding convex_hull_indexed by auto | |
| 1387 |   have fin: "finite {1..k}" by auto
 | |
| 69619 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1388 |   {
 | 
| 78475 | 1389 | fix j | 
| 1390 |     assume "j\<in>{1..k}"
 | |
| 1391 |     then have "y j \<in> p \<and> 0 \<le> sum u {i. Suc 0 \<le> i \<and> i \<le> k \<and> y i = y j}"
 | |
| 1392 | by (metis (mono_tags, lifting) One_nat_def atLeastAtMost_iff mem_Collect_eq obt(1) sum_nonneg) | |
| 69619 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1393 | } | 
| 78475 | 1394 |   moreover have "(\<Sum>v\<in>y ` {1..k}. sum u {i \<in> {1..k}. y i = v}) = 1"
 | 
| 1395 | unfolding sum.image_gen[OF fin, symmetric] using obt(2) by auto | |
| 1396 |   moreover have "(\<Sum>v\<in>y ` {1..k}. sum u {i \<in> {1..k}. y i = v} *\<^sub>R v) = x"
 | |
| 1397 | using sum.image_gen[OF fin, of "\<lambda>i. u i *\<^sub>R y i" y, symmetric] | |
| 1398 | unfolding scaleR_left.sum using obt(3) by auto | |
| 1399 | ultimately | |
| 1400 | have "\<exists>S u. finite S \<and> S \<subseteq> p \<and> (\<forall>x\<in>S. 0 \<le> u x) \<and> sum u S = 1 \<and> (\<Sum>v\<in>S. u v *\<^sub>R v) = x" | |
| 1401 | by (smt (verit, ccfv_SIG) imageE mem_Collect_eq obt(1) subsetI sum.cong sum.infinite sum_nonneg) | |
| 1402 | then show "x \<in> ?rhs" by auto | |
| 1403 | next | |
| 1404 | fix y | |
| 1405 | assume "y \<in> ?rhs" | |
| 1406 | then obtain S u where | |
| 1407 | S: "finite S" "S \<subseteq> p" "\<forall>x\<in>S. 0 \<le> u x" "sum u S = 1" "(\<Sum>v\<in>S. u v *\<^sub>R v) = y" | |
| 1408 | by auto | |
| 1409 |   obtain f where f: "inj_on f {1..card S}" "f ` {1..card S} = S"
 | |
| 1410 | using ex_bij_betw_nat_finite_1[OF S(1)] unfolding bij_betw_def by auto | |
| 1411 |   then have "0 \<le> u (f i)" "f i \<in> p" if "i \<in> {1..card S}" for i
 | |
| 1412 |     using S \<open>i \<in> {1..card S}\<close> by blast+
 | |
| 1413 | moreover | |
| 69619 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1414 |   {
 | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1415 | fix y | 
| 78475 | 1416 | assume "y\<in>S" | 
| 1417 |     then obtain i where "i\<in>{1..card S}" "f i = y"
 | |
| 1418 | by (metis f(2) image_iff) | |
| 1419 |     then have "{x. Suc 0 \<le> x \<and> x \<le> card S \<and> f x = y} = {i}"
 | |
| 1420 | using f(1) inj_onD by fastforce | |
| 1421 |     then have "(\<Sum>x\<in>{x \<in> {1..card S}. f x = y}. u (f x)) = u y"
 | |
| 1422 |       "(\<Sum>x\<in>{x \<in> {1..card S}. f x = y}. u (f x) *\<^sub>R f x) = u y *\<^sub>R y"
 | |
| 1423 | by (simp_all add: sum_constant_scaleR \<open>f i = y\<close>) | |
| 69619 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1424 | } | 
| 78475 | 1425 | then have "(\<Sum>x = 1..card S. u (f x)) = 1" "(\<Sum>i = 1..card S. u (f i) *\<^sub>R f i) = y" | 
| 1426 | by (metis (mono_tags, lifting) S(4,5) f sum.reindex_cong)+ | |
| 1427 | ultimately | |
| 1428 | show "y \<in> convex hull p" | |
| 1429 | unfolding convex_hull_indexed | |
| 1430 | by (smt (verit, del_insts) mem_Collect_eq sum.cong) | |
| 69619 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1431 | qed | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1432 | |
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1433 | |
| 70136 | 1434 | subsubsection\<^marker>\<open>tag unimportant\<close> \<open>A stepping theorem for that expansion\<close> | 
| 69619 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1435 | |
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1436 | lemma convex_hull_finite_step: | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1437 | fixes S :: "'a::real_vector set" | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1438 | assumes "finite S" | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1439 | shows | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1440 | "(\<exists>u. (\<forall>x\<in>insert a S. 0 \<le> u x) \<and> sum u (insert a S) = w \<and> sum (\<lambda>x. u x *\<^sub>R x) (insert a S) = y) | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1441 | \<longleftrightarrow> (\<exists>v\<ge>0. \<exists>u. (\<forall>x\<in>S. 0 \<le> u x) \<and> sum u S = w - v \<and> sum (\<lambda>x. u x *\<^sub>R x) S = y - v *\<^sub>R a)" | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1442 | (is "?lhs = ?rhs") | 
| 72385 | 1443 | proof (cases "a \<in> S") | 
| 1444 | case True | |
| 69619 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1445 | then have *: "insert a S = S" by auto | 
| 72385 | 1446 | show ?thesis | 
| 1447 | proof | |
| 1448 | assume ?lhs | |
| 1449 | then show ?rhs | |
| 1450 | unfolding * by force | |
| 1451 | next | |
| 1452 | have fin: "finite (insert a S)" using assms by auto | |
| 1453 | assume ?rhs | |
| 1454 | then obtain v u where uv: "v\<ge>0" "\<forall>x\<in>S. 0 \<le> u x" "sum u S = w - v" "(\<Sum>x\<in>S. u x *\<^sub>R x) = y - v *\<^sub>R a" | |
| 1455 | by auto | |
| 1456 | then show ?lhs | |
| 1457 | using uv True assms | |
| 1458 | apply (rule_tac x = "\<lambda>x. (if a = x then v else 0) + u x" in exI) | |
| 1459 | apply (auto simp: sum_clauses scaleR_left_distrib sum.distrib sum_delta''[OF fin]) | |
| 1460 | done | |
| 1461 | qed | |
| 69619 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1462 | next | 
| 72385 | 1463 | case False | 
| 1464 | show ?thesis | |
| 1465 | proof | |
| 1466 | assume ?lhs | |
| 1467 | then obtain u where u: "\<forall>x\<in>insert a S. 0 \<le> u x" "sum u (insert a S) = w" "(\<Sum>x\<in>insert a S. u x *\<^sub>R x) = y" | |
| 1468 | by auto | |
| 1469 | then show ?rhs | |
| 1470 | using u \<open>a\<notin>S\<close> by (rule_tac x="u a" in exI) (auto simp: sum_clauses assms) | |
| 1471 | next | |
| 1472 | assume ?rhs | |
| 1473 | then obtain v u where uv: "v\<ge>0" "\<forall>x\<in>S. 0 \<le> u x" "sum u S = w - v" "(\<Sum>x\<in>S. u x *\<^sub>R x) = y - v *\<^sub>R a" | |
| 1474 | by auto | |
| 1475 | moreover | |
| 1476 | have "(\<Sum>x\<in>S. if a = x then v else u x) = sum u S" "(\<Sum>x\<in>S. (if a = x then v else u x) *\<^sub>R x) = (\<Sum>x\<in>S. u x *\<^sub>R x)" | |
| 1477 | using False by (auto intro!: sum.cong) | |
| 1478 | ultimately show ?lhs | |
| 1479 | using False by (rule_tac x="\<lambda>x. if a = x then v else u x" in exI) (auto simp: sum_clauses(2)[OF assms]) | |
| 1480 | qed | |
| 69619 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1481 | qed | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1482 | |
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1483 | |
| 70136 | 1484 | subsubsection\<^marker>\<open>tag unimportant\<close> \<open>Hence some special cases\<close> | 
| 69619 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1485 | |
| 72385 | 1486 | lemma convex_hull_2: "convex hull {a,b} = {u *\<^sub>R a + v *\<^sub>R b | u v. 0 \<le> u \<and> 0 \<le> v \<and> u + v = 1}"
 | 
| 1487 | (is "?lhs = ?rhs") | |
| 69619 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1488 | proof - | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1489 |   have **: "finite {b}" by auto
 | 
| 72385 | 1490 | have "\<And>x v u. \<lbrakk>0 \<le> v; v \<le> 1; (1 - v) *\<^sub>R b = x - v *\<^sub>R a\<rbrakk> | 
| 1491 | \<Longrightarrow> \<exists>u v. x = u *\<^sub>R a + v *\<^sub>R b \<and> 0 \<le> u \<and> 0 \<le> v \<and> u + v = 1" | |
| 1492 | by (metis add.commute diff_add_cancel diff_ge_0_iff_ge) | |
| 1493 | moreover | |
| 1494 | have "\<And>u v. \<lbrakk>0 \<le> u; 0 \<le> v; u + v = 1\<rbrakk> | |
| 1495 | \<Longrightarrow> \<exists>p\<ge>0. \<exists>q. 0 \<le> q b \<and> q b = 1 - p \<and> q b *\<^sub>R b = u *\<^sub>R a + v *\<^sub>R b - p *\<^sub>R a" | |
| 69619 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1496 | apply (rule_tac x=u in exI, simp) | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1497 | apply (rule_tac x="\<lambda>x. v" in exI, simp) | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1498 | done | 
| 72385 | 1499 | ultimately show ?thesis | 
| 1500 | using convex_hull_finite_step[OF **, of a 1] | |
| 1501 | by (auto simp add: convex_hull_finite) | |
| 69619 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1502 | qed | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1503 | |
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1504 | lemma convex_hull_2_alt: "convex hull {a,b} = {a + u *\<^sub>R (b - a) | u.  0 \<le> u \<and> u \<le> 1}"
 | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1505 | unfolding convex_hull_2 | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1506 | proof (rule Collect_cong) | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1507 | have *: "\<And>x y ::real. x + y = 1 \<longleftrightarrow> x = 1 - y" | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1508 | by auto | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1509 | fix x | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1510 | show "(\<exists>v u. x = v *\<^sub>R a + u *\<^sub>R b \<and> 0 \<le> v \<and> 0 \<le> u \<and> v + u = 1) \<longleftrightarrow> | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1511 | (\<exists>u. x = a + u *\<^sub>R (b - a) \<and> 0 \<le> u \<and> u \<le> 1)" | 
| 72385 | 1512 | apply (simp add: *) | 
| 1513 | by (rule ex_cong1) (auto simp: algebra_simps) | |
| 69619 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1514 | qed | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1515 | |
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1516 | lemma convex_hull_3: | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1517 |   "convex hull {a,b,c} = { u *\<^sub>R a + v *\<^sub>R b + w *\<^sub>R c | u v w. 0 \<le> u \<and> 0 \<le> v \<and> 0 \<le> w \<and> u + v + w = 1}"
 | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1518 | proof - | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1519 |   have fin: "finite {a,b,c}" "finite {b,c}" "finite {c}"
 | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1520 | by auto | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1521 | have *: "\<And>x y z ::real. x + y + z = 1 \<longleftrightarrow> x = 1 - y - z" | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1522 | by (auto simp: field_simps) | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1523 | show ?thesis | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1524 | unfolding convex_hull_finite[OF fin(1)] and convex_hull_finite_step[OF fin(2)] and * | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1525 | unfolding convex_hull_finite_step[OF fin(3)] | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1526 | apply (rule Collect_cong, simp) | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1527 | apply auto | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1528 | apply (rule_tac x=va in exI) | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1529 | apply (rule_tac x="u c" in exI, simp) | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1530 | apply (rule_tac x="1 - v - w" in exI, simp) | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1531 | apply (rule_tac x=v in exI, simp) | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1532 | apply (rule_tac x="\<lambda>x. w" in exI, simp) | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1533 | done | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1534 | qed | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1535 | |
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1536 | lemma convex_hull_3_alt: | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1537 |   "convex hull {a,b,c} = {a + u *\<^sub>R (b - a) + v *\<^sub>R (c - a) | u v.  0 \<le> u \<and> 0 \<le> v \<and> u + v \<le> 1}"
 | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1538 | proof - | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1539 | have *: "\<And>x y z ::real. x + y + z = 1 \<longleftrightarrow> x = 1 - y - z" | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1540 | by auto | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1541 | show ?thesis | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1542 | unfolding convex_hull_3 | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1543 | apply (auto simp: *) | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1544 | apply (rule_tac x=v in exI) | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1545 | apply (rule_tac x=w in exI) | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1546 | apply (simp add: algebra_simps) | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1547 | apply (rule_tac x=u in exI) | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1548 | apply (rule_tac x=v in exI) | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1549 | apply (simp add: algebra_simps) | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1550 | done | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1551 | qed | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1552 | |
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1553 | |
| 70136 | 1554 | subsection\<^marker>\<open>tag unimportant\<close> \<open>Relations among closure notions and corresponding hulls\<close> | 
| 69619 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1555 | |
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1556 | lemma affine_imp_convex: "affine s \<Longrightarrow> convex s" | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1557 | unfolding affine_def convex_def by auto | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1558 | |
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1559 | lemma convex_affine_hull [simp]: "convex (affine hull S)" | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1560 | by (simp add: affine_imp_convex) | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1561 | |
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1562 | lemma subspace_imp_convex: "subspace s \<Longrightarrow> convex s" | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1563 | using subspace_imp_affine affine_imp_convex by auto | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1564 | |
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1565 | lemma convex_hull_subset_span: "(convex hull s) \<subseteq> (span s)" | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1566 | by (metis hull_minimal span_superset subspace_imp_convex subspace_span) | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1567 | |
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1568 | lemma convex_hull_subset_affine_hull: "(convex hull s) \<subseteq> (affine hull s)" | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1569 | by (metis affine_affine_hull affine_imp_convex hull_minimal hull_subset) | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1570 | |
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1571 | lemma aff_dim_convex_hull: | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1572 | fixes S :: "'n::euclidean_space set" | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1573 | shows "aff_dim (convex hull S) = aff_dim S" | 
| 78475 | 1574 | by (smt (verit) aff_dim_affine_hull aff_dim_subset convex_hull_subset_affine_hull hull_subset) | 
| 69619 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1575 | |
| 71242 | 1576 | |
| 69619 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1577 | subsection \<open>Caratheodory's theorem\<close> | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1578 | |
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1579 | lemma convex_hull_caratheodory_aff_dim: | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1580 |   fixes p :: "('a::euclidean_space) set"
 | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1581 | shows "convex hull p = | 
| 72385 | 1582 |     {y. \<exists>S u. finite S \<and> S \<subseteq> p \<and> card S \<le> aff_dim p + 1 \<and>
 | 
| 1583 | (\<forall>x\<in>S. 0 \<le> u x) \<and> sum u S = 1 \<and> sum (\<lambda>v. u v *\<^sub>R v) S = y}" | |
| 69619 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1584 | unfolding convex_hull_explicit set_eq_iff mem_Collect_eq | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1585 | proof (intro allI iffI) | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1586 | fix y | 
| 72385 | 1587 | let ?P = "\<lambda>n. \<exists>S u. finite S \<and> card S = n \<and> S \<subseteq> p \<and> (\<forall>x\<in>S. 0 \<le> u x) \<and> | 
| 1588 | sum u S = 1 \<and> (\<Sum>v\<in>S. u v *\<^sub>R v) = y" | |
| 1589 | assume "\<exists>S u. finite S \<and> S \<subseteq> p \<and> (\<forall>x\<in>S. 0 \<le> u x) \<and> sum u S = 1 \<and> (\<Sum>v\<in>S. u v *\<^sub>R v) = y" | |
| 69619 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1590 | then obtain N where "?P N" by auto | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1591 | then have "\<exists>n\<le>N. (\<forall>k<n. \<not> ?P k) \<and> ?P n" | 
| 72385 | 1592 | by (rule_tac ex_least_nat_le, auto) | 
| 69619 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1593 | then obtain n where "?P n" and smallest: "\<forall>k<n. \<not> ?P k" | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1594 | by blast | 
| 78475 | 1595 | then obtain S u where S: "finite S" "card S = n" "S\<subseteq>p" | 
| 1596 | and u: "\<forall>x\<in>S. 0 \<le> u x" "sum u S = 1" "(\<Sum>v\<in>S. u v *\<^sub>R v) = y" by auto | |
| 69619 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1597 | |
| 72385 | 1598 | have "card S \<le> aff_dim p + 1" | 
| 69619 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1599 | proof (rule ccontr, simp only: not_le) | 
| 72385 | 1600 | assume "aff_dim p + 1 < card S" | 
| 1601 | then have "affine_dependent S" | |
| 78475 | 1602 | by (smt (verit) independent_card_le_aff_dim S(3)) | 
| 72385 | 1603 | then obtain w v where wv: "sum w S = 0" "v\<in>S" "w v \<noteq> 0" "(\<Sum>v\<in>S. w v *\<^sub>R v) = 0" | 
| 78475 | 1604 | using affine_dependent_explicit_finite[OF S(1)] by auto | 
| 72385 | 1605 |     define i where "i = (\<lambda>v. (u v) / (- w v)) ` {v\<in>S. w v < 0}"
 | 
| 69619 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1606 | define t where "t = Min i" | 
| 72385 | 1607 | have "\<exists>x\<in>S. w x < 0" | 
| 78475 | 1608 | by (smt (verit, best) S(1) sum_pos2 wv) | 
| 69619 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1609 |     then have "i \<noteq> {}" unfolding i_def by auto
 | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1610 | then have "t \<ge> 0" | 
| 78475 | 1611 | using Min_ge_iff[of i 0] and S(1) u[unfolded le_less] | 
| 69619 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1612 | unfolding t_def i_def | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1613 | by (auto simp: divide_le_0_iff) | 
| 72385 | 1614 | have t: "\<forall>v\<in>S. u v + t * w v \<ge> 0" | 
| 69619 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1615 | proof | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1616 | fix v | 
| 72385 | 1617 | assume "v \<in> S" | 
| 69619 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1618 | then have v: "0 \<le> u v" | 
| 78475 | 1619 | using u(1) by blast | 
| 69619 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1620 | show "0 \<le> u v + t * w v" | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1621 | proof (cases "w v < 0") | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1622 | case False | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1623 | thus ?thesis using v \<open>t\<ge>0\<close> by auto | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1624 | next | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1625 | case True | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1626 | then have "t \<le> u v / (- w v)" | 
| 78475 | 1627 | using \<open>v\<in>S\<close> S unfolding t_def i_def by (auto intro: Min_le) | 
| 69619 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1628 | then show ?thesis | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1629 | unfolding real_0_le_add_iff | 
| 72385 | 1630 | using True neg_le_minus_divide_eq by auto | 
| 69619 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1631 | qed | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1632 | qed | 
| 72385 | 1633 | obtain a where "a \<in> S" and "t = (\<lambda>v. (u v) / (- w v)) a" and "w a < 0" | 
| 78475 | 1634 |       using Min_in[OF _ \<open>i\<noteq>{}\<close>] and S(1) unfolding i_def t_def by auto
 | 
| 72385 | 1635 | then have a: "a \<in> S" "u a + t * w a = 0" by auto | 
| 1636 |     have *: "\<And>f. sum f (S - {a}) = sum f S - ((f a)::'b::ab_group_add)"
 | |
| 78475 | 1637 | unfolding sum.remove[OF S(1) \<open>a\<in>S\<close>] by auto | 
| 72385 | 1638 | have "(\<Sum>v\<in>S. u v + t * w v) = 1" | 
| 78475 | 1639 | by (metis add.right_neutral mult_zero_right sum.distrib sum_distrib_left u(2) wv(1)) | 
| 72385 | 1640 | moreover have "(\<Sum>v\<in>S. u v *\<^sub>R v + (t * w v) *\<^sub>R v) - (u a *\<^sub>R a + (t * w a) *\<^sub>R a) = y" | 
| 78475 | 1641 | unfolding sum.distrib u(3) scaleR_scaleR[symmetric] scaleR_right.sum [symmetric] wv(4) | 
| 69619 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1642 | using a(2) [THEN eq_neg_iff_add_eq_0 [THEN iffD2]] by simp | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1643 | ultimately have "?P (n - 1)" | 
| 72385 | 1644 |       apply (rule_tac x="(S - {a})" in exI)
 | 
| 69619 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1645 | apply (rule_tac x="\<lambda>v. u v + t * w v" in exI) | 
| 78475 | 1646 | using S t a | 
| 69619 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1647 | apply (auto simp: * scaleR_left_distrib) | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1648 | done | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1649 | then show False | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1650 | using smallest[THEN spec[where x="n - 1"]] by auto | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1651 | qed | 
| 72385 | 1652 | then show "\<exists>S u. finite S \<and> S \<subseteq> p \<and> card S \<le> aff_dim p + 1 \<and> | 
| 1653 | (\<forall>x\<in>S. 0 \<le> u x) \<and> sum u S = 1 \<and> (\<Sum>v\<in>S. u v *\<^sub>R v) = y" | |
| 78475 | 1654 | using S u by auto | 
| 69619 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1655 | qed auto | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1656 | |
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1657 | lemma caratheodory_aff_dim: | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1658 |   fixes p :: "('a::euclidean_space) set"
 | 
| 72385 | 1659 |   shows "convex hull p = {x. \<exists>S. finite S \<and> S \<subseteq> p \<and> card S \<le> aff_dim p + 1 \<and> x \<in> convex hull S}"
 | 
| 69619 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1660 | (is "?lhs = ?rhs") | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1661 | proof | 
| 72385 | 1662 | have "\<And>x S u. \<lbrakk>finite S; S \<subseteq> p; int (card S) \<le> aff_dim p + 1; \<forall>x\<in>S. 0 \<le> u x; sum u S = 1\<rbrakk> | 
| 1663 | \<Longrightarrow> (\<Sum>v\<in>S. u v *\<^sub>R v) \<in> convex hull S" | |
| 78475 | 1664 | by (metis (mono_tags, lifting) convex_convex_hull convex_explicit hull_subset) | 
| 72385 | 1665 | then show "?lhs \<subseteq> ?rhs" | 
| 1666 | by (subst convex_hull_caratheodory_aff_dim, auto) | |
| 1667 | qed (use hull_mono in auto) | |
| 69619 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1668 | |
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1669 | lemma convex_hull_caratheodory: | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1670 |   fixes p :: "('a::euclidean_space) set"
 | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1671 | shows "convex hull p = | 
| 72385 | 1672 |             {y. \<exists>S u. finite S \<and> S \<subseteq> p \<and> card S \<le> DIM('a) + 1 \<and>
 | 
| 1673 | (\<forall>x\<in>S. 0 \<le> u x) \<and> sum u S = 1 \<and> sum (\<lambda>v. u v *\<^sub>R v) S = y}" | |
| 69619 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1674 | (is "?lhs = ?rhs") | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1675 | proof (intro set_eqI iffI) | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1676 | fix x | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1677 | assume "x \<in> ?lhs" then show "x \<in> ?rhs" | 
| 72385 | 1678 | unfolding convex_hull_caratheodory_aff_dim | 
| 1679 | using aff_dim_le_DIM [of p] by fastforce | |
| 1680 | qed (auto simp: convex_hull_explicit) | |
| 69619 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1681 | |
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1682 | theorem caratheodory: | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1683 | "convex hull p = | 
| 72385 | 1684 |     {x::'a::euclidean_space. \<exists>S. finite S \<and> S \<subseteq> p \<and> card S \<le> DIM('a) + 1 \<and> x \<in> convex hull S}"
 | 
| 69619 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1685 | proof safe | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1686 | fix x | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1687 | assume "x \<in> convex hull p" | 
| 72385 | 1688 |   then obtain S u where "finite S" "S \<subseteq> p" "card S \<le> DIM('a) + 1"
 | 
| 1689 | "\<forall>x\<in>S. 0 \<le> u x" "sum u S = 1" "(\<Sum>v\<in>S. u v *\<^sub>R v) = x" | |
| 69619 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1690 | unfolding convex_hull_caratheodory by auto | 
| 72385 | 1691 |   then show "\<exists>S. finite S \<and> S \<subseteq> p \<and> card S \<le> DIM('a) + 1 \<and> x \<in> convex hull S"
 | 
| 1692 | using convex_hull_finite by fastforce | |
| 1693 | qed (use hull_mono in force) | |
| 69619 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1694 | |
| 70136 | 1695 | subsection\<^marker>\<open>tag unimportant\<close>\<open>Some Properties of subset of standard basis\<close> | 
| 69619 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1696 | |
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1697 | lemma affine_hull_substd_basis: | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1698 | assumes "d \<subseteq> Basis" | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1699 |   shows "affine hull (insert 0 d) = {x::'a::euclidean_space. \<forall>i\<in>Basis. i \<notin> d \<longrightarrow> x\<bullet>i = 0}"
 | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1700 | (is "affine hull (insert 0 ?A) = ?B") | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1701 | proof - | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1702 | have *: "\<And>A. (+) (0::'a) ` A = A" "\<And>A. (+) (- (0::'a)) ` A = A" | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1703 | by auto | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1704 | show ?thesis | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1705 | unfolding affine_hull_insert_span_gen span_substd_basis[OF assms,symmetric] * .. | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1706 | qed | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1707 | |
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1708 | lemma affine_hull_convex_hull [simp]: "affine hull (convex hull S) = affine hull S" | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1709 | by (metis Int_absorb1 Int_absorb2 convex_hull_subset_affine_hull hull_hull hull_mono hull_subset) | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1710 | |
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1711 | |
| 70136 | 1712 | subsection\<^marker>\<open>tag unimportant\<close> \<open>Moving and scaling convex hulls\<close> | 
| 69619 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1713 | |
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1714 | lemma convex_hull_set_plus: | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1715 | "convex hull (S + T) = convex hull S + convex hull T" | 
| 78475 | 1716 | by (simp add: set_plus_image linear_iff scaleR_right_distrib convex_hull_Times | 
| 1717 | flip: convex_hull_linear_image) | |
| 69619 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1718 | |
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1719 | lemma translation_eq_singleton_plus: "(\<lambda>x. a + x) ` T = {a} + T"
 | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1720 | unfolding set_plus_def by auto | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1721 | |
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1722 | lemma convex_hull_translation: | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1723 | "convex hull ((\<lambda>x. a + x) ` S) = (\<lambda>x. a + x) ` (convex hull S)" | 
| 78475 | 1724 | by (simp add: convex_hull_set_plus translation_eq_singleton_plus) | 
| 69619 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1725 | |
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1726 | lemma convex_hull_scaling: | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1727 | "convex hull ((\<lambda>x. c *\<^sub>R x) ` S) = (\<lambda>x. c *\<^sub>R x) ` (convex hull S)" | 
| 78475 | 1728 | by (simp add: convex_hull_linear_image) | 
| 69619 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1729 | |
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1730 | lemma convex_hull_affinity: | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1731 | "convex hull ((\<lambda>x. a + c *\<^sub>R x) ` S) = (\<lambda>x. a + c *\<^sub>R x) ` (convex hull S)" | 
| 72385 | 1732 | by (metis convex_hull_scaling convex_hull_translation image_image) | 
| 69619 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1733 | |
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1734 | |
| 70136 | 1735 | subsection\<^marker>\<open>tag unimportant\<close> \<open>Convexity of cone hulls\<close> | 
| 69619 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1736 | |
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1737 | lemma convex_cone_hull: | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1738 | assumes "convex S" | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1739 | shows "convex (cone hull S)" | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1740 | proof (rule convexI) | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1741 | fix x y | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1742 | assume xy: "x \<in> cone hull S" "y \<in> cone hull S" | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1743 |   then have "S \<noteq> {}"
 | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1744 | using cone_hull_empty_iff[of S] by auto | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1745 | fix u v :: real | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1746 | assume uv: "u \<ge> 0" "v \<ge> 0" "u + v = 1" | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1747 | then have *: "u *\<^sub>R x \<in> cone hull S" "v *\<^sub>R y \<in> cone hull S" | 
| 78475 | 1748 | by (simp_all add: cone_cone_hull mem_cone uv xy) | 
| 1749 | then obtain cx :: real and xx | |
| 1750 | and cy :: real and yy where x: "u *\<^sub>R x = cx *\<^sub>R xx" "cx \<ge> 0" "xx \<in> S" | |
| 1751 | and y: "v *\<^sub>R y = cy *\<^sub>R yy" "cy \<ge> 0" "yy \<in> S" | |
| 69619 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1752 | using cone_hull_expl[of S] by auto | 
| 78475 | 1753 | |
| 1754 | have "u *\<^sub>R x + v *\<^sub>R y \<in> cone hull S" if "cx + cy \<le> 0" | |
| 1755 | using "*"(1) nless_le that x(2) y by fastforce | |
| 69619 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1756 | moreover | 
| 78475 | 1757 | have "u *\<^sub>R x + v *\<^sub>R y \<in> cone hull S" if "cx + cy > 0" | 
| 1758 | proof - | |
| 1759 | have "(cx / (cx + cy)) *\<^sub>R xx + (cy / (cx + cy)) *\<^sub>R yy \<in> S" | |
| 1760 | using assms mem_convex_alt[of S xx yy cx cy] x y that by auto | |
| 69619 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1761 | then have "cx *\<^sub>R xx + cy *\<^sub>R yy \<in> cone hull S" | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1762 | using mem_cone_hull[of "(cx/(cx+cy)) *\<^sub>R xx + (cy/(cx+cy)) *\<^sub>R yy" S "cx+cy"] \<open>cx+cy>0\<close> | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1763 | by (auto simp: scaleR_right_distrib) | 
| 78475 | 1764 | then show ?thesis | 
| 69619 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1765 | using x y by auto | 
| 78475 | 1766 | qed | 
| 69619 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1767 | moreover have "cx + cy \<le> 0 \<or> cx + cy > 0" by auto | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1768 | ultimately show "u *\<^sub>R x + v *\<^sub>R y \<in> cone hull S" by blast | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1769 | qed | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1770 | |
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1771 | lemma cone_convex_hull: | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1772 | assumes "cone S" | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1773 | shows "cone (convex hull S)" | 
| 78475 | 1774 | by (metis (no_types, lifting) affine_hull_convex_hull affine_hull_eq_empty assms cone_iff convex_hull_scaling hull_inc) | 
| 69619 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 1775 | |
| 78656 
4da1e18a9633
Loads of new material related to porting the Euler Polyhedron Formula from HOL Light
 paulson <lp15@cam.ac.uk> parents: 
78475diff
changeset | 1776 | section \<open>Conic sets and conic hull\<close> | 
| 
4da1e18a9633
Loads of new material related to porting the Euler Polyhedron Formula from HOL Light
 paulson <lp15@cam.ac.uk> parents: 
78475diff
changeset | 1777 | |
| 
4da1e18a9633
Loads of new material related to porting the Euler Polyhedron Formula from HOL Light
 paulson <lp15@cam.ac.uk> parents: 
78475diff
changeset | 1778 | definition conic :: "'a::real_vector set \<Rightarrow> bool" | 
| 
4da1e18a9633
Loads of new material related to porting the Euler Polyhedron Formula from HOL Light
 paulson <lp15@cam.ac.uk> parents: 
78475diff
changeset | 1779 | where "conic S \<equiv> \<forall>x c. x \<in> S \<longrightarrow> 0 \<le> c \<longrightarrow> (c *\<^sub>R x) \<in> S" | 
| 
4da1e18a9633
Loads of new material related to porting the Euler Polyhedron Formula from HOL Light
 paulson <lp15@cam.ac.uk> parents: 
78475diff
changeset | 1780 | |
| 
4da1e18a9633
Loads of new material related to porting the Euler Polyhedron Formula from HOL Light
 paulson <lp15@cam.ac.uk> parents: 
78475diff
changeset | 1781 | lemma conicD: "\<lbrakk>conic S; x \<in> S; 0 \<le> c\<rbrakk> \<Longrightarrow> (c *\<^sub>R x) \<in> S" | 
| 
4da1e18a9633
Loads of new material related to porting the Euler Polyhedron Formula from HOL Light
 paulson <lp15@cam.ac.uk> parents: 
78475diff
changeset | 1782 | by (meson conic_def) | 
| 
4da1e18a9633
Loads of new material related to porting the Euler Polyhedron Formula from HOL Light
 paulson <lp15@cam.ac.uk> parents: 
78475diff
changeset | 1783 | |
| 
4da1e18a9633
Loads of new material related to porting the Euler Polyhedron Formula from HOL Light
 paulson <lp15@cam.ac.uk> parents: 
78475diff
changeset | 1784 | lemma subspace_imp_conic: "subspace S \<Longrightarrow> conic S" | 
| 
4da1e18a9633
Loads of new material related to porting the Euler Polyhedron Formula from HOL Light
 paulson <lp15@cam.ac.uk> parents: 
78475diff
changeset | 1785 | by (simp add: conic_def subspace_def) | 
| 
4da1e18a9633
Loads of new material related to porting the Euler Polyhedron Formula from HOL Light
 paulson <lp15@cam.ac.uk> parents: 
78475diff
changeset | 1786 | |
| 
4da1e18a9633
Loads of new material related to porting the Euler Polyhedron Formula from HOL Light
 paulson <lp15@cam.ac.uk> parents: 
78475diff
changeset | 1787 | lemma conic_empty [simp]: "conic {}"
 | 
| 
4da1e18a9633
Loads of new material related to porting the Euler Polyhedron Formula from HOL Light
 paulson <lp15@cam.ac.uk> parents: 
78475diff
changeset | 1788 | using conic_def by blast | 
| 
4da1e18a9633
Loads of new material related to porting the Euler Polyhedron Formula from HOL Light
 paulson <lp15@cam.ac.uk> parents: 
78475diff
changeset | 1789 | |
| 
4da1e18a9633
Loads of new material related to porting the Euler Polyhedron Formula from HOL Light
 paulson <lp15@cam.ac.uk> parents: 
78475diff
changeset | 1790 | lemma conic_UNIV: "conic UNIV" | 
| 
4da1e18a9633
Loads of new material related to porting the Euler Polyhedron Formula from HOL Light
 paulson <lp15@cam.ac.uk> parents: 
78475diff
changeset | 1791 | by (simp add: conic_def) | 
| 
4da1e18a9633
Loads of new material related to porting the Euler Polyhedron Formula from HOL Light
 paulson <lp15@cam.ac.uk> parents: 
78475diff
changeset | 1792 | |
| 
4da1e18a9633
Loads of new material related to porting the Euler Polyhedron Formula from HOL Light
 paulson <lp15@cam.ac.uk> parents: 
78475diff
changeset | 1793 | lemma conic_Inter: "(\<And>S. S \<in> \<F> \<Longrightarrow> conic S) \<Longrightarrow> conic(\<Inter>\<F>)" | 
| 
4da1e18a9633
Loads of new material related to porting the Euler Polyhedron Formula from HOL Light
 paulson <lp15@cam.ac.uk> parents: 
78475diff
changeset | 1794 | by (simp add: conic_def) | 
| 
4da1e18a9633
Loads of new material related to porting the Euler Polyhedron Formula from HOL Light
 paulson <lp15@cam.ac.uk> parents: 
78475diff
changeset | 1795 | |
| 
4da1e18a9633
Loads of new material related to porting the Euler Polyhedron Formula from HOL Light
 paulson <lp15@cam.ac.uk> parents: 
78475diff
changeset | 1796 | lemma conic_linear_image: | 
| 
4da1e18a9633
Loads of new material related to porting the Euler Polyhedron Formula from HOL Light
 paulson <lp15@cam.ac.uk> parents: 
78475diff
changeset | 1797 | "\<lbrakk>conic S; linear f\<rbrakk> \<Longrightarrow> conic(f ` S)" | 
| 
4da1e18a9633
Loads of new material related to porting the Euler Polyhedron Formula from HOL Light
 paulson <lp15@cam.ac.uk> parents: 
78475diff
changeset | 1798 | by (smt (verit) conic_def image_iff linear.scaleR) | 
| 
4da1e18a9633
Loads of new material related to porting the Euler Polyhedron Formula from HOL Light
 paulson <lp15@cam.ac.uk> parents: 
78475diff
changeset | 1799 | |
| 
4da1e18a9633
Loads of new material related to porting the Euler Polyhedron Formula from HOL Light
 paulson <lp15@cam.ac.uk> parents: 
78475diff
changeset | 1800 | lemma conic_linear_image_eq: | 
| 
4da1e18a9633
Loads of new material related to porting the Euler Polyhedron Formula from HOL Light
 paulson <lp15@cam.ac.uk> parents: 
78475diff
changeset | 1801 | "\<lbrakk>linear f; inj f\<rbrakk> \<Longrightarrow> conic (f ` S) \<longleftrightarrow> conic S" | 
| 
4da1e18a9633
Loads of new material related to porting the Euler Polyhedron Formula from HOL Light
 paulson <lp15@cam.ac.uk> parents: 
78475diff
changeset | 1802 | by (smt (verit) conic_def conic_linear_image inj_image_mem_iff linear_cmul) | 
| 
4da1e18a9633
Loads of new material related to porting the Euler Polyhedron Formula from HOL Light
 paulson <lp15@cam.ac.uk> parents: 
78475diff
changeset | 1803 | |
| 
4da1e18a9633
Loads of new material related to porting the Euler Polyhedron Formula from HOL Light
 paulson <lp15@cam.ac.uk> parents: 
78475diff
changeset | 1804 | lemma conic_mul: "\<lbrakk>conic S; x \<in> S; 0 \<le> c\<rbrakk> \<Longrightarrow> (c *\<^sub>R x) \<in> S" | 
| 
4da1e18a9633
Loads of new material related to porting the Euler Polyhedron Formula from HOL Light
 paulson <lp15@cam.ac.uk> parents: 
78475diff
changeset | 1805 | using conic_def by blast | 
| 
4da1e18a9633
Loads of new material related to porting the Euler Polyhedron Formula from HOL Light
 paulson <lp15@cam.ac.uk> parents: 
78475diff
changeset | 1806 | |
| 
4da1e18a9633
Loads of new material related to porting the Euler Polyhedron Formula from HOL Light
 paulson <lp15@cam.ac.uk> parents: 
78475diff
changeset | 1807 | lemma conic_conic_hull: "conic(conic hull S)" | 
| 
4da1e18a9633
Loads of new material related to porting the Euler Polyhedron Formula from HOL Light
 paulson <lp15@cam.ac.uk> parents: 
78475diff
changeset | 1808 | by (metis (no_types, lifting) conic_Inter hull_def mem_Collect_eq) | 
| 
4da1e18a9633
Loads of new material related to porting the Euler Polyhedron Formula from HOL Light
 paulson <lp15@cam.ac.uk> parents: 
78475diff
changeset | 1809 | |
| 
4da1e18a9633
Loads of new material related to porting the Euler Polyhedron Formula from HOL Light
 paulson <lp15@cam.ac.uk> parents: 
78475diff
changeset | 1810 | lemma conic_hull_eq: "(conic hull S = S) \<longleftrightarrow> conic S" | 
| 
4da1e18a9633
Loads of new material related to porting the Euler Polyhedron Formula from HOL Light
 paulson <lp15@cam.ac.uk> parents: 
78475diff
changeset | 1811 | by (metis conic_conic_hull hull_same) | 
| 
4da1e18a9633
Loads of new material related to porting the Euler Polyhedron Formula from HOL Light
 paulson <lp15@cam.ac.uk> parents: 
78475diff
changeset | 1812 | |
| 
4da1e18a9633
Loads of new material related to porting the Euler Polyhedron Formula from HOL Light
 paulson <lp15@cam.ac.uk> parents: 
78475diff
changeset | 1813 | lemma conic_hull_UNIV [simp]: "conic hull UNIV = UNIV" | 
| 
4da1e18a9633
Loads of new material related to porting the Euler Polyhedron Formula from HOL Light
 paulson <lp15@cam.ac.uk> parents: 
78475diff
changeset | 1814 | by simp | 
| 
4da1e18a9633
Loads of new material related to porting the Euler Polyhedron Formula from HOL Light
 paulson <lp15@cam.ac.uk> parents: 
78475diff
changeset | 1815 | |
| 
4da1e18a9633
Loads of new material related to porting the Euler Polyhedron Formula from HOL Light
 paulson <lp15@cam.ac.uk> parents: 
78475diff
changeset | 1816 | lemma conic_negations: "conic S \<Longrightarrow> conic (image uminus S)" | 
| 
4da1e18a9633
Loads of new material related to porting the Euler Polyhedron Formula from HOL Light
 paulson <lp15@cam.ac.uk> parents: 
78475diff
changeset | 1817 | by (auto simp: conic_def image_iff) | 
| 
4da1e18a9633
Loads of new material related to porting the Euler Polyhedron Formula from HOL Light
 paulson <lp15@cam.ac.uk> parents: 
78475diff
changeset | 1818 | |
| 
4da1e18a9633
Loads of new material related to porting the Euler Polyhedron Formula from HOL Light
 paulson <lp15@cam.ac.uk> parents: 
78475diff
changeset | 1819 | lemma conic_span [iff]: "conic(span S)" | 
| 
4da1e18a9633
Loads of new material related to porting the Euler Polyhedron Formula from HOL Light
 paulson <lp15@cam.ac.uk> parents: 
78475diff
changeset | 1820 | by (simp add: subspace_imp_conic) | 
| 
4da1e18a9633
Loads of new material related to porting the Euler Polyhedron Formula from HOL Light
 paulson <lp15@cam.ac.uk> parents: 
78475diff
changeset | 1821 | |
| 
4da1e18a9633
Loads of new material related to porting the Euler Polyhedron Formula from HOL Light
 paulson <lp15@cam.ac.uk> parents: 
78475diff
changeset | 1822 | lemma conic_hull_explicit: | 
| 
4da1e18a9633
Loads of new material related to porting the Euler Polyhedron Formula from HOL Light
 paulson <lp15@cam.ac.uk> parents: 
78475diff
changeset | 1823 |    "conic hull S = {c *\<^sub>R x| c x. 0 \<le> c \<and> x \<in> S}"
 | 
| 
4da1e18a9633
Loads of new material related to porting the Euler Polyhedron Formula from HOL Light
 paulson <lp15@cam.ac.uk> parents: 
78475diff
changeset | 1824 | proof (rule hull_unique) | 
| 
4da1e18a9633
Loads of new material related to porting the Euler Polyhedron Formula from HOL Light
 paulson <lp15@cam.ac.uk> parents: 
78475diff
changeset | 1825 |     show "S \<subseteq> {c *\<^sub>R x |c x. 0 \<le> c \<and> x \<in> S}"
 | 
| 
4da1e18a9633
Loads of new material related to porting the Euler Polyhedron Formula from HOL Light
 paulson <lp15@cam.ac.uk> parents: 
78475diff
changeset | 1826 | by (metis (no_types) cone_hull_expl hull_subset) | 
| 
4da1e18a9633
Loads of new material related to porting the Euler Polyhedron Formula from HOL Light
 paulson <lp15@cam.ac.uk> parents: 
78475diff
changeset | 1827 |   show "conic {c *\<^sub>R x |c x. 0 \<le> c \<and> x \<in> S}"
 | 
| 
4da1e18a9633
Loads of new material related to porting the Euler Polyhedron Formula from HOL Light
 paulson <lp15@cam.ac.uk> parents: 
78475diff
changeset | 1828 | using mult_nonneg_nonneg by (force simp: conic_def) | 
| 
4da1e18a9633
Loads of new material related to porting the Euler Polyhedron Formula from HOL Light
 paulson <lp15@cam.ac.uk> parents: 
78475diff
changeset | 1829 | qed (auto simp: conic_def) | 
| 
4da1e18a9633
Loads of new material related to porting the Euler Polyhedron Formula from HOL Light
 paulson <lp15@cam.ac.uk> parents: 
78475diff
changeset | 1830 | |
| 
4da1e18a9633
Loads of new material related to porting the Euler Polyhedron Formula from HOL Light
 paulson <lp15@cam.ac.uk> parents: 
78475diff
changeset | 1831 | lemma conic_hull_as_image: | 
| 
4da1e18a9633
Loads of new material related to porting the Euler Polyhedron Formula from HOL Light
 paulson <lp15@cam.ac.uk> parents: 
78475diff
changeset | 1832 |    "conic hull S = (\<lambda>z. fst z *\<^sub>R snd z) ` ({0..} \<times> S)"
 | 
| 
4da1e18a9633
Loads of new material related to porting the Euler Polyhedron Formula from HOL Light
 paulson <lp15@cam.ac.uk> parents: 
78475diff
changeset | 1833 | by (force simp: conic_hull_explicit) | 
| 
4da1e18a9633
Loads of new material related to porting the Euler Polyhedron Formula from HOL Light
 paulson <lp15@cam.ac.uk> parents: 
78475diff
changeset | 1834 | |
| 
4da1e18a9633
Loads of new material related to porting the Euler Polyhedron Formula from HOL Light
 paulson <lp15@cam.ac.uk> parents: 
78475diff
changeset | 1835 | lemma conic_hull_linear_image: | 
| 
4da1e18a9633
Loads of new material related to porting the Euler Polyhedron Formula from HOL Light
 paulson <lp15@cam.ac.uk> parents: 
78475diff
changeset | 1836 | "linear f \<Longrightarrow> conic hull f ` S = f ` (conic hull S)" | 
| 
4da1e18a9633
Loads of new material related to porting the Euler Polyhedron Formula from HOL Light
 paulson <lp15@cam.ac.uk> parents: 
78475diff
changeset | 1837 | by (force simp: conic_hull_explicit image_iff set_eq_iff linear_scale) | 
| 
4da1e18a9633
Loads of new material related to porting the Euler Polyhedron Formula from HOL Light
 paulson <lp15@cam.ac.uk> parents: 
78475diff
changeset | 1838 | |
| 
4da1e18a9633
Loads of new material related to porting the Euler Polyhedron Formula from HOL Light
 paulson <lp15@cam.ac.uk> parents: 
78475diff
changeset | 1839 | lemma conic_hull_image_scale: | 
| 
4da1e18a9633
Loads of new material related to porting the Euler Polyhedron Formula from HOL Light
 paulson <lp15@cam.ac.uk> parents: 
78475diff
changeset | 1840 | assumes "\<And>x. x \<in> S \<Longrightarrow> 0 < c x" | 
| 
4da1e18a9633
Loads of new material related to porting the Euler Polyhedron Formula from HOL Light
 paulson <lp15@cam.ac.uk> parents: 
78475diff
changeset | 1841 | shows "conic hull (\<lambda>x. c x *\<^sub>R x) ` S = conic hull S" | 
| 
4da1e18a9633
Loads of new material related to porting the Euler Polyhedron Formula from HOL Light
 paulson <lp15@cam.ac.uk> parents: 
78475diff
changeset | 1842 | proof | 
| 
4da1e18a9633
Loads of new material related to porting the Euler Polyhedron Formula from HOL Light
 paulson <lp15@cam.ac.uk> parents: 
78475diff
changeset | 1843 | show "conic hull (\<lambda>x. c x *\<^sub>R x) ` S \<subseteq> conic hull S" | 
| 
4da1e18a9633
Loads of new material related to porting the Euler Polyhedron Formula from HOL Light
 paulson <lp15@cam.ac.uk> parents: 
78475diff
changeset | 1844 | proof (rule hull_minimal) | 
| 
4da1e18a9633
Loads of new material related to porting the Euler Polyhedron Formula from HOL Light
 paulson <lp15@cam.ac.uk> parents: 
78475diff
changeset | 1845 | show "(\<lambda>x. c x *\<^sub>R x) ` S \<subseteq> conic hull S" | 
| 
4da1e18a9633
Loads of new material related to porting the Euler Polyhedron Formula from HOL Light
 paulson <lp15@cam.ac.uk> parents: 
78475diff
changeset | 1846 | using assms conic_hull_explicit by fastforce | 
| 
4da1e18a9633
Loads of new material related to porting the Euler Polyhedron Formula from HOL Light
 paulson <lp15@cam.ac.uk> parents: 
78475diff
changeset | 1847 | qed (simp add: conic_conic_hull) | 
| 
4da1e18a9633
Loads of new material related to porting the Euler Polyhedron Formula from HOL Light
 paulson <lp15@cam.ac.uk> parents: 
78475diff
changeset | 1848 | show "conic hull S \<subseteq> conic hull (\<lambda>x. c x *\<^sub>R x) ` S" | 
| 
4da1e18a9633
Loads of new material related to porting the Euler Polyhedron Formula from HOL Light
 paulson <lp15@cam.ac.uk> parents: 
78475diff
changeset | 1849 | proof (rule hull_minimal) | 
| 
4da1e18a9633
Loads of new material related to porting the Euler Polyhedron Formula from HOL Light
 paulson <lp15@cam.ac.uk> parents: 
78475diff
changeset | 1850 | show "S \<subseteq> conic hull (\<lambda>x. c x *\<^sub>R x) ` S" | 
| 
4da1e18a9633
Loads of new material related to porting the Euler Polyhedron Formula from HOL Light
 paulson <lp15@cam.ac.uk> parents: 
78475diff
changeset | 1851 | proof clarsimp | 
| 
4da1e18a9633
Loads of new material related to porting the Euler Polyhedron Formula from HOL Light
 paulson <lp15@cam.ac.uk> parents: 
78475diff
changeset | 1852 | fix x | 
| 
4da1e18a9633
Loads of new material related to porting the Euler Polyhedron Formula from HOL Light
 paulson <lp15@cam.ac.uk> parents: 
78475diff
changeset | 1853 | assume "x \<in> S" | 
| 
4da1e18a9633
Loads of new material related to porting the Euler Polyhedron Formula from HOL Light
 paulson <lp15@cam.ac.uk> parents: 
78475diff
changeset | 1854 | then have "x = inverse(c x) *\<^sub>R c x *\<^sub>R x" | 
| 
4da1e18a9633
Loads of new material related to porting the Euler Polyhedron Formula from HOL Light
 paulson <lp15@cam.ac.uk> parents: 
78475diff
changeset | 1855 | using assms by fastforce | 
| 
4da1e18a9633
Loads of new material related to porting the Euler Polyhedron Formula from HOL Light
 paulson <lp15@cam.ac.uk> parents: 
78475diff
changeset | 1856 | then show "x \<in> conic hull (\<lambda>x. c x *\<^sub>R x) ` S" | 
| 
4da1e18a9633
Loads of new material related to porting the Euler Polyhedron Formula from HOL Light
 paulson <lp15@cam.ac.uk> parents: 
78475diff
changeset | 1857 | by (smt (verit, best) \<open>x \<in> S\<close> assms conic_conic_hull conic_mul hull_inc image_eqI inverse_nonpositive_iff_nonpositive) | 
| 
4da1e18a9633
Loads of new material related to porting the Euler Polyhedron Formula from HOL Light
 paulson <lp15@cam.ac.uk> parents: 
78475diff
changeset | 1858 | qed | 
| 
4da1e18a9633
Loads of new material related to porting the Euler Polyhedron Formula from HOL Light
 paulson <lp15@cam.ac.uk> parents: 
78475diff
changeset | 1859 | qed (simp add: conic_conic_hull) | 
| 
4da1e18a9633
Loads of new material related to porting the Euler Polyhedron Formula from HOL Light
 paulson <lp15@cam.ac.uk> parents: 
78475diff
changeset | 1860 | qed | 
| 
4da1e18a9633
Loads of new material related to porting the Euler Polyhedron Formula from HOL Light
 paulson <lp15@cam.ac.uk> parents: 
78475diff
changeset | 1861 | |
| 
4da1e18a9633
Loads of new material related to porting the Euler Polyhedron Formula from HOL Light
 paulson <lp15@cam.ac.uk> parents: 
78475diff
changeset | 1862 | lemma convex_conic_hull: | 
| 
4da1e18a9633
Loads of new material related to porting the Euler Polyhedron Formula from HOL Light
 paulson <lp15@cam.ac.uk> parents: 
78475diff
changeset | 1863 | assumes "convex S" | 
| 
4da1e18a9633
Loads of new material related to porting the Euler Polyhedron Formula from HOL Light
 paulson <lp15@cam.ac.uk> parents: 
78475diff
changeset | 1864 | shows "convex (conic hull S)" | 
| 
4da1e18a9633
Loads of new material related to porting the Euler Polyhedron Formula from HOL Light
 paulson <lp15@cam.ac.uk> parents: 
78475diff
changeset | 1865 | proof (clarsimp simp add: conic_hull_explicit convex_alt) | 
| 
4da1e18a9633
Loads of new material related to porting the Euler Polyhedron Formula from HOL Light
 paulson <lp15@cam.ac.uk> parents: 
78475diff
changeset | 1866 | fix c x d y and u :: real | 
| 
4da1e18a9633
Loads of new material related to porting the Euler Polyhedron Formula from HOL Light
 paulson <lp15@cam.ac.uk> parents: 
78475diff
changeset | 1867 | assume \<section>: "(0::real) \<le> c" "x \<in> S" "(0::real) \<le> d" "y \<in> S" "0 \<le> u" "u \<le> 1" | 
| 
4da1e18a9633
Loads of new material related to porting the Euler Polyhedron Formula from HOL Light
 paulson <lp15@cam.ac.uk> parents: 
78475diff
changeset | 1868 | show "\<exists>c'' x''. ((1 - u) * c) *\<^sub>R x + (u * d) *\<^sub>R y = c'' *\<^sub>R x'' \<and> 0 \<le> c'' \<and> x'' \<in> S" | 
| 
4da1e18a9633
Loads of new material related to porting the Euler Polyhedron Formula from HOL Light
 paulson <lp15@cam.ac.uk> parents: 
78475diff
changeset | 1869 | proof (cases "(1 - u) * c = 0") | 
| 
4da1e18a9633
Loads of new material related to porting the Euler Polyhedron Formula from HOL Light
 paulson <lp15@cam.ac.uk> parents: 
78475diff
changeset | 1870 | case True | 
| 
4da1e18a9633
Loads of new material related to porting the Euler Polyhedron Formula from HOL Light
 paulson <lp15@cam.ac.uk> parents: 
78475diff
changeset | 1871 | with \<open>0 \<le> d\<close> \<open>y \<in> S\<close>\<open>0 \<le> u\<close> | 
| 
4da1e18a9633
Loads of new material related to porting the Euler Polyhedron Formula from HOL Light
 paulson <lp15@cam.ac.uk> parents: 
78475diff
changeset | 1872 | show ?thesis by force | 
| 
4da1e18a9633
Loads of new material related to porting the Euler Polyhedron Formula from HOL Light
 paulson <lp15@cam.ac.uk> parents: 
78475diff
changeset | 1873 | next | 
| 
4da1e18a9633
Loads of new material related to porting the Euler Polyhedron Formula from HOL Light
 paulson <lp15@cam.ac.uk> parents: 
78475diff
changeset | 1874 | case False | 
| 
4da1e18a9633
Loads of new material related to porting the Euler Polyhedron Formula from HOL Light
 paulson <lp15@cam.ac.uk> parents: 
78475diff
changeset | 1875 | define \<xi> where "\<xi> \<equiv> (1 - u) * c + u * d" | 
| 
4da1e18a9633
Loads of new material related to porting the Euler Polyhedron Formula from HOL Light
 paulson <lp15@cam.ac.uk> parents: 
78475diff
changeset | 1876 | have *: "c * u \<le> c" | 
| 
4da1e18a9633
Loads of new material related to porting the Euler Polyhedron Formula from HOL Light
 paulson <lp15@cam.ac.uk> parents: 
78475diff
changeset | 1877 | by (simp add: "\<section>" mult_left_le) | 
| 
4da1e18a9633
Loads of new material related to porting the Euler Polyhedron Formula from HOL Light
 paulson <lp15@cam.ac.uk> parents: 
78475diff
changeset | 1878 | have "\<xi> > 0" | 
| 
4da1e18a9633
Loads of new material related to porting the Euler Polyhedron Formula from HOL Light
 paulson <lp15@cam.ac.uk> parents: 
78475diff
changeset | 1879 | using False \<section> by (smt (verit, best) \<xi>_def split_mult_pos_le) | 
| 
4da1e18a9633
Loads of new material related to porting the Euler Polyhedron Formula from HOL Light
 paulson <lp15@cam.ac.uk> parents: 
78475diff
changeset | 1880 | then have **: "c + d * u = \<xi> + c * u" | 
| 
4da1e18a9633
Loads of new material related to porting the Euler Polyhedron Formula from HOL Light
 paulson <lp15@cam.ac.uk> parents: 
78475diff
changeset | 1881 | by (simp add: \<xi>_def mult.commute right_diff_distrib') | 
| 
4da1e18a9633
Loads of new material related to porting the Euler Polyhedron Formula from HOL Light
 paulson <lp15@cam.ac.uk> parents: 
78475diff
changeset | 1882 | show ?thesis | 
| 
4da1e18a9633
Loads of new material related to porting the Euler Polyhedron Formula from HOL Light
 paulson <lp15@cam.ac.uk> parents: 
78475diff
changeset | 1883 | proof (intro exI conjI) | 
| 
4da1e18a9633
Loads of new material related to porting the Euler Polyhedron Formula from HOL Light
 paulson <lp15@cam.ac.uk> parents: 
78475diff
changeset | 1884 | show "0 \<le> \<xi>" | 
| 
4da1e18a9633
Loads of new material related to porting the Euler Polyhedron Formula from HOL Light
 paulson <lp15@cam.ac.uk> parents: 
78475diff
changeset | 1885 | using \<open>0 < \<xi>\<close> by auto | 
| 
4da1e18a9633
Loads of new material related to porting the Euler Polyhedron Formula from HOL Light
 paulson <lp15@cam.ac.uk> parents: 
78475diff
changeset | 1886 | show "((1 - u) * c) *\<^sub>R x + (u * d) *\<^sub>R y = \<xi> *\<^sub>R (((1 - u) * c / \<xi>) *\<^sub>R x + (u * d / \<xi>) *\<^sub>R y)" | 
| 
4da1e18a9633
Loads of new material related to porting the Euler Polyhedron Formula from HOL Light
 paulson <lp15@cam.ac.uk> parents: 
78475diff
changeset | 1887 | using \<open>\<xi> > 0\<close> by (simp add: algebra_simps diff_divide_distrib) | 
| 
4da1e18a9633
Loads of new material related to porting the Euler Polyhedron Formula from HOL Light
 paulson <lp15@cam.ac.uk> parents: 
78475diff
changeset | 1888 | show "((1 - u) * c / \<xi>) *\<^sub>R x + (u * d / \<xi>) *\<^sub>R y \<in> S" | 
| 
4da1e18a9633
Loads of new material related to porting the Euler Polyhedron Formula from HOL Light
 paulson <lp15@cam.ac.uk> parents: 
78475diff
changeset | 1889 | using \<open>0 < \<xi>\<close> | 
| 
4da1e18a9633
Loads of new material related to porting the Euler Polyhedron Formula from HOL Light
 paulson <lp15@cam.ac.uk> parents: 
78475diff
changeset | 1890 | by (intro convexD [OF assms]) (auto simp: \<section> field_split_simps * **) | 
| 
4da1e18a9633
Loads of new material related to porting the Euler Polyhedron Formula from HOL Light
 paulson <lp15@cam.ac.uk> parents: 
78475diff
changeset | 1891 | qed | 
| 
4da1e18a9633
Loads of new material related to porting the Euler Polyhedron Formula from HOL Light
 paulson <lp15@cam.ac.uk> parents: 
78475diff
changeset | 1892 | qed | 
| 
4da1e18a9633
Loads of new material related to porting the Euler Polyhedron Formula from HOL Light
 paulson <lp15@cam.ac.uk> parents: 
78475diff
changeset | 1893 | qed | 
| 
4da1e18a9633
Loads of new material related to porting the Euler Polyhedron Formula from HOL Light
 paulson <lp15@cam.ac.uk> parents: 
78475diff
changeset | 1894 | |
| 
4da1e18a9633
Loads of new material related to porting the Euler Polyhedron Formula from HOL Light
 paulson <lp15@cam.ac.uk> parents: 
78475diff
changeset | 1895 | lemma conic_halfspace_le: "conic {x. a \<bullet> x \<le> 0}"
 | 
| 
4da1e18a9633
Loads of new material related to porting the Euler Polyhedron Formula from HOL Light
 paulson <lp15@cam.ac.uk> parents: 
78475diff
changeset | 1896 | by (auto simp: conic_def mult_le_0_iff) | 
| 
4da1e18a9633
Loads of new material related to porting the Euler Polyhedron Formula from HOL Light
 paulson <lp15@cam.ac.uk> parents: 
78475diff
changeset | 1897 | |
| 
4da1e18a9633
Loads of new material related to porting the Euler Polyhedron Formula from HOL Light
 paulson <lp15@cam.ac.uk> parents: 
78475diff
changeset | 1898 | lemma conic_halfspace_ge: "conic {x. a \<bullet> x \<ge> 0}"
 | 
| 
4da1e18a9633
Loads of new material related to porting the Euler Polyhedron Formula from HOL Light
 paulson <lp15@cam.ac.uk> parents: 
78475diff
changeset | 1899 | by (auto simp: conic_def mult_le_0_iff) | 
| 
4da1e18a9633
Loads of new material related to porting the Euler Polyhedron Formula from HOL Light
 paulson <lp15@cam.ac.uk> parents: 
78475diff
changeset | 1900 | |
| 
4da1e18a9633
Loads of new material related to porting the Euler Polyhedron Formula from HOL Light
 paulson <lp15@cam.ac.uk> parents: 
78475diff
changeset | 1901 | lemma conic_hull_empty [simp]: "conic hull {} = {}"
 | 
| 
4da1e18a9633
Loads of new material related to porting the Euler Polyhedron Formula from HOL Light
 paulson <lp15@cam.ac.uk> parents: 
78475diff
changeset | 1902 | by (simp add: conic_hull_eq) | 
| 
4da1e18a9633
Loads of new material related to porting the Euler Polyhedron Formula from HOL Light
 paulson <lp15@cam.ac.uk> parents: 
78475diff
changeset | 1903 | |
| 
4da1e18a9633
Loads of new material related to porting the Euler Polyhedron Formula from HOL Light
 paulson <lp15@cam.ac.uk> parents: 
78475diff
changeset | 1904 | lemma conic_contains_0: "conic S \<Longrightarrow> (0 \<in> S \<longleftrightarrow> S \<noteq> {})"
 | 
| 
4da1e18a9633
Loads of new material related to porting the Euler Polyhedron Formula from HOL Light
 paulson <lp15@cam.ac.uk> parents: 
78475diff
changeset | 1905 | by (simp add: Convex.cone_def cone_contains_0 conic_def) | 
| 
4da1e18a9633
Loads of new material related to porting the Euler Polyhedron Formula from HOL Light
 paulson <lp15@cam.ac.uk> parents: 
78475diff
changeset | 1906 | |
| 
4da1e18a9633
Loads of new material related to porting the Euler Polyhedron Formula from HOL Light
 paulson <lp15@cam.ac.uk> parents: 
78475diff
changeset | 1907 | lemma conic_hull_eq_empty: "conic hull S = {} \<longleftrightarrow> (S = {})"
 | 
| 
4da1e18a9633
Loads of new material related to porting the Euler Polyhedron Formula from HOL Light
 paulson <lp15@cam.ac.uk> parents: 
78475diff
changeset | 1908 | using conic_hull_explicit by fastforce | 
| 
4da1e18a9633
Loads of new material related to porting the Euler Polyhedron Formula from HOL Light
 paulson <lp15@cam.ac.uk> parents: 
78475diff
changeset | 1909 | |
| 
4da1e18a9633
Loads of new material related to porting the Euler Polyhedron Formula from HOL Light
 paulson <lp15@cam.ac.uk> parents: 
78475diff
changeset | 1910 | lemma conic_sums: "\<lbrakk>conic S; conic T\<rbrakk> \<Longrightarrow> conic (\<Union>x\<in> S. \<Union>y \<in> T. {x + y})"
 | 
| 
4da1e18a9633
Loads of new material related to porting the Euler Polyhedron Formula from HOL Light
 paulson <lp15@cam.ac.uk> parents: 
78475diff
changeset | 1911 | by (simp add: conic_def) (metis scaleR_right_distrib) | 
| 
4da1e18a9633
Loads of new material related to porting the Euler Polyhedron Formula from HOL Light
 paulson <lp15@cam.ac.uk> parents: 
78475diff
changeset | 1912 | |
| 
4da1e18a9633
Loads of new material related to porting the Euler Polyhedron Formula from HOL Light
 paulson <lp15@cam.ac.uk> parents: 
78475diff
changeset | 1913 | lemma conic_Times: "\<lbrakk>conic S; conic T\<rbrakk> \<Longrightarrow> conic(S \<times> T)" | 
| 
4da1e18a9633
Loads of new material related to porting the Euler Polyhedron Formula from HOL Light
 paulson <lp15@cam.ac.uk> parents: 
78475diff
changeset | 1914 | by (auto simp: conic_def) | 
| 
4da1e18a9633
Loads of new material related to porting the Euler Polyhedron Formula from HOL Light
 paulson <lp15@cam.ac.uk> parents: 
78475diff
changeset | 1915 | |
| 
4da1e18a9633
Loads of new material related to porting the Euler Polyhedron Formula from HOL Light
 paulson <lp15@cam.ac.uk> parents: 
78475diff
changeset | 1916 | lemma conic_Times_eq: | 
| 
4da1e18a9633
Loads of new material related to porting the Euler Polyhedron Formula from HOL Light
 paulson <lp15@cam.ac.uk> parents: 
78475diff
changeset | 1917 |    "conic(S \<times> T) \<longleftrightarrow> S = {} \<or> T = {} \<or> conic S \<and> conic T" (is "?lhs = ?rhs")
 | 
| 
4da1e18a9633
Loads of new material related to porting the Euler Polyhedron Formula from HOL Light
 paulson <lp15@cam.ac.uk> parents: 
78475diff
changeset | 1918 | proof | 
| 
4da1e18a9633
Loads of new material related to porting the Euler Polyhedron Formula from HOL Light
 paulson <lp15@cam.ac.uk> parents: 
78475diff
changeset | 1919 | show "?lhs \<Longrightarrow> ?rhs" | 
| 
4da1e18a9633
Loads of new material related to porting the Euler Polyhedron Formula from HOL Light
 paulson <lp15@cam.ac.uk> parents: 
78475diff
changeset | 1920 | by (force simp: conic_def) | 
| 
4da1e18a9633
Loads of new material related to porting the Euler Polyhedron Formula from HOL Light
 paulson <lp15@cam.ac.uk> parents: 
78475diff
changeset | 1921 | show "?rhs \<Longrightarrow> ?lhs" | 
| 
4da1e18a9633
Loads of new material related to porting the Euler Polyhedron Formula from HOL Light
 paulson <lp15@cam.ac.uk> parents: 
78475diff
changeset | 1922 | by (force simp: conic_Times) | 
| 
4da1e18a9633
Loads of new material related to porting the Euler Polyhedron Formula from HOL Light
 paulson <lp15@cam.ac.uk> parents: 
78475diff
changeset | 1923 | qed | 
| 
4da1e18a9633
Loads of new material related to porting the Euler Polyhedron Formula from HOL Light
 paulson <lp15@cam.ac.uk> parents: 
78475diff
changeset | 1924 | |
| 
4da1e18a9633
Loads of new material related to porting the Euler Polyhedron Formula from HOL Light
 paulson <lp15@cam.ac.uk> parents: 
78475diff
changeset | 1925 | lemma conic_hull_0 [simp]: "conic hull {0} = {0}"
 | 
| 
4da1e18a9633
Loads of new material related to porting the Euler Polyhedron Formula from HOL Light
 paulson <lp15@cam.ac.uk> parents: 
78475diff
changeset | 1926 | by (simp add: conic_hull_eq subspace_imp_conic) | 
| 
4da1e18a9633
Loads of new material related to porting the Euler Polyhedron Formula from HOL Light
 paulson <lp15@cam.ac.uk> parents: 
78475diff
changeset | 1927 | |
| 
4da1e18a9633
Loads of new material related to porting the Euler Polyhedron Formula from HOL Light
 paulson <lp15@cam.ac.uk> parents: 
78475diff
changeset | 1928 | lemma conic_hull_contains_0 [simp]: "0 \<in> conic hull S \<longleftrightarrow> (S \<noteq> {})"
 | 
| 
4da1e18a9633
Loads of new material related to porting the Euler Polyhedron Formula from HOL Light
 paulson <lp15@cam.ac.uk> parents: 
78475diff
changeset | 1929 | by (simp add: conic_conic_hull conic_contains_0 conic_hull_eq_empty) | 
| 
4da1e18a9633
Loads of new material related to porting the Euler Polyhedron Formula from HOL Light
 paulson <lp15@cam.ac.uk> parents: 
78475diff
changeset | 1930 | |
| 
4da1e18a9633
Loads of new material related to porting the Euler Polyhedron Formula from HOL Light
 paulson <lp15@cam.ac.uk> parents: 
78475diff
changeset | 1931 | lemma conic_hull_eq_sing: | 
| 
4da1e18a9633
Loads of new material related to porting the Euler Polyhedron Formula from HOL Light
 paulson <lp15@cam.ac.uk> parents: 
78475diff
changeset | 1932 |   "conic hull S = {x} \<longleftrightarrow> S = {0} \<and> x = 0"
 | 
| 
4da1e18a9633
Loads of new material related to porting the Euler Polyhedron Formula from HOL Light
 paulson <lp15@cam.ac.uk> parents: 
78475diff
changeset | 1933 | proof | 
| 
4da1e18a9633
Loads of new material related to porting the Euler Polyhedron Formula from HOL Light
 paulson <lp15@cam.ac.uk> parents: 
78475diff
changeset | 1934 |   show "conic hull S = {x} \<Longrightarrow> S = {0} \<and> x = 0"
 | 
| 
4da1e18a9633
Loads of new material related to porting the Euler Polyhedron Formula from HOL Light
 paulson <lp15@cam.ac.uk> parents: 
78475diff
changeset | 1935 | by (metis conic_conic_hull conic_contains_0 conic_def conic_hull_eq hull_inc insert_not_empty singleton_iff) | 
| 
4da1e18a9633
Loads of new material related to porting the Euler Polyhedron Formula from HOL Light
 paulson <lp15@cam.ac.uk> parents: 
78475diff
changeset | 1936 | qed simp | 
| 
4da1e18a9633
Loads of new material related to porting the Euler Polyhedron Formula from HOL Light
 paulson <lp15@cam.ac.uk> parents: 
78475diff
changeset | 1937 | |
| 
4da1e18a9633
Loads of new material related to porting the Euler Polyhedron Formula from HOL Light
 paulson <lp15@cam.ac.uk> parents: 
78475diff
changeset | 1938 | lemma conic_hull_Int_affine_hull: | 
| 
4da1e18a9633
Loads of new material related to porting the Euler Polyhedron Formula from HOL Light
 paulson <lp15@cam.ac.uk> parents: 
78475diff
changeset | 1939 | assumes "T \<subseteq> S" "0 \<notin> affine hull S" | 
| 
4da1e18a9633
Loads of new material related to porting the Euler Polyhedron Formula from HOL Light
 paulson <lp15@cam.ac.uk> parents: 
78475diff
changeset | 1940 | shows "(conic hull T) \<inter> (affine hull S) = T" | 
| 
4da1e18a9633
Loads of new material related to porting the Euler Polyhedron Formula from HOL Light
 paulson <lp15@cam.ac.uk> parents: 
78475diff
changeset | 1941 | proof - | 
| 
4da1e18a9633
Loads of new material related to porting the Euler Polyhedron Formula from HOL Light
 paulson <lp15@cam.ac.uk> parents: 
78475diff
changeset | 1942 | have TaffS: "T \<subseteq> affine hull S" | 
| 
4da1e18a9633
Loads of new material related to porting the Euler Polyhedron Formula from HOL Light
 paulson <lp15@cam.ac.uk> parents: 
78475diff
changeset | 1943 | using \<open>T \<subseteq> S\<close> hull_subset by fastforce | 
| 
4da1e18a9633
Loads of new material related to porting the Euler Polyhedron Formula from HOL Light
 paulson <lp15@cam.ac.uk> parents: 
78475diff
changeset | 1944 | moreover | 
| 
4da1e18a9633
Loads of new material related to porting the Euler Polyhedron Formula from HOL Light
 paulson <lp15@cam.ac.uk> parents: 
78475diff
changeset | 1945 | have "conic hull T \<inter> affine hull S \<subseteq> T" | 
| 
4da1e18a9633
Loads of new material related to porting the Euler Polyhedron Formula from HOL Light
 paulson <lp15@cam.ac.uk> parents: 
78475diff
changeset | 1946 | proof (clarsimp simp: conic_hull_explicit) | 
| 
4da1e18a9633
Loads of new material related to porting the Euler Polyhedron Formula from HOL Light
 paulson <lp15@cam.ac.uk> parents: 
78475diff
changeset | 1947 | fix c x | 
| 
4da1e18a9633
Loads of new material related to porting the Euler Polyhedron Formula from HOL Light
 paulson <lp15@cam.ac.uk> parents: 
78475diff
changeset | 1948 | assume "c *\<^sub>R x \<in> affine hull S" | 
| 
4da1e18a9633
Loads of new material related to porting the Euler Polyhedron Formula from HOL Light
 paulson <lp15@cam.ac.uk> parents: 
78475diff
changeset | 1949 | and "0 \<le> c" | 
| 
4da1e18a9633
Loads of new material related to porting the Euler Polyhedron Formula from HOL Light
 paulson <lp15@cam.ac.uk> parents: 
78475diff
changeset | 1950 | and "x \<in> T" | 
| 
4da1e18a9633
Loads of new material related to porting the Euler Polyhedron Formula from HOL Light
 paulson <lp15@cam.ac.uk> parents: 
78475diff
changeset | 1951 | show "c *\<^sub>R x \<in> T" | 
| 
4da1e18a9633
Loads of new material related to porting the Euler Polyhedron Formula from HOL Light
 paulson <lp15@cam.ac.uk> parents: 
78475diff
changeset | 1952 | proof (cases "c=1") | 
| 
4da1e18a9633
Loads of new material related to porting the Euler Polyhedron Formula from HOL Light
 paulson <lp15@cam.ac.uk> parents: 
78475diff
changeset | 1953 | case True | 
| 
4da1e18a9633
Loads of new material related to porting the Euler Polyhedron Formula from HOL Light
 paulson <lp15@cam.ac.uk> parents: 
78475diff
changeset | 1954 | then show ?thesis | 
| 
4da1e18a9633
Loads of new material related to porting the Euler Polyhedron Formula from HOL Light
 paulson <lp15@cam.ac.uk> parents: 
78475diff
changeset | 1955 | by (simp add: \<open>x \<in> T\<close>) | 
| 
4da1e18a9633
Loads of new material related to porting the Euler Polyhedron Formula from HOL Light
 paulson <lp15@cam.ac.uk> parents: 
78475diff
changeset | 1956 | next | 
| 
4da1e18a9633
Loads of new material related to porting the Euler Polyhedron Formula from HOL Light
 paulson <lp15@cam.ac.uk> parents: 
78475diff
changeset | 1957 | case False | 
| 
4da1e18a9633
Loads of new material related to porting the Euler Polyhedron Formula from HOL Light
 paulson <lp15@cam.ac.uk> parents: 
78475diff
changeset | 1958 | then have "x /\<^sub>R (1 - c) = x + (c * inverse (1 - c)) *\<^sub>R x" | 
| 
4da1e18a9633
Loads of new material related to porting the Euler Polyhedron Formula from HOL Light
 paulson <lp15@cam.ac.uk> parents: 
78475diff
changeset | 1959 | by (smt (verit, ccfv_SIG) diff_add_cancel mult.commute real_vector_affinity_eq scaleR_collapse scaleR_scaleR) | 
| 
4da1e18a9633
Loads of new material related to porting the Euler Polyhedron Formula from HOL Light
 paulson <lp15@cam.ac.uk> parents: 
78475diff
changeset | 1960 | then have "0 = inverse(1 - c) *\<^sub>R c *\<^sub>R x + (1 - inverse(1 - c)) *\<^sub>R x" | 
| 
4da1e18a9633
Loads of new material related to porting the Euler Polyhedron Formula from HOL Light
 paulson <lp15@cam.ac.uk> parents: 
78475diff
changeset | 1961 | by (simp add: algebra_simps) | 
| 
4da1e18a9633
Loads of new material related to porting the Euler Polyhedron Formula from HOL Light
 paulson <lp15@cam.ac.uk> parents: 
78475diff
changeset | 1962 | then have "0 \<in> affine hull S" | 
| 
4da1e18a9633
Loads of new material related to porting the Euler Polyhedron Formula from HOL Light
 paulson <lp15@cam.ac.uk> parents: 
78475diff
changeset | 1963 | by (smt (verit) \<open>c *\<^sub>R x \<in> affine hull S\<close> \<open>x \<in> T\<close> affine_affine_hull TaffS in_mono mem_affine) | 
| 
4da1e18a9633
Loads of new material related to porting the Euler Polyhedron Formula from HOL Light
 paulson <lp15@cam.ac.uk> parents: 
78475diff
changeset | 1964 | then show ?thesis | 
| 
4da1e18a9633
Loads of new material related to porting the Euler Polyhedron Formula from HOL Light
 paulson <lp15@cam.ac.uk> parents: 
78475diff
changeset | 1965 | using assms by auto | 
| 
4da1e18a9633
Loads of new material related to porting the Euler Polyhedron Formula from HOL Light
 paulson <lp15@cam.ac.uk> parents: 
78475diff
changeset | 1966 | qed | 
| 
4da1e18a9633
Loads of new material related to porting the Euler Polyhedron Formula from HOL Light
 paulson <lp15@cam.ac.uk> parents: 
78475diff
changeset | 1967 | qed | 
| 
4da1e18a9633
Loads of new material related to porting the Euler Polyhedron Formula from HOL Light
 paulson <lp15@cam.ac.uk> parents: 
78475diff
changeset | 1968 | ultimately show ?thesis | 
| 
4da1e18a9633
Loads of new material related to porting the Euler Polyhedron Formula from HOL Light
 paulson <lp15@cam.ac.uk> parents: 
78475diff
changeset | 1969 | by (auto simp: hull_inc) | 
| 
4da1e18a9633
Loads of new material related to porting the Euler Polyhedron Formula from HOL Light
 paulson <lp15@cam.ac.uk> parents: 
78475diff
changeset | 1970 | qed | 
| 
4da1e18a9633
Loads of new material related to porting the Euler Polyhedron Formula from HOL Light
 paulson <lp15@cam.ac.uk> parents: 
78475diff
changeset | 1971 | |
| 
4da1e18a9633
Loads of new material related to porting the Euler Polyhedron Formula from HOL Light
 paulson <lp15@cam.ac.uk> parents: 
78475diff
changeset | 1972 | |
| 
4da1e18a9633
Loads of new material related to porting the Euler Polyhedron Formula from HOL Light
 paulson <lp15@cam.ac.uk> parents: 
78475diff
changeset | 1973 | section \<open>Convex cones and corresponding hulls\<close> | 
| 
4da1e18a9633
Loads of new material related to porting the Euler Polyhedron Formula from HOL Light
 paulson <lp15@cam.ac.uk> parents: 
78475diff
changeset | 1974 | |
| 
4da1e18a9633
Loads of new material related to porting the Euler Polyhedron Formula from HOL Light
 paulson <lp15@cam.ac.uk> parents: 
78475diff
changeset | 1975 | definition convex_cone :: "'a::real_vector set \<Rightarrow> bool" | 
| 
4da1e18a9633
Loads of new material related to porting the Euler Polyhedron Formula from HOL Light
 paulson <lp15@cam.ac.uk> parents: 
78475diff
changeset | 1976 |   where "convex_cone \<equiv> \<lambda>S. S \<noteq> {} \<and> convex S \<and> conic S"
 | 
| 
4da1e18a9633
Loads of new material related to porting the Euler Polyhedron Formula from HOL Light
 paulson <lp15@cam.ac.uk> parents: 
78475diff
changeset | 1977 | |
| 
4da1e18a9633
Loads of new material related to porting the Euler Polyhedron Formula from HOL Light
 paulson <lp15@cam.ac.uk> parents: 
78475diff
changeset | 1978 | lemma convex_cone_iff: | 
| 
4da1e18a9633
Loads of new material related to porting the Euler Polyhedron Formula from HOL Light
 paulson <lp15@cam.ac.uk> parents: 
78475diff
changeset | 1979 | "convex_cone S \<longleftrightarrow> | 
| 
4da1e18a9633
Loads of new material related to porting the Euler Polyhedron Formula from HOL Light
 paulson <lp15@cam.ac.uk> parents: 
78475diff
changeset | 1980 | 0 \<in> S \<and> (\<forall>x \<in> S. \<forall>y \<in> S. x + y \<in> S) \<and> (\<forall>x \<in> S. \<forall>c\<ge>0. c *\<^sub>R x \<in> S)" | 
| 
4da1e18a9633
Loads of new material related to porting the Euler Polyhedron Formula from HOL Light
 paulson <lp15@cam.ac.uk> parents: 
78475diff
changeset | 1981 | by (metis cone_def conic_contains_0 conic_def convex_cone convex_cone_def) | 
| 
4da1e18a9633
Loads of new material related to porting the Euler Polyhedron Formula from HOL Light
 paulson <lp15@cam.ac.uk> parents: 
78475diff
changeset | 1982 | |
| 
4da1e18a9633
Loads of new material related to porting the Euler Polyhedron Formula from HOL Light
 paulson <lp15@cam.ac.uk> parents: 
78475diff
changeset | 1983 | lemma convex_cone_add: "\<lbrakk>convex_cone S; x \<in> S; y \<in> S\<rbrakk> \<Longrightarrow> x+y \<in> S" | 
| 
4da1e18a9633
Loads of new material related to porting the Euler Polyhedron Formula from HOL Light
 paulson <lp15@cam.ac.uk> parents: 
78475diff
changeset | 1984 | by (simp add: convex_cone_iff) | 
| 
4da1e18a9633
Loads of new material related to porting the Euler Polyhedron Formula from HOL Light
 paulson <lp15@cam.ac.uk> parents: 
78475diff
changeset | 1985 | |
| 
4da1e18a9633
Loads of new material related to porting the Euler Polyhedron Formula from HOL Light
 paulson <lp15@cam.ac.uk> parents: 
78475diff
changeset | 1986 | lemma convex_cone_scaleR: "\<lbrakk>convex_cone S; 0 \<le> c; x \<in> S\<rbrakk> \<Longrightarrow> c *\<^sub>R x \<in> S" | 
| 
4da1e18a9633
Loads of new material related to porting the Euler Polyhedron Formula from HOL Light
 paulson <lp15@cam.ac.uk> parents: 
78475diff
changeset | 1987 | by (simp add: convex_cone_iff) | 
| 
4da1e18a9633
Loads of new material related to porting the Euler Polyhedron Formula from HOL Light
 paulson <lp15@cam.ac.uk> parents: 
78475diff
changeset | 1988 | |
| 
4da1e18a9633
Loads of new material related to porting the Euler Polyhedron Formula from HOL Light
 paulson <lp15@cam.ac.uk> parents: 
78475diff
changeset | 1989 | lemma convex_cone_nonempty: "convex_cone S \<Longrightarrow> S \<noteq> {}"
 | 
| 
4da1e18a9633
Loads of new material related to porting the Euler Polyhedron Formula from HOL Light
 paulson <lp15@cam.ac.uk> parents: 
78475diff
changeset | 1990 | by (simp add: convex_cone_def) | 
| 
4da1e18a9633
Loads of new material related to porting the Euler Polyhedron Formula from HOL Light
 paulson <lp15@cam.ac.uk> parents: 
78475diff
changeset | 1991 | |
| 
4da1e18a9633
Loads of new material related to porting the Euler Polyhedron Formula from HOL Light
 paulson <lp15@cam.ac.uk> parents: 
78475diff
changeset | 1992 | lemma convex_cone_linear_image: | 
| 
4da1e18a9633
Loads of new material related to porting the Euler Polyhedron Formula from HOL Light
 paulson <lp15@cam.ac.uk> parents: 
78475diff
changeset | 1993 | "convex_cone S \<and> linear f \<Longrightarrow> convex_cone(f ` S)" | 
| 
4da1e18a9633
Loads of new material related to porting the Euler Polyhedron Formula from HOL Light
 paulson <lp15@cam.ac.uk> parents: 
78475diff
changeset | 1994 | by (simp add: conic_linear_image convex_cone_def convex_linear_image) | 
| 
4da1e18a9633
Loads of new material related to porting the Euler Polyhedron Formula from HOL Light
 paulson <lp15@cam.ac.uk> parents: 
78475diff
changeset | 1995 | |
| 
4da1e18a9633
Loads of new material related to porting the Euler Polyhedron Formula from HOL Light
 paulson <lp15@cam.ac.uk> parents: 
78475diff
changeset | 1996 | lemma convex_cone_linear_image_eq: | 
| 
4da1e18a9633
Loads of new material related to porting the Euler Polyhedron Formula from HOL Light
 paulson <lp15@cam.ac.uk> parents: 
78475diff
changeset | 1997 | "\<lbrakk>linear f; inj f\<rbrakk> \<Longrightarrow> (convex_cone(f ` S) \<longleftrightarrow> convex_cone S)" | 
| 
4da1e18a9633
Loads of new material related to porting the Euler Polyhedron Formula from HOL Light
 paulson <lp15@cam.ac.uk> parents: 
78475diff
changeset | 1998 | by (simp add: conic_linear_image_eq convex_cone_def) | 
| 
4da1e18a9633
Loads of new material related to porting the Euler Polyhedron Formula from HOL Light
 paulson <lp15@cam.ac.uk> parents: 
78475diff
changeset | 1999 | |
| 
4da1e18a9633
Loads of new material related to porting the Euler Polyhedron Formula from HOL Light
 paulson <lp15@cam.ac.uk> parents: 
78475diff
changeset | 2000 | lemma convex_cone_halfspace_ge: "convex_cone {x. a \<bullet> x \<ge> 0}"
 | 
| 
4da1e18a9633
Loads of new material related to porting the Euler Polyhedron Formula from HOL Light
 paulson <lp15@cam.ac.uk> parents: 
78475diff
changeset | 2001 | by (simp add: convex_cone_iff inner_simps(2)) | 
| 
4da1e18a9633
Loads of new material related to porting the Euler Polyhedron Formula from HOL Light
 paulson <lp15@cam.ac.uk> parents: 
78475diff
changeset | 2002 | |
| 
4da1e18a9633
Loads of new material related to porting the Euler Polyhedron Formula from HOL Light
 paulson <lp15@cam.ac.uk> parents: 
78475diff
changeset | 2003 | lemma convex_cone_halfspace_le: "convex_cone {x. a \<bullet> x \<le> 0}"
 | 
| 
4da1e18a9633
Loads of new material related to porting the Euler Polyhedron Formula from HOL Light
 paulson <lp15@cam.ac.uk> parents: 
78475diff
changeset | 2004 | by (simp add: convex_cone_iff inner_right_distrib mult_nonneg_nonpos) | 
| 
4da1e18a9633
Loads of new material related to porting the Euler Polyhedron Formula from HOL Light
 paulson <lp15@cam.ac.uk> parents: 
78475diff
changeset | 2005 | |
| 
4da1e18a9633
Loads of new material related to porting the Euler Polyhedron Formula from HOL Light
 paulson <lp15@cam.ac.uk> parents: 
78475diff
changeset | 2006 | lemma convex_cone_contains_0: "convex_cone S \<Longrightarrow> 0 \<in> S" | 
| 
4da1e18a9633
Loads of new material related to porting the Euler Polyhedron Formula from HOL Light
 paulson <lp15@cam.ac.uk> parents: 
78475diff
changeset | 2007 | using convex_cone_iff by blast | 
| 
4da1e18a9633
Loads of new material related to porting the Euler Polyhedron Formula from HOL Light
 paulson <lp15@cam.ac.uk> parents: 
78475diff
changeset | 2008 | |
| 
4da1e18a9633
Loads of new material related to porting the Euler Polyhedron Formula from HOL Light
 paulson <lp15@cam.ac.uk> parents: 
78475diff
changeset | 2009 | lemma convex_cone_Inter: | 
| 
4da1e18a9633
Loads of new material related to porting the Euler Polyhedron Formula from HOL Light
 paulson <lp15@cam.ac.uk> parents: 
78475diff
changeset | 2010 | "(\<And>S. S \<in> f \<Longrightarrow> convex_cone S) \<Longrightarrow> convex_cone(\<Inter> f)" | 
| 
4da1e18a9633
Loads of new material related to porting the Euler Polyhedron Formula from HOL Light
 paulson <lp15@cam.ac.uk> parents: 
78475diff
changeset | 2011 | by (simp add: convex_cone_iff) | 
| 
4da1e18a9633
Loads of new material related to porting the Euler Polyhedron Formula from HOL Light
 paulson <lp15@cam.ac.uk> parents: 
78475diff
changeset | 2012 | |
| 
4da1e18a9633
Loads of new material related to porting the Euler Polyhedron Formula from HOL Light
 paulson <lp15@cam.ac.uk> parents: 
78475diff
changeset | 2013 | lemma convex_cone_convex_cone_hull: "convex_cone(convex_cone hull S)" | 
| 
4da1e18a9633
Loads of new material related to porting the Euler Polyhedron Formula from HOL Light
 paulson <lp15@cam.ac.uk> parents: 
78475diff
changeset | 2014 | by (metis (no_types, lifting) convex_cone_Inter hull_def mem_Collect_eq) | 
| 
4da1e18a9633
Loads of new material related to porting the Euler Polyhedron Formula from HOL Light
 paulson <lp15@cam.ac.uk> parents: 
78475diff
changeset | 2015 | |
| 
4da1e18a9633
Loads of new material related to porting the Euler Polyhedron Formula from HOL Light
 paulson <lp15@cam.ac.uk> parents: 
78475diff
changeset | 2016 | lemma convex_convex_cone_hull: "convex(convex_cone hull S)" | 
| 
4da1e18a9633
Loads of new material related to porting the Euler Polyhedron Formula from HOL Light
 paulson <lp15@cam.ac.uk> parents: 
78475diff
changeset | 2017 | by (meson convex_cone_convex_cone_hull convex_cone_def) | 
| 
4da1e18a9633
Loads of new material related to porting the Euler Polyhedron Formula from HOL Light
 paulson <lp15@cam.ac.uk> parents: 
78475diff
changeset | 2018 | |
| 
4da1e18a9633
Loads of new material related to porting the Euler Polyhedron Formula from HOL Light
 paulson <lp15@cam.ac.uk> parents: 
78475diff
changeset | 2019 | lemma conic_convex_cone_hull: "conic(convex_cone hull S)" | 
| 
4da1e18a9633
Loads of new material related to porting the Euler Polyhedron Formula from HOL Light
 paulson <lp15@cam.ac.uk> parents: 
78475diff
changeset | 2020 | by (metis convex_cone_convex_cone_hull convex_cone_def) | 
| 
4da1e18a9633
Loads of new material related to porting the Euler Polyhedron Formula from HOL Light
 paulson <lp15@cam.ac.uk> parents: 
78475diff
changeset | 2021 | |
| 
4da1e18a9633
Loads of new material related to porting the Euler Polyhedron Formula from HOL Light
 paulson <lp15@cam.ac.uk> parents: 
78475diff
changeset | 2022 | lemma convex_cone_hull_nonempty: "convex_cone hull S \<noteq> {}"
 | 
| 
4da1e18a9633
Loads of new material related to porting the Euler Polyhedron Formula from HOL Light
 paulson <lp15@cam.ac.uk> parents: 
78475diff
changeset | 2023 | by (simp add: convex_cone_convex_cone_hull convex_cone_nonempty) | 
| 
4da1e18a9633
Loads of new material related to porting the Euler Polyhedron Formula from HOL Light
 paulson <lp15@cam.ac.uk> parents: 
78475diff
changeset | 2024 | |
| 
4da1e18a9633
Loads of new material related to porting the Euler Polyhedron Formula from HOL Light
 paulson <lp15@cam.ac.uk> parents: 
78475diff
changeset | 2025 | lemma convex_cone_hull_contains_0: "0 \<in> convex_cone hull S" | 
| 
4da1e18a9633
Loads of new material related to porting the Euler Polyhedron Formula from HOL Light
 paulson <lp15@cam.ac.uk> parents: 
78475diff
changeset | 2026 | by (simp add: convex_cone_contains_0 convex_cone_convex_cone_hull) | 
| 
4da1e18a9633
Loads of new material related to porting the Euler Polyhedron Formula from HOL Light
 paulson <lp15@cam.ac.uk> parents: 
78475diff
changeset | 2027 | |
| 
4da1e18a9633
Loads of new material related to porting the Euler Polyhedron Formula from HOL Light
 paulson <lp15@cam.ac.uk> parents: 
78475diff
changeset | 2028 | lemma convex_cone_hull_add: | 
| 
4da1e18a9633
Loads of new material related to porting the Euler Polyhedron Formula from HOL Light
 paulson <lp15@cam.ac.uk> parents: 
78475diff
changeset | 2029 | "\<lbrakk>x \<in> convex_cone hull S; y \<in> convex_cone hull S\<rbrakk> \<Longrightarrow> x + y \<in> convex_cone hull S" | 
| 
4da1e18a9633
Loads of new material related to porting the Euler Polyhedron Formula from HOL Light
 paulson <lp15@cam.ac.uk> parents: 
78475diff
changeset | 2030 | by (simp add: convex_cone_add convex_cone_convex_cone_hull) | 
| 
4da1e18a9633
Loads of new material related to porting the Euler Polyhedron Formula from HOL Light
 paulson <lp15@cam.ac.uk> parents: 
78475diff
changeset | 2031 | |
| 
4da1e18a9633
Loads of new material related to porting the Euler Polyhedron Formula from HOL Light
 paulson <lp15@cam.ac.uk> parents: 
78475diff
changeset | 2032 | lemma convex_cone_hull_mul: | 
| 
4da1e18a9633
Loads of new material related to porting the Euler Polyhedron Formula from HOL Light
 paulson <lp15@cam.ac.uk> parents: 
78475diff
changeset | 2033 | "\<lbrakk>x \<in> convex_cone hull S; 0 \<le> c\<rbrakk> \<Longrightarrow> (c *\<^sub>R x) \<in> convex_cone hull S" | 
| 
4da1e18a9633
Loads of new material related to porting the Euler Polyhedron Formula from HOL Light
 paulson <lp15@cam.ac.uk> parents: 
78475diff
changeset | 2034 | by (simp add: conic_convex_cone_hull conic_mul) | 
| 
4da1e18a9633
Loads of new material related to porting the Euler Polyhedron Formula from HOL Light
 paulson <lp15@cam.ac.uk> parents: 
78475diff
changeset | 2035 | |
| 
4da1e18a9633
Loads of new material related to porting the Euler Polyhedron Formula from HOL Light
 paulson <lp15@cam.ac.uk> parents: 
78475diff
changeset | 2036 | thm convex_sums | 
| 
4da1e18a9633
Loads of new material related to porting the Euler Polyhedron Formula from HOL Light
 paulson <lp15@cam.ac.uk> parents: 
78475diff
changeset | 2037 | lemma convex_cone_sums: | 
| 
4da1e18a9633
Loads of new material related to porting the Euler Polyhedron Formula from HOL Light
 paulson <lp15@cam.ac.uk> parents: 
78475diff
changeset | 2038 |    "\<lbrakk>convex_cone S; convex_cone T\<rbrakk> \<Longrightarrow> convex_cone (\<Union>x\<in> S. \<Union>y \<in> T. {x + y})"
 | 
| 
4da1e18a9633
Loads of new material related to porting the Euler Polyhedron Formula from HOL Light
 paulson <lp15@cam.ac.uk> parents: 
78475diff
changeset | 2039 | by (simp add: convex_cone_def conic_sums convex_sums) | 
| 
4da1e18a9633
Loads of new material related to porting the Euler Polyhedron Formula from HOL Light
 paulson <lp15@cam.ac.uk> parents: 
78475diff
changeset | 2040 | |
| 
4da1e18a9633
Loads of new material related to porting the Euler Polyhedron Formula from HOL Light
 paulson <lp15@cam.ac.uk> parents: 
78475diff
changeset | 2041 | lemma convex_cone_Times: | 
| 
4da1e18a9633
Loads of new material related to porting the Euler Polyhedron Formula from HOL Light
 paulson <lp15@cam.ac.uk> parents: 
78475diff
changeset | 2042 | "\<lbrakk>convex_cone S; convex_cone T\<rbrakk> \<Longrightarrow> convex_cone(S \<times> T)" | 
| 
4da1e18a9633
Loads of new material related to porting the Euler Polyhedron Formula from HOL Light
 paulson <lp15@cam.ac.uk> parents: 
78475diff
changeset | 2043 | by (simp add: conic_Times convex_Times convex_cone_def) | 
| 
4da1e18a9633
Loads of new material related to porting the Euler Polyhedron Formula from HOL Light
 paulson <lp15@cam.ac.uk> parents: 
78475diff
changeset | 2044 | |
| 
4da1e18a9633
Loads of new material related to porting the Euler Polyhedron Formula from HOL Light
 paulson <lp15@cam.ac.uk> parents: 
78475diff
changeset | 2045 | lemma convex_cone_Times_D1: "convex_cone (S \<times> T) \<Longrightarrow> convex_cone S" | 
| 
4da1e18a9633
Loads of new material related to porting the Euler Polyhedron Formula from HOL Light
 paulson <lp15@cam.ac.uk> parents: 
78475diff
changeset | 2046 | by (metis Times_empty conic_Times_eq convex_cone_def convex_convex_hull convex_hull_Times hull_same times_eq_iff) | 
| 
4da1e18a9633
Loads of new material related to porting the Euler Polyhedron Formula from HOL Light
 paulson <lp15@cam.ac.uk> parents: 
78475diff
changeset | 2047 | |
| 
4da1e18a9633
Loads of new material related to porting the Euler Polyhedron Formula from HOL Light
 paulson <lp15@cam.ac.uk> parents: 
78475diff
changeset | 2048 | lemma convex_cone_Times_eq: | 
| 
4da1e18a9633
Loads of new material related to porting the Euler Polyhedron Formula from HOL Light
 paulson <lp15@cam.ac.uk> parents: 
78475diff
changeset | 2049 | "convex_cone(S \<times> T) \<longleftrightarrow> convex_cone S \<and> convex_cone T" | 
| 
4da1e18a9633
Loads of new material related to porting the Euler Polyhedron Formula from HOL Light
 paulson <lp15@cam.ac.uk> parents: 
78475diff
changeset | 2050 | proof (cases "S={} \<or> T={}")
 | 
| 
4da1e18a9633
Loads of new material related to porting the Euler Polyhedron Formula from HOL Light
 paulson <lp15@cam.ac.uk> parents: 
78475diff
changeset | 2051 | case True | 
| 
4da1e18a9633
Loads of new material related to porting the Euler Polyhedron Formula from HOL Light
 paulson <lp15@cam.ac.uk> parents: 
78475diff
changeset | 2052 | then show ?thesis | 
| 
4da1e18a9633
Loads of new material related to porting the Euler Polyhedron Formula from HOL Light
 paulson <lp15@cam.ac.uk> parents: 
78475diff
changeset | 2053 | by (auto dest: convex_cone_nonempty) | 
| 
4da1e18a9633
Loads of new material related to porting the Euler Polyhedron Formula from HOL Light
 paulson <lp15@cam.ac.uk> parents: 
78475diff
changeset | 2054 | next | 
| 
4da1e18a9633
Loads of new material related to porting the Euler Polyhedron Formula from HOL Light
 paulson <lp15@cam.ac.uk> parents: 
78475diff
changeset | 2055 | case False | 
| 
4da1e18a9633
Loads of new material related to porting the Euler Polyhedron Formula from HOL Light
 paulson <lp15@cam.ac.uk> parents: 
78475diff
changeset | 2056 | then have "convex_cone (S \<times> T) \<Longrightarrow> convex_cone T" | 
| 
4da1e18a9633
Loads of new material related to porting the Euler Polyhedron Formula from HOL Light
 paulson <lp15@cam.ac.uk> parents: 
78475diff
changeset | 2057 | by (metis conic_Times_eq convex_cone_def convex_convex_hull convex_hull_Times hull_same times_eq_iff) | 
| 
4da1e18a9633
Loads of new material related to porting the Euler Polyhedron Formula from HOL Light
 paulson <lp15@cam.ac.uk> parents: 
78475diff
changeset | 2058 | then show ?thesis | 
| 
4da1e18a9633
Loads of new material related to porting the Euler Polyhedron Formula from HOL Light
 paulson <lp15@cam.ac.uk> parents: 
78475diff
changeset | 2059 | using convex_cone_Times convex_cone_Times_D1 by blast | 
| 
4da1e18a9633
Loads of new material related to porting the Euler Polyhedron Formula from HOL Light
 paulson <lp15@cam.ac.uk> parents: 
78475diff
changeset | 2060 | qed | 
| 
4da1e18a9633
Loads of new material related to porting the Euler Polyhedron Formula from HOL Light
 paulson <lp15@cam.ac.uk> parents: 
78475diff
changeset | 2061 | |
| 
4da1e18a9633
Loads of new material related to porting the Euler Polyhedron Formula from HOL Light
 paulson <lp15@cam.ac.uk> parents: 
78475diff
changeset | 2062 | |
| 
4da1e18a9633
Loads of new material related to porting the Euler Polyhedron Formula from HOL Light
 paulson <lp15@cam.ac.uk> parents: 
78475diff
changeset | 2063 | lemma convex_cone_hull_Un: | 
| 
4da1e18a9633
Loads of new material related to porting the Euler Polyhedron Formula from HOL Light
 paulson <lp15@cam.ac.uk> parents: 
78475diff
changeset | 2064 |   "convex_cone hull(S \<union> T) = (\<Union>x \<in> convex_cone hull S. \<Union>y \<in> convex_cone hull T. {x + y})"
 | 
| 
4da1e18a9633
Loads of new material related to porting the Euler Polyhedron Formula from HOL Light
 paulson <lp15@cam.ac.uk> parents: 
78475diff
changeset | 2065 | (is "?lhs = ?rhs") | 
| 
4da1e18a9633
Loads of new material related to porting the Euler Polyhedron Formula from HOL Light
 paulson <lp15@cam.ac.uk> parents: 
78475diff
changeset | 2066 | proof | 
| 
4da1e18a9633
Loads of new material related to porting the Euler Polyhedron Formula from HOL Light
 paulson <lp15@cam.ac.uk> parents: 
78475diff
changeset | 2067 | show "?lhs \<subseteq> ?rhs" | 
| 
4da1e18a9633
Loads of new material related to porting the Euler Polyhedron Formula from HOL Light
 paulson <lp15@cam.ac.uk> parents: 
78475diff
changeset | 2068 | proof (rule hull_minimal) | 
| 
4da1e18a9633
Loads of new material related to porting the Euler Polyhedron Formula from HOL Light
 paulson <lp15@cam.ac.uk> parents: 
78475diff
changeset | 2069 |     show "S \<union> T \<subseteq> (\<Union>x\<in>convex_cone hull S. \<Union>y\<in>convex_cone hull T. {x + y})"
 | 
| 
4da1e18a9633
Loads of new material related to porting the Euler Polyhedron Formula from HOL Light
 paulson <lp15@cam.ac.uk> parents: 
78475diff
changeset | 2070 | apply (clarsimp simp: subset_iff) | 
| 
4da1e18a9633
Loads of new material related to porting the Euler Polyhedron Formula from HOL Light
 paulson <lp15@cam.ac.uk> parents: 
78475diff
changeset | 2071 | by (metis add_0 convex_cone_hull_contains_0 group_cancel.rule0 hull_inc) | 
| 
4da1e18a9633
Loads of new material related to porting the Euler Polyhedron Formula from HOL Light
 paulson <lp15@cam.ac.uk> parents: 
78475diff
changeset | 2072 |     show "convex_cone (\<Union>x\<in>convex_cone hull S. \<Union>y\<in>convex_cone hull T. {x + y})"
 | 
| 
4da1e18a9633
Loads of new material related to porting the Euler Polyhedron Formula from HOL Light
 paulson <lp15@cam.ac.uk> parents: 
78475diff
changeset | 2073 | by (simp add: convex_cone_convex_cone_hull convex_cone_sums) | 
| 
4da1e18a9633
Loads of new material related to porting the Euler Polyhedron Formula from HOL Light
 paulson <lp15@cam.ac.uk> parents: 
78475diff
changeset | 2074 | qed | 
| 
4da1e18a9633
Loads of new material related to porting the Euler Polyhedron Formula from HOL Light
 paulson <lp15@cam.ac.uk> parents: 
78475diff
changeset | 2075 | next | 
| 
4da1e18a9633
Loads of new material related to porting the Euler Polyhedron Formula from HOL Light
 paulson <lp15@cam.ac.uk> parents: 
78475diff
changeset | 2076 | show "?rhs \<subseteq> ?lhs" | 
| 
4da1e18a9633
Loads of new material related to porting the Euler Polyhedron Formula from HOL Light
 paulson <lp15@cam.ac.uk> parents: 
78475diff
changeset | 2077 | by clarify (metis convex_cone_hull_add hull_mono le_sup_iff subsetD subsetI) | 
| 
4da1e18a9633
Loads of new material related to porting the Euler Polyhedron Formula from HOL Light
 paulson <lp15@cam.ac.uk> parents: 
78475diff
changeset | 2078 | qed | 
| 
4da1e18a9633
Loads of new material related to porting the Euler Polyhedron Formula from HOL Light
 paulson <lp15@cam.ac.uk> parents: 
78475diff
changeset | 2079 | |
| 
4da1e18a9633
Loads of new material related to porting the Euler Polyhedron Formula from HOL Light
 paulson <lp15@cam.ac.uk> parents: 
78475diff
changeset | 2080 | lemma convex_cone_singleton [iff]: "convex_cone {0}"
 | 
| 
4da1e18a9633
Loads of new material related to porting the Euler Polyhedron Formula from HOL Light
 paulson <lp15@cam.ac.uk> parents: 
78475diff
changeset | 2081 | by (simp add: convex_cone_iff) | 
| 
4da1e18a9633
Loads of new material related to porting the Euler Polyhedron Formula from HOL Light
 paulson <lp15@cam.ac.uk> parents: 
78475diff
changeset | 2082 | |
| 
4da1e18a9633
Loads of new material related to porting the Euler Polyhedron Formula from HOL Light
 paulson <lp15@cam.ac.uk> parents: 
78475diff
changeset | 2083 | lemma convex_hull_subset_convex_cone_hull: | 
| 
4da1e18a9633
Loads of new material related to porting the Euler Polyhedron Formula from HOL Light
 paulson <lp15@cam.ac.uk> parents: 
78475diff
changeset | 2084 | "convex hull S \<subseteq> convex_cone hull S" | 
| 
4da1e18a9633
Loads of new material related to porting the Euler Polyhedron Formula from HOL Light
 paulson <lp15@cam.ac.uk> parents: 
78475diff
changeset | 2085 | by (simp add: convex_convex_cone_hull hull_minimal hull_subset) | 
| 
4da1e18a9633
Loads of new material related to porting the Euler Polyhedron Formula from HOL Light
 paulson <lp15@cam.ac.uk> parents: 
78475diff
changeset | 2086 | |
| 
4da1e18a9633
Loads of new material related to porting the Euler Polyhedron Formula from HOL Light
 paulson <lp15@cam.ac.uk> parents: 
78475diff
changeset | 2087 | lemma conic_hull_subset_convex_cone_hull: | 
| 
4da1e18a9633
Loads of new material related to porting the Euler Polyhedron Formula from HOL Light
 paulson <lp15@cam.ac.uk> parents: 
78475diff
changeset | 2088 | "conic hull S \<subseteq> convex_cone hull S" | 
| 
4da1e18a9633
Loads of new material related to porting the Euler Polyhedron Formula from HOL Light
 paulson <lp15@cam.ac.uk> parents: 
78475diff
changeset | 2089 | by (simp add: conic_convex_cone_hull hull_minimal hull_subset) | 
| 
4da1e18a9633
Loads of new material related to porting the Euler Polyhedron Formula from HOL Light
 paulson <lp15@cam.ac.uk> parents: 
78475diff
changeset | 2090 | |
| 
4da1e18a9633
Loads of new material related to porting the Euler Polyhedron Formula from HOL Light
 paulson <lp15@cam.ac.uk> parents: 
78475diff
changeset | 2091 | lemma subspace_imp_convex_cone: "subspace S \<Longrightarrow> convex_cone S" | 
| 
4da1e18a9633
Loads of new material related to porting the Euler Polyhedron Formula from HOL Light
 paulson <lp15@cam.ac.uk> parents: 
78475diff
changeset | 2092 | by (simp add: convex_cone_iff subspace_def) | 
| 
4da1e18a9633
Loads of new material related to porting the Euler Polyhedron Formula from HOL Light
 paulson <lp15@cam.ac.uk> parents: 
78475diff
changeset | 2093 | |
| 
4da1e18a9633
Loads of new material related to porting the Euler Polyhedron Formula from HOL Light
 paulson <lp15@cam.ac.uk> parents: 
78475diff
changeset | 2094 | lemma convex_cone_span: "convex_cone(span S)" | 
| 
4da1e18a9633
Loads of new material related to porting the Euler Polyhedron Formula from HOL Light
 paulson <lp15@cam.ac.uk> parents: 
78475diff
changeset | 2095 | by (simp add: subspace_imp_convex_cone) | 
| 
4da1e18a9633
Loads of new material related to porting the Euler Polyhedron Formula from HOL Light
 paulson <lp15@cam.ac.uk> parents: 
78475diff
changeset | 2096 | |
| 
4da1e18a9633
Loads of new material related to porting the Euler Polyhedron Formula from HOL Light
 paulson <lp15@cam.ac.uk> parents: 
78475diff
changeset | 2097 | lemma convex_cone_negations: | 
| 
4da1e18a9633
Loads of new material related to porting the Euler Polyhedron Formula from HOL Light
 paulson <lp15@cam.ac.uk> parents: 
78475diff
changeset | 2098 | "convex_cone S \<Longrightarrow> convex_cone (image uminus S)" | 
| 
4da1e18a9633
Loads of new material related to porting the Euler Polyhedron Formula from HOL Light
 paulson <lp15@cam.ac.uk> parents: 
78475diff
changeset | 2099 | by (simp add: convex_cone_linear_image module_hom_uminus) | 
| 
4da1e18a9633
Loads of new material related to porting the Euler Polyhedron Formula from HOL Light
 paulson <lp15@cam.ac.uk> parents: 
78475diff
changeset | 2100 | |
| 
4da1e18a9633
Loads of new material related to porting the Euler Polyhedron Formula from HOL Light
 paulson <lp15@cam.ac.uk> parents: 
78475diff
changeset | 2101 | lemma subspace_convex_cone_symmetric: | 
| 
4da1e18a9633
Loads of new material related to porting the Euler Polyhedron Formula from HOL Light
 paulson <lp15@cam.ac.uk> parents: 
78475diff
changeset | 2102 | "subspace S \<longleftrightarrow> convex_cone S \<and> (\<forall>x \<in> S. -x \<in> S)" | 
| 
4da1e18a9633
Loads of new material related to porting the Euler Polyhedron Formula from HOL Light
 paulson <lp15@cam.ac.uk> parents: 
78475diff
changeset | 2103 | by (smt (verit) convex_cone_iff scaleR_left.minus subspace_def subspace_neg) | 
| 
4da1e18a9633
Loads of new material related to porting the Euler Polyhedron Formula from HOL Light
 paulson <lp15@cam.ac.uk> parents: 
78475diff
changeset | 2104 | |
| 
4da1e18a9633
Loads of new material related to porting the Euler Polyhedron Formula from HOL Light
 paulson <lp15@cam.ac.uk> parents: 
78475diff
changeset | 2105 | lemma convex_cone_hull_separate_nonempty: | 
| 
4da1e18a9633
Loads of new material related to porting the Euler Polyhedron Formula from HOL Light
 paulson <lp15@cam.ac.uk> parents: 
78475diff
changeset | 2106 |   assumes "S \<noteq> {}"
 | 
| 
4da1e18a9633
Loads of new material related to porting the Euler Polyhedron Formula from HOL Light
 paulson <lp15@cam.ac.uk> parents: 
78475diff
changeset | 2107 | shows "convex_cone hull S = conic hull (convex hull S)" (is "?lhs = ?rhs") | 
| 
4da1e18a9633
Loads of new material related to porting the Euler Polyhedron Formula from HOL Light
 paulson <lp15@cam.ac.uk> parents: 
78475diff
changeset | 2108 | proof | 
| 
4da1e18a9633
Loads of new material related to porting the Euler Polyhedron Formula from HOL Light
 paulson <lp15@cam.ac.uk> parents: 
78475diff
changeset | 2109 | show "?lhs \<subseteq> ?rhs" | 
| 
4da1e18a9633
Loads of new material related to porting the Euler Polyhedron Formula from HOL Light
 paulson <lp15@cam.ac.uk> parents: 
78475diff
changeset | 2110 | by (metis assms conic_conic_hull convex_cone_def convex_conic_hull convex_convex_hull hull_subset subset_empty subset_hull) | 
| 
4da1e18a9633
Loads of new material related to porting the Euler Polyhedron Formula from HOL Light
 paulson <lp15@cam.ac.uk> parents: 
78475diff
changeset | 2111 | show "?rhs \<subseteq> ?lhs" | 
| 
4da1e18a9633
Loads of new material related to porting the Euler Polyhedron Formula from HOL Light
 paulson <lp15@cam.ac.uk> parents: 
78475diff
changeset | 2112 | by (simp add: conic_convex_cone_hull convex_hull_subset_convex_cone_hull subset_hull) | 
| 
4da1e18a9633
Loads of new material related to porting the Euler Polyhedron Formula from HOL Light
 paulson <lp15@cam.ac.uk> parents: 
78475diff
changeset | 2113 | qed | 
| 
4da1e18a9633
Loads of new material related to porting the Euler Polyhedron Formula from HOL Light
 paulson <lp15@cam.ac.uk> parents: 
78475diff
changeset | 2114 | |
| 
4da1e18a9633
Loads of new material related to porting the Euler Polyhedron Formula from HOL Light
 paulson <lp15@cam.ac.uk> parents: 
78475diff
changeset | 2115 | lemma convex_cone_hull_empty [simp]: "convex_cone hull {} = {0}"
 | 
| 
4da1e18a9633
Loads of new material related to porting the Euler Polyhedron Formula from HOL Light
 paulson <lp15@cam.ac.uk> parents: 
78475diff
changeset | 2116 | by (metis convex_cone_hull_contains_0 convex_cone_singleton hull_redundant hull_same) | 
| 
4da1e18a9633
Loads of new material related to porting the Euler Polyhedron Formula from HOL Light
 paulson <lp15@cam.ac.uk> parents: 
78475diff
changeset | 2117 | |
| 
4da1e18a9633
Loads of new material related to porting the Euler Polyhedron Formula from HOL Light
 paulson <lp15@cam.ac.uk> parents: 
78475diff
changeset | 2118 | lemma convex_cone_hull_separate: | 
| 
4da1e18a9633
Loads of new material related to porting the Euler Polyhedron Formula from HOL Light
 paulson <lp15@cam.ac.uk> parents: 
78475diff
changeset | 2119 | "convex_cone hull S = insert 0 (conic hull (convex hull S))" | 
| 
4da1e18a9633
Loads of new material related to porting the Euler Polyhedron Formula from HOL Light
 paulson <lp15@cam.ac.uk> parents: 
78475diff
changeset | 2120 | proof(cases "S={}")
 | 
| 
4da1e18a9633
Loads of new material related to porting the Euler Polyhedron Formula from HOL Light
 paulson <lp15@cam.ac.uk> parents: 
78475diff
changeset | 2121 | case False | 
| 
4da1e18a9633
Loads of new material related to porting the Euler Polyhedron Formula from HOL Light
 paulson <lp15@cam.ac.uk> parents: 
78475diff
changeset | 2122 | then show ?thesis | 
| 
4da1e18a9633
Loads of new material related to porting the Euler Polyhedron Formula from HOL Light
 paulson <lp15@cam.ac.uk> parents: 
78475diff
changeset | 2123 | using convex_cone_hull_contains_0 convex_cone_hull_separate_nonempty by blast | 
| 
4da1e18a9633
Loads of new material related to porting the Euler Polyhedron Formula from HOL Light
 paulson <lp15@cam.ac.uk> parents: 
78475diff
changeset | 2124 | qed auto | 
| 
4da1e18a9633
Loads of new material related to porting the Euler Polyhedron Formula from HOL Light
 paulson <lp15@cam.ac.uk> parents: 
78475diff
changeset | 2125 | |
| 
4da1e18a9633
Loads of new material related to porting the Euler Polyhedron Formula from HOL Light
 paulson <lp15@cam.ac.uk> parents: 
78475diff
changeset | 2126 | lemma convex_cone_hull_convex_hull_nonempty: | 
| 
4da1e18a9633
Loads of new material related to porting the Euler Polyhedron Formula from HOL Light
 paulson <lp15@cam.ac.uk> parents: 
78475diff
changeset | 2127 |    "S \<noteq> {} \<Longrightarrow> convex_cone hull S = (\<Union>x \<in> convex hull S. \<Union>c\<in>{0..}. {c *\<^sub>R x})"
 | 
| 
4da1e18a9633
Loads of new material related to porting the Euler Polyhedron Formula from HOL Light
 paulson <lp15@cam.ac.uk> parents: 
78475diff
changeset | 2128 | by (force simp: convex_cone_hull_separate_nonempty conic_hull_as_image) | 
| 
4da1e18a9633
Loads of new material related to porting the Euler Polyhedron Formula from HOL Light
 paulson <lp15@cam.ac.uk> parents: 
78475diff
changeset | 2129 | |
| 
4da1e18a9633
Loads of new material related to porting the Euler Polyhedron Formula from HOL Light
 paulson <lp15@cam.ac.uk> parents: 
78475diff
changeset | 2130 | lemma convex_cone_hull_convex_hull: | 
| 
4da1e18a9633
Loads of new material related to porting the Euler Polyhedron Formula from HOL Light
 paulson <lp15@cam.ac.uk> parents: 
78475diff
changeset | 2131 |    "convex_cone hull S = insert 0 (\<Union>x \<in> convex hull S. \<Union>c\<in>{0..}. {c *\<^sub>R x})"
 | 
| 
4da1e18a9633
Loads of new material related to porting the Euler Polyhedron Formula from HOL Light
 paulson <lp15@cam.ac.uk> parents: 
78475diff
changeset | 2132 | by (force simp: convex_cone_hull_separate conic_hull_as_image) | 
| 
4da1e18a9633
Loads of new material related to porting the Euler Polyhedron Formula from HOL Light
 paulson <lp15@cam.ac.uk> parents: 
78475diff
changeset | 2133 | |
| 
4da1e18a9633
Loads of new material related to porting the Euler Polyhedron Formula from HOL Light
 paulson <lp15@cam.ac.uk> parents: 
78475diff
changeset | 2134 | lemma convex_cone_hull_linear_image: | 
| 
4da1e18a9633
Loads of new material related to porting the Euler Polyhedron Formula from HOL Light
 paulson <lp15@cam.ac.uk> parents: 
78475diff
changeset | 2135 | "linear f \<Longrightarrow> convex_cone hull (f ` S) = image f (convex_cone hull S)" | 
| 
4da1e18a9633
Loads of new material related to porting the Euler Polyhedron Formula from HOL Light
 paulson <lp15@cam.ac.uk> parents: 
78475diff
changeset | 2136 | by (metis (no_types, lifting) conic_hull_linear_image convex_cone_hull_separate convex_hull_linear_image image_insert linear_0) | 
| 
4da1e18a9633
Loads of new material related to porting the Euler Polyhedron Formula from HOL Light
 paulson <lp15@cam.ac.uk> parents: 
78475diff
changeset | 2137 | |
| 69619 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 2138 | subsection \<open>Radon's theorem\<close> | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 2139 | |
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 2140 | text "Formalized by Lars Schewe." | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 2141 | |
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 2142 | lemma Radon_ex_lemma: | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 2143 | assumes "finite c" "affine_dependent c" | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 2144 | shows "\<exists>u. sum u c = 0 \<and> (\<exists>v\<in>c. u v \<noteq> 0) \<and> sum (\<lambda>v. u v *\<^sub>R v) c = 0" | 
| 78475 | 2145 | using affine_dependent_explicit_finite assms by blast | 
| 69619 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 2146 | |
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 2147 | lemma Radon_s_lemma: | 
| 72385 | 2148 | assumes "finite S" | 
| 2149 | and "sum f S = (0::real)" | |
| 2150 |   shows "sum f {x\<in>S. 0 < f x} = - sum f {x\<in>S. f x < 0}"
 | |
| 69619 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 2151 | proof - | 
| 78475 | 2152 | have "\<And>x. (if f x < 0 then f x else 0) + (if 0 < f x then f x else 0) = f x" | 
| 69619 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 2153 | by auto | 
| 78475 | 2154 | then show ?thesis | 
| 2155 | using assms by (simp add: sum.inter_filter flip: sum.distrib add_eq_0_iff) | |
| 69619 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 2156 | qed | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 2157 | |
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 2158 | lemma Radon_v_lemma: | 
| 72385 | 2159 | assumes "finite S" | 
| 2160 | and "sum f S = 0" | |
| 69619 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 2161 | and "\<forall>x. g x = (0::real) \<longrightarrow> f x = (0::'a::euclidean_space)" | 
| 72385 | 2162 |   shows "(sum f {x\<in>S. 0 < g x}) = - sum f {x\<in>S. g x < 0}"
 | 
| 69619 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 2163 | proof - | 
| 78475 | 2164 | have "\<And>x. (if 0 < g x then f x else 0) + (if g x < 0 then f x else 0) = f x" | 
| 2165 | using assms by auto | |
| 2166 | then show ?thesis | |
| 2167 | using assms by (simp add: sum.inter_filter eq_neg_iff_add_eq_0 flip: sum.distrib add_eq_0_iff) | |
| 69619 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 2168 | qed | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 2169 | |
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 2170 | lemma Radon_partition: | 
| 72385 | 2171 | assumes "finite C" "affine_dependent C" | 
| 78475 | 2172 |   shows "\<exists>M P. M \<inter> P = {} \<and> M \<union> P = C \<and> (convex hull M) \<inter> (convex hull P) \<noteq> {}"
 | 
| 69619 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 2173 | proof - | 
| 72385 | 2174 | obtain u v where uv: "sum u C = 0" "v\<in>C" "u v \<noteq> 0" "(\<Sum>v\<in>C. u v *\<^sub>R v) = 0" | 
| 69619 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 2175 | using Radon_ex_lemma[OF assms] by auto | 
| 72385 | 2176 |   have fin: "finite {x \<in> C. 0 < u x}" "finite {x \<in> C. 0 > u x}"
 | 
| 69619 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 2177 | using assms(1) by auto | 
| 72385 | 2178 |   define z  where "z = inverse (sum u {x\<in>C. u x > 0}) *\<^sub>R sum (\<lambda>x. u x *\<^sub>R x) {x\<in>C. u x > 0}"
 | 
| 2179 |   have "sum u {x \<in> C. 0 < u x} \<noteq> 0"
 | |
| 69619 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 2180 | proof (cases "u v \<ge> 0") | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 2181 | case False | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 2182 | then have "u v < 0" by auto | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 2183 | then show ?thesis | 
| 78475 | 2184 | by (smt (verit) assms(1) fin(1) mem_Collect_eq sum.neutral_const sum_mono_inv uv) | 
| 2185 | next | |
| 2186 | case True | |
| 2187 |     with fin uv show "sum u {x \<in> C. 0 < u x} \<noteq> 0"
 | |
| 2188 | by (smt (verit) fin(1) mem_Collect_eq sum_nonneg_eq_0_iff uv) | |
| 2189 | qed | |
| 72385 | 2190 |   then have *: "sum u {x\<in>C. u x > 0} > 0"
 | 
| 2191 | unfolding less_le by (metis (no_types, lifting) mem_Collect_eq sum_nonneg) | |
| 2192 |   moreover have "sum u ({x \<in> C. 0 < u x} \<union> {x \<in> C. u x < 0}) = sum u C"
 | |
| 2193 |     "(\<Sum>x\<in>{x \<in> C. 0 < u x} \<union> {x \<in> C. u x < 0}. u x *\<^sub>R x) = (\<Sum>x\<in>C. u x *\<^sub>R x)"
 | |
| 69619 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 2194 | using assms(1) | 
| 72385 | 2195 | by (rule_tac[!] sum.mono_neutral_left, auto) | 
| 2196 |   then have "sum u {x \<in> C. 0 < u x} = - sum u {x \<in> C. 0 > u x}"
 | |
| 2197 |     "(\<Sum>x\<in>{x \<in> C. 0 < u x}. u x *\<^sub>R x) = - (\<Sum>x\<in>{x \<in> C. 0 > u x}. u x *\<^sub>R x)"
 | |
| 69619 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 2198 | unfolding eq_neg_iff_add_eq_0 | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 2199 | using uv(1,4) | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 2200 | by (auto simp: sum.union_inter_neutral[OF fin, symmetric]) | 
| 72385 | 2201 |   moreover have "\<forall>x\<in>{v \<in> C. u v < 0}. 0 \<le> inverse (sum u {x \<in> C. 0 < u x}) * - u x"
 | 
| 2202 | using * by (fastforce intro: mult_nonneg_nonneg) | |
| 2203 |   ultimately have "z \<in> convex hull {v \<in> C. u v \<le> 0}"
 | |
| 69619 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 2204 | unfolding convex_hull_explicit mem_Collect_eq | 
| 72385 | 2205 |     apply (rule_tac x="{v \<in> C. u v < 0}" in exI)
 | 
| 2206 |     apply (rule_tac x="\<lambda>y. inverse (sum u {x\<in>C. u x > 0}) * - u y" in exI)
 | |
| 2207 | using assms(1) unfolding scaleR_scaleR[symmetric] scaleR_right.sum [symmetric] | |
| 2208 | by (auto simp: z_def sum_negf sum_distrib_left[symmetric]) | |
| 2209 |   moreover have "\<forall>x\<in>{v \<in> C. 0 < u v}. 0 \<le> inverse (sum u {x \<in> C. 0 < u x}) * u x"
 | |
| 2210 | using * by (fastforce intro: mult_nonneg_nonneg) | |
| 2211 |   then have "z \<in> convex hull {v \<in> C. u v > 0}"
 | |
| 69619 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 2212 | unfolding convex_hull_explicit mem_Collect_eq | 
| 72385 | 2213 |     apply (rule_tac x="{v \<in> C. 0 < u v}" in exI)
 | 
| 2214 |     apply (rule_tac x="\<lambda>y. inverse (sum u {x\<in>C. u x > 0}) * u y" in exI)
 | |
| 69619 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 2215 | using assms(1) | 
| 72385 | 2216 | unfolding scaleR_scaleR[symmetric] scaleR_right.sum [symmetric] | 
| 2217 | using * by (auto simp: z_def sum_negf sum_distrib_left[symmetric]) | |
| 69619 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 2218 | ultimately show ?thesis | 
| 72385 | 2219 |     apply (rule_tac x="{v\<in>C. u v \<le> 0}" in exI)
 | 
| 2220 |     apply (rule_tac x="{v\<in>C. u v > 0}" in exI, auto)
 | |
| 69619 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 2221 | done | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 2222 | qed | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 2223 | |
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 2224 | theorem Radon: | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 2225 | assumes "affine_dependent c" | 
| 78475 | 2226 |   obtains M P where "M \<subseteq> c" "P \<subseteq> c" "M \<inter> P = {}" "(convex hull M) \<inter> (convex hull P) \<noteq> {}"
 | 
| 2227 | by (smt (verit) Radon_partition affine_dependent_explicit affine_dependent_explicit_finite assms le_sup_iff) | |
| 69619 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 2228 | |
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 2229 | |
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 2230 | subsection \<open>Helly's theorem\<close> | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 2231 | |
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 2232 | lemma Helly_induct: | 
| 78475 | 2233 | fixes \<F> :: "'a::euclidean_space set set" | 
| 2234 | assumes "card \<F> = n" | |
| 69619 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 2235 |     and "n \<ge> DIM('a) + 1"
 | 
| 78475 | 2236 |     and "\<forall>S\<in>\<F>. convex S" "\<forall>T\<subseteq>\<F>. card T = DIM('a) + 1 \<longrightarrow> \<Inter>T \<noteq> {}"
 | 
| 2237 |   shows "\<Inter>\<F> \<noteq> {}"
 | |
| 69619 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 2238 | using assms | 
| 78475 | 2239 | proof (induction n arbitrary: \<F>) | 
| 69619 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 2240 | case 0 | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 2241 | then show ?case by auto | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 2242 | next | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 2243 | case (Suc n) | 
| 78475 | 2244 | have "finite \<F>" | 
| 2245 | using \<open>card \<F> = Suc n\<close> by (auto intro: card_ge_0_finite) | |
| 2246 |   show "\<Inter>\<F> \<noteq> {}"
 | |
| 69619 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 2247 |   proof (cases "n = DIM('a)")
 | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 2248 | case True | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 2249 | then show ?thesis | 
| 78475 | 2250 | by (simp add: Suc.prems) | 
| 69619 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 2251 | next | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 2252 | case False | 
| 78475 | 2253 |     have "\<Inter>(\<F> - {S}) \<noteq> {}" if "S \<in> \<F>" for S
 | 
| 69619 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 2254 | proof (rule Suc.IH[rule_format]) | 
| 78475 | 2255 |       show "card (\<F> - {S}) = n"
 | 
| 2256 | by (simp add: Suc.prems(1) \<open>finite \<F>\<close> that) | |
| 69619 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 2257 |       show "DIM('a) + 1 \<le> n"
 | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 2258 | using False Suc.prems(2) by linarith | 
| 78475 | 2259 |       show "\<And>t. \<lbrakk>t \<subseteq> \<F> - {S}; card t = DIM('a) + 1\<rbrakk> \<Longrightarrow> \<Inter>t \<noteq> {}"
 | 
| 69619 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 2260 | by (simp add: Suc.prems(4) subset_Diff_insert) | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 2261 | qed (use Suc in auto) | 
| 78475 | 2262 |     then have "\<forall>S\<in>\<F>. \<exists>x. x \<in> \<Inter>(\<F> - {S})"
 | 
| 69619 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 2263 | by blast | 
| 78475 | 2264 |     then obtain X where X: "\<And>S. S\<in>\<F> \<Longrightarrow> X S \<in> \<Inter>(\<F> - {S})"
 | 
| 69619 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 2265 | by metis | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 2266 | show ?thesis | 
| 78475 | 2267 | proof (cases "inj_on X \<F>") | 
| 69619 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 2268 | case False | 
| 78475 | 2269 | then obtain S T where "S\<noteq>T" and st: "S\<in>\<F>" "T\<in>\<F>" "X S = X T" | 
| 69619 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 2270 | unfolding inj_on_def by auto | 
| 78475 | 2271 |       then have *: "\<Inter>\<F> = \<Inter>(\<F> - {S}) \<inter> \<Inter>(\<F> - {T})" by auto
 | 
| 69619 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 2272 | show ?thesis | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 2273 | by (metis "*" X disjoint_iff_not_equal st) | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 2274 | next | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 2275 | case True | 
| 78475 | 2276 |       then obtain M P where mp: "M \<inter> P = {}" "M \<union> P = X ` \<F>" "convex hull M \<inter> convex hull P \<noteq> {}"
 | 
| 2277 | using Radon_partition[of "X ` \<F>"] and affine_dependent_biggerset[of "X ` \<F>"] | |
| 2278 | unfolding card_image[OF True] and \<open>card \<F> = Suc n\<close> | |
| 2279 | using Suc(3) \<open>finite \<F>\<close> and False | |
| 69619 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 2280 | by auto | 
| 78475 | 2281 | have "M \<subseteq> X ` \<F>" "P \<subseteq> X ` \<F>" | 
| 69619 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 2282 | using mp(2) by auto | 
| 78475 | 2283 | then obtain \<G> \<H> where gh:"M = X ` \<G>" "P = X ` \<H>" "\<G> \<subseteq> \<F>" "\<H> \<subseteq> \<F>" | 
| 69619 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 2284 | unfolding subset_image_iff by auto | 
| 78475 | 2285 | then have "\<F> \<union> (\<G> \<union> \<H>) = \<F>" by auto | 
| 2286 | then have \<F>: "\<F> = \<G> \<union> \<H>" | |
| 2287 | using inj_on_Un_image_eq_iff[of X \<F> "\<G> \<union> \<H>"] and True | |
| 69619 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 2288 | unfolding mp(2)[unfolded image_Un[symmetric] gh] | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 2289 | by auto | 
| 78475 | 2290 |       have *: "\<G> \<inter> \<H> = {}"
 | 
| 2291 | using gh local.mp(1) by blast | |
| 2292 | have "convex hull (X ` \<H>) \<subseteq> \<Inter>\<G>" "convex hull (X ` \<G>) \<subseteq> \<Inter>\<H>" | |
| 2293 | by (rule hull_minimal; use X * \<F> in \<open>auto simp: Suc.prems(3) convex_Inter\<close>)+ | |
| 69619 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 2294 | then show ?thesis | 
| 78475 | 2295 | unfolding \<F> using mp(3)[unfolded gh] by blast | 
| 69619 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 2296 | qed | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 2297 | qed | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 2298 | qed | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 2299 | |
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 2300 | theorem Helly: | 
| 78475 | 2301 | fixes \<F> :: "'a::euclidean_space set set" | 
| 2302 |   assumes "card \<F> \<ge> DIM('a) + 1" "\<forall>s\<in>\<F>. convex s"
 | |
| 2303 |     and "\<And>t. \<lbrakk>t\<subseteq>\<F>; card t = DIM('a) + 1\<rbrakk> \<Longrightarrow> \<Inter>t \<noteq> {}"
 | |
| 2304 |   shows "\<Inter>\<F> \<noteq> {}"
 | |
| 72385 | 2305 | using Helly_induct assms by blast | 
| 69619 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 2306 | |
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 2307 | subsection \<open>Epigraphs of convex functions\<close> | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 2308 | |
| 70136 | 2309 | definition\<^marker>\<open>tag important\<close> "epigraph S (f :: _ \<Rightarrow> real) = {xy. fst xy \<in> S \<and> f (fst xy) \<le> snd xy}"
 | 
| 69619 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 2310 | |
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 2311 | lemma mem_epigraph: "(x, y) \<in> epigraph S f \<longleftrightarrow> x \<in> S \<and> f x \<le> y" | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 2312 | unfolding epigraph_def by auto | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 2313 | |
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 2314 | lemma convex_epigraph: "convex (epigraph S f) \<longleftrightarrow> convex_on S f \<and> convex S" | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 2315 | proof safe | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 2316 | assume L: "convex (epigraph S f)" | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 2317 | then show "convex_on S f" | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 2318 | by (auto simp: convex_def convex_on_def epigraph_def) | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 2319 | show "convex S" | 
| 72385 | 2320 | using L by (fastforce simp: convex_def convex_on_def epigraph_def) | 
| 69619 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 2321 | next | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 2322 | assume "convex_on S f" "convex S" | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 2323 | then show "convex (epigraph S f)" | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 2324 | unfolding convex_def convex_on_def epigraph_def | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 2325 | apply safe | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 2326 | apply (rule_tac [2] y="u * f a + v * f aa" in order_trans) | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 2327 | apply (auto intro!:mult_left_mono add_mono) | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 2328 | done | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 2329 | qed | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 2330 | |
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 2331 | lemma convex_epigraphI: "convex_on S f \<Longrightarrow> convex S \<Longrightarrow> convex (epigraph S f)" | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 2332 | unfolding convex_epigraph by auto | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 2333 | |
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 2334 | lemma convex_epigraph_convex: "convex S \<Longrightarrow> convex_on S f \<longleftrightarrow> convex(epigraph S f)" | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 2335 | by (simp add: convex_epigraph) | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 2336 | |
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 2337 | |
| 70136 | 2338 | subsubsection\<^marker>\<open>tag unimportant\<close> \<open>Use this to derive general bound property of convex function\<close> | 
| 69619 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 2339 | |
| 72385 | 2340 | |
| 69619 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 2341 | lemma convex_on: | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 2342 | assumes "convex S" | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 2343 | shows "convex_on S f \<longleftrightarrow> | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 2344 |     (\<forall>k u x. (\<forall>i\<in>{1..k::nat}. 0 \<le> u i \<and> x i \<in> S) \<and> sum u {1..k} = 1 \<longrightarrow>
 | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 2345 |       f (sum (\<lambda>i. u i *\<^sub>R x i) {1..k}) \<le> sum (\<lambda>i. u i * f(x i)) {1..k})"
 | 
| 72385 | 2346 | (is "?lhs = (\<forall>k u x. ?rhs k u x)") | 
| 2347 | proof | |
| 2348 | assume ?lhs | |
| 2349 |   then have \<section>: "convex {xy. fst xy \<in> S \<and> f (fst xy) \<le> snd xy}"
 | |
| 2350 | by (metis assms convex_epigraph epigraph_def) | |
| 2351 | show "\<forall>k u x. ?rhs k u x" | |
| 2352 | proof (intro allI) | |
| 2353 | fix k u x | |
| 2354 | show "?rhs k u x" | |
| 2355 | using \<section> | |
| 2356 | unfolding convex mem_Collect_eq fst_sum snd_sum | |
| 2357 | apply safe | |
| 2358 | apply (drule_tac x=k in spec) | |
| 2359 | apply (drule_tac x=u in spec) | |
| 2360 | apply (drule_tac x="\<lambda>i. (x i, f (x i))" in spec) | |
| 2361 | apply simp | |
| 2362 | done | |
| 2363 | qed | |
| 2364 | next | |
| 2365 | assume "\<forall>k u x. ?rhs k u x" | |
| 2366 | then show ?lhs | |
| 2367 | unfolding convex_epigraph_convex[OF assms] convex epigraph_def Ball_def mem_Collect_eq fst_sum snd_sum | |
| 2368 | using assms[unfolded convex] apply clarsimp | |
| 2369 | apply (rule_tac y="\<Sum>i = 1..k. u i * f (fst (x i))" in order_trans) | |
| 2370 | by (auto simp add: mult_left_mono intro: sum_mono) | |
| 2371 | qed | |
| 69619 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 2372 | |
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 2373 | |
| 70136 | 2374 | subsection\<^marker>\<open>tag unimportant\<close> \<open>A bound within a convex hull\<close> | 
| 69619 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 2375 | |
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 2376 | lemma convex_on_convex_hull_bound: | 
| 72385 | 2377 | assumes "convex_on (convex hull S) f" | 
| 2378 | and "\<forall>x\<in>S. f x \<le> b" | |
| 2379 | shows "\<forall>x\<in> convex hull S. f x \<le> b" | |
| 69619 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 2380 | proof | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 2381 | fix x | 
| 72385 | 2382 | assume "x \<in> convex hull S" | 
| 69619 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 2383 | then obtain k u v where | 
| 72385 | 2384 |     u: "\<forall>i\<in>{1..k::nat}. 0 \<le> u i \<and> v i \<in> S" "sum u {1..k} = 1" "(\<Sum>i = 1..k. u i *\<^sub>R v i) = x"
 | 
| 69619 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 2385 | unfolding convex_hull_indexed mem_Collect_eq by auto | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 2386 | have "(\<Sum>i = 1..k. u i * f (v i)) \<le> b" | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 2387 |     using sum_mono[of "{1..k}" "\<lambda>i. u i * f (v i)" "\<lambda>i. u i * b"]
 | 
| 72385 | 2388 | unfolding sum_distrib_right[symmetric] u(2) mult_1 | 
| 2389 | using assms(2) mult_left_mono u(1) by blast | |
| 69619 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 2390 | then show "f x \<le> b" | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 2391 | using assms(1)[unfolded convex_on[OF convex_convex_hull], rule_format, of k u v] | 
| 72385 | 2392 | using hull_inc u by fastforce | 
| 69619 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 2393 | qed | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 2394 | |
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 2395 | lemma convex_set_plus: | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 2396 | assumes "convex S" and "convex T" shows "convex (S + T)" | 
| 78475 | 2397 | by (metis assms convex_hull_eq convex_hull_set_plus) | 
| 69619 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 2398 | |
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 2399 | lemma convex_set_sum: | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 2400 | assumes "\<And>i. i \<in> A \<Longrightarrow> convex (B i)" | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 2401 | shows "convex (\<Sum>i\<in>A. B i)" | 
| 78475 | 2402 | using assms | 
| 2403 | by (induction A rule: infinite_finite_induct) (auto simp: convex_set_plus) | |
| 69619 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 2404 | |
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 2405 | lemma finite_set_sum: | 
| 78475 | 2406 | assumes "\<forall>i\<in>A. finite (B i)" shows "finite (\<Sum>i\<in>A. B i)" | 
| 2407 | using assms | |
| 2408 | by (induction A rule: infinite_finite_induct) (auto simp: finite_set_plus) | |
| 69619 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 2409 | |
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 2410 | lemma box_eq_set_sum_Basis: | 
| 72385 | 2411 |   "{x. \<forall>i\<in>Basis. x\<bullet>i \<in> B i} = (\<Sum>i\<in>Basis. (\<lambda>x. x *\<^sub>R i) ` (B i))" (is "?lhs = ?rhs")
 | 
| 2412 | proof - | |
| 2413 | have "\<And>x. \<forall>i\<in>Basis. x \<bullet> i \<in> B i \<Longrightarrow> | |
| 2414 | \<exists>s. x = sum s Basis \<and> (\<forall>i\<in>Basis. s i \<in> (\<lambda>x. x *\<^sub>R i) ` B i)" | |
| 2415 | by (metis (mono_tags, lifting) euclidean_representation image_iff) | |
| 2416 | moreover | |
| 2417 | have "sum f Basis \<bullet> i \<in> B i" if "i \<in> Basis" and f: "\<forall>i\<in>Basis. f i \<in> (\<lambda>x. x *\<^sub>R i) ` B i" for i f | |
| 2418 | proof - | |
| 2419 |     have "(\<Sum>x\<in>Basis - {i}. f x \<bullet> i) = 0"
 | |
| 78475 | 2420 | proof (intro strip sum.neutral) | 
| 72385 | 2421 |       show "f x \<bullet> i = 0" if "x \<in> Basis - {i}" for x
 | 
| 2422 | using that f \<open>i \<in> Basis\<close> inner_Basis that by fastforce | |
| 2423 | qed | |
| 2424 | then have "(\<Sum>x\<in>Basis. f x \<bullet> i) = f i \<bullet> i" | |
| 2425 | by (metis (no_types) \<open>i \<in> Basis\<close> add.right_neutral sum.remove [OF finite_Basis]) | |
| 2426 | then have "(\<Sum>x\<in>Basis. f x \<bullet> i) \<in> B i" | |
| 2427 | using f that(1) by auto | |
| 2428 | then show ?thesis | |
| 2429 | by (simp add: inner_sum_left) | |
| 2430 | qed | |
| 2431 | ultimately show ?thesis | |
| 2432 | by (subst set_sum_alt [OF finite_Basis]) auto | |
| 2433 | qed | |
| 69619 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 2434 | |
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 2435 | lemma convex_hull_set_sum: | 
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 2436 | "convex hull (\<Sum>i\<in>A. B i) = (\<Sum>i\<in>A. convex hull (B i))" | 
| 78475 | 2437 | by (induction A rule: infinite_finite_induct) (auto simp: convex_hull_set_plus) | 
| 69619 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 2438 | |
| 
3f7d8e05e0f2
split off Convex.thy: material that does not require Topology_Euclidean_Space
 immler parents: diff
changeset | 2439 | end |