Skip to content

Commit e55b59b

Browse files
committed
feat(ConvexSpace): complete proof_wanted statements (leanprover-community#33562)
This PR proves the three `proof_wanted` statements for `convexComboPair`: - `convexComboPair_zero`: weight 0 on first point gives the second point - `convexComboPair_one`: weight 1 on first point gives the first point - `convexComboPair_same`: any convex combo of a point with itself is that point Also adds supporting lemmas: - `StdSimplex.ext`: extensionality lemma for `StdSimplex` - `StdSimplex.mk_single`: simp lemma for constructor applied to single - `@[simp]` attribute on `ConvexSpace.single` 🤖 Prepared with Claude Code
1 parent 9c68aa5 commit e55b59b

1 file changed

Lines changed: 24 additions & 7 deletions

File tree

Mathlib/LinearAlgebra/ConvexSpace.lean

Lines changed: 24 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -65,15 +65,25 @@ grind_pattern StdSimplex.total => self.weights
6565

6666
namespace StdSimplex
6767

68-
variable {R : Type u} [PartialOrder R] [Semiring R] [IsStrictOrderedRing R]
68+
variable {R : Type u} [PartialOrder R] [Semiring R]
6969
{M : Type v}
7070

71+
@[ext]
72+
theorem ext {f g : StdSimplex R M} (h : f.weights = g.weights) : f = g := by
73+
cases f; cases g; simp_all
74+
75+
variable [IsStrictOrderedRing R]
76+
7177
/-- The point mass distribution concentrated at `x`. -/
7278
def single (x : M) : StdSimplex R M where
7379
weights := Finsupp.single x 1
7480
nonneg := by simp
7581
total := by simp
7682

83+
@[simp]
84+
theorem mk_single (x : M) {nonneg total} :
85+
(StdSimplex.mk (Finsupp.single x (1 : R)) nonneg total) = single x := rfl
86+
7787
/-- A probability distribution with weight `s` on `x` and weight `t` on `y`. -/
7888
def duple (x y : M) {s t : R} (hs : 0 ≤ s) (ht : 0 ≤ t) (h : s + t = 1) : StdSimplex R M where
7989
weights := Finsupp.single x s + Finsupp.single y t
@@ -119,6 +129,8 @@ class ConvexSpace (R : Type u) (M : Type v)
119129
/-- A convex combination of a single point is that point. -/
120130
single (x : M) : convexCombination (.single x) = x
121131

132+
attribute [simp] ConvexSpace.single
133+
122134
open ConvexSpace
123135

124136
variable {R M} [PartialOrder R] [Semiring R] [IsStrictOrderedRing R] [ConvexSpace R M]
@@ -128,13 +140,18 @@ def convexComboPair (s t : R) (hs : 0 ≤ s) (ht : 0 ≤ t) (h : s + t = 1) (x y
128140
convexCombination (.duple x y hs ht h)
129141

130142
/-- A binary convex combination with weight 0 on the first point returns the second point. -/
131-
proof_wanted convexComboPair_zero {x y : M} :
132-
convexComboPair (0 : R) 1 (by simp) (by simp) (by simp) x y = y
143+
theorem convexComboPair_zero {x y : M} :
144+
convexComboPair (0 : R) 1 (by simp) (by simp) (by simp) x y = y := by
145+
simp [convexComboPair, StdSimplex.duple]
133146

134147
/-- A binary convex combination with weight 1 on the first point returns the first point. -/
135-
proof_wanted convexComboPair_one {x y : M} :
136-
convexComboPair (1 : R) 0 (by simp) (by simp) (by simp) x y = x
148+
theorem convexComboPair_one {x y : M} :
149+
convexComboPair (1 : R) 0 (by simp) (by simp) (by simp) x y = x := by
150+
simp [convexComboPair, StdSimplex.duple]
137151

138152
/-- A convex combination of a point with itself is that point. -/
139-
proof_wanted convexComboPair_same {s t : R} (hs : 0 ≤ s) (ht : 0 ≤ t) (h : s + t = 1) {x : M} :
140-
convexComboPair s t hs ht h x x = x
153+
theorem convexComboPair_same {s t : R} (hs : 0 ≤ s) (ht : 0 ≤ t) (h : s + t = 1) {x : M} :
154+
convexComboPair s t hs ht h x x = x := by
155+
unfold convexComboPair
156+
convert ConvexSpace.single x
157+
simp only [StdSimplex.duple, StdSimplex.single, ← Finsupp.single_add, h]

0 commit comments

Comments
 (0)