diff -r 0d065af1a99c -r 4da1e18a9633 src/HOL/Analysis/Convex.thy --- a/src/HOL/Analysis/Convex.thy Sat Sep 09 17:18:52 2023 +0100 +++ b/src/HOL/Analysis/Convex.thy Sat Sep 09 19:26:08 2023 +0100 @@ -1773,6 +1773,368 @@ shows "cone (convex hull S)" by (metis (no_types, lifting) affine_hull_convex_hull affine_hull_eq_empty assms cone_iff convex_hull_scaling hull_inc) +section \Conic sets and conic hull\ + +definition conic :: "'a::real_vector set \ bool" + where "conic S \ \x c. x \ S \ 0 \ c \ (c *\<^sub>R x) \ S" + +lemma conicD: "\conic S; x \ S; 0 \ c\ \ (c *\<^sub>R x) \ S" + by (meson conic_def) + +lemma subspace_imp_conic: "subspace S \ conic S" + by (simp add: conic_def subspace_def) + +lemma conic_empty [simp]: "conic {}" + using conic_def by blast + +lemma conic_UNIV: "conic UNIV" + by (simp add: conic_def) + +lemma conic_Inter: "(\S. S \ \ \ conic S) \ conic(\\)" + by (simp add: conic_def) + +lemma conic_linear_image: + "\conic S; linear f\ \ conic(f ` S)" + by (smt (verit) conic_def image_iff linear.scaleR) + +lemma conic_linear_image_eq: + "\linear f; inj f\ \ conic (f ` S) \ conic S" + by (smt (verit) conic_def conic_linear_image inj_image_mem_iff linear_cmul) + +lemma conic_mul: "\conic S; x \ S; 0 \ c\ \ (c *\<^sub>R x) \ S" + using conic_def by blast + +lemma conic_conic_hull: "conic(conic hull S)" + by (metis (no_types, lifting) conic_Inter hull_def mem_Collect_eq) + +lemma conic_hull_eq: "(conic hull S = S) \ conic S" + by (metis conic_conic_hull hull_same) + +lemma conic_hull_UNIV [simp]: "conic hull UNIV = UNIV" + by simp + +lemma conic_negations: "conic S \ conic (image uminus S)" + by (auto simp: conic_def image_iff) + +lemma conic_span [iff]: "conic(span S)" + by (simp add: subspace_imp_conic) + +lemma conic_hull_explicit: + "conic hull S = {c *\<^sub>R x| c x. 0 \ c \ x \ S}" + proof (rule hull_unique) + show "S \ {c *\<^sub>R x |c x. 0 \ c \ x \ S}" + by (metis (no_types) cone_hull_expl hull_subset) + show "conic {c *\<^sub>R x |c x. 0 \ c \ x \ S}" + using mult_nonneg_nonneg by (force simp: conic_def) +qed (auto simp: conic_def) + +lemma conic_hull_as_image: + "conic hull S = (\z. fst z *\<^sub>R snd z) ` ({0..} \ S)" + by (force simp: conic_hull_explicit) + +lemma conic_hull_linear_image: + "linear f \ conic hull f ` S = f ` (conic hull S)" + by (force simp: conic_hull_explicit image_iff set_eq_iff linear_scale) + +lemma conic_hull_image_scale: + assumes "\x. x \ S \ 0 < c x" + shows "conic hull (\x. c x *\<^sub>R x) ` S = conic hull S" +proof + show "conic hull (\x. c x *\<^sub>R x) ` S \ conic hull S" + proof (rule hull_minimal) + show "(\x. c x *\<^sub>R x) ` S \ conic hull S" + using assms conic_hull_explicit by fastforce + qed (simp add: conic_conic_hull) + show "conic hull S \ conic hull (\x. c x *\<^sub>R x) ` S" + proof (rule hull_minimal) + show "S \ conic hull (\x. c x *\<^sub>R x) ` S" + proof clarsimp + fix x + assume "x \ S" + then have "x = inverse(c x) *\<^sub>R c x *\<^sub>R x" + using assms by fastforce + then show "x \ conic hull (\x. c x *\<^sub>R x) ` S" + by (smt (verit, best) \x \ S\ assms conic_conic_hull conic_mul hull_inc image_eqI inverse_nonpositive_iff_nonpositive) + qed + qed (simp add: conic_conic_hull) +qed + +lemma convex_conic_hull: + assumes "convex S" + shows "convex (conic hull S)" +proof (clarsimp simp add: conic_hull_explicit convex_alt) + fix c x d y and u :: real + assume \
: "(0::real) \ c" "x \ S" "(0::real) \ d" "y \ S" "0 \ u" "u \ 1" + show "\c'' x''. ((1 - u) * c) *\<^sub>R x + (u * d) *\<^sub>R y = c'' *\<^sub>R x'' \ 0 \ c'' \ x'' \ S" + proof (cases "(1 - u) * c = 0") + case True + with \0 \ d\ \y \ S\\0 \ u\ + show ?thesis by force + next + case False + define \ where "\ \ (1 - u) * c + u * d" + have *: "c * u \ c" + by (simp add: "\
" mult_left_le) + have "\ > 0" + using False \
by (smt (verit, best) \_def split_mult_pos_le) + then have **: "c + d * u = \ + c * u" + by (simp add: \_def mult.commute right_diff_distrib') + show ?thesis + proof (intro exI conjI) + show "0 \ \" + using \0 < \\ by auto + show "((1 - u) * c) *\<^sub>R x + (u * d) *\<^sub>R y = \ *\<^sub>R (((1 - u) * c / \) *\<^sub>R x + (u * d / \) *\<^sub>R y)" + using \\ > 0\ by (simp add: algebra_simps diff_divide_distrib) + show "((1 - u) * c / \) *\<^sub>R x + (u * d / \) *\<^sub>R y \ S" + using \0 < \\ + by (intro convexD [OF assms]) (auto simp: \
field_split_simps * **) + qed + qed +qed + +lemma conic_halfspace_le: "conic {x. a \ x \ 0}" + by (auto simp: conic_def mult_le_0_iff) + +lemma conic_halfspace_ge: "conic {x. a \ x \ 0}" + by (auto simp: conic_def mult_le_0_iff) + +lemma conic_hull_empty [simp]: "conic hull {} = {}" + by (simp add: conic_hull_eq) + +lemma conic_contains_0: "conic S \ (0 \ S \ S \ {})" + by (simp add: Convex.cone_def cone_contains_0 conic_def) + +lemma conic_hull_eq_empty: "conic hull S = {} \ (S = {})" + using conic_hull_explicit by fastforce + +lemma conic_sums: "\conic S; conic T\ \ conic (\x\ S. \y \ T. {x + y})" + by (simp add: conic_def) (metis scaleR_right_distrib) + +lemma conic_Times: "\conic S; conic T\ \ conic(S \ T)" + by (auto simp: conic_def) + +lemma conic_Times_eq: + "conic(S \ T) \ S = {} \ T = {} \ conic S \ conic T" (is "?lhs = ?rhs") +proof + show "?lhs \ ?rhs" + by (force simp: conic_def) + show "?rhs \ ?lhs" + by (force simp: conic_Times) +qed + +lemma conic_hull_0 [simp]: "conic hull {0} = {0}" + by (simp add: conic_hull_eq subspace_imp_conic) + +lemma conic_hull_contains_0 [simp]: "0 \ conic hull S \ (S \ {})" + by (simp add: conic_conic_hull conic_contains_0 conic_hull_eq_empty) + +lemma conic_hull_eq_sing: + "conic hull S = {x} \ S = {0} \ x = 0" +proof + show "conic hull S = {x} \ S = {0} \ x = 0" + by (metis conic_conic_hull conic_contains_0 conic_def conic_hull_eq hull_inc insert_not_empty singleton_iff) +qed simp + +lemma conic_hull_Int_affine_hull: + assumes "T \ S" "0 \ affine hull S" + shows "(conic hull T) \ (affine hull S) = T" +proof - + have TaffS: "T \ affine hull S" + using \T \ S\ hull_subset by fastforce + moreover + have "conic hull T \ affine hull S \ T" + proof (clarsimp simp: conic_hull_explicit) + fix c x + assume "c *\<^sub>R x \ affine hull S" + and "0 \ c" + and "x \ T" + show "c *\<^sub>R x \ T" + proof (cases "c=1") + case True + then show ?thesis + by (simp add: \x \ T\) + next + case False + then have "x /\<^sub>R (1 - c) = x + (c * inverse (1 - c)) *\<^sub>R x" + by (smt (verit, ccfv_SIG) diff_add_cancel mult.commute real_vector_affinity_eq scaleR_collapse scaleR_scaleR) + then have "0 = inverse(1 - c) *\<^sub>R c *\<^sub>R x + (1 - inverse(1 - c)) *\<^sub>R x" + by (simp add: algebra_simps) + then have "0 \ affine hull S" + by (smt (verit) \c *\<^sub>R x \ affine hull S\ \x \ T\ affine_affine_hull TaffS in_mono mem_affine) + then show ?thesis + using assms by auto + qed + qed + ultimately show ?thesis + by (auto simp: hull_inc) +qed + + +section \Convex cones and corresponding hulls\ + +definition convex_cone :: "'a::real_vector set \ bool" + where "convex_cone \ \S. S \ {} \ convex S \ conic S" + +lemma convex_cone_iff: + "convex_cone S \ + 0 \ S \ (\x \ S. \y \ S. x + y \ S) \ (\x \ S. \c\0. c *\<^sub>R x \ S)" + by (metis cone_def conic_contains_0 conic_def convex_cone convex_cone_def) + +lemma convex_cone_add: "\convex_cone S; x \ S; y \ S\ \ x+y \ S" + by (simp add: convex_cone_iff) + +lemma convex_cone_scaleR: "\convex_cone S; 0 \ c; x \ S\ \ c *\<^sub>R x \ S" + by (simp add: convex_cone_iff) + +lemma convex_cone_nonempty: "convex_cone S \ S \ {}" + by (simp add: convex_cone_def) + +lemma convex_cone_linear_image: + "convex_cone S \ linear f \ convex_cone(f ` S)" + by (simp add: conic_linear_image convex_cone_def convex_linear_image) + +lemma convex_cone_linear_image_eq: + "\linear f; inj f\ \ (convex_cone(f ` S) \ convex_cone S)" + by (simp add: conic_linear_image_eq convex_cone_def) + +lemma convex_cone_halfspace_ge: "convex_cone {x. a \ x \ 0}" + by (simp add: convex_cone_iff inner_simps(2)) + +lemma convex_cone_halfspace_le: "convex_cone {x. a \ x \ 0}" + by (simp add: convex_cone_iff inner_right_distrib mult_nonneg_nonpos) + +lemma convex_cone_contains_0: "convex_cone S \ 0 \ S" + using convex_cone_iff by blast + +lemma convex_cone_Inter: + "(\S. S \ f \ convex_cone S) \ convex_cone(\ f)" + by (simp add: convex_cone_iff) + +lemma convex_cone_convex_cone_hull: "convex_cone(convex_cone hull S)" + by (metis (no_types, lifting) convex_cone_Inter hull_def mem_Collect_eq) + +lemma convex_convex_cone_hull: "convex(convex_cone hull S)" + by (meson convex_cone_convex_cone_hull convex_cone_def) + +lemma conic_convex_cone_hull: "conic(convex_cone hull S)" + by (metis convex_cone_convex_cone_hull convex_cone_def) + +lemma convex_cone_hull_nonempty: "convex_cone hull S \ {}" + by (simp add: convex_cone_convex_cone_hull convex_cone_nonempty) + +lemma convex_cone_hull_contains_0: "0 \ convex_cone hull S" + by (simp add: convex_cone_contains_0 convex_cone_convex_cone_hull) + +lemma convex_cone_hull_add: + "\x \ convex_cone hull S; y \ convex_cone hull S\ \ x + y \ convex_cone hull S" + by (simp add: convex_cone_add convex_cone_convex_cone_hull) + +lemma convex_cone_hull_mul: + "\x \ convex_cone hull S; 0 \ c\ \ (c *\<^sub>R x) \ convex_cone hull S" + by (simp add: conic_convex_cone_hull conic_mul) + +thm convex_sums +lemma convex_cone_sums: + "\convex_cone S; convex_cone T\ \ convex_cone (\x\ S. \y \ T. {x + y})" + by (simp add: convex_cone_def conic_sums convex_sums) + +lemma convex_cone_Times: + "\convex_cone S; convex_cone T\ \ convex_cone(S \ T)" + by (simp add: conic_Times convex_Times convex_cone_def) + +lemma convex_cone_Times_D1: "convex_cone (S \ T) \ convex_cone S" + by (metis Times_empty conic_Times_eq convex_cone_def convex_convex_hull convex_hull_Times hull_same times_eq_iff) + +lemma convex_cone_Times_eq: + "convex_cone(S \ T) \ convex_cone S \ convex_cone T" +proof (cases "S={} \ T={}") + case True + then show ?thesis + by (auto dest: convex_cone_nonempty) +next + case False + then have "convex_cone (S \ T) \ convex_cone T" + by (metis conic_Times_eq convex_cone_def convex_convex_hull convex_hull_Times hull_same times_eq_iff) + then show ?thesis + using convex_cone_Times convex_cone_Times_D1 by blast +qed + + +lemma convex_cone_hull_Un: + "convex_cone hull(S \ T) = (\x \ convex_cone hull S. \y \ convex_cone hull T. {x + y})" + (is "?lhs = ?rhs") +proof + show "?lhs \ ?rhs" + proof (rule hull_minimal) + show "S \ T \ (\x\convex_cone hull S. \y\convex_cone hull T. {x + y})" + apply (clarsimp simp: subset_iff) + by (metis add_0 convex_cone_hull_contains_0 group_cancel.rule0 hull_inc) + show "convex_cone (\x\convex_cone hull S. \y\convex_cone hull T. {x + y})" + by (simp add: convex_cone_convex_cone_hull convex_cone_sums) + qed +next + show "?rhs \ ?lhs" + by clarify (metis convex_cone_hull_add hull_mono le_sup_iff subsetD subsetI) +qed + +lemma convex_cone_singleton [iff]: "convex_cone {0}" + by (simp add: convex_cone_iff) + +lemma convex_hull_subset_convex_cone_hull: + "convex hull S \ convex_cone hull S" + by (simp add: convex_convex_cone_hull hull_minimal hull_subset) + +lemma conic_hull_subset_convex_cone_hull: + "conic hull S \ convex_cone hull S" + by (simp add: conic_convex_cone_hull hull_minimal hull_subset) + +lemma subspace_imp_convex_cone: "subspace S \ convex_cone S" + by (simp add: convex_cone_iff subspace_def) + +lemma convex_cone_span: "convex_cone(span S)" + by (simp add: subspace_imp_convex_cone) + +lemma convex_cone_negations: + "convex_cone S \ convex_cone (image uminus S)" + by (simp add: convex_cone_linear_image module_hom_uminus) + +lemma subspace_convex_cone_symmetric: + "subspace S \ convex_cone S \ (\x \ S. -x \ S)" + by (smt (verit) convex_cone_iff scaleR_left.minus subspace_def subspace_neg) + +lemma convex_cone_hull_separate_nonempty: + assumes "S \ {}" + shows "convex_cone hull S = conic hull (convex hull S)" (is "?lhs = ?rhs") +proof + show "?lhs \ ?rhs" + by (metis assms conic_conic_hull convex_cone_def convex_conic_hull convex_convex_hull hull_subset subset_empty subset_hull) + show "?rhs \ ?lhs" + by (simp add: conic_convex_cone_hull convex_hull_subset_convex_cone_hull subset_hull) +qed + +lemma convex_cone_hull_empty [simp]: "convex_cone hull {} = {0}" + by (metis convex_cone_hull_contains_0 convex_cone_singleton hull_redundant hull_same) + +lemma convex_cone_hull_separate: + "convex_cone hull S = insert 0 (conic hull (convex hull S))" +proof(cases "S={}") + case False + then show ?thesis + using convex_cone_hull_contains_0 convex_cone_hull_separate_nonempty by blast +qed auto + +lemma convex_cone_hull_convex_hull_nonempty: + "S \ {} \ convex_cone hull S = (\x \ convex hull S. \c\{0..}. {c *\<^sub>R x})" + by (force simp: convex_cone_hull_separate_nonempty conic_hull_as_image) + +lemma convex_cone_hull_convex_hull: + "convex_cone hull S = insert 0 (\x \ convex hull S. \c\{0..}. {c *\<^sub>R x})" + by (force simp: convex_cone_hull_separate conic_hull_as_image) + +lemma convex_cone_hull_linear_image: + "linear f \ convex_cone hull (f ` S) = image f (convex_cone hull S)" + by (metis (no_types, lifting) conic_hull_linear_image convex_cone_hull_separate convex_hull_linear_image image_insert linear_0) + subsection \Radon's theorem\ text "Formalized by Lars Schewe."