@@ -62,6 +62,7 @@ grind_pattern StdSimplex.total => self.weights
6262initialize_simps_projections StdSimplex (as_prefix weights)
6363
6464namespace StdSimplex
65+ section Semiring
6566variable {R : Type u} [PartialOrder R] [Semiring R] {M N P : Type *} {w : StdSimplex R M} {x : M}
6667
6768@[simp] lemma weights_nonneg {w : StdSimplex R M} (i : M) : 0 ≤ w.weights i := w.nonneg i
@@ -167,6 +168,56 @@ private lemma map_join (f : StdSimplex R (StdSimplex R M)) (g : M → N) :
167168@[simp] private lemma join_single (x : StdSimplex R M) : join (.single x) = x := by
168169 ext; simp [join, ← mk_single]
169170
171+ end Semiring
172+
173+ section Semifield
174+ variable [Semifield K] [LinearOrder K] [IsStrictOrderedRing K]
175+
176+ private lemma restrict_nonneg_aux {w : StdSimplex K X} {p : X → Prop } [DecidablePred p] :
177+ 0 ≤ (filter p w.weights).sum fun _x k ↦ k :=
178+ sum_nonneg <| by simp [filter_apply, apply_ite]
179+
180+ private lemma restrict_ne_zero_aux {w : StdSimplex K X} {p : X → Prop } [DecidablePred p]
181+ (hp : ∃ a, p a ∧ w.weights a ≠ 0 ) :
182+ (filter p w.weights).sum (fun _x k ↦ k) ≠ 0 :=
183+ (sum_pos (by simp +contextual [lt_iff_le_and_ne, eq_comm]) <| by simpa [ne_iff, filter_apply]).ne'
184+
185+ /-- Project an element of the standard simplex to a lower-dimensional standard simplex,
186+ assuming at least one non-zero weight subsists. -/
187+ def restrict (w : StdSimplex K X) (s : Set X) (hs : ∃ x ∈ s, w.weights x ≠ 0 ) : StdSimplex K X where
188+ weights := open scoped Classical in
189+ ((w.weights.filter (· ∈ s)).sum fun x k ↦ k)⁻¹ • w.weights.filter (· ∈ s)
190+ nonneg := by
191+ classical
192+ exact smul_nonneg (inv_nonneg.2 restrict_nonneg_aux) fun _ ↦ by simp [filter_apply, apply_ite]
193+ total := by classical simp [sum_smul_index, ← mul_sum, restrict_ne_zero_aux hs]
194+
195+ lemma weights_restrict (w : StdSimplex K X) (s : Set X) (hs) [DecidablePred (· ∈ s)] :
196+ (w.restrict s hs).weights =
197+ ((w.weights.filter (· ∈ s)).sum fun _x k ↦ k)⁻¹ • w.weights.filter (· ∈ s) := by
198+ simp [restrict]; congr
199+
200+ variable [IsDomain K]
201+
202+ @[simp]
203+ lemma support_weights_restrict (w : StdSimplex K X) (s : Set X) (hs) [DecidablePred (· ∈ s)] :
204+ (w.restrict s hs).weights.support = w.weights.support.filter (· ∈ s) := by
205+ have : (w.weights.filter (· ∈ s)).sum (fun x k ↦ k) ≠ 0 :=
206+ (sum_pos (by simp +contextual [lt_iff_le_and_ne, eq_comm]) <| by
207+ simpa [ne_iff, filter_apply]).ne'
208+ rw [weights_restrict, support_smul_eq (by convert inv_ne_zero this)]
209+ simp
210+
211+ @[simp] lemma restrict_singleton (w : StdSimplex K X) (x : X) (hx) :
212+ w.restrict {x} hx = single x := by
213+ classical
214+ simp only [← support_weights_eq_singleton, support_weights_restrict, Set.mem_singleton_iff]
215+ ext
216+ simp only [Finset.mem_filter, mem_support_iff, ne_eq, Finset.mem_singleton, and_iff_right_iff_imp]
217+ rintro rfl
218+ simpa using hx
219+
220+ end Semifield
170221end StdSimplex
171222
172223/--
@@ -240,6 +291,19 @@ lemma map_sConvexComb (s : StdSimplex R (StdSimplex R I)) (f : I → J) :
240291 s.sConvexComb.map f = (s.map (map f)).sConvexComb :=
241292 StdSimplex.map_join s f
242293
294+ variable [Semifield K] [LinearOrder K] [IsStrictOrderedRing K]
295+
296+ lemma convexCombPair_restrict_restrict_compl (w : StdSimplex K I) (s : Set I) (hs hs')
297+ [DecidablePred (· ∈ s)] :
298+ convexCombPair
299+ ((w.weights.filter (· ∈ s)).sum fun _x k ↦ k)
300+ ((w.weights.filter (· ∉ s)).sum fun _x k ↦ k)
301+ (by exact restrict_nonneg_aux) (by exact restrict_nonneg_aux) (by simp)
302+ (w.restrict s hs) (w.restrict sᶜ hs') = w := by
303+ ext : 1
304+ simp only [Set.mem_compl_iff] at hs'
305+ simp [weights_restrict, smul_inv_smul₀, restrict_ne_zero_aux, hs, hs']
306+
243307end StdSimplex
244308
245309lemma sConvexComb_sConvexComb (f : StdSimplex R (StdSimplex R M)) :
@@ -299,8 +363,8 @@ lemma iConvexComb_id (w : StdSimplex R M) : w.iConvexComb id = w.sConvexComb :=
299363 w.iConvexComb (fun x ↦ x) = w.sConvexComb := iConvexComb_id _
300364
301365@[simp] lemma iConvexComb_map (s : StdSimplex R I) (f : I → J) (g : J → M) :
302- (s.map f).iConvexComb g = s.iConvexComb (g ∘ f ) := by
303- simp only [iConvexComb, map_comp ]
366+ (s.map f).iConvexComb g = s.iConvexComb (fun i ↦ g (f i) ) := by
367+ simp only [iConvexComb, map_map ]
304368
305369@[congr] lemma iConvexComb_congr {w : StdSimplex R I} {f g : I → M}
306370 (hfg : ∀ i, w.weights i ≠ 0 → f i = g i) :
0 commit comments