# HG changeset patch # User paulson # Date 1694283968 -3600 # Node ID 4da1e18a963302532de351d01a92ced4f98c47d7 # Parent 0d065af1a99ca1b598a653829571e53559dfa0a4 Loads of new material related to porting the Euler Polyhedron Formula from HOL Light 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." diff -r 0d065af1a99c -r 4da1e18a9633 src/HOL/Analysis/Lebesgue_Measure.thy --- a/src/HOL/Analysis/Lebesgue_Measure.thy Sat Sep 09 17:18:52 2023 +0100 +++ b/src/HOL/Analysis/Lebesgue_Measure.thy Sat Sep 09 19:26:08 2023 +0100 @@ -1092,11 +1092,6 @@ shows "lebesgue = density (distr lebesgue lebesgue (\x. c * x)) (\x. ennreal \c\)" using assms by (subst lebesgue_affine_euclidean[of "\_. c" 0]) simp_all -lemma divideR_right: - fixes x y :: "'a::real_normed_vector" - shows "r \ 0 \ y = x /\<^sub>R r \ r *\<^sub>R y = x" - using scaleR_cancel_left[of r y "x /\<^sub>R r"] by simp - lemma lborel_has_bochner_integral_real_affine_iff: fixes x :: "'a :: {banach, second_countable_topology}" shows "c \ 0 \ diff -r 0d065af1a99c -r 4da1e18a9633 src/HOL/Analysis/Linear_Algebra.thy --- a/src/HOL/Analysis/Linear_Algebra.thy Sat Sep 09 17:18:52 2023 +0100 +++ b/src/HOL/Analysis/Linear_Algebra.thy Sat Sep 09 19:26:08 2023 +0100 @@ -704,7 +704,7 @@ text \Low-dimensional subset is in a hyperplane (weak orthogonal complement).\ -lemma span_not_univ_orthogonal: +lemma span_not_UNIV_orthogonal: fixes S :: "'a::euclidean_space set" assumes sU: "span S \ UNIV" shows "\a::'a. a \ 0 \ (\x \ span S. a \ x = 0)" @@ -754,7 +754,7 @@ fixes S :: "'a::euclidean_space set" assumes SU: "span S \ UNIV" shows "\ a. a \0 \ span S \ {x. a \ x = 0}" - using span_not_univ_orthogonal[OF SU] by auto + using span_not_UNIV_orthogonal[OF SU] by auto lemma lowdim_subset_hyperplane: fixes S :: "'a::euclidean_space set" diff -r 0d065af1a99c -r 4da1e18a9633 src/HOL/Analysis/Polytope.thy --- a/src/HOL/Analysis/Polytope.thy Sat Sep 09 17:18:52 2023 +0100 +++ b/src/HOL/Analysis/Polytope.thy Sat Sep 09 19:26:08 2023 +0100 @@ -28,8 +28,12 @@ lemma face_of_linear_image: assumes "linear f" "inj f" - shows "(f ` c face_of f ` S) \ c face_of S" -by (simp add: face_of_def inj_image_subset_iff inj_image_mem_iff open_segment_linear_image assms) + shows "(f ` c face_of f ` S) \ c face_of S" + by (simp add: face_of_def inj_image_subset_iff inj_image_mem_iff open_segment_linear_image assms) + +lemma faces_of_linear_image: + "\linear f; inj f\ \ {T. T face_of (f ` S)} = (image f) ` {T. T face_of S}" + by (smt (verit) Collect_cong face_of_def face_of_linear_image setcompr_eq_image subset_imageE) lemma face_of_refl: "convex S \ S face_of S" by (auto simp: face_of_def) @@ -269,6 +273,39 @@ using \affine S\ xy by (auto simp: affine_alt) qed +proposition face_of_conic: + assumes "conic S" "f face_of S" + shows "conic f" + unfolding conic_def +proof (intro strip) + fix x and c::real + assume "x \ f" and "0 \ c" + have f: "\a b x. \a \ S; b \ S; x \ f; x \ open_segment a b\ \ a \ f \ b \ f" + using \f face_of S\ face_ofD by blast + show "c *\<^sub>R x \ f" + proof (cases "x=0 \ c=1") + case True + then show ?thesis + using \x \ f\ by auto + next + case False + with \0 \ c\ obtain d e where de: "0 \ d" "0 \ e" "d < 1" "1 < e" "d < e" "(d = c \ e = c)" + apply (simp add: neq_iff) + by (metis gt_ex less_eq_real_def order_less_le_trans zero_less_one) + then obtain [simp]: "c *\<^sub>R x \ S" "e *\<^sub>R x \ S" \x \ S\ + using \x \ f\ assms conic_mul face_of_imp_subset by blast + have "x \ open_segment (d *\<^sub>R x) (e *\<^sub>R x)" if "c *\<^sub>R x \ f" + using de False that + apply (simp add: in_segment) + apply (rule_tac x="(1 - d) / (e - d)" in exI) + apply (simp add: field_simps) + by (smt (verit, del_insts) add_divide_distrib divide_self scaleR_collapse) + then show ?thesis + using \conic S\ f [of "d *\<^sub>R x" "e *\<^sub>R x" x] de \x \ f\ + by (force simp: conic_def in_segment) + qed +qed + proposition face_of_convex_hulls: assumes S: "finite S" "T \ S" and disj: "affine hull T \ convex hull (S - T) = {}" shows "(convex hull T) face_of (convex hull S)" @@ -927,6 +964,18 @@ by (auto simp: face_of_singleton hull_same) qed (use assms in \simp add: hull_inc\) +lemma extreme_point_of_conic: + assumes "conic S" and x: "x extreme_point_of S" + shows "x = 0" +proof - + have "{x} face_of S" + by (simp add: face_of_singleton x) + then have "conic{x}" + using assms(1) face_of_conic by blast + then show ?thesis + by (force simp: conic_def) +qed + subsection\Facets\ definition\<^marker>\tag important\ facet_of :: "['a::euclidean_space set, 'a set] \ bool" @@ -3826,5 +3875,135 @@ using that by (auto simp: in\) qed qed +section \Finitely generated cone is polyhedral, and hence closed\ + +proposition polyhedron_convex_cone_hull: + fixes S :: "'a::euclidean_space set" + assumes "finite S" + shows "polyhedron(convex_cone hull S)" +proof (cases "S = {}") + case True + then show ?thesis + by (simp add: affine_imp_polyhedron) +next + case False + then have "polyhedron(convex hull (insert 0 S))" + by (simp add: assms polyhedron_convex_hull) + then obtain F a b where "finite F" + and F: "convex hull (insert 0 S) = \ F" + and ab: "\h. h \ F \ a h \ 0 \ h = {x. a h \ x \ b h}" + unfolding polyhedron_def by metis + then have "F \ {}" + by (metis bounded_convex_hull finite_imp_bounded Inf_empty assms finite_insert not_bounded_UNIV) + show ?thesis + unfolding polyhedron_def + proof (intro exI conjI) + show "convex_cone hull S = \ {h \ F. b h = 0}" (is "?lhs = ?rhs") + proof + show "?lhs \ ?rhs" + proof (rule hull_minimal) + show "S \ \ {h \ F. b h = 0}" + by (smt (verit, best) F InterE InterI hull_subset insert_subset mem_Collect_eq subset_eq) + have "\S. \S \ F; b S = 0\ \ convex_cone S" + by (metis ab convex_cone_halfspace_le) + then show "convex_cone (\ {h \ F. b h = 0})" + by (force intro: convex_cone_Inter) + qed + have "x \ convex_cone hull S" + if x: "\h. \h \ F; b h = 0\ \ x \ h" for x + proof - + have "\t. 0 < t \ (t *\<^sub>R x) \ h" if "h \ F" for h + proof (cases "b h = 0") + case True + then show ?thesis + by (metis x linordered_field_no_ub mult_1 scaleR_one that zero_less_mult_iff) + next + case False + then have "b h > 0" + by (smt (verit, del_insts) F InterE ab hull_subset inner_zero_right insert_subset mem_Collect_eq that) + then have "0 \ interior {x. a h \ x \ b h}" + by (simp add: ab that) + then have "0 \ interior h" + using ab that by auto + then obtain \ where "0 < \" and \: "ball 0 \ \ h" + using mem_interior by blast + show ?thesis + proof (cases "x=0") + case True + then show ?thesis + using \ \0 < \\ by auto + next + case False + with \ \0 < \\ show ?thesis + by (rule_tac x="\ / (2 * norm x)" in exI) (auto simp: divide_simps) + qed + qed + then obtain t where t: "\h. h \ F \ 0 < t h \ (t h *\<^sub>R x) \ h" + by metis + then have "Inf (t ` F) *\<^sub>R x /\<^sub>R Inf (t ` F) = x" + by (smt (verit) \F \ {}\ \finite F\ divideR_right finite_imageI finite_less_Inf_iff image_iff image_is_empty) + moreover have "Inf (t ` F) *\<^sub>R x /\<^sub>R Inf (t ` F) \ convex_cone hull S" + proof (rule conicD [OF conic_convex_cone_hull]) + have "Inf (t ` F) *\<^sub>R x \ \ F" + proof clarify + fix h + assume "h \ F" + have eq: "Inf (t ` F) *\<^sub>R x = (1 - Inf(t ` F) / t h) *\<^sub>R 0 + (Inf(t ` F) / t h) *\<^sub>R t h *\<^sub>R x" + using \h \ F\ t by force + show "Inf (t ` F) *\<^sub>R x \ h" + unfolding eq + proof (rule convexD_alt) + have "h = {x. a h \ x \ b h}" + by (simp add: \h \ F\ ab) + then show "convex h" + by (metis convex_halfspace_le) + show "0 \ h" + by (metis F InterE \h \ F\ hull_subset insertCI subsetD) + show "t h *\<^sub>R x \ h" + by (simp add: \h \ F\ t) + show "0 \ Inf (t ` F) / t h" + by (metis \F \ {}\ \h \ F\ cINF_greatest divide_nonneg_pos less_eq_real_def t) + show "Inf (t ` F) / t h \ 1" + by (simp add: \finite F\ \h \ F\ cInf_le_finite t) + qed + qed + moreover have "convex hull (insert 0 S) \ convex_cone hull S" + by (simp add: convex_cone_hull_contains_0 convex_convex_cone_hull hull_minimal hull_subset) + ultimately show "Inf (t ` F) *\<^sub>R x \ convex_cone hull S" + using F by blast + show "0 \ inverse (Inf (t ` F))" + using t by (simp add: \F \ {}\ \finite F\ finite_less_Inf_iff less_eq_real_def) + qed + ultimately show ?thesis + by auto + qed + then show "?rhs \ ?lhs" + by auto + qed + show "\h\{h \ F. b h = 0}. \a b. a \ 0 \ h = {x. a \ x \ b}" + using ab by blast + qed (auto simp: \finite F\) +qed + + +lemma closed_convex_cone_hull: + fixes S :: "'a::euclidean_space set" + shows "finite S \ closed(convex_cone hull S)" + by (simp add: polyhedron_convex_cone_hull polyhedron_imp_closed) + +lemma polyhedron_convex_cone_hull_polytope: + fixes S :: "'a::euclidean_space set" + shows "polytope S \ polyhedron(convex_cone hull S)" + by (metis convex_cone_hull_separate hull_hull polyhedron_convex_cone_hull polytope_def) + +lemma polyhedron_conic_hull_polytope: + fixes S :: "'a::euclidean_space set" + shows "polytope S \ polyhedron(conic hull S)" + by (metis conic_hull_eq_empty convex_cone_hull_separate_nonempty hull_hull polyhedron_convex_cone_hull_polytope polyhedron_empty polytope_def) + +lemma closed_conic_hull_strong: + fixes S :: "'a::euclidean_space set" + shows "0 \ rel_interior S \ polytope S \ compact S \ ~(0 \ S) \ closed(conic hull S)" + using closed_conic_hull polyhedron_conic_hull_polytope polyhedron_imp_closed by blast end diff -r 0d065af1a99c -r 4da1e18a9633 src/HOL/Analysis/Starlike.thy --- a/src/HOL/Analysis/Starlike.thy Sat Sep 09 17:18:52 2023 +0100 +++ b/src/HOL/Analysis/Starlike.thy Sat Sep 09 19:26:08 2023 +0100 @@ -214,6 +214,84 @@ by (simp add: closure_mono interior_subset subset_antisym) qed +lemma openin_subset_relative_interior: + fixes S :: "'a::euclidean_space set" + shows "openin (top_of_set (affine hull T)) S \ (S \ rel_interior T) = (S \ T)" + by (meson order.trans rel_interior_maximal rel_interior_subset) + +lemma conic_hull_eq_span_affine_hull: + fixes S :: "'a::euclidean_space set" + assumes "0 \ rel_interior S" + shows "conic hull S = span S \ conic hull S = affine hull S" +proof - + obtain \ where "\>0" and \: "cball 0 \ \ affine hull S \ S" + using assms mem_rel_interior_cball by blast + have *: "affine hull S = span S" + by (meson affine_hull_span_0 assms hull_inc mem_rel_interior_cball) + moreover + have "conic hull S \ span S" + by (simp add: hull_minimal span_superset) + moreover + have "affine hull S \ conic hull S" + proof clarsimp + fix x + assume "x \ affine hull S" + show "x \ conic hull S" + proof (cases "x=0") + case True + then show ?thesis + using \x \ affine hull S\ by auto + next + case False + then have "(\ / norm x) *\<^sub>R x \ cball 0 \ \ affine hull S" + using \0 < \\ \x \ affine hull S\ * span_mul by fastforce + then have "(\ / norm x) *\<^sub>R x \ S" + by (meson \ subsetD) + then have "\c xa. x = c *\<^sub>R xa \ 0 \ c \ xa \ S" + by (smt (verit, del_insts) \0 < \\ divide_nonneg_nonneg eq_vector_fraction_iff norm_eq_zero norm_ge_zero) + then show ?thesis + by (simp add: conic_hull_explicit) + qed + qed + ultimately show ?thesis + by blast +qed + +lemma conic_hull_eq_span: + fixes S :: "'a::euclidean_space set" + assumes "0 \ rel_interior S" + shows "conic hull S = span S" + by (simp add: assms conic_hull_eq_span_affine_hull) + +lemma conic_hull_eq_affine_hull: + fixes S :: "'a::euclidean_space set" + assumes "0 \ rel_interior S" + shows "conic hull S = affine hull S" + using assms conic_hull_eq_span_affine_hull by blast + +lemma conic_hull_eq_span_eq: + fixes S :: "'a::euclidean_space set" + shows "0 \ rel_interior(conic hull S) \ conic hull S = span S" (is "?lhs = ?rhs") +proof + show "?lhs \ ?rhs" + by (metis conic_hull_eq_span conic_span hull_hull hull_minimal hull_subset span_eq) + show "?rhs \ ?lhs" + by (metis rel_interior_affine subspace_affine subspace_span) +qed + +lemma aff_dim_psubset: + "(affine hull S) \ (affine hull T) \ aff_dim S < aff_dim T" + by (metis aff_dim_affine_hull aff_dim_empty aff_dim_subset affine_affine_hull affine_dim_equal order_less_le) + +lemma aff_dim_eq_full_gen: + "S \ T \ (aff_dim S = aff_dim T \ affine hull S = affine hull T)" + by (smt (verit, del_insts) aff_dim_affine_hull2 aff_dim_psubset hull_mono psubsetI) + +lemma aff_dim_eq_full: + fixes S :: "'n::euclidean_space set" + shows "aff_dim S = (DIM('n)) \ affine hull S = UNIV" + by (metis aff_dim_UNIV aff_dim_affine_hull affine_hull_UNIV) + lemma closure_convex_Int_superset: fixes S :: "'a::euclidean_space set" assumes "convex S" "interior S \ {}" "interior S \ closure T" @@ -772,6 +850,61 @@ qed auto qed +lemma empty_interior_subset_hyperplane_aux: + fixes S :: "'a::euclidean_space set" + assumes "convex S" "0 \ S" and empty_int: "interior S = {}" + shows "\a b. a\0 \ S \ {x. a \ x = b}" +proof - + have False if "\a. a = 0 \ (\b. \T \ S. a \ T \ b)" + proof - + have rel_int: "rel_interior S \ {}" + using assms rel_interior_eq_empty by auto + moreover + have "dim S \ dim (UNIV::'a set)" + by (metis aff_dim_zero affine_hull_UNIV \0 \ S\ dim_UNIV empty_int hull_inc rel_int rel_interior_interior) + then obtain a where "a \ 0" and a: "span S \ {x. a \ x = 0}" + using lowdim_subset_hyperplane + by (metis dim_UNIV dim_subset_UNIV order_less_le) + have "span UNIV = span S" + by (metis span_base span_not_UNIV_orthogonal that) + then have "UNIV \ affine hull S" + by (simp add: \0 \ S\ hull_inc affine_hull_span_0) + ultimately show False + using \rel_interior S \ {}\ empty_int rel_interior_interior by blast + qed + then show ?thesis + by blast +qed + +lemma empty_interior_subset_hyperplane: + fixes S :: "'a::euclidean_space set" + assumes "convex S" and int: "interior S = {}" + obtains a b where "a \ 0" "S \ {x. a \ x = b}" +proof (cases "S = {}") + case True + then show ?thesis + using that by blast +next + case False + then obtain u where "u \ S" + by blast + have "\a b. a \ 0 \ (\x. x - u) ` S \ {x. a \ x = b}" + proof (rule empty_interior_subset_hyperplane_aux) + show "convex ((\x. x - u) ` S)" + using \convex S\ by force + show "0 \ (\x. x - u) ` S" + by (simp add: \u \ S\) + show "interior ((\x. x - u) ` S) = {}" + by (simp add: int interior_translation_subtract) + qed + then obtain a b where "a \ 0" and ab: "(\x. x - u) ` S \ {x. a \ x = b}" + by metis + then have "S \ {x. a \ x = b + (a \ u)}" + using ab by (auto simp: algebra_simps) + then show ?thesis + using \a \ 0\ that by auto +qed + lemma rel_interior_same_affine_hull: fixes S :: "'n::euclidean_space set" assumes "convex S" @@ -1327,118 +1460,119 @@ then show ?thesis by auto qed -lemma convex_closure_rel_interior_inter: - assumes "\S\I. convex (S :: 'n::euclidean_space set)" - and "\{rel_interior S |S. S \ I} \ {}" - shows "\{closure S |S. S \ I} \ closure (\{rel_interior S |S. S \ I})" +lemma convex_closure_rel_interior_Int: + assumes "\S. S\\ \ convex (S :: 'n::euclidean_space set)" + and "\(rel_interior ` \) \ {}" + shows "\(closure ` \) \ closure (\(rel_interior ` \))" proof - - obtain x where x: "\S\I. x \ rel_interior S" + obtain x where x: "\S\\. x \ rel_interior S" using assms by auto - { + show ?thesis + proof fix y - assume "y \ \{closure S |S. S \ I}" - then have y: "\S \ I. y \ closure S" - by auto - { - assume "y = x" - then have "y \ closure (\{rel_interior S |S. S \ I})" - using x closure_subset[of "\{rel_interior S |S. S \ I}"] by auto - } - moreover - { - assume "y \ x" - { fix e :: real - assume e: "e > 0" - define e1 where "e1 = min 1 (e/norm (y - x))" - then have e1: "e1 > 0" "e1 \ 1" "e1 * norm (y - x) \ e" - using \y \ x\ \e > 0\ le_divide_eq[of e1 e "norm (y - x)"] + assume y: "y \ \ (closure ` \)" + show "y \ closure (\(rel_interior ` \))" + proof (cases "y=x") + case True + with closure_subset x show ?thesis + by fastforce + next + case False + show ?thesis + proof (clarsimp simp: closure_approachable_le) + fix \ :: real + assume e: "\ > 0" + define e1 where "e1 = min 1 (\/norm (y - x))" + then have e1: "e1 > 0" "e1 \ 1" "e1 * norm (y - x) \ \" + using \y \ x\ \\ > 0\ le_divide_eq[of e1 \ "norm (y - x)"] by simp_all define z where "z = y - e1 *\<^sub>R (y - x)" { fix S - assume "S \ I" + assume "S \ \" then have "z \ rel_interior S" using rel_interior_closure_convex_shrink[of S x y e1] assms x y e1 z_def by auto } - then have *: "z \ \{rel_interior S |S. S \ I}" + then have *: "z \ \(rel_interior ` \)" by auto - have "\z. z \ \{rel_interior S |S. S \ I} \ z \ y \ dist z y \ e" + show "\x\\ (rel_interior ` \). dist x y \ \" using \y \ x\ z_def * e1 e dist_norm[of z y] - by (rule_tac x="z" in exI) auto - } - then have "y islimpt \{rel_interior S |S. S \ I}" - unfolding islimpt_approachable_le by blast - then have "y \ closure (\{rel_interior S |S. S \ I})" - unfolding closure_def by auto - } - ultimately have "y \ closure (\{rel_interior S |S. S \ I})" - by auto - } - then show ?thesis by auto -qed - -lemma convex_closure_inter: - assumes "\S\I. convex (S :: 'n::euclidean_space set)" - and "\{rel_interior S |S. S \ I} \ {}" - shows "closure (\I) = \{closure S |S. S \ I}" + by force + qed + qed + qed +qed + + +lemma closure_Inter_convex: + fixes \ :: "'n::euclidean_space set set" + assumes "\S. S \ \ \ convex S" and "\(rel_interior ` \) \ {}" + shows "closure(\\) = \(closure ` \)" proof - - have "\{closure S |S. S \ I} \ closure (\{rel_interior S |S. S \ I})" - using convex_closure_rel_interior_inter assms by auto + have "\(closure ` \) \ closure (\(rel_interior ` \))" + by (meson assms convex_closure_rel_interior_Int) moreover - have "closure (\{rel_interior S |S. S \ I}) \ closure (\I)" - using rel_interior_inter_aux closure_mono[of "\{rel_interior S |S. S \ I}" "\I"] + have "closure (\(rel_interior ` \)) \ closure (\\)" + using rel_interior_inter_aux closure_mono[of "\(rel_interior ` \)" "\\"] by auto ultimately show ?thesis - using closure_Int[of I] by auto -qed - -lemma convex_inter_rel_interior_same_closure: - assumes "\S\I. convex (S :: 'n::euclidean_space set)" - and "\{rel_interior S |S. S \ I} \ {}" - shows "closure (\{rel_interior S |S. S \ I}) = closure (\I)" + using closure_Int[of \] by blast +qed + +lemma closure_Inter_convex_open: + "(\S::'n::euclidean_space set. S \ \ \ convex S \ open S) + \ closure(\\) = (if \\ = {} then {} else \(closure ` \))" + by (simp add: closure_Inter_convex rel_interior_open) + +lemma convex_Inter_rel_interior_same_closure: + fixes \ :: "'n::euclidean_space set set" + assumes "\S. S \ \ \ convex S" + and "\(rel_interior ` \) \ {}" + shows "closure (\(rel_interior ` \)) = closure (\\)" proof - - have "\{closure S |S. S \ I} \ closure (\{rel_interior S |S. S \ I})" - using convex_closure_rel_interior_inter assms by auto + have "\(closure ` \) \ closure (\(rel_interior ` \))" + by (meson assms convex_closure_rel_interior_Int) moreover - have "closure (\{rel_interior S |S. S \ I}) \ closure (\I)" - using rel_interior_inter_aux closure_mono[of "\{rel_interior S |S. S \ I}" "\I"] - by auto + have "closure (\(rel_interior ` \)) \ closure (\\)" + by (metis Setcompr_eq_image closure_mono rel_interior_inter_aux) ultimately show ?thesis - using closure_Int[of I] by auto -qed - -lemma convex_rel_interior_inter: - assumes "\S\I. convex (S :: 'n::euclidean_space set)" - and "\{rel_interior S |S. S \ I} \ {}" - shows "rel_interior (\I) \ \{rel_interior S |S. S \ I}" + by (simp add: assms closure_Inter_convex) +qed + +lemma convex_rel_interior_Inter: + fixes \ :: "'n::euclidean_space set set" + assumes "\S. S \ \ \ convex S" + and "\(rel_interior ` \) \ {}" + shows "rel_interior (\\) \ \(rel_interior ` \)" proof - - have "convex (\I)" + have "convex (\\)" using assms convex_Inter by auto moreover - have "convex (\{rel_interior S |S. S \ I})" - using assms convex_rel_interior by (force intro: convex_Inter) + have "convex (\(rel_interior ` \))" + using assms by (metis convex_rel_interior convex_INT) ultimately - have "rel_interior (\{rel_interior S |S. S \ I}) = rel_interior (\I)" - using convex_inter_rel_interior_same_closure assms - closure_eq_rel_interior_eq[of "\{rel_interior S |S. S \ I}" "\I"] + have "rel_interior (\(rel_interior ` \)) = rel_interior (\\)" + using convex_Inter_rel_interior_same_closure assms + closure_eq_rel_interior_eq[of "\(rel_interior ` \)" "\\"] by blast then show ?thesis - using rel_interior_subset[of "\{rel_interior S |S. S \ I}"] by auto -qed - -lemma convex_rel_interior_finite_inter: - assumes "\S\I. convex (S :: 'n::euclidean_space set)" - and "\{rel_interior S |S. S \ I} \ {}" - and "finite I" - shows "rel_interior (\I) = \{rel_interior S |S. S \ I}" + using rel_interior_subset[of "\(rel_interior ` \)"] by auto +qed + +lemma convex_rel_interior_finite_Inter: + fixes \ :: "'n::euclidean_space set set" + assumes "\S. S \ \ \ convex S" + and "\(rel_interior ` \) \ {}" + and "finite \" + shows "rel_interior (\\) = \(rel_interior ` \)" proof - - have "\I \ {}" - using assms rel_interior_inter_aux[of I] by auto - have "convex (\I)" + have "\\ \ {}" + using assms rel_interior_inter_aux[of \] by auto + have "convex (\\)" using convex_Inter assms by auto show ?thesis - proof (cases "I = {}") + proof (cases "\ = {}") case True then show ?thesis using Inter_empty rel_interior_UNIV by auto @@ -1446,43 +1580,43 @@ case False { fix z - assume z: "z \ \{rel_interior S |S. S \ I}" + assume z: "z \ \(rel_interior ` \)" { fix x - assume x: "x \ \I" + assume x: "x \ \\" { fix S - assume S: "S \ I" + assume S: "S \ \" then have "z \ rel_interior S" "x \ S" using z x by auto then have "\m. m > 1 \ (\e. e > 1 \ e \ m \ (1 - e)*\<^sub>R x + e *\<^sub>R z \ S)" using convex_rel_interior_if[of S z] S assms hull_subset[of S] by auto } then obtain mS where - mS: "\S\I. mS S > 1 \ (\e. e > 1 \ e \ mS S \ (1 - e) *\<^sub>R x + e *\<^sub>R z \ S)" by metis - define e where "e = Min (mS ` I)" - then have "e \ mS ` I" using assms \I \ {}\ by simp + mS: "\S\\. mS S > 1 \ (\e. e > 1 \ e \ mS S \ (1 - e) *\<^sub>R x + e *\<^sub>R z \ S)" by metis + define e where "e = Min (mS ` \)" + then have "e \ mS ` \" using assms \\ \ {}\ by simp then have "e > 1" using mS by auto - moreover have "\S\I. e \ mS S" + moreover have "\S\\. e \ mS S" using e_def assms by auto - ultimately have "\e > 1. (1 - e) *\<^sub>R x + e *\<^sub>R z \ \I" + ultimately have "\e > 1. (1 - e) *\<^sub>R x + e *\<^sub>R z \ \\" using mS by auto } - then have "z \ rel_interior (\I)" - using convex_rel_interior_iff[of "\I" z] \\I \ {}\ \convex (\I)\ by auto + then have "z \ rel_interior (\\)" + using convex_rel_interior_iff[of "\\" z] \\\ \ {}\ \convex (\\)\ by auto } then show ?thesis - using convex_rel_interior_inter[of I] assms by auto + using convex_rel_interior_Inter[of \] assms by auto qed qed -lemma convex_closure_inter_two: +lemma closure_Int_convex: fixes S T :: "'n::euclidean_space set" assumes "convex S" and "convex T" assumes "rel_interior S \ rel_interior T \ {}" shows "closure (S \ T) = closure S \ closure T" - using convex_closure_inter[of "{S,T}"] assms by auto + using closure_Inter_convex[of "{S,T}"] assms by auto lemma convex_rel_interior_inter_two: fixes S T :: "'n::euclidean_space set" @@ -1490,7 +1624,7 @@ and "convex T" and "rel_interior S \ rel_interior T \ {}" shows "rel_interior (S \ T) = rel_interior S \ rel_interior T" - using convex_rel_interior_finite_inter[of "{S,T}"] assms by auto + using convex_rel_interior_finite_Inter[of "{S,T}"] assms by auto lemma convex_affine_closure_Int: fixes S T :: "'n::euclidean_space set" @@ -1498,7 +1632,7 @@ and "affine T" and "rel_interior S \ T \ {}" shows "closure (S \ T) = closure S \ T" - by (metis affine_imp_convex assms convex_closure_inter_two rel_interior_affine rel_interior_eq_closure) + by (metis affine_imp_convex assms closure_Int_convex rel_interior_affine rel_interior_eq_closure) lemma connected_component_1_gen: fixes S :: "'a :: euclidean_space set" @@ -1749,22 +1883,21 @@ shows "convex (((*\<^sub>R) c) ` S) \ rel_open (((*\<^sub>R) c) ` S)" by (metis assms convex_scaling rel_interior_convex_scaleR rel_open_def) -lemma convex_rel_open_finite_inter: - assumes "\S\I. convex (S :: 'n::euclidean_space set) \ rel_open S" - and "finite I" - shows "convex (\I) \ rel_open (\I)" -proof (cases "\{rel_interior S |S. S \ I} = {}") +lemma convex_rel_open_finite_Inter: + fixes \ :: "'n::euclidean_space set set" + assumes "\S. S \ \ \ convex S \ rel_open S" + and "finite \" + shows "convex (\\) \ rel_open (\\)" +proof (cases "\{rel_interior S |S. S \ \} = {}") case True - then have "\I = {}" + then have "\\ = {}" using assms unfolding rel_open_def by auto then show ?thesis unfolding rel_open_def by auto next case False - then have "rel_open (\I)" - using assms unfolding rel_open_def - using convex_rel_interior_finite_inter[of I] - by auto + then have "rel_open (\\)" + using assms convex_rel_interior_finite_Inter[of \] by (force simp: rel_open_def) then show ?thesis using convex_Inter assms by auto qed @@ -2880,12 +3013,9 @@ by (auto simp: algebra_simps sum_subtractf sum.distrib) qed have "y \ rel_interior (convex hull S)" - using y - apply (simp add: mem_rel_interior) - apply (auto simp: convex_hull_finite [OF fs]) - apply (drule_tac x=u in spec) - apply (auto intro: *) - done + using y convex_hull_finite [OF fs] * + apply simp + by (metis (no_types, lifting) IntD1 affine_hull_convex_hull mem_rel_interior) } with rel_interior_subset show "?lhs \ ?rhs" by blast qed @@ -4022,6 +4152,133 @@ by (force simp: closedin_limpt) qed +subsection \Closure of conic hulls\ +proposition closedin_conic_hull: + fixes S :: "'a::euclidean_space set" + assumes "compact T" "0 \ T" "T \ S" + shows "closedin (top_of_set (conic hull S)) (conic hull T)" +proof - + have **: "compact ({0..} \ T \ (\z. fst z *\<^sub>R snd z) -` K)" (is "compact ?L") + if "K \ (\z. (fst z) *\<^sub>R snd z) ` ({0..} \ S)" "compact K" for K + proof - + obtain r where "r > 0" and r: "\x. x \ K \ norm x \ r" + by (metis \compact K\ bounded_normE compact_imp_bounded) + show ?thesis + unfolding compact_eq_bounded_closed + proof + have "bounded ({0..r / setdist{0}T} \ T)" + by (simp add: assms(1) bounded_Times compact_imp_bounded) + moreover have "?L \ ({0..r / setdist{0}T} \ T)" + proof clarsimp + fix a b + assume "a *\<^sub>R b \ K" and "b \ T" and "0 \ a" + have "setdist {0} T \ 0" + using \b \ T\ assms compact_imp_closed setdist_eq_0_closed by auto + then have T0: "setdist {0} T > 0" + using less_eq_real_def by fastforce + then have "a * setdist {0} T \ r" + by (smt (verit, ccfv_SIG) \0 \ a\ \a *\<^sub>R b \ K\ \b \ T\ dist_0_norm mult_mono' norm_scaleR r setdist_le_dist singletonI) + with T0 \r>0\ show "a \ r / setdist {0} T" + by (simp add: divide_simps) + qed + ultimately show "bounded ?L" + by (meson bounded_subset) + show "closed ?L" + proof (rule continuous_closed_preimage) + show "continuous_on ({0..} \ T) (\z. fst z *\<^sub>R snd z)" + by (intro continuous_intros) + show "closed ({0::real..} \ T)" + by (simp add: assms(1) closed_Times compact_imp_closed) + show "closed K" + by (simp add: compact_imp_closed that(2)) + qed + qed + qed + show ?thesis + unfolding conic_hull_as_image + proof (rule proper_map) + show "compact ({0..} \ T \ (\z. fst z *\<^sub>R snd z) -` K)" (is "compact ?L") + if "K \ (\z. (fst z) *\<^sub>R snd z) ` ({0..} \ S)" "compact K" for K + proof - + obtain r where "r > 0" and r: "\x. x \ K \ norm x \ r" + by (metis \compact K\ bounded_normE compact_imp_bounded) + show ?thesis + unfolding compact_eq_bounded_closed + proof + have "bounded ({0..r / setdist{0}T} \ T)" + by (simp add: assms(1) bounded_Times compact_imp_bounded) + moreover have "?L \ ({0..r / setdist{0}T} \ T)" + proof clarsimp + fix a b + assume "a *\<^sub>R b \ K" and "b \ T" and "0 \ a" + have "setdist {0} T \ 0" + using \b \ T\ assms compact_imp_closed setdist_eq_0_closed by auto + then have T0: "setdist {0} T > 0" + using less_eq_real_def by fastforce + then have "a * setdist {0} T \ r" + by (smt (verit, ccfv_SIG) \0 \ a\ \a *\<^sub>R b \ K\ \b \ T\ dist_0_norm mult_mono' norm_scaleR r setdist_le_dist singletonI) + with T0 \r>0\ show "a \ r / setdist {0} T" + by (simp add: divide_simps) + qed + ultimately show "bounded ?L" + by (meson bounded_subset) + show "closed ?L" + proof (rule continuous_closed_preimage) + show "continuous_on ({0..} \ T) (\z. fst z *\<^sub>R snd z)" + by (intro continuous_intros) + show "closed ({0::real..} \ T)" + by (simp add: assms(1) closed_Times compact_imp_closed) + show "closed K" + by (simp add: compact_imp_closed that(2)) + qed + qed + qed + show "(\z. fst z *\<^sub>R snd z) ` ({0::real..} \ T) \ (\z. fst z *\<^sub>R snd z) ` ({0..} \ S)" + using \T \ S\ by force + qed auto +qed + +lemma closed_conic_hull: + fixes S :: "'a::euclidean_space set" + assumes "0 \ rel_interior S \ compact S \ 0 \ S" + shows "closed(conic hull S)" + using assms +proof + assume "0 \ rel_interior S" + then show "closed (conic hull S)" + by (simp add: conic_hull_eq_span) +next + assume "compact S \ 0 \ S" + then have "closedin (top_of_set UNIV) (conic hull S)" + using closedin_conic_hull by force + then show "closed (conic hull S)" + by simp +qed + +lemma conic_closure: + fixes S :: "'a::euclidean_space set" + shows "conic S \ conic(closure S)" + by (meson Convex.cone_def cone_closure conic_def) + +lemma closure_conic_hull: + fixes S :: "'a::euclidean_space set" + assumes "0 \ rel_interior S \ bounded S \ ~(0 \ closure S)" + shows "closure(conic hull S) = conic hull (closure S)" + using assms +proof + assume "0 \ rel_interior S" + then show "closure (conic hull S) = conic hull closure S" + by (metis closed_affine_hull closure_closed closure_same_affine_hull closure_subset conic_hull_eq_affine_hull subsetD subset_rel_interior) +next + have "\x. x \ conic hull closure S \ x \ closure (conic hull S)" + by (metis (no_types, opaque_lifting) closure_mono conic_closure conic_conic_hull subset_eq subset_hull) + moreover + assume "bounded S \ 0 \ closure S" + then have "\x. x \ closure (conic hull S) \ x \ conic hull closure S" + by (metis closed_conic_hull closure_Un_frontier closure_closed closure_mono compact_closure hull_Un_subset le_sup_iff subsetD) + ultimately show "closure (conic hull S) = conic hull closure S" + by blast +qed lemma compact_continuous_image_eq: fixes f :: "'a::heine_borel \ 'b::heine_borel" diff -r 0d065af1a99c -r 4da1e18a9633 src/HOL/Binomial.thy --- a/src/HOL/Binomial.thy Sat Sep 09 17:18:52 2023 +0100 +++ b/src/HOL/Binomial.thy Sat Sep 09 19:26:08 2023 +0100 @@ -115,6 +115,9 @@ lemma binomial_1 [simp]: "n choose Suc 0 = n" by (induct n) simp_all +lemma choose_one: "n choose 1 = n" for n :: nat + by simp + lemma choose_reduce_nat: "0 < n \ 0 < k \ n choose k = ((n - 1) choose (k - 1)) + ((n - 1) choose k)" @@ -1084,109 +1087,190 @@ qed -subsection \More on Binomial Coefficients\ +subsection \Inclusion-exclusion principle\ + +lemma Inter_over_Union: + "\ {\ (\ x) |x. x \ S} = \ {\ (G ` S) |G. \x\S. G x \ \ x}" +proof - + have "\x. \s\S. \X \ \ s. x \ X \ \G. (\x\S. G x \ \ x) \ (\s\S. x \ G s)" + by metis + then show ?thesis + by (auto simp flip: all_simps ex_simps) +qed + +lemma subset_insert_lemma: + "{T. T \ (insert a S) \ P T} = {T. T \ S \ P T} \ {insert a T |T. T \ S \ P(insert a T)}" (is "?L=?R") +proof + show "?L \ ?R" + by (smt (verit) UnI1 UnI2 insert_Diff mem_Collect_eq subsetI subset_insert_iff) +qed blast + + +text\Versions for additive real functions, where the additivity applies only to some + specific subsets (e.g. cardinality of finite sets, measurable sets with bounded measure. + (From HOL Light)\ + +locale Incl_Excl = + fixes P :: "'a set \ bool" and f :: "'a set \ 'b::ring_1" + assumes disj_add: "\P S; P T; disjnt S T\ \ f(S \ T) = f S + f T" + and empty: "P{}" + and Int: "\P S; P T\ \ P(S \ T)" + and Un: "\P S; P T\ \ P(S \ T)" + and Diff: "\P S; P T\ \ P(S - T)" + +begin + +lemma f_empty [simp]: "f{} = 0" + using disj_add empty by fastforce + +lemma f_Un_Int: "\P S; P T\ \ f(S \ T) + f(S \ T) = f S + f T" + by (smt (verit, ccfv_threshold) Groups.add_ac(2) Incl_Excl.Diff Incl_Excl.Int Incl_Excl_axioms Int_Diff_Un Int_Diff_disjoint Int_absorb Un_Diff Un_Int_eq(2) disj_add disjnt_def group_cancel.add2 sup_bot.right_neutral) -lemma choose_one: "n choose 1 = n" for n :: nat - by simp +lemma restricted_indexed: + assumes "finite A" and X: "\a. a \ A \ P(X a)" + shows "f(\(X ` A)) = (\B | B \ A \ B \ {}. (- 1) ^ (card B + 1) * f (\ (X ` B)))" +proof - + have "\finite A; card A = n; \a \ A. P (X a)\ + \ f(\(X ` A)) = (\B | B \ A \ B \ {}. (- 1) ^ (card B + 1) * f (\ (X ` B)))" for n X and A :: "'c set" + proof (induction n arbitrary: A X rule: less_induct) + case (less n0 A0 X) + show ?case + proof (cases "n0=0") + case True + with less show ?thesis + by fastforce + next + case False + with less.prems obtain A n a where *: "n0 = Suc n" "A0 = insert a A" "a \ A" "card A = n" "finite A" + by (metis card_Suc_eq_finite not0_implies_Suc) + with less have "P (X a)" by blast + have APX: "\a \ A. P (X a)" + by (simp add: "*" less.prems) + have PUXA: "P (\ (X ` A))" + using \finite A\ APX + by (induction) (auto simp: empty Un) + have "f (\ (X ` A0)) = f (X a \ \ (X ` A))" + by (simp add: *) + also have "... = f (X a) + f (\ (X ` A)) - f (X a \ \ (X ` A))" + using f_Un_Int add_diff_cancel PUXA \P (X a)\ by metis + also have "... = f (X a) - (\B | B \ A \ B \ {}. (- 1) ^ card B * f (\ (X ` B))) + + (\B | B \ A \ B \ {}. (- 1) ^ card B * f (X a \ \ (X ` B)))" + proof - + have 1: "f (\i\A. X a \ X i) = (\B | B \ A \ B \ {}. (- 1) ^ (card B + 1) * f (\b\B. X a \ X b))" + using less.IH [of n A "\i. X a \ X i"] APX Int \P (X a)\ by (simp add: *) + have 2: "X a \ \ (X ` A) = (\i\A. X a \ X i)" + by auto + have 3: "f (\ (X ` A)) = (\B | B \ A \ B \ {}. (- 1) ^ (card B + 1) * f (\ (X ` B)))" + using less.IH [of n A X] APX Int \P (X a)\ by (simp add: *) + show ?thesis + unfolding 3 2 1 + by (simp add: sum_negf) + qed + also have "... = (\B | B \ A0 \ B \ {}. (- 1) ^ (card B + 1) * f (\ (X ` B)))" + proof - + have F: "{insert a B |B. B \ A} = insert a ` Pow A \ {B. B \ A \ B \ {}} = Pow A - {{}}" + by auto + have G: "(\B\Pow A. (- 1) ^ card (insert a B) * f (X a \ \ (X ` B))) = (\B\Pow A. - ((- 1) ^ card B * f (X a \ \ (X ` B))))" + proof (rule sum.cong [OF refl]) + fix B + assume B: "B \ Pow A" + then have "finite B" + using \finite A\ finite_subset by auto + show "(- 1) ^ card (insert a B) * f (X a \ \ (X ` B)) = - ((- 1) ^ card B * f (X a \ \ (X ` B)))" + using B * by (auto simp add: card_insert_if \finite B\) + qed + have disj: "{B. B \ A \ B \ {}} \ {insert a B |B. B \ A} = {}" + using * by blast + have inj: "inj_on (insert a) (Pow A)" + using "*" inj_on_def by fastforce + show ?thesis + apply (simp add: * subset_insert_lemma sum.union_disjoint disj sum_negf) + apply (simp add: F G sum_negf sum.reindex [OF inj] o_def sum_diff *) + done + qed + finally show ?thesis . + qed + qed + then show ?thesis + by (meson assms) +qed + +lemma restricted: + assumes "finite A" "\a. a \ A \ P a" + shows "f(\ A) = (\B | B \ A \ B \ {}. (- 1) ^ (card B + 1) * f (\ B))" + using restricted_indexed [of A "\x. x"] assms by auto + +end + +subsection\Versions for unrestrictedly additive functions\ + +lemma Incl_Excl_UN: + fixes f :: "'a set \ 'b::ring_1" + assumes "\S T. disjnt S T \ f(S \ T) = f S + f T" "finite A" + shows "f(\(G ` A)) = (\B | B \ A \ B \ {}. (-1) ^ (card B + 1) * f (\ (G ` B)))" +proof - + interpret Incl_Excl "\x. True" f + by (simp add: Incl_Excl.intro assms(1)) + show ?thesis + using restricted_indexed assms by blast +qed + +lemma Incl_Excl_Union: + fixes f :: "'a set \ 'b::ring_1" + assumes "\S T. disjnt S T \ f(S \ T) = f S + f T" "finite A" + shows "f(\ A) = (\B | B \ A \ B \ {}. (- 1) ^ (card B + 1) * f (\ B))" + using Incl_Excl_UN[of f A "\X. X"] assms by simp text \The famous inclusion-exclusion formula for the cardinality of a union\ lemma int_card_UNION: - assumes "finite A" - and "\k \ A. finite k" + assumes "finite A" "\K. K \ A \ finite K" shows "int (card (\A)) = (\I | I \ A \ I \ {}. (- 1) ^ (card I + 1) * int (card (\I)))" - (is "?lhs = ?rhs") +proof - + interpret Incl_Excl finite "int o card" + proof qed (auto simp add: card_Un_disjnt) + show ?thesis + using restricted assms by auto +qed + +text\A more conventional form\ +lemma inclusion_exclusion: + assumes "finite A" "\K. K \ A \ finite K" + shows "int(card(\ A)) = + (\n=1..card A. (-1) ^ (Suc n) * (\B | B \ A \ card B = n. int (card (\ B))))" (is "_=?R") proof - - have "?rhs = (\I | I \ A \ I \ {}. (- 1) ^ (card I + 1) * (\_\\I. 1))" - by simp - also have "\ = (\I | I \ A \ I \ {}. (\_\\I. (- 1) ^ (card I + 1)))" - by (subst sum_distrib_left) simp - also have "\ = (\(I, _)\Sigma {I. I \ A \ I \ {}} Inter. (- 1) ^ (card I + 1))" - using assms by (subst sum.Sigma) auto - also have "\ = (\(x, I)\(SIGMA x:UNIV. {I. I \ A \ I \ {} \ x \ \I}). (- 1) ^ (card I + 1))" - by (rule sum.reindex_cong [where l = "\(x, y). (y, x)"]) (auto intro: inj_onI) - also have "\ = (\(x, I)\(SIGMA x:\A. {I. I \ A \ I \ {} \ x \ \I}). (- 1) ^ (card I + 1))" - using assms - by (auto intro!: sum.mono_neutral_cong_right finite_SigmaI2 intro: finite_subset[where B="\A"]) - also have "\ = (\x\\A. (\I|I \ A \ I \ {} \ x \ \I. (- 1) ^ (card I + 1)))" - using assms by (subst sum.Sigma) auto - also have "\ = (\_\\A. 1)" (is "sum ?lhs _ = _") - proof (rule sum.cong[OF refl]) - fix x - assume x: "x \ \A" - define K where "K = {X \ A. x \ X}" - with \finite A\ have K: "finite K" - by auto - let ?I = "\i. {I. I \ A \ card I = i \ x \ \I}" - have "inj_on snd (SIGMA i:{1..card A}. ?I i)" - using assms by (auto intro!: inj_onI) - moreover have [symmetric]: "snd ` (SIGMA i:{1..card A}. ?I i) = {I. I \ A \ I \ {} \ x \ \I}" - using assms - by (auto intro!: rev_image_eqI[where x="(card a, a)" for a] - simp add: card_gt_0_iff[folded Suc_le_eq] - dest: finite_subset intro: card_mono) - ultimately have "?lhs x = (\(i, I)\(SIGMA i:{1..card A}. ?I i). (- 1) ^ (i + 1))" - by (rule sum.reindex_cong [where l = snd]) fastforce - also have "\ = (\i=1..card A. (\I|I \ A \ card I = i \ x \ \I. (- 1) ^ (i + 1)))" - using assms by (subst sum.Sigma) auto - also have "\ = (\i=1..card A. (- 1) ^ (i + 1) * (\I|I \ A \ card I = i \ x \ \I. 1))" - by (subst sum_distrib_left) simp - also have "\ = (\i=1..card K. (- 1) ^ (i + 1) * (\I|I \ K \ card I = i. 1))" - (is "_ = ?rhs") - proof (rule sum.mono_neutral_cong_right[rule_format]) - show "finite {1..card A}" - by simp - show "{1..card K} \ {1..card A}" - using \finite A\ by (auto simp add: K_def intro: card_mono) - next - fix i - assume "i \ {1..card A} - {1..card K}" - then have i: "i \ card A" "card K < i" - by auto - have "{I. I \ A \ card I = i \ x \ \I} = {I. I \ K \ card I = i}" - by (auto simp add: K_def) - also have "\ = {}" - using \finite A\ i by (auto simp add: K_def dest: card_mono[rotated 1]) - finally show "(- 1) ^ (i + 1) * (\I | I \ A \ card I = i \ x \ \I. 1 :: int) = 0" - by (metis mult_zero_right sum.empty) - next - fix i - have "(\I | I \ A \ card I = i \ x \ \I. 1) = (\I | I \ K \ card I = i. 1 :: int)" - (is "?lhs = ?rhs") - by (rule sum.cong) (auto simp add: K_def) - then show "(- 1) ^ (i + 1) * ?lhs = (- 1) ^ (i + 1) * ?rhs" - by simp - qed - also have "{I. I \ K \ card I = 0} = {{}}" - using assms by (auto simp add: card_eq_0_iff K_def dest: finite_subset) - then have "?rhs = (\i = 0..card K. (- 1) ^ (i + 1) * (\I | I \ K \ card I = i. 1 :: int)) + 1" - by (subst (2) sum.atLeast_Suc_atMost) simp_all - also have "\ = (\i = 0..card K. (- 1) * ((- 1) ^ i * int (card K choose i))) + 1" - using K by (subst n_subsets[symmetric]) simp_all - also have "\ = - (\i = 0..card K. (- 1) ^ i * int (card K choose i)) + 1" - by (subst sum_distrib_left[symmetric]) simp - also have "\ = - ((-1 + 1) ^ card K) + 1" - by (subst binomial_ring) (simp add: ac_simps atMost_atLeast0) - also have "\ = 1" - using x K by (auto simp add: K_def card_gt_0_iff) - finally show "?lhs x = 1" . + have fin: "finite {I. I \ A \ I \ {}}" + by (simp add: assms) + have "\k. \Suc 0 \ k; k \ card A\ \ \B\A. B \ {} \ k = card B" + by (metis (mono_tags, lifting) Suc_le_D Zero_neq_Suc card_eq_0_iff obtain_subset_with_card_n) + with \finite A\ finite_subset + have card_eq: "card ` {I. I \ A \ I \ {}} = {1..card A}" + using not_less_eq_eq card_mono by (fastforce simp: image_iff) + have "int(card(\ A)) + = (\y = 1..card A. \I\{x. x \ A \ x \ {} \ card x = y}. - ((- 1) ^ y * int (card (\ I))))" + by (simp add: int_card_UNION assms sum.image_gen [OF fin, where g=card] card_eq) + also have "... = ?R" + proof - + have "{B. B \ A \ B \ {} \ card B = k} = {B. B \ A \ card B = k}" + if "Suc 0 \ k" and "k \ card A" for k + using that by auto + then show ?thesis + by (clarsimp simp add: sum_negf simp flip: sum_distrib_left) qed - also have "\ = int (card (\A))" - by simp - finally show ?thesis .. + finally show ?thesis . qed lemma card_UNION: - assumes "finite A" - and "\k \ A. finite k" + assumes "finite A" and "\K. K \ A \ finite K" shows "card (\A) = nat (\I | I \ A \ I \ {}. (- 1) ^ (card I + 1) * int (card (\I)))" by (simp only: flip: int_card_UNION [OF assms]) lemma card_UNION_nonneg: - assumes "finite A" - and "\k \ A. finite k" + assumes "finite A" and "\K. K \ A \ finite K" shows "(\I | I \ A \ I \ {}. (- 1) ^ (card I + 1) * int (card (\I))) \ 0" using int_card_UNION [OF assms] by presburger +subsection \More on Binomial Coefficients\ + text \The number of nat lists of length \m\ summing to \N\ is \<^term>\(N + m - 1) choose N\:\ lemma card_length_sum_list_rec: assumes "m \ 1" diff -r 0d065af1a99c -r 4da1e18a9633 src/HOL/Real_Vector_Spaces.thy --- a/src/HOL/Real_Vector_Spaces.thy Sat Sep 09 17:18:52 2023 +0100 +++ b/src/HOL/Real_Vector_Spaces.thy Sat Sep 09 19:26:08 2023 +0100 @@ -142,7 +142,7 @@ lemma scaleR_minus1_left [simp]: "scaleR (-1) x = - x" for x :: "'a::real_vector" - using scaleR_minus_left [of 1 x] by simp + by simp lemma scaleR_2: fixes x :: "'a::real_vector" @@ -786,6 +786,11 @@ class real_normed_div_algebra = real_div_algebra + real_normed_vector + assumes norm_mult: "norm (x * y) = norm x * norm y" +lemma divideR_right: + fixes x y :: "'a::real_normed_vector" + shows "r \ 0 \ y = x /\<^sub>R r \ r *\<^sub>R y = x" + by auto + class real_normed_field = real_field + real_normed_div_algebra instance real_normed_div_algebra < real_normed_algebra_1