Skip to content

Commit 3a3edd3

Browse files
committed
feat: the ConvexCone generated by a set (leanprover-community#25292)
Define `ConvexCone.copy` and `ConvexCone.hull` and use them to golf the `CompleteLattice` instance. From Toric
1 parent 5e62b58 commit 3a3edd3

2 files changed

Lines changed: 94 additions & 35 deletions

File tree

Mathlib/Analysis/Convex/Cone/Basic.lean

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ The next steps are:
4242

4343
open ContinuousLinearMap Filter Function Set
4444

45-
variable {R E F G : Type*} [Semiring R] [PartialOrder R] [IsOrderedRing R]
45+
variable {𝕜 R E F G : Type*} [Semiring R] [PartialOrder R] [IsOrderedRing R]
4646
variable [AddCommMonoid E] [TopologicalSpace E] [Module R E]
4747
variable [AddCommMonoid F] [TopologicalSpace F] [Module R F]
4848
variable [AddCommMonoid G] [TopologicalSpace G] [Module R G]
@@ -161,11 +161,23 @@ end ProperCone
161161
### Topological properties of convex cones
162162
163163
This section proves topological results about convex cones.
164+
165+
#### TODO
166+
167+
This result generalises to G-submodules.
164168
-/
165169

166170
namespace ConvexCone
167-
variable {𝕜 E : Type*} [TopologicalSpace 𝕜] [Semifield 𝕜] [LinearOrder 𝕜] [OrderTopology 𝕜]
168-
[DenselyOrdered 𝕜] [NoMaxOrder 𝕜] [AddCommGroup E] [TopologicalSpace E] [Module 𝕜 E]
171+
variable [Semifield 𝕜] [LinearOrder 𝕜] [Module 𝕜 E] {s : Set E}
172+
173+
-- FIXME: This is necessary for the proof below but triggers the `unusedSectionVars` linter.
174+
-- variable [IsStrictOrderedRing 𝕜] [IsTopologicalAddGroup M] in
175+
/-- This is true essentially by `Submodule.span_eq_iUnion_nat`, except that `Submodule` currently
176+
doesn't support that use case. See
177+
https://leanprover.zulipchat.com/#narrow/channel/116395-maths/topic/G-submodules/with/514426583 -/
178+
proof_wanted isOpen_hull (hs : IsOpen s) : IsOpen (hull 𝕜 s : Set E)
179+
180+
variable [TopologicalSpace 𝕜] [OrderTopology 𝕜] [DenselyOrdered 𝕜] [NoMaxOrder 𝕜]
169181
[ContinuousSMul 𝕜 E] {C : ConvexCone 𝕜 E}
170182

171183
lemma Pointed.of_nonempty_of_isClosed (hC : (C : Set E).Nonempty) (hSclos : IsClosed (C : Set E)) :

Mathlib/Geometry/Convex/Cone/Basic.lean

Lines changed: 79 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -90,15 +90,14 @@ protected lemma add_mem ⦃x⦄ (hx : x ∈ C) ⦃y⦄ (hy : y ∈ C) : x + y
9090

9191
instance : AddMemClass (ConvexCone R M) M where add_mem ha hb := add_mem' _ ha hb
9292

93-
instance : Min (ConvexCone R M) :=
94-
fun S T =>
95-
⟨S ∩ T, fun _ hc _ hx => ⟨S.smul_mem hc hx.1, T.smul_mem hc hx.2⟩, fun _ hx _ hy =>
96-
⟨S.add_mem hx.1 hy.1, T.add_mem hx.2 hy.2⟩⟩⟩
93+
/-- Copy of a convex cone with a new `carrier` equal to the old one. Useful to fix definitional
94+
equalities. -/
95+
@[simps] protected def copy (C : ConvexCone R M) (s : Set M) (hs : s = C) : ConvexCone R M where
96+
carrier := s
97+
add_mem' := hs.symm ▸ C.add_mem'
98+
smul_mem' := by simpa [hs] using C.smul_mem'
9799

98-
variable (C₁ C₂) in
99-
@[simp, norm_cast] lemma coe_inf : (C₁ ⊓ C₂) = (C₁ ∩ C₂ : Set M) := rfl
100-
101-
@[simp] lemma mem_inf : x ∈ C₁ ⊓ C₂ ↔ x ∈ C₁ ∧ x ∈ C₂ := .rfl
100+
lemma copy_eq (C : ConvexCone R M) (s : Set M) (hs) : C.copy s hs = C := SetLike.coe_injective hs
102101

103102
instance : InfSet (ConvexCone R M) where
104103
sInf S :=
@@ -119,6 +118,30 @@ theorem coe_iInf {ι : Sort*} (f : ι → ConvexCone R M) : ↑(iInf f) = ⋂ i,
119118
lemma mem_iInf {ι : Sort*} {f : ι → ConvexCone R M} : x ∈ iInf f ↔ ∀ i, x ∈ f i :=
120119
mem_iInter₂.trans <| by simp
121120

121+
instance : CompleteSemilatticeInf (ConvexCone R M) where
122+
sInf_le C C hC := by rw [← SetLike.coe_subset_coe, coe_sInf]; exact biInter_subset_of_mem hC
123+
le_sInf C C hC := by rw [← SetLike.coe_subset_coe, coe_sInf]; exact subset_iInter₂ hC
124+
125+
variable (R s) in
126+
/-- The cone hull of a set. The smallest convex cone containing that set. -/
127+
def hull : ConvexCone R M := sInf {C : ConvexCone R M | s ⊆ C}
128+
129+
lemma subset_hull : s ⊆ hull R s := by simp [hull]
130+
131+
lemma hull_min (hsC : s ⊆ C) : hull R s ≤ C := sInf_le hsC
132+
133+
lemma hull_le_iff : hull R s ≤ C ↔ s ⊆ C := ⟨subset_hull.trans, hull_min⟩
134+
135+
lemma gc_hull_coe : GaloisConnection (hull R : Set M → ConvexCone R M) (↑) :=
136+
fun _C _s ↦ hull_le_iff
137+
138+
/-- Galois insertion between `ConvexCone` and `SetLike.coe`. -/
139+
protected def gi : GaloisInsertion (hull R : Set M → ConvexCone R M) (↑) where
140+
gc := gc_hull_coe
141+
le_l_u _ := subset_hull
142+
choice s hs := (hull R s).copy s <| subset_hull.antisymm hs
143+
choice_eq _ _ := copy_eq _ _ _
144+
122145
instance : Bot (ConvexCone R M) :=
123146
⟨⟨∅, fun _ _ _ => False.elim, fun _ => False.elim⟩⟩
124147

@@ -133,35 +156,23 @@ theorem mem_bot (x : M) : (x ∈ (⊥ : ConvexCone R M)) = False :=
133156
@[simp, norm_cast]
134157
lemma coe_eq_empty : (C : Set M) = ∅ ↔ C = ⊥ := by rw [← coe_bot (R := R)]; norm_cast
135158

136-
instance : Top (ConvexCone R M) :=
137-
⟨⟨univ, fun _ _ _ _ => mem_univ _, fun _ _ _ _ => mem_univ _⟩⟩
159+
instance : CompleteLattice (ConvexCone R M) where
160+
bot := ⊥
161+
bot_le _ := empty_subset _
162+
__ := instCompleteSemilatticeInf
163+
__ := ConvexCone.gi.liftCompleteLattice
164+
165+
variable (C₁ C₂) in
166+
@[simp, norm_cast] lemma coe_inf : (C₁ ⊓ C₂) = (C₁ ∩ C₂ : Set M) := rfl
167+
168+
@[simp] lemma mem_inf : x ∈ C₁ ⊓ C₂ ↔ x ∈ C₁ ∧ x ∈ C₂ := .rfl
138169

139170
@[simp] lemma mem_top : x ∈ (⊤ : ConvexCone R M) := mem_univ x
140171

141172
@[simp, norm_cast] lemma coe_top : ↑(⊤ : ConvexCone R M) = (univ : Set M) := rfl
142173

143-
instance : CompleteLattice (ConvexCone R M) :=
144-
{ SetLike.instPartialOrder with
145-
le := (· ≤ ·)
146-
lt := (· < ·)
147-
bot := ⊥
148-
bot_le := fun _ _ => False.elim
149-
top := ⊤
150-
le_top _ _ _ := mem_top
151-
inf := (· ⊓ ·)
152-
sInf := InfSet.sInf
153-
sup := fun a b => sInf { x | a ≤ x ∧ b ≤ x }
154-
sSup := fun s => sInf { T | ∀ S ∈ s, S ≤ T }
155-
le_sup_left := fun _ _ => fun _ hx => mem_sInf.2 fun _ hs => hs.1 hx
156-
le_sup_right := fun _ _ => fun _ hx => mem_sInf.2 fun _ hs => hs.2 hx
157-
sup_le := fun _ _ c ha hb _ hx => mem_sInf.1 hx c ⟨ha, hb⟩
158-
le_inf := fun _ _ _ ha hb _ hx => ⟨ha hx, hb hx⟩
159-
inf_le_left := fun _ _ _ => And.left
160-
inf_le_right := fun _ _ _ => And.right
161-
le_sSup := fun _ p hs _ hx => mem_sInf.2 fun _ ht => ht p hs hx
162-
sSup_le := fun _ p hs _ hx => mem_sInf.1 hx p hs
163-
le_sInf := fun _ _ ha _ hx => mem_sInf.2 fun t ht => ha t ht hx
164-
sInf_le := fun _ _ ha _ hx => mem_sInf.1 hx _ ha }
174+
@[simp, norm_cast] lemma disjoint_coe : Disjoint (C₁ : Set M) C₂ ↔ Disjoint C₁ C₂ := by
175+
simp [disjoint_iff, ← coe_inf]
165176

166177
instance : Inhabited (ConvexCone R M) := ⟨⊥⟩
167178

@@ -376,6 +387,42 @@ end Module
376387

377388
end OrderedSemiring
378389

390+
section Field
391+
variable [Field 𝕜] [LinearOrder 𝕜] [IsStrictOrderedRing 𝕜] [AddCommGroup M] [Module 𝕜 M]
392+
{C : ConvexCone 𝕜 M} {s : Set M} {x : M}
393+
394+
/-- The cone hull of a convex set is simply the union of the open halflines through that set. -/
395+
lemma mem_hull_of_convex (hs : Convex 𝕜 s) : x ∈ hull 𝕜 s ↔ ∃ r : 𝕜, 0 < r ∧ x ∈ r • s where
396+
mp hx := hull_min (C := {
397+
carrier := {y | ∃ r : 𝕜, 0 < r ∧ y ∈ r • s}
398+
smul_mem' := by
399+
intro r₁ hr₁ y ⟨r₂, hr₂, hy⟩
400+
refine ⟨r₁ * r₂, mul_pos hr₁ hr₂, ?_⟩
401+
rw [mul_smul]
402+
exact smul_mem_smul_set hy
403+
add_mem' := by
404+
rintro y₁ ⟨r₁, hr₁, hy₁⟩ y₂ ⟨r₂, hr₂, hy₂⟩
405+
refine ⟨r₁ + r₂, add_pos hr₁ hr₂, ?_⟩
406+
rw [hs.add_smul hr₁.le hr₂.le]
407+
exact add_mem_add hy₁ hy₂
408+
}) (fun y hy ↦ ⟨1, by simpa⟩) hx
409+
mpr := by rintro ⟨r, hr, y, hy, rfl⟩; exact (hull 𝕜 s).smul_mem hr <| subset_hull hy
410+
411+
/-- The cone hull of a convex set is simply the union of the open halflines through that set. -/
412+
lemma coe_hull_of_convex (hs : Convex 𝕜 s) : hull 𝕜 s = {x | ∃ r : 𝕜, 0 < r ∧ x ∈ r • s} := by
413+
ext; exact mem_hull_of_convex hs
414+
415+
lemma disjoint_hull_left_of_convex (hs : Convex 𝕜 s) : Disjoint (hull 𝕜 s) C ↔ Disjoint s C where
416+
mp := by rw [← disjoint_coe]; exact .mono_left subset_hull
417+
mpr := by
418+
simp_rw [← disjoint_coe, disjoint_left, SetLike.mem_coe, mem_hull_of_convex hs]
419+
rintro hsC _ ⟨r, hr, y, hy, rfl⟩
420+
exact (C.smul_mem_iff hr).not.mpr (hsC hy)
421+
422+
lemma disjoint_hull_right_of_convex (hs : Convex 𝕜 s) : Disjoint C (hull 𝕜 s) ↔ Disjoint ↑C s := by
423+
rw [disjoint_comm, disjoint_hull_left_of_convex hs, disjoint_comm]
424+
425+
end Field
379426
end ConvexCone
380427

381428
namespace Submodule

0 commit comments

Comments
 (0)