@@ -9,6 +9,7 @@ public import Mathlib.Analysis.Convex.Combination
99public import Mathlib.Analysis.Normed.Group.AddTorsor
1010public import Mathlib.Analysis.Normed.Module.Basic
1111public import Mathlib.Geometry.Convex.ConvexSpace.AffineSpace
12+ public import Mathlib.Geometry.Convex.ConvexSpace.Module
1213
1314/-!
1415
@@ -40,11 +41,9 @@ public section
4041
4142namespace Convexity
4243
43- attribute [local instance ] AddTorsor.toConvexSpace
44-
4544open ConvexSpace
4645
47- variable {I X : Type *} [ConvexSpace ℝ X] [MetricSpace X]
46+ variable {I X : Type *}
4847
4948variable (X) in
5049/-- A convex metric space is a real convex space with a compatible metric structure.
@@ -56,19 +55,19 @@ In particular, convex subsets of normed affine spaces are convex metric spaces.
5655Note that there is a separate notion of
5756[ convex metric spaces ] (https://en.wikipedia.org/wiki/Convex_metric_space) in the literature
5857that has little to do with this definition. -/
59- class IsConvexDist : Prop where
58+ class IsConvexDist [inst₁ : ConvexSpace ℝ X] [inst₂ : MetricSpace X] : Prop where
6059 /-- Use `dist_iConvexComb_le` instead. -/
61- dist_iConvexComb_fst_snd_le (f : StdSimplex ℝ (X × X)) :
60+ dist_iConvexComb_fst_snd_le [inst₁] [inst₂] (f : StdSimplex ℝ (X × X)) :
6261 dist (f.iConvexComb Prod.fst) (f.iConvexComb Prod.snd) ≤ f.iConvexComb fun x ↦ dist x.1 x.2
6362
6463@ [deprecated (since := "2026-05-15" )] alias IsConvexMetricSpace := IsConvexDist
6564
66- variable [IsConvexDist X]
65+ variable [ConvexSpace ℝ X] [MetricSpace X] [ IsConvexDist X]
6766
6867/-- `dist(∑ tᵢ xᵢ, ∑ tᵢ yᵢ) ≤ ∑ tᵢ dist(xᵢ, yᵢ)` -/
6968lemma dist_iConvexComb_le {ι : Type *} (f : StdSimplex ℝ ι) (x y : ι → X) :
7069 dist (f.iConvexComb x) (f.iConvexComb y) ≤ f.iConvexComb fun i ↦ dist (x i) (y i) := by
71- simpa [iConvexComb_map, Function.comp_def ]
70+ simpa [iConvexComb_map, Finsupp.sum_mapDomain_index, add_mul ]
7271 using IsConvexDist.dist_iConvexComb_fst_snd_le (f.map fun i ↦ (x i, y i))
7372
7473@ [deprecated (since := "2026-05-15" )] alias dist_convexCombination_right_le := dist_iConvexComb_le
@@ -257,13 +256,13 @@ lemma continuous_convexCombPair' [BoundedSpace X]
257256@ [deprecated (since := "2026-05-15" )]
258257alias continuous_convexComboPair' := continuous_convexCombPair'
259258
259+ variable {R E : Type *} [LinearOrder R] [Field R] [IsStrictOrderedRing R] [AddCommGroup E]
260+ [Module R E] [ConvexSpace R E] [IsModuleConvexSpace R E] {S : Set E}
261+
260262/-- A convex subset of a vector space is a convex space. -/
261263-- TODO: this should generalize to arbitrary convex space once `Convex` is redefined.
262264@ [expose, implicit_reducible]
263- noncomputable def ConvexSpace.ofConvex
264- {R E : Type *} [LinearOrder R] [Field R] [IsStrictOrderedRing R]
265- [AddCommGroup E] [Module R E] {S : Set E} (H : Convex R S) :
266- ConvexSpace R S where
265+ noncomputable def ConvexSpace.ofConvex (H : Convex R S) : ConvexSpace R S where
267266 sConvexComb f :=
268267 ⟨sConvexComb (f.map (↑)), by
269268 simpa [sConvexComb_eq_sum, StdSimplex.map, Finsupp.sum_mapDomain_index, add_smul] using
@@ -273,52 +272,49 @@ noncomputable def ConvexSpace.ofConvex
273272 StdSimplex.join, Finsupp.sum_sum_index, Finsupp.sum_smul_index, mul_smul, Finsupp.smul_sum]
274273 sConvexComb_single x := by simp [sConvexComb_eq_sum, ← StdSimplex.mk_single, StdSimplex.map]
275274
276- lemma isAffineMap_coe {R E : Type *} [LinearOrder R] [Field R] [IsStrictOrderedRing R]
277- [AddCommGroup E] [Module R E] (S : Set E) (H : Convex R S) :
275+ lemma isAffineMap_coe (S : Set E) (H : Convex R S) :
278276 letI : ConvexSpace R S := .ofConvex H
279277 IsAffineMap R ((↑) : S → E) :=
280278 letI : ConvexSpace R S := .ofConvex H
281279 ⟨fun _ ↦ rfl⟩
282280
283281@[simp]
284- lemma ConvexSpace.ofConvex.coe_sConvexComb
285- {R E : Type *} [LinearOrder R] [Field R] [IsStrictOrderedRing R]
286- [AddCommGroup E] [Module R E] (S : Set E) (H : Convex R S) (f : StdSimplex R S) :
282+ lemma ConvexSpace.ofConvex.coe_sConvexComb (S : Set E) (H : Convex R S) (f : StdSimplex R S) :
287283 letI : ConvexSpace R S := .ofConvex H
288284 (↑f.sConvexComb : E) = (f.map (↑)).sConvexComb :=
289285 rfl
290286
291287@[simp]
292- lemma ConvexSpace.ofConvex.coe_iConvexComb
293- {R I E : Type *} [LinearOrder R] [Field R] [IsStrictOrderedRing R]
294- [AddCommGroup E] [Module R E] (S : Set E) (H : Convex R S) (f : StdSimplex R I) (g : I → S) :
288+ lemma ConvexSpace.ofConvex.coe_iConvexComb (S : Set E) (H : Convex R S) (f : StdSimplex R I)
289+ (g : I → S) :
295290 letI : ConvexSpace R S := .ofConvex H
296291 (↑(f.iConvexComb g) : E) = f.iConvexComb fun x ↦ ↑(g x) :=
297292 letI : ConvexSpace R S := .ofConvex H
298293 (isAffineMap_coe S H).map_iConvexComb f g
299294
295+ attribute [local instance ] AddTorsor.toConvexSpace in
300296instance (priority := low) {V P : Type *}
301297 [NormedAddCommGroup V] [NormedSpace ℝ V] [MetricSpace P] [NormedAddTorsor V P] :
302298 IsConvexDist P where
303299 dist_iConvexComb_fst_snd_le f := by
304300 let p : P := Nonempty.some inferInstance
305- simp only [AddTorsor.iConvexComb_eq_affineCombination, ge_iff_le ]
301+ simp only [AddTorsor.iConvexComb_eq_affineCombination]
306302 rw [Finset.affineCombination_eq_weightedVSubOfPoint_vadd_of_sum_eq_one _ _ _ f.total p,
307- Finset.affineCombination_eq_weightedVSubOfPoint_vadd_of_sum_eq_one _ _ _ f.total p,
308- Finset.affineCombination_eq_weightedVSubOfPoint_vadd_of_sum_eq_one _ _ _ f.total 0 ]
303+ Finset.affineCombination_eq_weightedVSubOfPoint_vadd_of_sum_eq_one _ _ _ f.total p]
309304 suffices ‖f.weights.sum fun a b ↦ b • (a.1 -ᵥ a.2 )‖ ≤
310305 f.weights.sum fun a b ↦ b * ‖a.1 -ᵥ a.2 ‖ by
311306 simpa [dist_eq_norm_vsub, Finsupp.sum, ← Finset.sum_sub_distrib, ← smul_sub]
312307 grw [Finsupp.sum, Finsupp.sum, norm_sum_le]
313308 simp [norm_smul, abs_eq_self.mpr (f.nonneg _)]
314309
315310instance IsConvexDist.of_convex {E : Type *} [NormedAddCommGroup E]
316- [NormedSpace ℝ E] {S : Set E} (H : Convex ℝ S) :
311+ [NormedSpace ℝ E] [ConvexSpace ℝ E] [IsModuleConvexSpace ℝ E] [IsConvexDist E] {S : Set E}
312+ (H : Convex ℝ S) :
317313 letI : ConvexSpace ℝ S := .ofConvex H
318314 IsConvexDist S := by
319315 letI : ConvexSpace ℝ S := .ofConvex H
320316 refine ⟨fun f ↦ ?_⟩
321317 convert dist_iConvexComb_fst_snd_le (X := E) (f.map fun x ↦ (x.1 , x.2 )) <;>
322- simp [Subtype.dist_eq, iConvexComb_map, Function.comp_def ]
318+ simp [Subtype.dist_eq, Finsupp.sum_mapDomain_index, add_mul, add_smul ]
323319
324320end Convexity
0 commit comments