src/HOL/Analysis/Convex_Euclidean_Space.thy
changeset 67399 eab6ce8368fa
parent 67155 9e5b05d54f9d
child 67613 ce654b0e6d69
equal deleted inserted replaced
67398:5eb932e604a2 67399:eab6ce8368fa
   122 
   122 
   123 lemma sum_not_0: "sum f A \<noteq> 0 \<Longrightarrow> \<exists>a \<in> A. f a \<noteq> 0"
   123 lemma sum_not_0: "sum f A \<noteq> 0 \<Longrightarrow> \<exists>a \<in> A. f a \<noteq> 0"
   124   by (rule ccontr) auto
   124   by (rule ccontr) auto
   125 
   125 
   126 lemma subset_translation_eq [simp]:
   126 lemma subset_translation_eq [simp]:
   127     fixes a :: "'a::real_vector" shows "op + a ` s \<subseteq> op + a ` t \<longleftrightarrow> s \<subseteq> t"
   127     fixes a :: "'a::real_vector" shows "(+) a ` s \<subseteq> (+) a ` t \<longleftrightarrow> s \<subseteq> t"
   128   by auto
   128   by auto
   129 
   129 
   130 lemma translate_inj_on:
   130 lemma translate_inj_on:
   131   fixes A :: "'a::ab_group_add set"
   131   fixes A :: "'a::ab_group_add set"
   132   shows "inj_on (\<lambda>x. a + x) A"
   132   shows "inj_on (\<lambda>x. a + x) A"
   712 
   712 
   713 lemma convex_affinity:
   713 lemma convex_affinity:
   714   assumes "convex S"
   714   assumes "convex S"
   715   shows "convex ((\<lambda>x. a + c *\<^sub>R x) ` S)"
   715   shows "convex ((\<lambda>x. a + c *\<^sub>R x) ` S)"
   716 proof -
   716 proof -
   717   have "(\<lambda>x. a + c *\<^sub>R x) ` S = op + a ` op *\<^sub>R c ` S"
   717   have "(\<lambda>x. a + c *\<^sub>R x) ` S = (+) a ` ( *\<^sub>R) c ` S"
   718     by auto
   718     by auto
   719   then show ?thesis
   719   then show ?thesis
   720     using convex_translation[OF convex_scaling[OF assms], of a c] by auto
   720     using convex_translation[OF convex_scaling[OF assms], of a c] by auto
   721 qed
   721 qed
   722 
   722 
  1328   apply (rule closure_minimal, simp add: closure_subset image_mono)
  1328   apply (rule closure_minimal, simp add: closure_subset image_mono)
  1329   by (meson bounded_closure closed_closure compact_continuous_image compact_eq_bounded_closed linear_continuous_on linear_conv_bounded_linear)
  1329   by (meson bounded_closure closed_closure compact_continuous_image compact_eq_bounded_closed linear_continuous_on linear_conv_bounded_linear)
  1330 
  1330 
  1331 lemma closure_scaleR:
  1331 lemma closure_scaleR:
  1332   fixes S :: "'a::real_normed_vector set"
  1332   fixes S :: "'a::real_normed_vector set"
  1333   shows "(op *\<^sub>R c) ` (closure S) = closure ((op *\<^sub>R c) ` S)"
  1333   shows "(( *\<^sub>R) c) ` (closure S) = closure ((( *\<^sub>R) c) ` S)"
  1334 proof
  1334 proof
  1335   show "(op *\<^sub>R c) ` (closure S) \<subseteq> closure ((op *\<^sub>R c) ` S)"
  1335   show "(( *\<^sub>R) c) ` (closure S) \<subseteq> closure ((( *\<^sub>R) c) ` S)"
  1336     using bounded_linear_scaleR_right
  1336     using bounded_linear_scaleR_right
  1337     by (rule closure_bounded_linear_image_subset)
  1337     by (rule closure_bounded_linear_image_subset)
  1338   show "closure ((op *\<^sub>R c) ` S) \<subseteq> (op *\<^sub>R c) ` (closure S)"
  1338   show "closure ((( *\<^sub>R) c) ` S) \<subseteq> (( *\<^sub>R) c) ` (closure S)"
  1339     by (intro closure_minimal image_mono closure_subset closed_scaling closed_closure)
  1339     by (intro closure_minimal image_mono closure_subset closed_scaling closed_closure)
  1340 qed
  1340 qed
  1341 
  1341 
  1342 lemma fst_linear: "linear fst"
  1342 lemma fst_linear: "linear fst"
  1343   unfolding linear_iff by (simp add: algebra_simps)
  1343   unfolding linear_iff by (simp add: algebra_simps)
  2152 lemma cone_Union[intro]: "(\<forall>s\<in>f. cone s) \<longrightarrow> cone (\<Union>f)"
  2152 lemma cone_Union[intro]: "(\<forall>s\<in>f. cone s) \<longrightarrow> cone (\<Union>f)"
  2153   unfolding cone_def by blast
  2153   unfolding cone_def by blast
  2154 
  2154 
  2155 lemma cone_iff:
  2155 lemma cone_iff:
  2156   assumes "S \<noteq> {}"
  2156   assumes "S \<noteq> {}"
  2157   shows "cone S \<longleftrightarrow> 0 \<in> S \<and> (\<forall>c. c > 0 \<longrightarrow> (op *\<^sub>R c) ` S = S)"
  2157   shows "cone S \<longleftrightarrow> 0 \<in> S \<and> (\<forall>c. c > 0 \<longrightarrow> (( *\<^sub>R) c) ` S = S)"
  2158 proof -
  2158 proof -
  2159   {
  2159   {
  2160     assume "cone S"
  2160     assume "cone S"
  2161     {
  2161     {
  2162       fix c :: real
  2162       fix c :: real
  2163       assume "c > 0"
  2163       assume "c > 0"
  2164       {
  2164       {
  2165         fix x
  2165         fix x
  2166         assume "x \<in> S"
  2166         assume "x \<in> S"
  2167         then have "x \<in> (op *\<^sub>R c) ` S"
  2167         then have "x \<in> (( *\<^sub>R) c) ` S"
  2168           unfolding image_def
  2168           unfolding image_def
  2169           using \<open>cone S\<close> \<open>c>0\<close> mem_cone[of S x "1/c"]
  2169           using \<open>cone S\<close> \<open>c>0\<close> mem_cone[of S x "1/c"]
  2170             exI[of "(\<lambda>t. t \<in> S \<and> x = c *\<^sub>R t)" "(1 / c) *\<^sub>R x"]
  2170             exI[of "(\<lambda>t. t \<in> S \<and> x = c *\<^sub>R t)" "(1 / c) *\<^sub>R x"]
  2171           by auto
  2171           by auto
  2172       }
  2172       }
  2173       moreover
  2173       moreover
  2174       {
  2174       {
  2175         fix x
  2175         fix x
  2176         assume "x \<in> (op *\<^sub>R c) ` S"
  2176         assume "x \<in> (( *\<^sub>R) c) ` S"
  2177         then have "x \<in> S"
  2177         then have "x \<in> S"
  2178           using \<open>cone S\<close> \<open>c > 0\<close>
  2178           using \<open>cone S\<close> \<open>c > 0\<close>
  2179           unfolding cone_def image_def \<open>c > 0\<close> by auto
  2179           unfolding cone_def image_def \<open>c > 0\<close> by auto
  2180       }
  2180       }
  2181       ultimately have "(op *\<^sub>R c) ` S = S" by auto
  2181       ultimately have "(( *\<^sub>R) c) ` S = S" by auto
  2182     }
  2182     }
  2183     then have "0 \<in> S \<and> (\<forall>c. c > 0 \<longrightarrow> (op *\<^sub>R c) ` S = S)"
  2183     then have "0 \<in> S \<and> (\<forall>c. c > 0 \<longrightarrow> (( *\<^sub>R) c) ` S = S)"
  2184       using \<open>cone S\<close> cone_contains_0[of S] assms by auto
  2184       using \<open>cone S\<close> cone_contains_0[of S] assms by auto
  2185   }
  2185   }
  2186   moreover
  2186   moreover
  2187   {
  2187   {
  2188     assume a: "0 \<in> S \<and> (\<forall>c. c > 0 \<longrightarrow> (op *\<^sub>R c) ` S = S)"
  2188     assume a: "0 \<in> S \<and> (\<forall>c. c > 0 \<longrightarrow> (( *\<^sub>R) c) ` S = S)"
  2189     {
  2189     {
  2190       fix x
  2190       fix x
  2191       assume "x \<in> S"
  2191       assume "x \<in> S"
  2192       fix c1 :: real
  2192       fix c1 :: real
  2193       assume "c1 \<ge> 0"
  2193       assume "c1 \<ge> 0"
  2269 proof (cases "S = {}")
  2269 proof (cases "S = {}")
  2270   case True
  2270   case True
  2271   then show ?thesis by auto
  2271   then show ?thesis by auto
  2272 next
  2272 next
  2273   case False
  2273   case False
  2274   then have "0 \<in> S \<and> (\<forall>c. c > 0 \<longrightarrow> op *\<^sub>R c ` S = S)"
  2274   then have "0 \<in> S \<and> (\<forall>c. c > 0 \<longrightarrow> ( *\<^sub>R) c ` S = S)"
  2275     using cone_iff[of S] assms by auto
  2275     using cone_iff[of S] assms by auto
  2276   then have "0 \<in> closure S \<and> (\<forall>c. c > 0 \<longrightarrow> op *\<^sub>R c ` closure S = closure S)"
  2276   then have "0 \<in> closure S \<and> (\<forall>c. c > 0 \<longrightarrow> ( *\<^sub>R) c ` closure S = closure S)"
  2277     using closure_subset by (auto simp add: closure_scaleR)
  2277     using closure_subset by (auto simp add: closure_scaleR)
  2278   then show ?thesis
  2278   then show ?thesis
  2279     using False cone_iff[of "closure S"] by auto
  2279     using False cone_iff[of "closure S"] by auto
  2280 qed
  2280 qed
  2281 
  2281 
  3342   assumes "affine_dependent S"
  3342   assumes "affine_dependent S"
  3343   shows "affine_dependent ((\<lambda>x. a + x) ` S)"
  3343   shows "affine_dependent ((\<lambda>x. a + x) ` S)"
  3344 proof -
  3344 proof -
  3345   obtain x where x: "x \<in> S \<and> x \<in> affine hull (S - {x})"
  3345   obtain x where x: "x \<in> S \<and> x \<in> affine hull (S - {x})"
  3346     using assms affine_dependent_def by auto
  3346     using assms affine_dependent_def by auto
  3347   have "op + a ` (S - {x}) = op + a ` S - {a + x}"
  3347   have "(+) a ` (S - {x}) = (+) a ` S - {a + x}"
  3348     by auto
  3348     by auto
  3349   then have "a + x \<in> affine hull ((\<lambda>x. a + x) ` S - {a + x})"
  3349   then have "a + x \<in> affine hull ((\<lambda>x. a + x) ` S - {a + x})"
  3350     using affine_hull_translation[of a "S - {x}"] x by auto
  3350     using affine_hull_translation[of a "S - {x}"] x by auto
  3351   moreover have "a + x \<in> (\<lambda>x. a + x) ` S"
  3351   moreover have "a + x \<in> (\<lambda>x. a + x) ` S"
  3352     using x by auto
  3352     using x by auto
  3407 
  3407 
  3408 lemma affine_dependent_iff_dependent:
  3408 lemma affine_dependent_iff_dependent:
  3409   assumes "a \<notin> S"
  3409   assumes "a \<notin> S"
  3410   shows "affine_dependent (insert a S) \<longleftrightarrow> dependent ((\<lambda>x. -a + x) ` S)"
  3410   shows "affine_dependent (insert a S) \<longleftrightarrow> dependent ((\<lambda>x. -a + x) ` S)"
  3411 proof -
  3411 proof -
  3412   have "(op + (- a) ` S) = {x - a| x . x : S}" by auto
  3412   have "((+) (- a) ` S) = {x - a| x . x : S}" by auto
  3413   then show ?thesis
  3413   then show ?thesis
  3414     using affine_dependent_translation_eq[of "(insert a S)" "-a"]
  3414     using affine_dependent_translation_eq[of "(insert a S)" "-a"]
  3415       affine_dependent_imp_dependent2 assms
  3415       affine_dependent_imp_dependent2 assms
  3416       dependent_imp_affine_dependent[of a S]
  3416       dependent_imp_affine_dependent[of a S]
  3417     by (auto simp del: uminus_add_conv_diff)
  3417     by (auto simp del: uminus_add_conv_diff)
  3446       apply auto
  3446       apply auto
  3447       done
  3447       done
  3448     then have "insert 0 ((\<lambda>x. -a+x) ` (s - {a})) = (\<lambda>x. -a+x) ` s"
  3448     then have "insert 0 ((\<lambda>x. -a+x) ` (s - {a})) = (\<lambda>x. -a+x) ` s"
  3449       by auto
  3449       by auto
  3450     then have "span ((\<lambda>x. -a+x) ` (s - {a}))=span ((\<lambda>x. -a+x) ` s)"
  3450     then have "span ((\<lambda>x. -a+x) ` (s - {a}))=span ((\<lambda>x. -a+x) ` s)"
  3451       using span_insert_0[of "op + (- a) ` (s - {a})"] by (auto simp del: uminus_add_conv_diff)
  3451       using span_insert_0[of "(+) (- a) ` (s - {a})"] by (auto simp del: uminus_add_conv_diff)
  3452     moreover have "{x - a |x. x \<in> (s - {a})} = ((\<lambda>x. -a+x) ` (s - {a}))"
  3452     moreover have "{x - a |x. x \<in> (s - {a})} = ((\<lambda>x. -a+x) ` (s - {a}))"
  3453       by auto
  3453       by auto
  3454     moreover have "insert a (s - {a}) = insert a s"
  3454     moreover have "insert a (s - {a}) = insert a s"
  3455       by auto
  3455       by auto
  3456     ultimately have ?thesis
  3456     ultimately have ?thesis
  4022     using that by blast
  4022     using that by blast
  4023 next
  4023 next
  4024   case False
  4024   case False
  4025   then obtain c S' where "c \<notin> S'" "S = insert c S'"
  4025   then obtain c S' where "c \<notin> S'" "S = insert c S'"
  4026     by (meson equals0I mk_disjoint_insert)
  4026     by (meson equals0I mk_disjoint_insert)
  4027   have "dim (op + (-c) ` S) < DIM('a)"
  4027   have "dim ((+) (-c) ` S) < DIM('a)"
  4028     by (metis \<open>S = insert c S'\<close> aff_dim_eq_dim assms hull_inc insertI1 of_nat_less_imp_less)
  4028     by (metis \<open>S = insert c S'\<close> aff_dim_eq_dim assms hull_inc insertI1 of_nat_less_imp_less)
  4029   then obtain a where "a \<noteq> 0" "span (op + (-c) ` S) \<subseteq> {x. a \<bullet> x = 0}"
  4029   then obtain a where "a \<noteq> 0" "span ((+) (-c) ` S) \<subseteq> {x. a \<bullet> x = 0}"
  4030     using lowdim_subset_hyperplane by blast
  4030     using lowdim_subset_hyperplane by blast
  4031   moreover
  4031   moreover
  4032   have "a \<bullet> w = a \<bullet> c" if "span (op + (- c) ` S) \<subseteq> {x. a \<bullet> x = 0}" "w \<in> S" for w
  4032   have "a \<bullet> w = a \<bullet> c" if "span ((+) (- c) ` S) \<subseteq> {x. a \<bullet> x = 0}" "w \<in> S" for w
  4033   proof -
  4033   proof -
  4034     have "w-c \<in> span (op + (- c) ` S)"
  4034     have "w-c \<in> span ((+) (- c) ` S)"
  4035       by (simp add: span_superset \<open>w \<in> S\<close>)
  4035       by (simp add: span_superset \<open>w \<in> S\<close>)
  4036     with that have "w-c \<in> {x. a \<bullet> x = 0}"
  4036     with that have "w-c \<in> {x. a \<bullet> x = 0}"
  4037       by blast
  4037       by blast
  4038     then show ?thesis
  4038     then show ?thesis
  4039       by (auto simp: algebra_simps)
  4039       by (auto simp: algebra_simps)
  4233 proof -
  4233 proof -
  4234   have "(\<lambda>x. a + x) ` (cball 0 e) \<subseteq> cball a e"
  4234   have "(\<lambda>x. a + x) ` (cball 0 e) \<subseteq> cball a e"
  4235     unfolding cball_def dist_norm by auto
  4235     unfolding cball_def dist_norm by auto
  4236   then have "aff_dim (cball (0 :: 'n::euclidean_space) e) \<le> aff_dim (cball a e)"
  4236   then have "aff_dim (cball (0 :: 'n::euclidean_space) e) \<le> aff_dim (cball a e)"
  4237     using aff_dim_translation_eq[of a "cball 0 e"]
  4237     using aff_dim_translation_eq[of a "cball 0 e"]
  4238           aff_dim_subset[of "op + a ` cball 0 e" "cball a e"]
  4238           aff_dim_subset[of "(+) a ` cball 0 e" "cball a e"]
  4239     by auto
  4239     by auto
  4240   moreover have "aff_dim (cball (0 :: 'n::euclidean_space) e) = int (DIM('n))"
  4240   moreover have "aff_dim (cball (0 :: 'n::euclidean_space) e) = int (DIM('n))"
  4241     using hull_inc[of "(0 :: 'n::euclidean_space)" "cball 0 e"]
  4241     using hull_inc[of "(0 :: 'n::euclidean_space)" "cball 0 e"]
  4242       centre_in_cball[of "(0 :: 'n::euclidean_space)"] assms
  4242       centre_in_cball[of "(0 :: 'n::euclidean_space)"] assms
  4243     by (simp add: dim_cball[of e] aff_dim_zero[of "cball 0 e"])
  4243     by (simp add: dim_cball[of e] aff_dim_zero[of "cball 0 e"])
  4803 proof -
  4803 proof -
  4804   {
  4804   {
  4805     assume "S \<noteq> {}"
  4805     assume "S \<noteq> {}"
  4806     then obtain L where L: "subspace L" "affine_parallel S L"
  4806     then obtain L where L: "subspace L" "affine_parallel S L"
  4807       using assms affine_parallel_subspace[of S] by auto
  4807       using assms affine_parallel_subspace[of S] by auto
  4808     then obtain a where a: "S = (op + a ` L)"
  4808     then obtain a where a: "S = ((+) a ` L)"
  4809       using affine_parallel_def[of L S] affine_parallel_commut by auto
  4809       using affine_parallel_def[of L S] affine_parallel_commut by auto
  4810     from L have "closed L" using closed_subspace by auto
  4810     from L have "closed L" using closed_subspace by auto
  4811     then have "closed S"
  4811     then have "closed S"
  4812       using closed_translation a by auto
  4812       using closed_translation a by auto
  4813   }
  4813   }
  4998   have "(\<lambda>x. (-a) + x) ` rel_interior ((\<lambda>x. a + x) ` S) \<subseteq> rel_interior S"
  4998   have "(\<lambda>x. (-a) + x) ` rel_interior ((\<lambda>x. a + x) ` S) \<subseteq> rel_interior S"
  4999     using rel_interior_translation_aux[of "-a" "(\<lambda>x. a + x) ` S"]
  4999     using rel_interior_translation_aux[of "-a" "(\<lambda>x. a + x) ` S"]
  5000       translation_assoc[of "-a" "a"]
  5000       translation_assoc[of "-a" "a"]
  5001     by auto
  5001     by auto
  5002   then have "((\<lambda>x. a + x) ` rel_interior S) \<supseteq> rel_interior ((\<lambda>x. a + x) ` S)"
  5002   then have "((\<lambda>x. a + x) ` rel_interior S) \<supseteq> rel_interior ((\<lambda>x. a + x) ` S)"
  5003     using translation_inverse_subset[of a "rel_interior (op + a ` S)" "rel_interior S"]
  5003     using translation_inverse_subset[of a "rel_interior ((+) a ` S)" "rel_interior S"]
  5004     by auto
  5004     by auto
  5005   then show ?thesis
  5005   then show ?thesis
  5006     using rel_interior_translation_aux[of a S] by auto
  5006     using rel_interior_translation_aux[of a S] by auto
  5007 qed
  5007 qed
  5008 
  5008 
  5139 lemma affine_hull_substd_basis:
  5139 lemma affine_hull_substd_basis:
  5140   assumes "d \<subseteq> Basis"
  5140   assumes "d \<subseteq> Basis"
  5141   shows "affine hull (insert 0 d) = {x::'a::euclidean_space. \<forall>i\<in>Basis. i \<notin> d \<longrightarrow> x\<bullet>i = 0}"
  5141   shows "affine hull (insert 0 d) = {x::'a::euclidean_space. \<forall>i\<in>Basis. i \<notin> d \<longrightarrow> x\<bullet>i = 0}"
  5142   (is "affine hull (insert 0 ?A) = ?B")
  5142   (is "affine hull (insert 0 ?A) = ?B")
  5143 proof -
  5143 proof -
  5144   have *: "\<And>A. op + (0::'a) ` A = A" "\<And>A. op + (- (0::'a)) ` A = A"
  5144   have *: "\<And>A. (+) (0::'a) ` A = A" "\<And>A. (+) (- (0::'a)) ` A = A"
  5145     by auto
  5145     by auto
  5146   show ?thesis
  5146   show ?thesis
  5147     unfolding affine_hull_insert_span_gen span_substd_basis[OF assms,symmetric] * ..
  5147     unfolding affine_hull_insert_span_gen span_substd_basis[OF assms,symmetric] * ..
  5148 qed
  5148 qed
  5149 
  5149 
  5980     fix x assume "x \<in> T"
  5980     fix x assume "x \<in> T"
  5981     then have "inner a x - b / 2 < k"
  5981     then have "inner a x - b / 2 < k"
  5982       unfolding k_def
  5982       unfolding k_def
  5983     proof (subst less_cSUP_iff)
  5983     proof (subst less_cSUP_iff)
  5984       show "T \<noteq> {}" by fact
  5984       show "T \<noteq> {}" by fact
  5985       show "bdd_above (op \<bullet> a ` T)"
  5985       show "bdd_above ((\<bullet>) a ` T)"
  5986         using ab[rule_format, of y] \<open>y \<in> S\<close>
  5986         using ab[rule_format, of y] \<open>y \<in> S\<close>
  5987         by (intro bdd_aboveI2[where M="inner a y - b"]) (auto simp: field_simps intro: less_imp_le)
  5987         by (intro bdd_aboveI2[where M="inner a y - b"]) (auto simp: field_simps intro: less_imp_le)
  5988     qed (auto intro!: bexI[of _ x] \<open>0<b\<close>)
  5988     qed (auto intro!: bexI[of _ x] \<open>0<b\<close>)
  5989     then show "inner a x < k + b / 2"
  5989     then show "inner a x < k + b / 2"
  5990       by auto
  5990       by auto
  6071   from separating_hyperplane_set_0[OF convex_differences[OF assms(2,1)]]
  6071   from separating_hyperplane_set_0[OF convex_differences[OF assms(2,1)]]
  6072   obtain a where "a \<noteq> 0" "\<forall>x\<in>{x - y |x y. x \<in> t \<and> y \<in> s}. 0 \<le> inner a x"
  6072   obtain a where "a \<noteq> 0" "\<forall>x\<in>{x - y |x y. x \<in> t \<and> y \<in> s}. 0 \<le> inner a x"
  6073     using assms(3-5) by fastforce
  6073     using assms(3-5) by fastforce
  6074   then have *: "\<And>x y. x \<in> t \<Longrightarrow> y \<in> s \<Longrightarrow> inner a y \<le> inner a x"
  6074   then have *: "\<And>x y. x \<in> t \<Longrightarrow> y \<in> s \<Longrightarrow> inner a y \<le> inner a x"
  6075     by (force simp add: inner_diff)
  6075     by (force simp add: inner_diff)
  6076   then have bdd: "bdd_above ((op \<bullet> a)`s)"
  6076   then have bdd: "bdd_above (((\<bullet>) a)`s)"
  6077     using \<open>t \<noteq> {}\<close> by (auto intro: bdd_aboveI2[OF *])
  6077     using \<open>t \<noteq> {}\<close> by (auto intro: bdd_aboveI2[OF *])
  6078   show ?thesis
  6078   show ?thesis
  6079     using \<open>a\<noteq>0\<close>
  6079     using \<open>a\<noteq>0\<close>
  6080     by (intro exI[of _ a] exI[of _ "SUP x:s. a \<bullet> x"])
  6080     by (intro exI[of _ a] exI[of _ "SUP x:s. a \<bullet> x"])
  6081        (auto intro!: cSUP_upper bdd cSUP_least \<open>a \<noteq> 0\<close> \<open>s \<noteq> {}\<close> *)
  6081        (auto intro!: cSUP_upper bdd cSUP_least \<open>a \<noteq> 0\<close> \<open>s \<noteq> {}\<close> *)
  6207 proof (cases "S = {}")
  6207 proof (cases "S = {}")
  6208   case True
  6208   case True
  6209   then show ?thesis by auto
  6209   then show ?thesis by auto
  6210 next
  6210 next
  6211   case False
  6211   case False
  6212   then have *: "0 \<in> S \<and> (\<forall>c. c > 0 \<longrightarrow> op *\<^sub>R c ` S = S)"
  6212   then have *: "0 \<in> S \<and> (\<forall>c. c > 0 \<longrightarrow> ( *\<^sub>R) c ` S = S)"
  6213     using cone_iff[of S] assms by auto
  6213     using cone_iff[of S] assms by auto
  6214   {
  6214   {
  6215     fix c :: real
  6215     fix c :: real
  6216     assume "c > 0"
  6216     assume "c > 0"
  6217     then have "op *\<^sub>R c ` (convex hull S) = convex hull (op *\<^sub>R c ` S)"
  6217     then have "( *\<^sub>R) c ` (convex hull S) = convex hull (( *\<^sub>R) c ` S)"
  6218       using convex_hull_scaling[of _ S] by auto
  6218       using convex_hull_scaling[of _ S] by auto
  6219     also have "\<dots> = convex hull S"
  6219     also have "\<dots> = convex hull S"
  6220       using * \<open>c > 0\<close> by auto
  6220       using * \<open>c > 0\<close> by auto
  6221     finally have "op *\<^sub>R c ` (convex hull S) = convex hull S"
  6221     finally have "( *\<^sub>R) c ` (convex hull S) = convex hull S"
  6222       by auto
  6222       by auto
  6223   }
  6223   }
  6224   then have "0 \<in> convex hull S" "\<And>c. c > 0 \<Longrightarrow> (op *\<^sub>R c ` (convex hull S)) = (convex hull S)"
  6224   then have "0 \<in> convex hull S" "\<And>c. c > 0 \<Longrightarrow> (( *\<^sub>R) c ` (convex hull S)) = (convex hull S)"
  6225     using * hull_subset[of S convex] by auto
  6225     using * hull_subset[of S convex] by auto
  6226   then show ?thesis
  6226   then show ?thesis
  6227     using \<open>S \<noteq> {}\<close> cone_iff[of "convex hull S"] by auto
  6227     using \<open>S \<noteq> {}\<close> cone_iff[of "convex hull S"] by auto
  6228 qed
  6228 qed
  6229 
  6229 
  7028 
  7028 
  7029 lemma cbox_image_unit_interval:
  7029 lemma cbox_image_unit_interval:
  7030   fixes a :: "'a::euclidean_space"
  7030   fixes a :: "'a::euclidean_space"
  7031   assumes "cbox a b \<noteq> {}"
  7031   assumes "cbox a b \<noteq> {}"
  7032     shows "cbox a b =
  7032     shows "cbox a b =
  7033            op + a ` (\<lambda>x. \<Sum>k\<in>Basis. ((b \<bullet> k - a \<bullet> k) * (x \<bullet> k)) *\<^sub>R k) ` cbox 0 One"
  7033            (+) a ` (\<lambda>x. \<Sum>k\<in>Basis. ((b \<bullet> k - a \<bullet> k) * (x \<bullet> k)) *\<^sub>R k) ` cbox 0 One"
  7034 using assms
  7034 using assms
  7035 apply (simp add: box_ne_empty image_stretch_interval cbox_translation [symmetric])
  7035 apply (simp add: box_ne_empty image_stretch_interval cbox_translation [symmetric])
  7036 apply (simp add: min_def max_def algebra_simps sum_subtractf euclidean_representation)
  7036 apply (simp add: min_def max_def algebra_simps sum_subtractf euclidean_representation)
  7037 done
  7037 done
  7038 
  7038 
  7046   case False
  7046   case False
  7047   obtain s::"'a set" where "finite s" and eq: "cbox 0 One = convex hull s"
  7047   obtain s::"'a set" where "finite s" and eq: "cbox 0 One = convex hull s"
  7048     by (blast intro: unit_cube_convex_hull)
  7048     by (blast intro: unit_cube_convex_hull)
  7049   have lin: "linear (\<lambda>x. \<Sum>k\<in>Basis. ((b \<bullet> k - a \<bullet> k) * (x \<bullet> k)) *\<^sub>R k)"
  7049   have lin: "linear (\<lambda>x. \<Sum>k\<in>Basis. ((b \<bullet> k - a \<bullet> k) * (x \<bullet> k)) *\<^sub>R k)"
  7050     by (rule linear_compose_sum) (auto simp: algebra_simps linearI)
  7050     by (rule linear_compose_sum) (auto simp: algebra_simps linearI)
  7051   have "finite (op + a ` (\<lambda>x. \<Sum>k\<in>Basis. ((b \<bullet> k - a \<bullet> k) * (x \<bullet> k)) *\<^sub>R k) ` s)"
  7051   have "finite ((+) a ` (\<lambda>x. \<Sum>k\<in>Basis. ((b \<bullet> k - a \<bullet> k) * (x \<bullet> k)) *\<^sub>R k) ` s)"
  7052     by (rule finite_imageI \<open>finite s\<close>)+
  7052     by (rule finite_imageI \<open>finite s\<close>)+
  7053   then show ?thesis
  7053   then show ?thesis
  7054     apply (rule that)
  7054     apply (rule that)
  7055     apply (simp add: convex_hull_translation convex_hull_linear_image [OF lin, symmetric])
  7055     apply (simp add: convex_hull_translation convex_hull_linear_image [OF lin, symmetric])
  7056     apply (simp add: eq [symmetric] cbox_image_unit_interval [OF False])
  7056     apply (simp add: eq [symmetric] cbox_image_unit_interval [OF False])