Skip to content

Commit 89e23b4

Browse files
YaelDilliesReemMelamed
authored andcommitted
feat(Geometry/Convex): star-convex sets in a convex space (leanprover-community#40230)
Define `IsStarConvexSet`,a predicate for a set in a `ConvexSpace` to be star-convex at a point. Add a few lemmas about `IsAffineMap` as preliminaries to lemmas about star-convex sets in a module. The existing `Module`-specific `StarConvex` predicate will be deprecated in a future PR.
1 parent 43c4b9b commit 89e23b4

4 files changed

Lines changed: 174 additions & 9 deletions

File tree

Mathlib.lean

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4550,6 +4550,7 @@ public import Mathlib.Geometry.Convex.ConvexSpace.Module
45504550
public import Mathlib.Geometry.Convex.ConvexSpace.Prod
45514551
public import Mathlib.Geometry.Convex.Hull
45524552
public import Mathlib.Geometry.Convex.Set
4553+
public import Mathlib.Geometry.Convex.Star
45534554
public import Mathlib.Geometry.Diffeology.Basic
45544555
public import Mathlib.Geometry.Euclidean.Altitude
45554556
public import Mathlib.Geometry.Euclidean.Angle.Bisector

Mathlib/Analysis/Convex/Star.lean

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,13 +39,11 @@ Concretely, the empty set is star-convex at every point.
3939
4040
## TODO
4141
42-
Balanced sets are star-convex.
43-
4442
The closure of a star-convex set is star-convex.
4543
46-
Star-convex sets are contractible.
47-
4844
A nonempty open star-convex set in `ℝ^n` is diffeomorphic to the entire space.
45+
46+
Replace with `Convexity.IsStarConvexSet`.
4947
-/
5048

5149
@[expose] public section

Mathlib/Geometry/Convex/ConvexSpace/Module.lean

Lines changed: 51 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@ Authors: Yaël Dillies
55
-/
66
module
77

8-
public import Mathlib.Geometry.Convex.Set
8+
public import Mathlib.Algebra.Group.Pointwise.Set.Basic
9+
public import Mathlib.Geometry.Convex.Star
910
public import Mathlib.LinearAlgebra.AffineSpace.Combination
1011
public import Mathlib.LinearAlgebra.AffineSpace.AffineMap
1112

@@ -21,12 +22,16 @@ This file shows that every module over ordered coefficients is a convex space.
2122
* `IsModuleConvexSpace`: Predicate for a convex space and module structures to be compatible.
2223
-/
2324

25+
open scoped Pointwise
26+
2427
public noncomputable section
2528

2629
namespace Convexity
2730
variable {F R M N I : Type*} [Semiring R] [PartialOrder R] [IsStrictOrderedRing R]
28-
[AddCommMonoid M] [Module R M] [AddCommMonoid N] [Module R N] [SetLike F M]
29-
[AddSubmonoidClass F M] [SMulMemClass F R M]
31+
32+
section AddCommMonoid
33+
variable [AddCommMonoid M] [Module R M] [AddCommMonoid N] [Module R N] [SetLike F M]
34+
[AddSubmonoidClass F M] [SMulMemClass F R M] {f g : M → N}
3035

3136
/-- Any semimodule over an ordered semiring is a convex space.
3237
@@ -62,7 +67,8 @@ protected lemma IsModuleConvexSpace.ofModule : IsModuleConvexSpace R M where
6267
instance isModuleConvexSpace_self : IsModuleConvexSpace R R := .ofModule
6368

6469
section IsModuleConvexSpace
65-
variable [ConvexSpace R M] [IsModuleConvexSpace R M]
70+
variable [ConvexSpace R M] [IsModuleConvexSpace R M] [ConvexSpace R N] [IsModuleConvexSpace R N]
71+
{x y : M} {s t : Set M} {a b : R}
6672

6773
/-- `iConvexComb` in a module can be expressed as a sum. -/
6874
@[simp]
@@ -76,6 +82,14 @@ lemma convexCombPair_eq_sum (a b : R) (ha hb hab) (x y : M) :
7682
convexCombPair a b ha hb hab x y = a • x + b • y := by
7783
classical simp [convexCombPair, sConvexComb_eq_sum, Finsupp.sum_add_index, add_smul]
7884

85+
lemma IsAffineMap.map_sum_weights (hf : IsAffineMap R f) (w : StdSimplex R I) (g : I → M) :
86+
f (w.weights.sum fun i r ↦ r • g i) = w.weights.sum fun i r ↦ r • f (g i) := by
87+
simpa using hf.map_iConvexComb w g
88+
89+
lemma IsAffineMap.map_smul_add_smul (hf : IsAffineMap R f) (ha : 0 ≤ a) (hb : 0 ≤ b)
90+
(hab : a + b = 1) (x y : M) : f (a • x + b • y) = a • f x + b • f y := by
91+
simpa using hf.map_convexCombPair ha hb hab x y
92+
7993
@[simp] lemma isConvexSet_coe (S : F) : IsConvexSet R (S : Set M) := by
8094
refine .of_sConvexComb_mem fun w hw ↦ ?_
8195
rw [sConvexComb_eq_sum]
@@ -96,7 +110,7 @@ lemma subtypeVal_submodule_convexCombPair (S : F) (a b : R) (ha hb hab) (x y : S
96110

97111
instance (S : F) : IsModuleConvexSpace R S where sConvexComb_eq_sum w := by ext; simp [Finsupp.sum]
98112

99-
instance [ConvexSpace R N] [IsModuleConvexSpace R N] : IsModuleConvexSpace R (M × N) where
113+
instance : IsModuleConvexSpace R (M × N) where
100114
sConvexComb_eq_sum w := by ext <;> simp [Finsupp.sum, Prod.fst_sum, Prod.snd_sum]
101115

102116
instance {ι : Type*} {M : ι → Type*} [∀ i, AddCommMonoid (M i)] [∀ i, Module R (M i)]
@@ -107,10 +121,42 @@ instance {ι : Type*} {M : ι → Type*} [∀ i, AddCommMonoid (M i)] [∀ i, Mo
107121
instance {ι : Type*} : IsModuleConvexSpace R (ι →₀ M) where
108122
sConvexComb_eq_sum w := by ext; simp [Finsupp.sum]
109123

124+
@[to_fun (attr := fun_prop)]
125+
lemma IsAffineMap.add (hf : IsAffineMap R f) (hg : IsAffineMap R g) : IsAffineMap R (f + g) where
126+
map_sConvexComb w := by
127+
simp [hf.map_sum_weights, hg.map_sum_weights, Finsupp.sum_mapDomain_index, add_smul]
128+
129+
lemma IsStarConvexSet.add (hs : IsStarConvexSet R x s) (ht : IsStarConvexSet R y t) :
130+
IsStarConvexSet R (x + y) (s + t) := by
131+
rw [← Set.add_image_prod]; exact (hs.prod ht).image (by fun_prop)
132+
110133
end IsModuleConvexSpace
111134

112135
variable (R I) in
113136
lemma StdSimplex.isAffineMap_weights : IsAffineMap R (weights (R := R) (M := I)) where
114137
map_sConvexComb s := by simp [sConvexComb_eq_sum, Finsupp.sum_mapDomain_index, add_smul]
115138

139+
end AddCommMonoid
140+
141+
section AddCommGroup
142+
variable [AddCommGroup M] [Module R M] [AddCommGroup N] [Module R N]
143+
[ConvexSpace R M] [IsModuleConvexSpace R M] [ConvexSpace R N] [IsModuleConvexSpace R N]
144+
{x y : M} {s t : Set M} {f g : M → N}
145+
146+
@[to_fun (attr := fun_prop)]
147+
lemma IsAffineMap.neg (hf : IsAffineMap R f) : IsAffineMap R (-f) where
148+
map_sConvexComb w := by simp [hf.map_sum_weights, Finsupp.sum_mapDomain_index, add_smul]
149+
150+
@[to_fun (attr := fun_prop)]
151+
lemma IsAffineMap.sub (hf : IsAffineMap R f) (hg : IsAffineMap R g) : IsAffineMap R (f - g) := by
152+
simpa [sub_eq_add_neg] using hf.add hg.neg
153+
154+
lemma IsStarConvexSet.neg (hs : IsStarConvexSet R x s) : IsStarConvexSet R (-x) (-s) := by
155+
rw [← Set.image_neg_eq_neg]; exact hs.image (by fun_prop)
156+
157+
lemma IsStarConvexSet.sub (hs : IsStarConvexSet R x s) (ht : IsStarConvexSet R y t) :
158+
IsStarConvexSet R (x - y) (s - t) := by
159+
rw [← Set.sub_image_prod]; exact (hs.prod ht).image (by fun_prop)
160+
161+
end AddCommGroup
116162
end Convexity

Mathlib/Geometry/Convex/Star.lean

Lines changed: 120 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
1+
/-
2+
Copyright (c) 2026 Yaël Dillies. All rights reserved.
3+
Released under Apache 2.0 license as described in the file LICENSE.
4+
Authors: Yaël Dillies
5+
-/
6+
module
7+
8+
public import Mathlib.Geometry.Convex.Set
9+
10+
/-!
11+
# Star-convex sets
12+
13+
This file defines star-convex sets in a convex space.
14+
15+
A set is star-convex at `x` if every segment from `x` to a point in the set is contained in the set.
16+
17+
This is the prototypical example of a contractible set in homotopy theory (by scaling every point
18+
towards `x`), but has wider uses.
19+
20+
Note that this has nothing to do with star rings, `Star` and co.
21+
22+
## Implementation notes
23+
24+
Instead of saying that a set is star-convex, we say a set is star-convex *at a point*. This has the
25+
advantage of allowing us to talk about convexity as being "everywhere star-convexity" and of making
26+
the union of star-convex sets be star-convex.
27+
28+
Incidentally, this choice means we don't need to assume a set is nonempty for it to be star-convex.
29+
Concretely, the empty set is star-convex at every point.
30+
-/
31+
32+
open Finsupp Set
33+
34+
public section
35+
36+
namespace Convexity
37+
variable {R X Y : Type*} {ι : Sort*} {κ : ι → Sort*}
38+
39+
section Semiring
40+
variable [Semiring R] [PartialOrder R] [IsStrictOrderedRing R] [ConvexSpace R X] [ConvexSpace R Y]
41+
{f : X → Y} {w : StdSimplex R X} {x : X} {s t : Set X} {y : X}
42+
43+
variable (R x s) in
44+
/-- A set `s` is star-convex at a point `x` if every segment from `x` to a point in `s` is
45+
contained in `s`.
46+
47+
TODO: Replace `StarConvex` with this predicate. -/
48+
@[expose]
49+
def IsStarConvexSet : Prop :=
50+
∀ ⦃y⦄, y ∈ s → ∀ ⦃a b : R⦄ ha hb hab, convexCombPair a b ha hb hab x y ∈ s
51+
52+
@[simp] protected lemma IsStarConvexSet.empty : IsStarConvexSet R x ∅ := by simp [IsStarConvexSet]
53+
54+
@[simp]
55+
protected lemma IsStarConvexSet.univ : IsStarConvexSet R x .univ := by simp [IsStarConvexSet]
56+
57+
@[simp] protected lemma IsStarConvexSet.singleton : IsStarConvexSet R x {x} := by
58+
simp [IsStarConvexSet]
59+
60+
@[grind ←]
61+
protected lemma IsStarConvexSet.inter (hs : IsStarConvexSet R x s) (ht : IsStarConvexSet R x t) :
62+
IsStarConvexSet R x (s ∩ t) := by simp +contextual [IsStarConvexSet, hs _, ht _]
63+
64+
@[grind ←]
65+
protected lemma IsStarConvexSet.union (hs : IsStarConvexSet R x s) (ht : IsStarConvexSet R x t) :
66+
IsStarConvexSet R x (s ∪ t) := by simp +contextual [IsStarConvexSet, hs _, ht _, or_imp]
67+
68+
@[grind ←]
69+
protected lemma IsStarConvexSet.sInter {S : Set (Set X)} (hS : ∀ s ∈ S, IsStarConvexSet R x s) :
70+
IsStarConvexSet R x (⋂₀ S) := by simp +contextual [IsStarConvexSet, hS _ _ _]
71+
72+
@[grind ←]
73+
protected lemma IsStarConvexSet.iInter {s : ι → Set X} (hs : ∀ i, IsStarConvexSet R x (s i)) :
74+
IsStarConvexSet R x (⋂ i, s i) := by simp +contextual [IsStarConvexSet, hs _ _]
75+
76+
lemma IsStarConvexSet.iInter₂ {s : ∀ i, κ i → Set X} (h : ∀ i j, IsStarConvexSet R x (s i j)) :
77+
IsStarConvexSet R x (⋂ i, ⋂ j, s i j) := .iInter fun i ↦ .iInter <| h i
78+
79+
@[grind ←]
80+
protected lemma IsStarConvexSet.sUnion {S : Set (Set X)} (hS : ∀ s ∈ S, IsStarConvexSet R x s) :
81+
IsStarConvexSet R x (⋃₀ S) := by
82+
rintro y ⟨s, hs, hy⟩ a ha b hb hab; exact ⟨s, hs, hS _ hs hy _ ..⟩
83+
84+
@[grind ←]
85+
protected lemma IsStarConvexSet.iUnion {s : ι → Set X} (hs : ∀ i, IsStarConvexSet R x (s i)) :
86+
IsStarConvexSet R x (⋃ i, s i) := .sUnion <| by simpa
87+
88+
protected lemma IsStarConvexSet.iUnion₂ {s : ∀ i, κ i → Set X}
89+
(h : ∀ i j, IsStarConvexSet R x (s i j)) : IsStarConvexSet R x (⋃ i, ⋃ j, s i j) :=
90+
.iUnion fun i ↦ .iUnion <| h i
91+
92+
lemma IsConvexSet.isStarConvexSet (hs : IsConvexSet R s) (hx : x ∈ s) : IsStarConvexSet R x s :=
93+
fun _y hy _a _b _ha _hb _hab ↦ hs.convexCombPair_mem hx hy ..
94+
95+
lemma IsStarConvexSet.mem (hs : IsStarConvexSet R x s) (hs₀ : s.Nonempty) : x ∈ s := by
96+
obtain ⟨y, hy⟩ := hs₀; simpa using hs hy zero_le_one le_rfl (add_zero _)
97+
98+
@[grind ←]
99+
protected lemma IsStarConvexSet.preimage {s : Set Y} (hf : IsAffineMap R f)
100+
(hs : IsStarConvexSet R (f x) s) : IsStarConvexSet R x (f ⁻¹' s) :=
101+
fun y hy a b ha hb hab ↦ by simpa [mem_preimage, hf.map_convexCombPair] using hs hy _ ..
102+
103+
@[grind <=]
104+
protected lemma IsStarConvexSet.image (hf : IsAffineMap R f) (hs : IsStarConvexSet R x s) :
105+
IsStarConvexSet R (f x) (f '' s) := by
106+
rintro _ ⟨y, hy, rfl⟩ a b ha hb hab; exact ⟨_, hs hy _ .., hf.map_convexCombPair ..⟩
107+
108+
@[grind ←]
109+
protected lemma IsStarConvexSet.prod {t : Set Y} {y : Y} (hs : IsStarConvexSet R x s)
110+
(ht : IsStarConvexSet R y t) : IsStarConvexSet R (x, y) (s ×ˢ t) := by
111+
rintro ⟨w, z⟩ ⟨hw, hz⟩ a b ha hb hab; exact ⟨by simpa using hs hw _ .., by simpa using ht hz _ ..⟩
112+
113+
@[grind ←]
114+
protected lemma IsStarConvexSet.pi {ι : Type*} {X : ι → Type*} [∀ i, ConvexSpace R (X i)]
115+
{s : Set ι} {x : ∀ i, X i} {t : ∀ i, Set (X i)} (ht : ∀ i ∈ s, IsStarConvexSet R (x i) (t i)) :
116+
IsStarConvexSet R x (s.pi t) :=
117+
fun y hy a b ha hb hab i hi ↦ by simpa using ht _ hi (hy _ hi) _ ..
118+
119+
end Semiring
120+
end Convexity

0 commit comments

Comments
 (0)