Datasets:
Tasks:
Text Generation
Modalities:
Text
Sub-tasks:
language-modeling
Languages:
English
Size:
100K - 1M
License:
/- | |
Copyright (c) 2021 YaΓ«l Dillies. All rights reserved. | |
Released under Apache 2.0 license as described in the file LICENSE. | |
Authors: YaΓ«l Dillies | |
-/ | |
import analysis.convex.basic | |
/-! | |
# Star-convex sets | |
This files defines star-convex sets (aka star domains, star-shaped set, radially convex set). | |
A set is star-convex at `x` if every segment from `x` to a point in the set is contained in the set. | |
This is the prototypical example of a contractible set in homotopy theory (by scaling every point | |
towards `x`), but has wider uses. | |
Note that this has nothing to do with star rings, `has_star` and co. | |
## Main declarations | |
* `star_convex π x s`: `s` is star-convex at `x` with scalars `π`. | |
## Implementation notes | |
Instead of saying that a set is star-convex, we say a set is star-convex *at a point*. This has the | |
advantage of allowing us to talk about convexity as being "everywhere star-convexity" and of making | |
the union of star-convex sets be star-convex. | |
Incidentally, this choice means we don't need to assume a set is nonempty for it to be star-convex. | |
Concretely, the empty set is star-convex at every point. | |
## TODO | |
Balanced sets are star-convex. | |
The closure of a star-convex set is star-convex. | |
Star-convex sets are contractible. | |
A nonempty open star-convex set in `β^n` is diffeomorphic to the entire space. | |
-/ | |
open set | |
open_locale convex pointwise | |
variables {π E F Ξ² : Type*} | |
section ordered_semiring | |
variables [ordered_semiring π] | |
section add_comm_monoid | |
variables [add_comm_monoid E] [add_comm_monoid F] | |
section has_smul | |
variables (π) [has_smul π E] [has_smul π F] (x : E) (s : set E) | |
/-- Star-convexity of sets. `s` is star-convex at `x` if every segment from `x` to a point in `s` is | |
contained in `s`. -/ | |
def star_convex : Prop := | |
β β¦y : Eβ¦, y β s β β β¦a b : πβ¦, 0 β€ a β 0 β€ b β a + b = 1 β a β’ x + b β’ y β s | |
variables {π x s} {t : set E} | |
lemma convex_iff_forall_star_convex : convex π s β β x β s, star_convex π x s := | |
forall_congr $ Ξ» x, forall_swap | |
lemma convex.star_convex (h : convex π s) (hx : x β s) : star_convex π x s := | |
convex_iff_forall_star_convex.1 h _ hx | |
lemma star_convex_iff_segment_subset : star_convex π x s β β β¦yβ¦, y β s β [x -[π] y] β s := | |
begin | |
split, | |
{ rintro h y hy z β¨a, b, ha, hb, hab, rflβ©, | |
exact h hy ha hb hab }, | |
{ rintro h y hy a b ha hb hab, | |
exact h hy β¨a, b, ha, hb, hab, rflβ© } | |
end | |
lemma star_convex.segment_subset (h : star_convex π x s) {y : E} (hy : y β s) : [x -[π] y] β s := | |
star_convex_iff_segment_subset.1 h hy | |
lemma star_convex.open_segment_subset (h : star_convex π x s) {y : E} (hy : y β s) : | |
open_segment π x y β s := | |
(open_segment_subset_segment π x y).trans (h.segment_subset hy) | |
/-- Alternative definition of star-convexity, in terms of pointwise set operations. -/ | |
lemma star_convex_iff_pointwise_add_subset : | |
star_convex π x s β β β¦a b : πβ¦, 0 β€ a β 0 β€ b β a + b = 1 β a β’ {x} + b β’ s β s := | |
begin | |
refine β¨_, Ξ» h y hy a b ha hb hab, | |
h ha hb hab (add_mem_add (smul_mem_smul_set $ mem_singleton _) β¨_, hy, rflβ©)β©, | |
rintro hA a b ha hb hab w β¨au, bv, β¨u, (rfl : u = x), rflβ©, β¨v, hv, rflβ©, rflβ©, | |
exact hA hv ha hb hab, | |
end | |
lemma star_convex_empty (x : E) : star_convex π x β := Ξ» y hy, hy.elim | |
lemma star_convex_univ (x : E) : star_convex π x univ := Ξ» _ _ _ _ _ _ _, trivial | |
lemma star_convex.inter (hs : star_convex π x s) (ht : star_convex π x t) : | |
star_convex π x (s β© t) := | |
Ξ» y hy a b ha hb hab, β¨hs hy.left ha hb hab, ht hy.right ha hb habβ© | |
lemma star_convex_sInter {S : set (set E)} (h : β s β S, star_convex π x s) : | |
star_convex π x (ββ S) := | |
Ξ» y hy a b ha hb hab s hs, h s hs (hy s hs) ha hb hab | |
lemma star_convex_Inter {ΞΉ : Sort*} {s : ΞΉ β set E} (h : β i, star_convex π x (s i)) : | |
star_convex π x (β i, s i) := | |
(sInter_range s) βΈ star_convex_sInter $ forall_range_iff.2 h | |
lemma star_convex.union (hs : star_convex π x s) (ht : star_convex π x t) : | |
star_convex π x (s βͺ t) := | |
begin | |
rintro y (hy | hy) a b ha hb hab, | |
{ exact or.inl (hs hy ha hb hab) }, | |
{ exact or.inr (ht hy ha hb hab) } | |
end | |
lemma star_convex_Union {ΞΉ : Sort*} {s : ΞΉ β set E} (hs : β i, star_convex π x (s i)) : | |
star_convex π x (β i, s i) := | |
begin | |
rintro y hy a b ha hb hab, | |
rw mem_Union at β’ hy, | |
obtain β¨i, hyβ© := hy, | |
exact β¨i, hs i hy ha hb habβ©, | |
end | |
lemma star_convex_sUnion {S : set (set E)} (hS : β s β S, star_convex π x s) : | |
star_convex π x (ββ S) := | |
begin | |
rw sUnion_eq_Union, | |
exact star_convex_Union (Ξ» s, hS _ s.2), | |
end | |
lemma star_convex.prod {y : F} {s : set E} {t : set F} (hs : star_convex π x s) | |
(ht : star_convex π y t) : | |
star_convex π (x, y) (s ΓΛ’ t) := | |
Ξ» y hy a b ha hb hab, β¨hs hy.1 ha hb hab, ht hy.2 ha hb habβ© | |
lemma star_convex_pi {ΞΉ : Type*} {E : ΞΉ β Type*} [Ξ i, add_comm_monoid (E i)] | |
[Ξ i, has_smul π (E i)] {x : Ξ i, E i} {s : set ΞΉ} {t : Ξ i, set (E i)} | |
(ht : β i, star_convex π (x i) (t i)) : | |
star_convex π x (s.pi t) := | |
Ξ» y hy a b ha hb hab i hi, ht i (hy i hi) ha hb hab | |
end has_smul | |
section module | |
variables [module π E] [module π F] {x y z : E} {s : set E} | |
lemma star_convex.mem (hs : star_convex π x s) (h : s.nonempty) : x β s := | |
begin | |
obtain β¨y, hyβ© := h, | |
convert hs hy zero_le_one le_rfl (add_zero 1), | |
rw [one_smul, zero_smul, add_zero], | |
end | |
lemma convex.star_convex_iff (hs : convex π s) (h : s.nonempty) : star_convex π x s β x β s := | |
β¨Ξ» hxs, hxs.mem h, hs.star_convexβ© | |
lemma star_convex_iff_forall_pos (hx : x β s) : | |
star_convex π x s β β β¦yβ¦, y β s β β β¦a b : πβ¦, 0 < a β 0 < b β a + b = 1 β a β’ x + b β’ y β s := | |
begin | |
refine β¨Ξ» h y hy a b ha hb hab, h hy ha.le hb.le hab, _β©, | |
intros h y hy a b ha hb hab, | |
obtain rfl | ha := ha.eq_or_lt, | |
{ rw zero_add at hab, | |
rwa [hab, one_smul, zero_smul, zero_add] }, | |
obtain rfl | hb := hb.eq_or_lt, | |
{ rw add_zero at hab, | |
rwa [hab, one_smul, zero_smul, add_zero] }, | |
exact h hy ha hb hab, | |
end | |
lemma star_convex_iff_forall_ne_pos (hx : x β s) : | |
star_convex π x s β β β¦yβ¦, y β s β x β y β β β¦a b : πβ¦, 0 < a β 0 < b β a + b = 1 β | |
a β’ x + b β’ y β s := | |
begin | |
refine β¨Ξ» h y hy _ a b ha hb hab, h hy ha.le hb.le hab, _β©, | |
intros h y hy a b ha hb hab, | |
obtain rfl | ha' := ha.eq_or_lt, | |
{ rw [zero_add] at hab, rwa [hab, zero_smul, one_smul, zero_add] }, | |
obtain rfl | hb' := hb.eq_or_lt, | |
{ rw [add_zero] at hab, rwa [hab, zero_smul, one_smul, add_zero] }, | |
obtain rfl | hxy := eq_or_ne x y, | |
{ rwa convex.combo_self hab }, | |
exact h hy hxy ha' hb' hab, | |
end | |
lemma star_convex_iff_open_segment_subset (hx : x β s) : | |
star_convex π x s β β β¦yβ¦, y β s β open_segment π x y β s := | |
star_convex_iff_segment_subset.trans $ forallβ_congr $ Ξ» y hy, | |
(open_segment_subset_iff_segment_subset hx hy).symm | |
lemma star_convex_singleton (x : E) : star_convex π x {x} := | |
begin | |
rintro y (rfl : y = x) a b ha hb hab, | |
exact convex.combo_self hab _, | |
end | |
lemma star_convex.linear_image (hs : star_convex π x s) (f : E ββ[π] F) : | |
star_convex π (f x) (s.image f) := | |
begin | |
intros y hy a b ha hb hab, | |
obtain β¨y', hy', rflβ© := hy, | |
exact β¨a β’ x + b β’ y', hs hy' ha hb hab, by rw [f.map_add, f.map_smul, f.map_smul]β©, | |
end | |
lemma star_convex.is_linear_image (hs : star_convex π x s) {f : E β F} (hf : is_linear_map π f) : | |
star_convex π (f x) (f '' s) := | |
hs.linear_image $ hf.mk' f | |
lemma star_convex.linear_preimage {s : set F} (f : E ββ[π] F) (hs : star_convex π (f x) s) : | |
star_convex π x (s.preimage f) := | |
begin | |
intros y hy a b ha hb hab, | |
rw [mem_preimage, f.map_add, f.map_smul, f.map_smul], | |
exact hs hy ha hb hab, | |
end | |
lemma star_convex.is_linear_preimage {s : set F} {f : E β F} (hs : star_convex π (f x) s) | |
(hf : is_linear_map π f) : | |
star_convex π x (preimage f s) := | |
hs.linear_preimage $ hf.mk' f | |
lemma star_convex.add {t : set E} (hs : star_convex π x s) (ht : star_convex π y t) : | |
star_convex π (x + y) (s + t) := | |
by { rw βadd_image_prod, exact (hs.prod ht).is_linear_image is_linear_map.is_linear_map_add } | |
lemma star_convex.add_left (hs : star_convex π x s) (z : E) : | |
star_convex π (z + x) ((Ξ» x, z + x) '' s) := | |
begin | |
intros y hy a b ha hb hab, | |
obtain β¨y', hy', rflβ© := hy, | |
refine β¨a β’ x + b β’ y', hs hy' ha hb hab, _β©, | |
rw [smul_add, smul_add, add_add_add_comm, βadd_smul, hab, one_smul], | |
end | |
lemma star_convex.add_right (hs : star_convex π x s) (z : E) : | |
star_convex π (x + z) ((Ξ» x, x + z) '' s) := | |
begin | |
intros y hy a b ha hb hab, | |
obtain β¨y', hy', rflβ© := hy, | |
refine β¨a β’ x + b β’ y', hs hy' ha hb hab, _β©, | |
rw [smul_add, smul_add, add_add_add_comm, βadd_smul, hab, one_smul], | |
end | |
/-- The translation of a star-convex set is also star-convex. -/ | |
lemma star_convex.preimage_add_right (hs : star_convex π (z + x) s) : | |
star_convex π x ((Ξ» x, z + x) β»ΒΉ' s) := | |
begin | |
intros y hy a b ha hb hab, | |
have h := hs hy ha hb hab, | |
rwa [smul_add, smul_add, add_add_add_comm, βadd_smul, hab, one_smul] at h, | |
end | |
/-- The translation of a star-convex set is also star-convex. -/ | |
lemma star_convex.preimage_add_left (hs : star_convex π (x + z) s) : | |
star_convex π x ((Ξ» x, x + z) β»ΒΉ' s) := | |
begin | |
rw add_comm at hs, | |
simpa only [add_comm] using hs.preimage_add_right, | |
end | |
end module | |
end add_comm_monoid | |
section add_comm_group | |
variables [add_comm_group E] [module π E] {x y : E} | |
lemma star_convex.sub' {s : set (E Γ E)} (hs : star_convex π (x, y) s) : | |
star_convex π (x - y) ((Ξ» x : E Γ E, x.1 - x.2) '' s) := | |
hs.is_linear_image is_linear_map.is_linear_map_sub | |
end add_comm_group | |
end ordered_semiring | |
section ordered_comm_semiring | |
variables [ordered_comm_semiring π] | |
section add_comm_monoid | |
variables [add_comm_monoid E] [add_comm_monoid F] [module π E] [module π F] {x : E} {s : set E} | |
lemma star_convex.smul (hs : star_convex π x s) (c : π) : star_convex π (c β’ x) (c β’ s) := | |
hs.linear_image $ linear_map.lsmul _ _ c | |
lemma star_convex.preimage_smul {c : π} (hs : star_convex π (c β’ x) s) : | |
star_convex π x ((Ξ» z, c β’ z) β»ΒΉ' s) := | |
hs.linear_preimage (linear_map.lsmul _ _ c) | |
lemma star_convex.affinity (hs : star_convex π x s) (z : E) (c : π) : | |
star_convex π (z + c β’ x) ((Ξ» x, z + c β’ x) '' s) := | |
begin | |
have h := (hs.smul c).add_left z, | |
rwa [βimage_smul, image_image] at h, | |
end | |
end add_comm_monoid | |
end ordered_comm_semiring | |
section ordered_ring | |
variables [ordered_ring π] | |
section add_comm_monoid | |
variables [add_comm_monoid E] [smul_with_zero π E]{s : set E} | |
lemma star_convex_zero_iff : | |
star_convex π 0 s β β β¦x : Eβ¦, x β s β β β¦a : πβ¦, 0 β€ a β a β€ 1 β a β’ x β s := | |
begin | |
refine forall_congr (Ξ» x, forall_congr $ Ξ» hx, β¨Ξ» h a haβ haβ, _, Ξ» h a b ha hb hab, _β©), | |
{ simpa only [sub_add_cancel, eq_self_iff_true, forall_true_left, zero_add, smul_zero'] using | |
h (sub_nonneg_of_le haβ) haβ }, | |
{ rw [smul_zero', zero_add], | |
exact h hb (by { rw βhab, exact le_add_of_nonneg_left ha }) } | |
end | |
end add_comm_monoid | |
section add_comm_group | |
variables [add_comm_group E] [add_comm_group F] [module π E] [module π F] {x y : E} {s t : set E} | |
lemma star_convex.add_smul_mem (hs : star_convex π x s) (hy : x + y β s) {t : π} (htβ : 0 β€ t) | |
(htβ : t β€ 1) : | |
x + t β’ y β s := | |
begin | |
have h : x + t β’ y = (1 - t) β’ x + t β’ (x + y), | |
{ rw [smul_add, βadd_assoc, βadd_smul, sub_add_cancel, one_smul] }, | |
rw h, | |
exact hs hy (sub_nonneg_of_le htβ) htβ (sub_add_cancel _ _), | |
end | |
lemma star_convex.smul_mem (hs : star_convex π 0 s) (hx : x β s) {t : π} (htβ : 0 β€ t) | |
(htβ : t β€ 1) : | |
t β’ x β s := | |
by simpa using hs.add_smul_mem (by simpa using hx) htβ htβ | |
lemma star_convex.add_smul_sub_mem (hs : star_convex π x s) (hy : y β s) {t : π} (htβ : 0 β€ t) | |
(htβ : t β€ 1) : | |
x + t β’ (y - x) β s := | |
begin | |
apply hs.segment_subset hy, | |
rw segment_eq_image', | |
exact mem_image_of_mem _ β¨htβ, htββ©, | |
end | |
/-- The preimage of a star-convex set under an affine map is star-convex. -/ | |
lemma star_convex.affine_preimage (f : E βα΅[π] F) {s : set F} (hs : star_convex π (f x) s) : | |
star_convex π x (f β»ΒΉ' s) := | |
begin | |
intros y hy a b ha hb hab, | |
rw [mem_preimage, convex.combo_affine_apply hab], | |
exact hs hy ha hb hab, | |
end | |
/-- The image of a star-convex set under an affine map is star-convex. -/ | |
lemma star_convex.affine_image (f : E βα΅[π] F) {s : set E} (hs : star_convex π x s) : | |
star_convex π (f x) (f '' s) := | |
begin | |
rintro y β¨y', β¨hy', hy'fβ©β© a b ha hb hab, | |
refine β¨a β’ x + b β’ y', β¨hs hy' ha hb hab, _β©β©, | |
rw [convex.combo_affine_apply hab, hy'f], | |
end | |
lemma star_convex.neg (hs : star_convex π x s) : star_convex π (-x) (-s) := | |
by { rw βimage_neg, exact hs.is_linear_image is_linear_map.is_linear_map_neg } | |
lemma star_convex.sub (hs : star_convex π x s) (ht : star_convex π y t) : | |
star_convex π (x - y) (s - t) := | |
by { simp_rw sub_eq_add_neg, exact hs.add ht.neg } | |
end add_comm_group | |
end ordered_ring | |
section linear_ordered_field | |
variables [linear_ordered_field π] | |
section add_comm_group | |
variables [add_comm_group E] [module π E] {x : E} {s : set E} | |
/-- Alternative definition of star-convexity, using division. -/ | |
lemma star_convex_iff_div : | |
star_convex π x s β β β¦yβ¦, y β s β β β¦a b : πβ¦, 0 β€ a β 0 β€ b β 0 < a + b β | |
(a / (a + b)) β’ x + (b / (a + b)) β’ y β s := | |
β¨Ξ» h y hy a b ha hb hab, begin | |
apply h hy, | |
{ have ha', from mul_le_mul_of_nonneg_left ha (inv_pos.2 hab).le, | |
rwa [mul_zero, βdiv_eq_inv_mul] at ha' }, | |
{ have hb', from mul_le_mul_of_nonneg_left hb (inv_pos.2 hab).le, | |
rwa [mul_zero, βdiv_eq_inv_mul] at hb' }, | |
{ rw βadd_div, | |
exact div_self hab.ne' } | |
end, Ξ» h y hy a b ha hb hab, | |
begin | |
have h', from h hy ha hb, | |
rw [hab, div_one, div_one] at h', | |
exact h' zero_lt_one | |
endβ© | |
lemma star_convex.mem_smul (hs : star_convex π 0 s) (hx : x β s) {t : π} (ht : 1 β€ t) : | |
x β t β’ s := | |
begin | |
rw mem_smul_set_iff_inv_smul_memβ (zero_lt_one.trans_le ht).ne', | |
exact hs.smul_mem hx (inv_nonneg.2 $ zero_le_one.trans ht) (inv_le_one ht), | |
end | |
end add_comm_group | |
end linear_ordered_field | |
/-! | |
#### Star-convex sets in an ordered space | |
Relates `star_convex` and `set.ord_connected`. | |
-/ | |
section ord_connected | |
lemma set.ord_connected.star_convex [ordered_semiring π] [ordered_add_comm_monoid E] | |
[module π E] [ordered_smul π E] {x : E} {s : set E} (hs : s.ord_connected) (hx : x β s) | |
(h : β y β s, x β€ y β¨ y β€ x) : | |
star_convex π x s := | |
begin | |
intros y hy a b ha hb hab, | |
obtain hxy | hyx := h _ hy, | |
{ refine hs.out hx hy (mem_Icc.2 β¨_, _β©), | |
calc | |
x = a β’ x + b β’ x : (convex.combo_self hab _).symm | |
... β€ a β’ x + b β’ y : add_le_add_left (smul_le_smul_of_nonneg hxy hb) _, | |
calc | |
a β’ x + b β’ y | |
β€ a β’ y + b β’ y : add_le_add_right (smul_le_smul_of_nonneg hxy ha) _ | |
... = y : convex.combo_self hab _ }, | |
{ refine hs.out hy hx (mem_Icc.2 β¨_, _β©), | |
calc | |
y = a β’ y + b β’ y : (convex.combo_self hab _).symm | |
... β€ a β’ x + b β’ y : add_le_add_right (smul_le_smul_of_nonneg hyx ha) _, | |
calc | |
a β’ x + b β’ y | |
β€ a β’ x + b β’ x : add_le_add_left (smul_le_smul_of_nonneg hyx hb) _ | |
... = x : convex.combo_self hab _ } | |
end | |
lemma star_convex_iff_ord_connected [linear_ordered_field π] {x : π} {s : set π} (hx : x β s) : | |
star_convex π x s β s.ord_connected := | |
by simp_rw [ord_connected_iff_interval_subset_left hx, star_convex_iff_segment_subset, | |
segment_eq_interval] | |
alias star_convex_iff_ord_connected β star_convex.ord_connected _ | |
end ord_connected | |
/-! #### Star-convexity of submodules/subspaces -/ | |
section submodule | |
open submodule | |
lemma submodule.star_convex [ordered_semiring π] [add_comm_monoid E] [module π E] | |
(K : submodule π E) : | |
star_convex π (0 : E) K := | |
K.convex.star_convex K.zero_mem | |
lemma subspace.star_convex [linear_ordered_field π] [add_comm_group E] [module π E] | |
(K : subspace π E) : | |
star_convex π (0 : E) K := | |
K.convex.star_convex K.zero_mem | |
end submodule | |