Datasets:
Tasks:
Text Generation
Modalities:
Text
Sub-tasks:
language-modeling
Languages:
English
Size:
100K - 1M
License:
/- | |
Copyright (c) 2020 Yury Kudryashov. All rights reserved. | |
Released under Apache 2.0 license as described in the file LICENSE. | |
Authors: Alexander Bentkamp, Yury Kudryashov | |
-/ | |
import analysis.convex.jensen | |
import analysis.normed.group.pointwise | |
import analysis.normed_space.finite_dimension | |
import analysis.normed_space.ray | |
import topology.path_connected | |
import topology.algebra.affine | |
/-! | |
# Topological and metric properties of convex sets | |
We prove the following facts: | |
* `convex.interior` : interior of a convex set is convex; | |
* `convex.closure` : closure of a convex set is convex; | |
* `set.finite.compact_convex_hull` : convex hull of a finite set is compact; | |
* `set.finite.is_closed_convex_hull` : convex hull of a finite set is closed; | |
* `convex_on_norm`, `convex_on_dist` : norm and distance to a fixed point is convex on any convex | |
set; | |
* `convex_on_univ_norm`, `convex_on_univ_dist` : norm and distance to a fixed point is convex on | |
the whole space; | |
* `convex_hull_ediam`, `convex_hull_diam` : convex hull of a set has the same (e)metric diameter | |
as the original set; | |
* `bounded_convex_hull` : convex hull of a set is bounded if and only if the original set | |
is bounded. | |
* `bounded_std_simplex`, `is_closed_std_simplex`, `compact_std_simplex`: topological properties | |
of the standard simplex; | |
-/ | |
variables {ΞΉ : Type*} {E : Type*} | |
open metric set | |
open_locale pointwise convex | |
lemma real.convex_iff_is_preconnected {s : set β} : convex β s β is_preconnected s := | |
convex_iff_ord_connected.trans is_preconnected_iff_ord_connected.symm | |
alias real.convex_iff_is_preconnected β _ is_preconnected.convex | |
/-! ### Standard simplex -/ | |
section std_simplex | |
variables [fintype ΞΉ] | |
/-- Every vector in `std_simplex π ΞΉ` has `max`-norm at most `1`. -/ | |
lemma std_simplex_subset_closed_ball : | |
std_simplex β ΞΉ β metric.closed_ball 0 1 := | |
begin | |
assume f hf, | |
rw [metric.mem_closed_ball, dist_zero_right], | |
refine (nnreal.coe_one βΈ nnreal.coe_le_coe.2 $ finset.sup_le $ Ξ» x hx, _), | |
change |f x| β€ 1, | |
rw [abs_of_nonneg $ hf.1 x], | |
exact (mem_Icc_of_mem_std_simplex hf x).2 | |
end | |
variable (ΞΉ) | |
/-- `std_simplex β ΞΉ` is bounded. -/ | |
lemma bounded_std_simplex : metric.bounded (std_simplex β ΞΉ) := | |
(metric.bounded_iff_subset_ball 0).2 β¨1, std_simplex_subset_closed_ballβ© | |
/-- `std_simplex β ΞΉ` is closed. -/ | |
lemma is_closed_std_simplex : is_closed (std_simplex β ΞΉ) := | |
(std_simplex_eq_inter β ΞΉ).symm βΈ is_closed.inter | |
(is_closed_Inter $ Ξ» i, is_closed_le continuous_const (continuous_apply i)) | |
(is_closed_eq (continuous_finset_sum _ $ Ξ» x _, continuous_apply x) continuous_const) | |
/-- `std_simplex β ΞΉ` is compact. -/ | |
lemma compact_std_simplex : is_compact (std_simplex β ΞΉ) := | |
metric.compact_iff_closed_bounded.2 β¨is_closed_std_simplex ΞΉ, bounded_std_simplex ΞΉβ© | |
end std_simplex | |
/-! ### Topological vector space -/ | |
section has_continuous_const_smul | |
variables {π : Type*} [linear_ordered_field π] [add_comm_group E] [module π E] [topological_space E] | |
[topological_add_group E] [has_continuous_const_smul π E] | |
/-- If `s` is a convex set, then `a β’ interior s + b β’ closure s β interior s` for all `0 < a`, | |
`0 β€ b`, `a + b = 1`. See also `convex.combo_interior_self_subset_interior` for a weaker version. -/ | |
lemma convex.combo_interior_closure_subset_interior {s : set E} (hs : convex π s) {a b : π} | |
(ha : 0 < a) (hb : 0 β€ b) (hab : a + b = 1) : | |
a β’ interior s + b β’ closure s β interior s := | |
interior_smulβ ha.ne' s βΈ | |
calc interior (a β’ s) + b β’ closure s β interior (a β’ s) + closure (b β’ s) : | |
add_subset_add subset.rfl (smul_closure_subset b s) | |
... = interior (a β’ s) + b β’ s : by rw is_open_interior.add_closure (b β’ s) | |
... β interior (a β’ s + b β’ s) : subset_interior_add_left | |
... β interior s : interior_mono $ hs.set_combo_subset ha.le hb hab | |
/-- If `s` is a convex set, then `a β’ interior s + b β’ s β interior s` for all `0 < a`, `0 β€ b`, | |
`a + b = 1`. See also `convex.combo_interior_closure_subset_interior` for a stronger version. -/ | |
lemma convex.combo_interior_self_subset_interior {s : set E} (hs : convex π s) {a b : π} | |
(ha : 0 < a) (hb : 0 β€ b) (hab : a + b = 1) : | |
a β’ interior s + b β’ s β interior s := | |
calc a β’ interior s + b β’ s β a β’ interior s + b β’ closure s : | |
add_subset_add subset.rfl $ image_subset _ subset_closure | |
... β interior s : hs.combo_interior_closure_subset_interior ha hb hab | |
/-- If `s` is a convex set, then `a β’ closure s + b β’ interior s β interior s` for all `0 β€ a`, | |
`0 < b`, `a + b = 1`. See also `convex.combo_self_interior_subset_interior` for a weaker version. -/ | |
lemma convex.combo_closure_interior_subset_interior {s : set E} (hs : convex π s) {a b : π} | |
(ha : 0 β€ a) (hb : 0 < b) (hab : a + b = 1) : | |
a β’ closure s + b β’ interior s β interior s := | |
by { rw add_comm, exact hs.combo_interior_closure_subset_interior hb ha (add_comm a b βΈ hab) } | |
/-- If `s` is a convex set, then `a β’ s + b β’ interior s β interior s` for all `0 β€ a`, `0 < b`, | |
`a + b = 1`. See also `convex.combo_closure_interior_subset_interior` for a stronger version. -/ | |
lemma convex.combo_self_interior_subset_interior {s : set E} (hs : convex π s) {a b : π} | |
(ha : 0 β€ a) (hb : 0 < b) (hab : a + b = 1) : | |
a β’ s + b β’ interior s β interior s := | |
by { rw add_comm, exact hs.combo_interior_self_subset_interior hb ha (add_comm a b βΈ hab) } | |
lemma convex.combo_interior_closure_mem_interior {s : set E} (hs : convex π s) {x y : E} | |
(hx : x β interior s) (hy : y β closure s) {a b : π} (ha : 0 < a) (hb : 0 β€ b) (hab : a + b = 1) : | |
a β’ x + b β’ y β interior s := | |
hs.combo_interior_closure_subset_interior ha hb hab $ | |
add_mem_add (smul_mem_smul_set hx) (smul_mem_smul_set hy) | |
lemma convex.combo_interior_self_mem_interior {s : set E} (hs : convex π s) {x y : E} | |
(hx : x β interior s) (hy : y β s) {a b : π} (ha : 0 < a) (hb : 0 β€ b) (hab : a + b = 1) : | |
a β’ x + b β’ y β interior s := | |
hs.combo_interior_closure_mem_interior hx (subset_closure hy) ha hb hab | |
lemma convex.combo_closure_interior_mem_interior {s : set E} (hs : convex π s) {x y : E} | |
(hx : x β closure s) (hy : y β interior s) {a b : π} (ha : 0 β€ a) (hb : 0 < b) (hab : a + b = 1) : | |
a β’ x + b β’ y β interior s := | |
hs.combo_closure_interior_subset_interior ha hb hab $ | |
add_mem_add (smul_mem_smul_set hx) (smul_mem_smul_set hy) | |
lemma convex.combo_self_interior_mem_interior {s : set E} (hs : convex π s) {x y : E} | |
(hx : x β s) (hy : y β interior s) {a b : π} (ha : 0 β€ a) (hb : 0 < b) (hab : a + b = 1) : | |
a β’ x + b β’ y β interior s := | |
hs.combo_closure_interior_mem_interior (subset_closure hx) hy ha hb hab | |
lemma convex.open_segment_interior_closure_subset_interior {s : set E} (hs : convex π s) {x y : E} | |
(hx : x β interior s) (hy : y β closure s) : open_segment π x y β interior s := | |
begin | |
rintro _ β¨a, b, ha, hb, hab, rflβ©, | |
exact hs.combo_interior_closure_mem_interior hx hy ha hb.le hab | |
end | |
lemma convex.open_segment_interior_self_subset_interior {s : set E} (hs : convex π s) {x y : E} | |
(hx : x β interior s) (hy : y β s) : open_segment π x y β interior s := | |
hs.open_segment_interior_closure_subset_interior hx (subset_closure hy) | |
lemma convex.open_segment_closure_interior_subset_interior {s : set E} (hs : convex π s) {x y : E} | |
(hx : x β closure s) (hy : y β interior s) : open_segment π x y β interior s := | |
begin | |
rintro _ β¨a, b, ha, hb, hab, rflβ©, | |
exact hs.combo_closure_interior_mem_interior hx hy ha.le hb hab | |
end | |
lemma convex.open_segment_self_interior_subset_interior {s : set E} (hs : convex π s) {x y : E} | |
(hx : x β s) (hy : y β interior s) : open_segment π x y β interior s := | |
hs.open_segment_closure_interior_subset_interior (subset_closure hx) hy | |
/-- If `x β closure s` and `y β interior s`, then the segment `(x, y]` is included in `interior s`. | |
-/ | |
lemma convex.add_smul_sub_mem_interior' {s : set E} (hs : convex π s) | |
{x y : E} (hx : x β closure s) (hy : y β interior s) {t : π} (ht : t β Ioc (0 : π) 1) : | |
x + t β’ (y - x) β interior s := | |
by simpa only [sub_smul, smul_sub, one_smul, add_sub, add_comm] | |
using hs.combo_interior_closure_mem_interior hy hx ht.1 (sub_nonneg.mpr ht.2) | |
(add_sub_cancel'_right _ _) | |
/-- If `x β s` and `y β interior s`, then the segment `(x, y]` is included in `interior s`. -/ | |
lemma convex.add_smul_sub_mem_interior {s : set E} (hs : convex π s) | |
{x y : E} (hx : x β s) (hy : y β interior s) {t : π} (ht : t β Ioc (0 : π) 1) : | |
x + t β’ (y - x) β interior s := | |
hs.add_smul_sub_mem_interior' (subset_closure hx) hy ht | |
/-- If `x β closure s` and `x + y β interior s`, then `x + t y β interior s` for `t β (0, 1]`. -/ | |
lemma convex.add_smul_mem_interior' {s : set E} (hs : convex π s) | |
{x y : E} (hx : x β closure s) (hy : x + y β interior s) {t : π} (ht : t β Ioc (0 : π) 1) : | |
x + t β’ y β interior s := | |
by simpa only [add_sub_cancel'] using hs.add_smul_sub_mem_interior' hx hy ht | |
/-- If `x β s` and `x + y β interior s`, then `x + t y β interior s` for `t β (0, 1]`. -/ | |
lemma convex.add_smul_mem_interior {s : set E} (hs : convex π s) | |
{x y : E} (hx : x β s) (hy : x + y β interior s) {t : π} (ht : t β Ioc (0 : π) 1) : | |
x + t β’ y β interior s := | |
hs.add_smul_mem_interior' (subset_closure hx) hy ht | |
/-- In a topological vector space, the interior of a convex set is convex. -/ | |
protected lemma convex.interior {s : set E} (hs : convex π s) : convex π (interior s) := | |
convex_iff_open_segment_subset.mpr $ Ξ» x y hx hy, | |
hs.open_segment_closure_interior_subset_interior (interior_subset_closure hx) hy | |
/-- In a topological vector space, the closure of a convex set is convex. -/ | |
protected lemma convex.closure {s : set E} (hs : convex π s) : convex π (closure s) := | |
Ξ» x y hx hy a b ha hb hab, | |
let f : E β E β E := Ξ» x' y', a β’ x' + b β’ y' in | |
have hf : continuous (Ξ» p : E Γ E, f p.1 p.2), from | |
(continuous_fst.const_smul _).add (continuous_snd.const_smul _), | |
show f x y β closure s, from | |
mem_closure_of_continuous2 hf hx hy (Ξ» x' hx' y' hy', subset_closure | |
(hs hx' hy' ha hb hab)) | |
end has_continuous_const_smul | |
section has_continuous_smul | |
variables [add_comm_group E] [module β E] [topological_space E] | |
[topological_add_group E] [has_continuous_smul β E] | |
/-- Convex hull of a finite set is compact. -/ | |
lemma set.finite.compact_convex_hull {s : set E} (hs : s.finite) : | |
is_compact (convex_hull β s) := | |
begin | |
rw [hs.convex_hull_eq_image], | |
apply (compact_std_simplex _).image, | |
haveI := hs.fintype, | |
apply linear_map.continuous_on_pi | |
end | |
/-- Convex hull of a finite set is closed. -/ | |
lemma set.finite.is_closed_convex_hull [t2_space E] {s : set E} (hs : s.finite) : | |
is_closed (convex_hull β s) := | |
hs.compact_convex_hull.is_closed | |
open affine_map | |
/-- If we dilate the interior of a convex set about a point in its interior by a scale `t > 1`, | |
the result includes the closure of the original set. | |
TODO Generalise this from convex sets to sets that are balanced / star-shaped about `x`. -/ | |
lemma convex.closure_subset_image_homothety_interior_of_one_lt {s : set E} (hs : convex β s) | |
{x : E} (hx : x β interior s) (t : β) (ht : 1 < t) : | |
closure s β homothety x t '' interior s := | |
begin | |
intros y hy, | |
have hne : t β 0, from (one_pos.trans ht).ne', | |
refine β¨homothety x tβ»ΒΉ y, hs.open_segment_interior_closure_subset_interior hx hy _, | |
(affine_equiv.homothety_units_mul_hom x (units.mk0 t hne)).apply_symm_apply yβ©, | |
rw [open_segment_eq_image_line_map, β inv_one, β inv_Ioi (@one_pos β _ _), β image_inv, | |
image_image, homothety_eq_line_map], | |
exact mem_image_of_mem _ ht | |
end | |
/-- If we dilate a convex set about a point in its interior by a scale `t > 1`, the interior of | |
the result includes the closure of the original set. | |
TODO Generalise this from convex sets to sets that are balanced / star-shaped about `x`. -/ | |
lemma convex.closure_subset_interior_image_homothety_of_one_lt {s : set E} (hs : convex β s) | |
{x : E} (hx : x β interior s) (t : β) (ht : 1 < t) : | |
closure s β interior (homothety x t '' s) := | |
(hs.closure_subset_image_homothety_interior_of_one_lt hx t ht).trans $ | |
(homothety_is_open_map x t (one_pos.trans ht).ne').image_interior_subset _ | |
/-- If we dilate a convex set about a point in its interior by a scale `t > 1`, the interior of | |
the result includes the closure of the original set. | |
TODO Generalise this from convex sets to sets that are balanced / star-shaped about `x`. -/ | |
lemma convex.subset_interior_image_homothety_of_one_lt {s : set E} (hs : convex β s) | |
{x : E} (hx : x β interior s) (t : β) (ht : 1 < t) : | |
s β interior (homothety x t '' s) := | |
subset_closure.trans $ hs.closure_subset_interior_image_homothety_of_one_lt hx t ht | |
/-- A nonempty convex set is path connected. -/ | |
protected lemma convex.is_path_connected {s : set E} (hconv : convex β s) (hne : s.nonempty) : | |
is_path_connected s := | |
begin | |
refine is_path_connected_iff.mpr β¨hne, _β©, | |
intros x x_in y y_in, | |
have H := hconv.segment_subset x_in y_in, | |
rw segment_eq_image_line_map at H, | |
exact joined_in.of_line affine_map.line_map_continuous.continuous_on (line_map_apply_zero _ _) | |
(line_map_apply_one _ _) H | |
end | |
/-- A nonempty convex set is connected. -/ | |
protected lemma convex.is_connected {s : set E} (h : convex β s) (hne : s.nonempty) : | |
is_connected s := | |
(h.is_path_connected hne).is_connected | |
/-- A convex set is preconnected. -/ | |
protected lemma convex.is_preconnected {s : set E} (h : convex β s) : is_preconnected s := | |
s.eq_empty_or_nonempty.elim (Ξ» h, h.symm βΈ is_preconnected_empty) | |
(Ξ» hne, (h.is_connected hne).is_preconnected) | |
/-- | |
Every topological vector space over β is path connected. | |
Not an instance, because it creates enormous TC subproblems (turn on `pp.all`). | |
-/ | |
protected lemma topological_add_group.path_connected : path_connected_space E := | |
path_connected_space_iff_univ.mpr $ convex_univ.is_path_connected β¨(0 : E), trivialβ© | |
end has_continuous_smul | |
/-! ### Normed vector space -/ | |
section normed_space | |
variables [seminormed_add_comm_group E] [normed_space β E] {s t : set E} | |
/-- The norm on a real normed space is convex on any convex set. See also `seminorm.convex_on` | |
and `convex_on_univ_norm`. -/ | |
lemma convex_on_norm (hs : convex β s) : convex_on β s norm := | |
β¨hs, Ξ» x y hx hy a b ha hb hab, | |
calc β₯a β’ x + b β’ yβ₯ β€ β₯a β’ xβ₯ + β₯b β’ yβ₯ : norm_add_le _ _ | |
... = a * β₯xβ₯ + b * β₯yβ₯ | |
: by rw [norm_smul, norm_smul, real.norm_of_nonneg ha, real.norm_of_nonneg hb]β© | |
/-- The norm on a real normed space is convex on the whole space. See also `seminorm.convex_on` | |
and `convex_on_norm`. -/ | |
lemma convex_on_univ_norm : convex_on β univ (norm : E β β) := convex_on_norm convex_univ | |
lemma convex_on_dist (z : E) (hs : convex β s) : convex_on β s (Ξ» z', dist z' z) := | |
by simpa [dist_eq_norm, preimage_preimage] | |
using (convex_on_norm (hs.translate (-z))).comp_affine_map | |
(affine_map.id β E - affine_map.const β E z) | |
lemma convex_on_univ_dist (z : E) : convex_on β univ (Ξ»z', dist z' z) := | |
convex_on_dist z convex_univ | |
lemma convex_ball (a : E) (r : β) : convex β (metric.ball a r) := | |
by simpa only [metric.ball, sep_univ] using (convex_on_univ_dist a).convex_lt r | |
lemma convex_closed_ball (a : E) (r : β) : convex β (metric.closed_ball a r) := | |
by simpa only [metric.closed_ball, sep_univ] using (convex_on_univ_dist a).convex_le r | |
lemma convex.thickening (hs : convex β s) (Ξ΄ : β) : convex β (thickening Ξ΄ s) := | |
by { rw βadd_ball_zero, exact hs.add (convex_ball 0 _) } | |
lemma convex.cthickening (hs : convex β s) (Ξ΄ : β) : convex β (cthickening Ξ΄ s) := | |
begin | |
obtain hΞ΄ | hΞ΄ := le_total 0 Ξ΄, | |
{ rw cthickening_eq_Inter_thickening hΞ΄, | |
exact convex_Interβ (Ξ» _ _, hs.thickening _) }, | |
{ rw cthickening_of_nonpos hΞ΄, | |
exact hs.closure } | |
end | |
/-- If `s`, `t` are disjoint convex sets, `s` is compact and `t` is closed then we can find open | |
disjoint convex sets containing them. -/ | |
lemma disjoint.exists_open_convexes (disj : disjoint s t) (hsβ : convex β s) (hsβ : is_compact s) | |
(htβ : convex β t) (htβ : is_closed t) : | |
β u v, is_open u β§ is_open v β§ convex β u β§ convex β v β§ s β u β§ t β v β§ disjoint u v := | |
let β¨Ξ΄, hΞ΄, hstβ© := disj.exists_thickenings hsβ htβ in | |
β¨_, _, is_open_thickening, is_open_thickening, hsβ.thickening _, htβ.thickening _, | |
self_subset_thickening hΞ΄ _, self_subset_thickening hΞ΄ _, hstβ© | |
/-- Given a point `x` in the convex hull of `s` and a point `y`, there exists a point | |
of `s` at distance at least `dist x y` from `y`. -/ | |
lemma convex_hull_exists_dist_ge {s : set E} {x : E} (hx : x β convex_hull β s) (y : E) : | |
β x' β s, dist x y β€ dist x' y := | |
(convex_on_dist y (convex_convex_hull β _)).exists_ge_of_mem_convex_hull hx | |
/-- Given a point `x` in the convex hull of `s` and a point `y` in the convex hull of `t`, | |
there exist points `x' β s` and `y' β t` at distance at least `dist x y`. -/ | |
lemma convex_hull_exists_dist_ge2 {s t : set E} {x y : E} | |
(hx : x β convex_hull β s) (hy : y β convex_hull β t) : | |
β (x' β s) (y' β t), dist x y β€ dist x' y' := | |
begin | |
rcases convex_hull_exists_dist_ge hx y with β¨x', hx', Hx'β©, | |
rcases convex_hull_exists_dist_ge hy x' with β¨y', hy', Hy'β©, | |
use [x', hx', y', hy'], | |
exact le_trans Hx' (dist_comm y x' βΈ dist_comm y' x' βΈ Hy') | |
end | |
/-- Emetric diameter of the convex hull of a set `s` equals the emetric diameter of `s. -/ | |
@[simp] lemma convex_hull_ediam (s : set E) : | |
emetric.diam (convex_hull β s) = emetric.diam s := | |
begin | |
refine (emetric.diam_le $ Ξ» x hx y hy, _).antisymm (emetric.diam_mono $ subset_convex_hull β s), | |
rcases convex_hull_exists_dist_ge2 hx hy with β¨x', hx', y', hy', Hβ©, | |
rw edist_dist, | |
apply le_trans (ennreal.of_real_le_of_real H), | |
rw β edist_dist, | |
exact emetric.edist_le_diam_of_mem hx' hy' | |
end | |
/-- Diameter of the convex hull of a set `s` equals the emetric diameter of `s. -/ | |
@[simp] lemma convex_hull_diam (s : set E) : | |
metric.diam (convex_hull β s) = metric.diam s := | |
by simp only [metric.diam, convex_hull_ediam] | |
/-- Convex hull of `s` is bounded if and only if `s` is bounded. -/ | |
@[simp] lemma bounded_convex_hull {s : set E} : | |
metric.bounded (convex_hull β s) β metric.bounded s := | |
by simp only [metric.bounded_iff_ediam_ne_top, convex_hull_ediam] | |
@[priority 100] | |
instance normed_space.path_connected : path_connected_space E := | |
topological_add_group.path_connected | |
@[priority 100] | |
instance normed_space.loc_path_connected : loc_path_connected_space E := | |
loc_path_connected_of_bases (Ξ» x, metric.nhds_basis_ball) | |
(Ξ» x r r_pos, (convex_ball x r).is_path_connected $ by simp [r_pos]) | |
lemma dist_add_dist_of_mem_segment {x y z : E} (h : y β [x -[β] z]) : | |
dist x y + dist y z = dist x z := | |
begin | |
simp only [dist_eq_norm, mem_segment_iff_same_ray] at *, | |
simpa only [sub_add_sub_cancel', norm_sub_rev] using h.norm_add.symm | |
end | |
end normed_space | |