# HG changeset patch # User paulson # Date 1524859174 -3600 # Node ID e98988801fa9d06eb734e6066dd51a3a037323e6 # Parent 68def9274939821e2bae01db990a2cda4770d899 another big cleanup diff -r 68def9274939 -r e98988801fa9 src/HOL/Analysis/Convex_Euclidean_Space.thy --- a/src/HOL/Analysis/Convex_Euclidean_Space.thy Fri Apr 27 12:43:05 2018 +0100 +++ b/src/HOL/Analysis/Convex_Euclidean_Space.thy Fri Apr 27 20:59:34 2018 +0100 @@ -4893,112 +4893,77 @@ subsection%unimportant \Openness and compactness are preserved by convex hull operation\ lemma open_convex_hull[intro]: - fixes s :: "'a::real_normed_vector set" - assumes "open s" - shows "open (convex hull s)" - unfolding open_contains_cball convex_hull_explicit - unfolding mem_Collect_eq ball_simps(8) -proof (rule, rule) - fix a - assume "\sa u. finite sa \ sa \ s \ (\x\sa. 0 \ u x) \ sum u sa = 1 \ (\v\sa. u v *\<^sub>R v) = a" - then obtain t u where obt: "finite t" "t\s" "\x\t. 0 \ u x" "sum u t = 1" "(\v\t. u v *\<^sub>R v) = a" - by auto + fixes S :: "'a::real_normed_vector set" + assumes "open S" + shows "open (convex hull S)" +proof (clarsimp simp: open_contains_cball convex_hull_explicit) + fix T and u :: "'a\real" + assume obt: "finite T" "T\S" "\x\T. 0 \ u x" "sum u T = 1" from assms[unfolded open_contains_cball] obtain b - where b: "\x\s. 0 < b x \ cball x (b x) \ s" - using bchoice[of s "\x e. e > 0 \ cball x e \ s"] by auto - have "b ` t \ {}" + where b: "\x. x\S \ 0 < b x \ cball x (b x) \ S" by metis + have "b ` T \ {}" using obt by auto - define i where "i = b ` t" - - show "\e > 0. - cball a e \ {y. \sa u. finite sa \ sa \ s \ (\x\sa. 0 \ u x) \ sum u sa = 1 \ (\v\sa. u v *\<^sub>R v) = y}" - apply (rule_tac x = "Min i" in exI) - unfolding subset_eq - apply rule - defer - apply rule - unfolding mem_Collect_eq - proof - + define i where "i = b ` T" + let ?\ = "\y. \F. finite F \ F \ S \ (\u. (\x\F. 0 \ u x) \ sum u F = 1 \ (\v\F. u v *\<^sub>R v) = y)" + let ?a = "\v\T. u v *\<^sub>R v" + show "\e > 0. cball ?a e \ {y. ?\ y}" + proof (intro exI subsetI conjI) show "0 < Min i" - unfolding i_def and Min_gr_iff[OF finite_imageI[OF obt(1)] \b ` t\{}\] - using b - apply simp - apply rule - apply (erule_tac x=x in ballE) - using \t\s\ - apply auto - done + unfolding i_def and Min_gr_iff[OF finite_imageI[OF obt(1)] \b ` T\{}\] + using b \T\S\ by auto next fix y - assume "y \ cball a (Min i)" - then have y: "norm (a - y) \ Min i" + assume "y \ cball ?a (Min i)" + then have y: "norm (?a - y) \ Min i" unfolding dist_norm[symmetric] by auto - { - fix x - assume "x \ t" + { fix x + assume "x \ T" then have "Min i \ b x" - unfolding i_def - apply (rule_tac Min_le) - using obt(1) - apply auto - done - then have "x + (y - a) \ cball x (b x)" + by (simp add: i_def obt(1)) + then have "x + (y - ?a) \ cball x (b x)" using y unfolding mem_cball dist_norm by auto - moreover from \x\t\ have "x \ s" - using obt(2) by auto - ultimately have "x + (y - a) \ s" - using y and b[THEN bspec[where x=x]] unfolding subset_eq by fast + moreover have "x \ S" + using \x\T\ \T\S\ by auto + ultimately have "x + (y - ?a) \ S" + using y b by blast } moreover - have *: "inj_on (\v. v + (y - a)) t" + have *: "inj_on (\v. v + (y - ?a)) T" unfolding inj_on_def by auto - have "(\v\(\v. v + (y - a)) ` t. u (v - (y - a))) = 1" - unfolding sum.reindex[OF *] o_def using obt(4) by auto - moreover have "(\v\(\v. v + (y - a)) ` t. u (v - (y - a)) *\<^sub>R v) = y" - unfolding sum.reindex[OF *] o_def using obt(4,5) + have "(\v\(\v. v + (y - ?a)) ` T. u (v - (y - ?a)) *\<^sub>R v) = y" + unfolding sum.reindex[OF *] o_def using obt(4) by (simp add: sum.distrib sum_subtractf scaleR_left.sum[symmetric] scaleR_right_distrib) - ultimately - show "\sa u. finite sa \ (\x\sa. x \ s) \ (\x\sa. 0 \ u x) \ sum u sa = 1 \ (\v\sa. u v *\<^sub>R v) = y" - apply (rule_tac x="(\v. v + (y - a)) ` t" in exI) - apply (rule_tac x="\v. u (v - (y - a))" in exI) - using obt(1, 3) - apply auto - done + ultimately show "y \ {y. ?\ y}" + proof (intro CollectI exI conjI) + show "finite ((\v. v + (y - ?a)) ` T)" + by (simp add: obt(1)) + show "sum (\v. u (v - (y - ?a))) ((\v. v + (y - ?a)) ` T) = 1" + unfolding sum.reindex[OF *] o_def using obt(4) by auto + qed (use obt(1, 3) in auto) qed qed lemma compact_convex_combinations: - fixes s t :: "'a::real_normed_vector set" - assumes "compact s" "compact t" - shows "compact { (1 - u) *\<^sub>R x + u *\<^sub>R y | x y u. 0 \ u \ u \ 1 \ x \ s \ y \ t}" + fixes S T :: "'a::real_normed_vector set" + assumes "compact S" "compact T" + shows "compact { (1 - u) *\<^sub>R x + u *\<^sub>R y | x y u. 0 \ u \ u \ 1 \ x \ S \ y \ T}" proof - - let ?X = "{0..1} \ s \ t" + let ?X = "{0..1} \ S \ T" let ?h = "(\z. (1 - fst z) *\<^sub>R fst (snd z) + fst z *\<^sub>R snd (snd z))" - have *: "{ (1 - u) *\<^sub>R x + u *\<^sub>R y | x y u. 0 \ u \ u \ 1 \ x \ s \ y \ t} = ?h ` ?X" - apply (rule set_eqI) - unfolding image_iff mem_Collect_eq - apply rule - apply auto - apply (rule_tac x=u in rev_bexI, simp) - apply (erule rev_bexI) - apply (erule rev_bexI, simp) - apply auto - done + have *: "{ (1 - u) *\<^sub>R x + u *\<^sub>R y | x y u. 0 \ u \ u \ 1 \ x \ S \ y \ T} = ?h ` ?X" + by force have "continuous_on ?X (\z. (1 - fst z) *\<^sub>R fst (snd z) + fst z *\<^sub>R snd (snd z))" unfolding continuous_on by (rule ballI) (intro tendsto_intros) - then show ?thesis - unfolding * - apply (rule compact_continuous_image) - apply (intro compact_Times compact_Icc assms) - done + with assms show ?thesis + by (simp add: * compact_Times compact_continuous_image) qed lemma finite_imp_compact_convex_hull: - fixes s :: "'a::real_normed_vector set" - assumes "finite s" - shows "compact (convex hull s)" -proof (cases "s = {}") + fixes S :: "'a::real_normed_vector set" + assumes "finite S" + shows "compact (convex hull S)" +proof (cases "S = {}") case True then show ?thesis by simp next @@ -5029,20 +4994,20 @@ qed lemma compact_convex_hull: - fixes s :: "'a::euclidean_space set" - assumes "compact s" - shows "compact (convex hull s)" -proof (cases "s = {}") + fixes S :: "'a::euclidean_space set" + assumes "compact S" + shows "compact (convex hull S)" +proof (cases "S = {}") case True then show ?thesis using compact_empty by simp next case False - then obtain w where "w \ s" by auto + then obtain w where "w \ S" by auto show ?thesis - unfolding caratheodory[of s] + unfolding caratheodory[of S] proof (induct ("DIM('a) + 1")) case 0 - have *: "{x.\sa. finite sa \ sa \ s \ card sa \ 0 \ x \ convex hull sa} = {}" + have *: "{x.\sa. finite sa \ sa \ S \ card sa \ 0 \ x \ convex hull sa} = {}" using compact_empty by auto from 0 show ?case unfolding * by simp next @@ -5050,27 +5015,27 @@ show ?case proof (cases "n = 0") case True - have "{x. \t. finite t \ t \ s \ card t \ Suc n \ x \ convex hull t} = s" + have "{x. \T. finite T \ T \ S \ card T \ Suc n \ x \ convex hull T} = S" unfolding set_eq_iff and mem_Collect_eq proof (rule, rule) fix x - assume "\t. finite t \ t \ s \ card t \ Suc n \ x \ convex hull t" - then obtain t where t: "finite t" "t \ s" "card t \ Suc n" "x \ convex hull t" + assume "\T. finite T \ T \ S \ card T \ Suc n \ x \ convex hull T" + then obtain T where T: "finite T" "T \ S" "card T \ Suc n" "x \ convex hull T" by auto - show "x \ s" - proof (cases "card t = 0") + show "x \ S" + proof (cases "card T = 0") case True then show ?thesis - using t(4) unfolding card_0_eq[OF t(1)] by simp + using T(4) unfolding card_0_eq[OF T(1)] by simp next case False - then have "card t = Suc 0" using t(3) \n=0\ by auto - then obtain a where "t = {a}" unfolding card_Suc_eq by auto - then show ?thesis using t(2,4) by simp + then have "card T = Suc 0" using T(3) \n=0\ by auto + then obtain a where "T = {a}" unfolding card_Suc_eq by auto + then show ?thesis using T(2,4) by simp qed next - fix x assume "x\s" - then show "\t. finite t \ t \ s \ card t \ Suc n \ x \ convex hull t" + fix x assume "x\S" + then show "\T. finite T \ T \ S \ card T \ Suc n \ x \ convex hull T" apply (rule_tac x="{x}" in exI) unfolding convex_hull_singleton apply auto @@ -5079,56 +5044,56 @@ then show ?thesis using assms by simp next case False - have "{x. \t. finite t \ t \ s \ card t \ Suc n \ x \ convex hull t} = + have "{x. \T. finite T \ T \ S \ card T \ Suc n \ x \ convex hull T} = {(1 - u) *\<^sub>R x + u *\<^sub>R y | x y u. - 0 \ u \ u \ 1 \ x \ s \ y \ {x. \t. finite t \ t \ s \ card t \ n \ x \ convex hull t}}" + 0 \ u \ u \ 1 \ x \ S \ y \ {x. \T. finite T \ T \ S \ card T \ n \ x \ convex hull T}}" unfolding set_eq_iff and mem_Collect_eq proof (rule, rule) fix x assume "\u v c. x = (1 - c) *\<^sub>R u + c *\<^sub>R v \ - 0 \ c \ c \ 1 \ u \ s \ (\t. finite t \ t \ s \ card t \ n \ v \ convex hull t)" - then obtain u v c t where obt: "x = (1 - c) *\<^sub>R u + c *\<^sub>R v" - "0 \ c \ c \ 1" "u \ s" "finite t" "t \ s" "card t \ n" "v \ convex hull t" + 0 \ c \ c \ 1 \ u \ S \ (\T. finite T \ T \ S \ card T \ n \ v \ convex hull T)" + then obtain u v c T where obt: "x = (1 - c) *\<^sub>R u + c *\<^sub>R v" + "0 \ c \ c \ 1" "u \ S" "finite T" "T \ S" "card T \ n" "v \ convex hull T" by auto - moreover have "(1 - c) *\<^sub>R u + c *\<^sub>R v \ convex hull insert u t" + moreover have "(1 - c) *\<^sub>R u + c *\<^sub>R v \ convex hull insert u T" apply (rule convexD_alt) - using obt(2) and convex_convex_hull and hull_subset[of "insert u t" convex] - using obt(7) and hull_mono[of t "insert u t"] + using obt(2) and convex_convex_hull and hull_subset[of "insert u T" convex] + using obt(7) and hull_mono[of T "insert u T"] apply auto done - ultimately show "\t. finite t \ t \ s \ card t \ Suc n \ x \ convex hull t" - apply (rule_tac x="insert u t" in exI) + ultimately show "\T. finite T \ T \ S \ card T \ Suc n \ x \ convex hull T" + apply (rule_tac x="insert u T" in exI) apply (auto simp: card_insert_if) done next fix x - assume "\t. finite t \ t \ s \ card t \ Suc n \ x \ convex hull t" - then obtain t where t: "finite t" "t \ s" "card t \ Suc n" "x \ convex hull t" + assume "\T. finite T \ T \ S \ card T \ Suc n \ x \ convex hull T" + then obtain T where T: "finite T" "T \ S" "card T \ Suc n" "x \ convex hull T" by auto show "\u v c. x = (1 - c) *\<^sub>R u + c *\<^sub>R v \ - 0 \ c \ c \ 1 \ u \ s \ (\t. finite t \ t \ s \ card t \ n \ v \ convex hull t)" - proof (cases "card t = Suc n") + 0 \ c \ c \ 1 \ u \ S \ (\T. finite T \ T \ S \ card T \ n \ v \ convex hull T)" + proof (cases "card T = Suc n") case False - then have "card t \ n" using t(3) by auto + then have "card T \ n" using T(3) by auto then show ?thesis apply (rule_tac x=w in exI, rule_tac x=x in exI, rule_tac x=1 in exI) - using \w\s\ and t - apply (auto intro!: exI[where x=t]) + using \w\S\ and T + apply (auto intro!: exI[where x=T]) done next case True - then obtain a u where au: "t = insert a u" "a\u" + then obtain a u where au: "T = insert a u" "a\u" apply (drule_tac card_eq_SucD, auto) done show ?thesis proof (cases "u = {}") case True - then have "x = a" using t(4)[unfolded au] by auto + then have "x = a" using T(4)[unfolded au] by auto show ?thesis unfolding \x = a\ apply (rule_tac x=a in exI) apply (rule_tac x=a in exI) apply (rule_tac x=1 in exI) - using t and \n \ 0\ + using T and \n \ 0\ unfolding au apply (auto intro!: exI[where x="{a}"]) done @@ -5136,14 +5101,14 @@ case False obtain ux vx b where obt: "ux\0" "vx\0" "ux + vx = 1" "b \ convex hull u" "x = ux *\<^sub>R a + vx *\<^sub>R b" - using t(4)[unfolded au convex_hull_insert[OF False]] + using T(4)[unfolded au convex_hull_insert[OF False]] by auto have *: "1 - vx = ux" using obt(3) by auto show ?thesis apply (rule_tac x=a in exI) apply (rule_tac x=b in exI) apply (rule_tac x=vx in exI) - using obt and t(1-3) + using obt and T(1-3) unfolding au and * using card_insert_disjoint[OF _ au(2)] apply (auto intro!: exI[where x=u]) done @@ -5195,25 +5160,25 @@ using dist_increases_online[of d a 0] unfolding dist_norm by auto lemma simplex_furthest_lt: - fixes s :: "'a::real_inner set" - assumes "finite s" - shows "\x \ convex hull s. x \ s \ (\y \ convex hull s. norm (x - a) < norm(y - a))" + fixes S :: "'a::real_inner set" + assumes "finite S" + shows "\x \ convex hull S. x \ S \ (\y \ convex hull S. norm (x - a) < norm(y - a))" using assms proof induct - fix x s - assume as: "finite s" "x\s" "\x\convex hull s. x \ s \ (\y\convex hull s. norm (x - a) < norm (y - a))" - show "\xa\convex hull insert x s. xa \ insert x s \ - (\y\convex hull insert x s. norm (xa - a) < norm (y - a))" - proof (rule, rule, cases "s = {}") + fix x S + assume as: "finite S" "x\S" "\x\convex hull S. x \ S \ (\y\convex hull S. norm (x - a) < norm (y - a))" + show "\xa\convex hull insert x S. xa \ insert x S \ + (\y\convex hull insert x S. norm (xa - a) < norm (y - a))" + proof (intro impI ballI, cases "S = {}") case False fix y - assume y: "y \ convex hull insert x s" "y \ insert x s" - obtain u v b where obt: "u\0" "v\0" "u + v = 1" "b \ convex hull s" "y = u *\<^sub>R x + v *\<^sub>R b" + assume y: "y \ convex hull insert x S" "y \ insert x S" + obtain u v b where obt: "u\0" "v\0" "u + v = 1" "b \ convex hull S" "y = u *\<^sub>R x + v *\<^sub>R b" using y(1)[unfolded convex_hull_insert[OF False]] by auto - show "\z\convex hull insert x s. norm (y - a) < norm (z - a)" - proof (cases "y \ convex hull s") + show "\z\convex hull insert x S. norm (y - a) < norm (z - a)" + proof (cases "y \ convex hull S") case True - then obtain z where "z \ convex hull s" "norm (y - a) < norm (z - a)" + then obtain z where "z \ convex hull S" "norm (y - a) < norm (z - a)" using as(3)[THEN bspec[where x=y]] and y(2) by auto then show ?thesis apply (rule_tac x=z in bexI) @@ -5252,14 +5217,12 @@ unfolding dist_commute[of a] unfolding dist_norm obt(5) by (simp add: algebra_simps) - moreover have "(u + w) *\<^sub>R x + (v - w) *\<^sub>R b \ convex hull insert x s" - unfolding convex_hull_insert[OF \s\{}\] and mem_Collect_eq - apply (rule_tac x="u + w" in exI, rule) - defer - apply (rule_tac x="v - w" in exI) - using \u \ 0\ and w and obt(3,4) - apply auto - done + moreover have "(u + w) *\<^sub>R x + (v - w) *\<^sub>R b \ convex hull insert x S" + unfolding convex_hull_insert[OF \S\{}\] + proof (intro CollectI conjI exI) + show "u + w \ 0" "v - w \ 0" + using obt(1) w by auto + qed (use obt in auto) ultimately show ?thesis by auto next assume "dist a y < dist a (y - w *\<^sub>R (x - b))" @@ -5267,14 +5230,12 @@ unfolding dist_commute[of a] unfolding dist_norm obt(5) by (simp add: algebra_simps) - moreover have "(u - w) *\<^sub>R x + (v + w) *\<^sub>R b \ convex hull insert x s" - unfolding convex_hull_insert[OF \s\{}\] and mem_Collect_eq - apply (rule_tac x="u - w" in exI, rule) - defer - apply (rule_tac x="v + w" in exI) - using \u \ 0\ and w and obt(3,4) - apply auto - done + moreover have "(u - w) *\<^sub>R x + (v + w) *\<^sub>R b \ convex hull insert x S" + unfolding convex_hull_insert[OF \S\{}\] + proof (intro CollectI conjI exI) + show "u - w \ 0" "v + w \ 0" + using obt(1) w by auto + qed (use obt in auto) ultimately show ?thesis by auto qed qed auto @@ -5283,22 +5244,22 @@ qed (auto simp: assms) lemma simplex_furthest_le: - fixes s :: "'a::real_inner set" - assumes "finite s" - and "s \ {}" - shows "\y\s. \x\ convex hull s. norm (x - a) \ norm (y - a)" + fixes S :: "'a::real_inner set" + assumes "finite S" + and "S \ {}" + shows "\y\S. \x\ convex hull S. norm (x - a) \ norm (y - a)" proof - - have "convex hull s \ {}" - using hull_subset[of s convex] and assms(2) by auto - then obtain x where x: "x \ convex hull s" "\y\convex hull s. norm (y - a) \ norm (x - a)" - using distance_attains_sup[OF finite_imp_compact_convex_hull[OF assms(1)], of a] + have "convex hull S \ {}" + using hull_subset[of S convex] and assms(2) by auto + then obtain x where x: "x \ convex hull S" "\y\convex hull S. norm (y - a) \ norm (x - a)" + using distance_attains_sup[OF finite_imp_compact_convex_hull[OF \finite S\], of a] unfolding dist_commute[of a] unfolding dist_norm by auto show ?thesis - proof (cases "x \ s") + proof (cases "x \ S") case False - then obtain y where "y \ convex hull s" "norm (x - a) < norm (y - a)" + then obtain y where "y \ convex hull S" "norm (x - a) < norm (y - a)" using simplex_furthest_lt[OF assms(1), THEN bspec[where x=x]] and x(1) by auto then show ?thesis @@ -5310,34 +5271,34 @@ qed lemma simplex_furthest_le_exists: - fixes s :: "('a::real_inner) set" - shows "finite s \ \x\(convex hull s). \y\s. norm (x - a) \ norm (y - a)" - using simplex_furthest_le[of s] by (cases "s = {}") auto + fixes S :: "('a::real_inner) set" + shows "finite S \ \x\(convex hull S). \y\S. norm (x - a) \ norm (y - a)" + using simplex_furthest_le[of S] by (cases "S = {}") auto lemma simplex_extremal_le: - fixes s :: "'a::real_inner set" - assumes "finite s" - and "s \ {}" - shows "\u\s. \v\s. \x\convex hull s. \y \ convex hull s. norm (x - y) \ norm (u - v)" + fixes S :: "'a::real_inner set" + assumes "finite S" + and "S \ {}" + shows "\u\S. \v\S. \x\convex hull S. \y \ convex hull S. norm (x - y) \ norm (u - v)" proof - - have "convex hull s \ {}" - using hull_subset[of s convex] and assms(2) by auto - then obtain u v where obt: "u \ convex hull s" "v \ convex hull s" - "\x\convex hull s. \y\convex hull s. norm (x - y) \ norm (u - v)" + have "convex hull S \ {}" + using hull_subset[of S convex] and assms(2) by auto + then obtain u v where obt: "u \ convex hull S" "v \ convex hull S" + "\x\convex hull S. \y\convex hull S. norm (x - y) \ norm (u - v)" using compact_sup_maxdistance[OF finite_imp_compact_convex_hull[OF assms(1)]] by (auto simp: dist_norm) then show ?thesis - proof (cases "u\s \ v\s", elim disjE) - assume "u \ s" - then obtain y where "y \ convex hull s" "norm (u - v) < norm (y - v)" + proof (cases "u\S \ v\S", elim disjE) + assume "u \ S" + then obtain y where "y \ convex hull S" "norm (u - v) < norm (y - v)" using simplex_furthest_lt[OF assms(1), THEN bspec[where x=u]] and obt(1) by auto then show ?thesis using obt(3)[THEN bspec[where x=y], THEN bspec[where x=v]] and obt(2) by auto next - assume "v \ s" - then obtain y where "y \ convex hull s" "norm (v - u) < norm (y - u)" + assume "v \ S" + then obtain y where "y \ convex hull S" "norm (v - u) < norm (y - u)" using simplex_furthest_lt[OF assms(1), THEN bspec[where x=v]] and obt(2) by auto then show ?thesis @@ -5347,45 +5308,45 @@ qed lemma simplex_extremal_le_exists: - fixes s :: "'a::real_inner set" - shows "finite s \ x \ convex hull s \ y \ convex hull s \ - \u\s. \v\s. norm (x - y) \ norm (u - v)" - using convex_hull_empty simplex_extremal_le[of s] - by(cases "s = {}") auto + fixes S :: "'a::real_inner set" + shows "finite S \ x \ convex hull S \ y \ convex hull S \ + \u\S. \v\S. norm (x - y) \ norm (u - v)" + using convex_hull_empty simplex_extremal_le[of S] + by(cases "S = {}") auto subsection \Closest point of a convex set is unique, with a continuous projection\ definition%important closest_point :: "'a::{real_inner,heine_borel} set \ 'a \ 'a" - where "closest_point s a = (SOME x. x \ s \ (\y\s. dist a x \ dist a y))" + where "closest_point S a = (SOME x. x \ S \ (\y\S. dist a x \ dist a y))" lemma closest_point_exists: - assumes "closed s" - and "s \ {}" - shows "closest_point s a \ s" - and "\y\s. dist a (closest_point s a) \ dist a y" + assumes "closed S" + and "S \ {}" + shows "closest_point S a \ S" + and "\y\S. dist a (closest_point S a) \ dist a y" unfolding closest_point_def apply(rule_tac[!] someI2_ex) apply (auto intro: distance_attains_inf[OF assms(1,2), of a]) done -lemma closest_point_in_set: "closed s \ s \ {} \ closest_point s a \ s" +lemma closest_point_in_set: "closed S \ S \ {} \ closest_point S a \ S" by (meson closest_point_exists) -lemma closest_point_le: "closed s \ x \ s \ dist a (closest_point s a) \ dist a x" - using closest_point_exists[of s] by auto +lemma closest_point_le: "closed S \ x \ S \ dist a (closest_point S a) \ dist a x" + using closest_point_exists[of S] by auto lemma closest_point_self: - assumes "x \ s" - shows "closest_point s x = x" + assumes "x \ S" + shows "closest_point S x = x" unfolding closest_point_def apply (rule some1_equality, rule ex1I[of _ x]) using assms apply auto done -lemma closest_point_refl: "closed s \ s \ {} \ closest_point s x = x \ x \ s" - using closest_point_in_set[of s x] closest_point_self[of x s] +lemma closest_point_refl: "closed S \ S \ {} \ closest_point S x = x \ x \ S" + using closest_point_in_set[of S x] closest_point_self[of x S] by auto lemma closer_points_lemma: @@ -5417,14 +5378,14 @@ qed lemma any_closest_point_dot: - assumes "convex s" "closed s" "x \ s" "y \ s" "\z\s. dist a x \ dist a z" + assumes "convex S" "closed S" "x \ S" "y \ S" "\z\S. dist a x \ dist a z" shows "inner (a - x) (y - x) \ 0" proof (rule ccontr) assume "\ ?thesis" then obtain u where u: "u>0" "u\1" "dist (x + u *\<^sub>R (y - x)) a < dist x a" using closer_point_lemma[of a x y] by auto let ?z = "(1 - u) *\<^sub>R x + u *\<^sub>R y" - have "?z \ s" + have "?z \ S" using convexD_alt[OF assms(1,3,4), of u] using u by auto then show False using assms(5)[THEN bspec[where x="?z"]] and u(3) @@ -5433,30 +5394,30 @@ lemma any_closest_point_unique: fixes x :: "'a::real_inner" - assumes "convex s" "closed s" "x \ s" "y \ s" - "\z\s. dist a x \ dist a z" "\z\s. dist a y \ dist a z" + assumes "convex S" "closed S" "x \ S" "y \ S" + "\z\S. dist a x \ dist a z" "\z\S. dist a y \ dist a z" shows "x = y" using any_closest_point_dot[OF assms(1-4,5)] and any_closest_point_dot[OF assms(1-2,4,3,6)] unfolding norm_pths(1) and norm_le_square by (auto simp: algebra_simps) lemma closest_point_unique: - assumes "convex s" "closed s" "x \ s" "\z\s. dist a x \ dist a z" - shows "x = closest_point s a" - using any_closest_point_unique[OF assms(1-3) _ assms(4), of "closest_point s a"] + assumes "convex S" "closed S" "x \ S" "\z\S. dist a x \ dist a z" + shows "x = closest_point S a" + using any_closest_point_unique[OF assms(1-3) _ assms(4), of "closest_point S a"] using closest_point_exists[OF assms(2)] and assms(3) by auto lemma closest_point_dot: - assumes "convex s" "closed s" "x \ s" - shows "inner (a - closest_point s a) (x - closest_point s a) \ 0" + assumes "convex S" "closed S" "x \ S" + shows "inner (a - closest_point S a) (x - closest_point S a) \ 0" apply (rule any_closest_point_dot[OF assms(1,2) _ assms(3)]) using closest_point_exists[OF assms(2)] and assms(3) apply auto done lemma closest_point_lt: - assumes "convex s" "closed s" "x \ s" "x \ closest_point s a" - shows "dist a (closest_point s a) < dist a x" + assumes "convex S" "closed S" "x \ S" "x \ closest_point S a" + shows "dist a (closest_point S a) < dist a x" apply (rule ccontr) apply (rule_tac notE[OF assms(4)]) apply (rule closest_point_unique[OF assms(1-3), of a]) @@ -5465,34 +5426,34 @@ done lemma closest_point_lipschitz: - assumes "convex s" - and "closed s" "s \ {}" - shows "dist (closest_point s x) (closest_point s y) \ dist x y" + assumes "convex S" + and "closed S" "S \ {}" + shows "dist (closest_point S x) (closest_point S y) \ dist x y" proof - - have "inner (x - closest_point s x) (closest_point s y - closest_point s x) \ 0" - and "inner (y - closest_point s y) (closest_point s x - closest_point s y) \ 0" + have "inner (x - closest_point S x) (closest_point S y - closest_point S x) \ 0" + and "inner (y - closest_point S y) (closest_point S x - closest_point S y) \ 0" apply (rule_tac[!] any_closest_point_dot[OF assms(1-2)]) using closest_point_exists[OF assms(2-3)] apply auto done then show ?thesis unfolding dist_norm and norm_le - using inner_ge_zero[of "(x - closest_point s x) - (y - closest_point s y)"] + using inner_ge_zero[of "(x - closest_point S x) - (y - closest_point S y)"] by (simp add: inner_add inner_diff inner_commute) qed lemma continuous_at_closest_point: - assumes "convex s" - and "closed s" - and "s \ {}" - shows "continuous (at x) (closest_point s)" + assumes "convex S" + and "closed S" + and "S \ {}" + shows "continuous (at x) (closest_point S)" unfolding continuous_at_eps_delta using le_less_trans[OF closest_point_lipschitz[OF assms]] by auto lemma continuous_on_closest_point: - assumes "convex s" - and "closed s" - and "s \ {}" - shows "continuous_on t (closest_point s)" + assumes "convex S" + and "closed S" + and "S \ {}" + shows "continuous_on t (closest_point S)" by (metis continuous_at_imp_continuous_on continuous_at_closest_point[OF assms]) proposition closest_point_in_rel_interior: @@ -5543,119 +5504,84 @@ lemma supporting_hyperplane_closed_point: fixes z :: "'a::{real_inner,heine_borel}" - assumes "convex s" - and "closed s" - and "s \ {}" - and "z \ s" - shows "\a b. \y\s. inner a z < b \ inner a y = b \ (\x\s. inner a x \ b)" + assumes "convex S" + and "closed S" + and "S \ {}" + and "z \ S" + shows "\a b. \y\S. inner a z < b \ inner a y = b \ (\x\S. inner a x \ b)" proof - - obtain y where "y \ s" and y: "\x\s. dist z y \ dist z x" + obtain y where "y \ S" and y: "\x\S. dist z y \ dist z x" by (metis distance_attains_inf[OF assms(2-3)]) show ?thesis - apply (rule_tac x="y - z" in exI) - apply (rule_tac x="inner (y - z) y" in exI) - apply (rule_tac x=y in bexI, rule) - defer - apply rule - defer - apply rule - apply (rule ccontr) - using \y \ s\ - proof - - show "inner (y - z) z < inner (y - z) y" - apply (subst diff_gt_0_iff_gt [symmetric]) - unfolding inner_diff_right[symmetric] and inner_gt_zero_iff - using \y\s\ \z\s\ - apply auto - done - next - fix x - assume "x \ s" - have *: "\u. 0 \ u \ u \ 1 \ dist z y \ dist z ((1 - u) *\<^sub>R y + u *\<^sub>R x)" - using assms(1)[unfolded convex_alt] and y and \x\s\ and \y\s\ by auto - assume "\ inner (y - z) y \ inner (y - z) x" - then obtain v where "v > 0" "v \ 1" "dist (y + v *\<^sub>R (x - y)) z < dist y z" - using closer_point_lemma[of z y x] by (auto simp: inner_diff) - then show False - using *[THEN spec[where x=v]] by (auto simp: dist_commute algebra_simps) - qed auto + proof (intro exI bexI conjI ballI) + show "(y - z) \ z < (y - z) \ y" + by (metis \y \ S\ assms(4) diff_gt_0_iff_gt inner_commute inner_diff_left inner_gt_zero_iff right_minus_eq) + show "(y - z) \ y \ (y - z) \ x" if "x \ S" for x + proof (rule ccontr) + have *: "\u. 0 \ u \ u \ 1 \ dist z y \ dist z ((1 - u) *\<^sub>R y + u *\<^sub>R x)" + using assms(1)[unfolded convex_alt] and y and \x\S\ and \y\S\ by auto + assume "\ (y - z) \ y \ (y - z) \ x" + then obtain v where "v > 0" "v \ 1" "dist (y + v *\<^sub>R (x - y)) z < dist y z" + using closer_point_lemma[of z y x] by (auto simp: inner_diff) + then show False + using *[of v] by (auto simp: dist_commute algebra_simps) + qed + qed (use \y \ S\ in auto) qed lemma separating_hyperplane_closed_point: fixes z :: "'a::{real_inner,heine_borel}" - assumes "convex s" - and "closed s" - and "z \ s" - shows "\a b. inner a z < b \ (\x\s. inner a x > b)" -proof (cases "s = {}") + assumes "convex S" + and "closed S" + and "z \ S" + shows "\a b. inner a z < b \ (\x\S. inner a x > b)" +proof (cases "S = {}") case True then show ?thesis - apply (rule_tac x="-z" in exI) - apply (rule_tac x=1 in exI) - using less_le_trans[OF _ inner_ge_zero[of z]] - apply auto - done + by (simp add: gt_ex) next case False - obtain y where "y \ s" and y: "\x\s. dist z y \ dist z x" + obtain y where "y \ S" and y: "\x. x \ S \ dist z y \ dist z x" by (metis distance_attains_inf[OF assms(2) False]) show ?thesis - apply (rule_tac x="y - z" in exI) - apply (rule_tac x="inner (y - z) z + (norm (y - z))\<^sup>2 / 2" in exI) - apply rule - defer - apply rule - proof - + proof (intro exI conjI ballI) + show "(y - z) \ z < inner (y - z) z + (norm (y - z))\<^sup>2 / 2" + using \y\S\ \z\S\ by auto + next fix x - assume "x \ s" - have "\ 0 < inner (z - y) (x - y)" - apply (rule notI) - apply (drule closer_point_lemma) + assume "x \ S" + have "False" if *: "0 < inner (z - y) (x - y)" proof - - assume "\u>0. u \ 1 \ dist (y + u *\<^sub>R (x - y)) z < dist y z" - then obtain u where "u > 0" "u \ 1" "dist (y + u *\<^sub>R (x - y)) z < dist y z" - by auto - then show False using y[THEN bspec[where x="y + u *\<^sub>R (x - y)"]] - using assms(1)[unfolded convex_alt, THEN bspec[where x=y]] - using \x\s\ \y\s\ by (auto simp: dist_commute algebra_simps) + obtain u where "u > 0" "u \ 1" "dist (y + u *\<^sub>R (x - y)) z < dist y z" + using * closer_point_lemma by blast + then show False using y[of "y + u *\<^sub>R (x - y)"] convexD_alt [OF \convex S\] + using \x\S\ \y\S\ by (auto simp: dist_commute algebra_simps) qed moreover have "0 < (norm (y - z))\<^sup>2" - using \y\s\ \z\s\ by auto + using \y\S\ \z\S\ by auto then have "0 < inner (y - z) (y - z)" unfolding power2_norm_eq_inner by simp - ultimately show "inner (y - z) z + (norm (y - z))\<^sup>2 / 2 < inner (y - z) x" - unfolding power2_norm_eq_inner and not_less - by (auto simp: field_simps inner_commute inner_diff) - qed (insert \y\s\ \z\s\, auto) + ultimately show "(y - z) \ z + (norm (y - z))\<^sup>2 / 2 < (y - z) \ x" + by (force simp: field_simps power2_norm_eq_inner inner_commute inner_diff) + qed qed lemma separating_hyperplane_closed_0: - assumes "convex (s::('a::euclidean_space) set)" - and "closed s" - and "0 \ s" - shows "\a b. a \ 0 \ 0 < b \ (\x\s. inner a x > b)" -proof (cases "s = {}") + assumes "convex (S::('a::euclidean_space) set)" + and "closed S" + and "0 \ S" + shows "\a b. a \ 0 \ 0 < b \ (\x\S. inner a x > b)" +proof (cases "S = {}") case True - have "norm ((SOME i. i\Basis)::'a) = 1" "(SOME i. i\Basis) \ (0::'a)" - defer - apply (subst norm_le_zero_iff[symmetric]) - apply (auto simp: SOME_Basis) - done + have "(SOME i. i\Basis) \ (0::'a)" + by (metis Basis_zero SOME_Basis) then show ?thesis - apply (rule_tac x="SOME i. i\Basis" in exI) - apply (rule_tac x=1 in exI) - using True using DIM_positive[where 'a='a] - apply auto - done + using True zero_less_one by blast next case False then show ?thesis using False using separating_hyperplane_closed_point[OF assms] - apply (elim exE) - unfolding inner_zero_right - apply (rule_tac x=a in exI) - apply (rule_tac x=b in exI, auto) - done + by (metis all_not_in_conv inner_zero_left inner_zero_right less_eq_real_def not_le) qed @@ -5826,19 +5752,13 @@ assumes "convex S" shows "convex (interior S)" unfolding convex_alt Ball_def mem_interior - apply (rule,rule,rule,rule,rule,rule) - apply (elim exE conjE) -proof - +proof clarify fix x y u assume u: "0 \ u" "u \ (1::real)" fix e d assume ed: "ball x e \ S" "ball y d \ S" "0e>0. ball ((1 - u) *\<^sub>R x + u *\<^sub>R y) e \ S" - apply (rule_tac x="min d e" in exI, rule) - unfolding subset_eq - defer - apply rule - proof - + proof (intro exI conjI subsetI) fix z assume "z \ ball ((1 - u) *\<^sub>R x + u *\<^sub>R y) (min d e)" then have "(1- u) *\<^sub>R (z - u *\<^sub>R (y - x)) + u *\<^sub>R (z + (1 - u) *\<^sub>R (y - x)) \ S" @@ -6129,7 +6049,7 @@ and "\s\f. convex s" "\t\f. card t = DIM('a) + 1 \ \t \ {}" shows "\f \ {}" using assms -proof (induct n arbitrary: f) +proof (induction n arbitrary: f) case 0 then show ?case by auto next @@ -6137,45 +6057,39 @@ have "finite f" using \card f = Suc n\ by (auto intro: card_ge_0_finite) show "\f \ {}" - apply (cases "n = DIM('a)") - apply (rule Suc(5)[rule_format]) - unfolding \card f = Suc n\ - proof - - assume ng: "n \ DIM('a)" - then have "\X. \s\f. X s \ \(f - {s})" - apply (rule_tac bchoice) - unfolding ex_in_conv - apply (rule, rule Suc(1)[rule_format]) - unfolding card_Diff_singleton_if[OF \finite f\] \card f = Suc n\ - defer - defer - apply (rule Suc(4)[rule_format]) - defer - apply (rule Suc(5)[rule_format]) - using Suc(3) \finite f\ - apply auto - done - then obtain X where X: "\s\f. X s \ \(f - {s})" by auto + proof (cases "n = DIM('a)") + case True + then show ?thesis + by (simp add: Suc.prems(1) Suc.prems(4)) + next + case False + have "\(f - {s}) \ {}" if "s \ f" for s + proof (rule Suc.IH[rule_format]) + show "card (f - {s}) = n" + by (simp add: Suc.prems(1) \finite f\ that) + show "DIM('a) + 1 \ n" + using False Suc.prems(2) by linarith + show "\t. \t \ f - {s}; card t = DIM('a) + 1\ \ \t \ {}" + by (simp add: Suc.prems(4) subset_Diff_insert) + qed (use Suc in auto) + then have "\s\f. \x. x \ \(f - {s})" + by blast + then obtain X where X: "\s. s\f \ X s \ \(f - {s})" + by metis show ?thesis proof (cases "inj_on X f") case False - then obtain s t where st: "s\t" "s\f" "t\f" "X s = X t" + then obtain s t where "s\t" and st: "s\f" "t\f" "X s = X t" unfolding inj_on_def by auto then have *: "\f = \(f - {s}) \ \(f - {t})" by auto show ?thesis - unfolding * - unfolding ex_in_conv[symmetric] - apply (rule_tac x="X s" in exI, rule) - apply (rule X[rule_format]) - using X st - apply auto - done + by (metis "*" X disjoint_iff_not_equal st) next case True then obtain m p where mp: "m \ p = {}" "m \ p = X ` f" "convex hull m \ convex hull p \ {}" using radon_partition[of "X ` f"] and affine_dependent_biggerset[of "X ` f"] unfolding card_image[OF True] and \card f = Suc n\ - using Suc(3) \finite f\ and ng + using Suc(3) \finite f\ and False by auto have "m \ X ` f" "p \ X ` f" using mp(2) by auto @@ -6192,40 +6106,17 @@ using inj_on_image_Int[OF True gh(3,4)] by auto have "convex hull (X ` h) \ \g" "convex hull (X ` g) \ \h" - apply (rule_tac [!] hull_minimal) - using Suc gh(3-4) - unfolding subset_eq - apply (rule_tac [2] convex_Inter, rule_tac [4] convex_Inter) - prefer 3 - apply rule - proof - - fix x - assume "x \ X ` g" - then obtain y where "y \ g" "x = X y" - unfolding image_iff .. - then show "x \ \h" - using X[THEN bspec[where x=y]] using * f by auto - next - show "\x\X ` h. x \ \g" - proof - fix x - assume "x \ X ` h" - then obtain y where "y \ h" "x = X y" - unfolding image_iff .. - then show "x \ \g" - using X[THEN bspec[where x=y]] using * f by auto - qed - qed auto + by (rule hull_minimal; use X * f in \auto simp: Suc.prems(3) convex_Inter\)+ then show ?thesis unfolding f using mp(3)[unfolded gh] by blast qed - qed auto + qed qed theorem%important helly: fixes f :: "'a::euclidean_space set set" assumes "card f \ DIM('a) + 1" "\s\f. convex s" - and "\t\f. card t = DIM('a) + 1 \ \t \ {}" + and "\t. \t\f; card t = DIM('a) + 1\ \ \t \ {}" shows "\f \ {}" apply%unimportant (rule helly_induct) using assms @@ -6235,70 +6126,76 @@ subsection \Epigraphs of convex functions\ -definition%important "epigraph s (f :: _ \ real) = {xy. fst xy \ s \ f (fst xy) \ snd xy}" - -lemma mem_epigraph: "(x, y) \ epigraph s f \ x \ s \ f x \ y" +definition%important "epigraph S (f :: _ \ real) = {xy. fst xy \ S \ f (fst xy) \ snd xy}" + +lemma mem_epigraph: "(x, y) \ epigraph S f \ x \ S \ f x \ y" unfolding epigraph_def by auto -lemma convex_epigraph: "convex (epigraph s f) \ convex_on s f \ convex s" - unfolding convex_def convex_on_def - unfolding Ball_def split_paired_All epigraph_def - unfolding mem_Collect_eq fst_conv snd_conv fst_add snd_add fst_scaleR snd_scaleR Ball_def[symmetric] - apply safe - defer - apply (erule_tac x=x in allE) - apply (erule_tac x="f x" in allE, safe) - apply (erule_tac x=xa in allE) - apply (erule_tac x="f xa" in allE) - prefer 3 - apply (rule_tac y="u * f a + v * f aa" in order_trans) - defer - apply (auto intro!:mult_left_mono add_mono) - done - -lemma convex_epigraphI: "convex_on s f \ convex s \ convex (epigraph s f)" +lemma convex_epigraph: "convex (epigraph S f) \ convex_on S f \ convex S" +proof safe + assume L: "convex (epigraph S f)" + then show "convex_on S f" + by (auto simp: convex_def convex_on_def epigraph_def) + show "convex S" + using L + apply (clarsimp simp: convex_def convex_on_def epigraph_def) + apply (erule_tac x=x in allE) + apply (erule_tac x="f x" in allE, safe) + apply (erule_tac x=y in allE) + apply (erule_tac x="f y" in allE) + apply (auto simp: ) + done +next + assume "convex_on S f" "convex S" + then show "convex (epigraph S f)" + unfolding convex_def convex_on_def epigraph_def + apply safe + apply (rule_tac [2] y="u * f a + v * f aa" in order_trans) + apply (auto intro!:mult_left_mono add_mono) + done +qed + +lemma convex_epigraphI: "convex_on S f \ convex S \ convex (epigraph S f)" unfolding convex_epigraph by auto -lemma convex_epigraph_convex: "convex s \ convex_on s f \ convex(epigraph s f)" +lemma convex_epigraph_convex: "convex S \ convex_on S f \ convex(epigraph S f)" by (simp add: convex_epigraph) subsubsection%unimportant \Use this to derive general bound property of convex function\ lemma convex_on: - assumes "convex s" - shows "convex_on s f \ - (\k u x. (\i\{1..k::nat}. 0 \ u i \ x i \ s) \ sum u {1..k} = 1 \ + assumes "convex S" + shows "convex_on S f \ + (\k u x. (\i\{1..k::nat}. 0 \ u i \ x i \ S) \ sum u {1..k} = 1 \ f (sum (\i. u i *\<^sub>R x i) {1..k}) \ sum (\i. u i * f(x i)) {1..k})" + unfolding convex_epigraph_convex[OF assms] convex epigraph_def Ball_def mem_Collect_eq unfolding fst_sum snd_sum fst_scaleR snd_scaleR apply safe - apply (drule_tac x=k in spec) - apply (drule_tac x=u in spec) - apply (drule_tac x="\i. (x i, f (x i))" in spec) - apply simp - using assms[unfolded convex] - apply simp - apply (rule_tac y="\i = 1..k. u i * f (fst (x i))" in order_trans) - defer - apply (rule sum_mono) - apply (erule_tac x=i in allE) + apply (drule_tac x=k in spec) + apply (drule_tac x=u in spec) + apply (drule_tac x="\i. (x i, f (x i))" in spec) + apply simp + using assms[unfolded convex] apply simp + apply (rule_tac y="\i = 1..k. u i * f (fst (x i))" in order_trans, force) + apply (rule sum_mono) + apply (erule_tac x=i in allE) unfolding real_scaleR_def - apply (rule mult_left_mono) - using assms[unfolded convex] - apply auto + apply (rule mult_left_mono) + using assms[unfolded convex] apply auto done subsection%unimportant \Convexity of general and special intervals\ lemma is_interval_convex: - fixes s :: "'a::euclidean_space set" - assumes "is_interval s" - shows "convex s" + fixes S :: "'a::euclidean_space set" + assumes "is_interval S" + shows "convex S" proof (rule convexI) fix x y and u v :: real - assume as: "x \ s" "y \ s" "0 \ u" "0 \ v" "u + v = 1" + assume as: "x \ S" "y \ S" "0 \ u" "0 \ v" "u + v = 1" then have *: "u = 1 - v" "1 - v \ 0" and **: "v = 1 - u" "1 - u \ 0" by auto { @@ -6331,7 +6228,7 @@ using **(2) as(3) by (auto simp: field_simps intro!:mult_right_mono) } - ultimately show "u *\<^sub>R x + v *\<^sub>R y \ s" + ultimately show "u *\<^sub>R x + v *\<^sub>R y \ S" apply - apply (rule assms[unfolded is_interval_def, rule_format, OF as(1,2)]) using as(3-) DIM_positive[where 'a='a] @@ -6340,8 +6237,8 @@ qed lemma is_interval_connected: - fixes s :: "'a::euclidean_space set" - shows "is_interval s \ connected s" + fixes S :: "'a::euclidean_space set" + shows "is_interval S \ connected S" using is_interval_convex convex_connected by auto lemma convex_box [simp]: "convex (cbox a b)" "convex (box a (b::'a::euclidean_space))" @@ -6818,20 +6715,16 @@ finally have w: "(1 / t) *\<^sub>R w + ((t - 1) / t) *\<^sub>R x = y" unfolding w_def using False and \t > 0\ by (auto simp: algebra_simps) - have "2 * B < e * t" + have 2: "2 * B < e * t" unfolding t_def using \0 < e\ \0 < k\ \B > 0\ and as and False by (auto simp:field_simps) - then have "(f w - f x) / t < e" - using B(2)[OF \w\s\] and B(2)[OF \x\s\] - using \t > 0\ by (auto simp:field_simps) - then have th1: "f y - f x < e" - apply - - apply (rule le_less_trans) - defer - apply assumption + have "f y - f x \ (f w - f x) / t" using assms(2)[unfolded convex_on_def,rule_format,of w x "1/t" "(t - 1)/t", unfolded w] using \0 < t\ \2 < t\ and \x \ s\ \w \ s\ by (auto simp:field_simps) + also have "... < e" + using B(2)[OF \w\s\] and B(2)[OF \x\s\] 2 \t > 0\ by (auto simp: field_simps) + finally have th1: "f y - f x < e" . } moreover {