|
| 1 | +import Mathlib.Analysis.Convex.Combination |
| 2 | + |
| 3 | +open AffineMap Finset |
| 4 | + |
| 5 | +section oldVars |
| 6 | +variable {ι R E : Type*} [LinearOrderedField R] [AddCommGroup E] [Module R E] {s : Finset ι} |
| 7 | + {f : ι → E} {x : E} |
| 8 | + |
| 9 | +lemma mem_convexHull_image : |
| 10 | + x ∈ convexHull R (f '' s) ↔ |
| 11 | + ∃ w : ι → R, (∀ i ∈ s, 0 ≤ w i) ∧ ∑ i ∈ s, w i = 1 ∧ s.centerMass w f = x where |
| 12 | + mp hp := by |
| 13 | + classical |
| 14 | + rw [← Subtype.range_val (s := s.toSet), ← Set.range_comp, |
| 15 | + convexHull_range_eq_exists_affineCombination] at hp |
| 16 | + obtain ⟨t, w, hw₀, hw₁, rfl⟩ := hp |
| 17 | + refine ⟨fun i ↦ if hi : i ∈ Subtype.val '' (t : Set s.toSet) then w ⟨i, by aesop⟩ else 0, |
| 18 | + by aesop, ?_⟩ |
| 19 | + · simp [Finset.sum_dite] |
| 20 | + sorry |
| 21 | + mpr := by |
| 22 | + rintro ⟨w, hw₀, hw₁, rfl⟩; exact s.centerMass_mem_convexHull hw₀ (by simp [hw₁]) (by aesop) |
| 23 | + |
| 24 | +end oldVars |
| 25 | + |
| 26 | +variable {ι 𝕜 V : Type*} [LinearOrderedField 𝕜] [AddCommGroup V] [Module 𝕜 V] |
| 27 | + {s t : Finset ι} {v w : ι → 𝕜} {x y : ι → V} {i : ι} |
| 28 | + |
| 29 | +lemma centerMass_congr (hst : s = t) (hvw : ∀ i ∈ t, v i = w i) (hxy : ∀ i ∈ t, x i = y i) : |
| 30 | + s.centerMass v x = t.centerMass w y := by |
| 31 | + unfold centerMass; rw [sum_congr hst hvw, sum_congr hst fun i hi ↦ by rw [hvw i hi, hxy i hi]] |
| 32 | + |
| 33 | +variable [DecidableEq ι] |
| 34 | + |
| 35 | +lemma centerMass_union (hst : Disjoint s t) (hs : (∀ i ∈ s, w i = 0) ∨ ∑ i ∈ s, w i ≠ 0) |
| 36 | + (ht : (∀ i ∈ t, w i = 0) ∨ ∑ i ∈ t, w i ≠ 0) (hw₁ : ∑ i ∈ s ∪ t, w i = 1) : |
| 37 | + (s ∪ t).centerMass w x = |
| 38 | + (∑ i ∈ s, w i) • s.centerMass w x + (∑ i ∈ t, w i) • t.centerMass w x := by |
| 39 | + obtain hs | hs := hs |
| 40 | + · simp only [sum_union hst, sum_eq_zero hs, zero_add] at hw₁ |
| 41 | + simp only [centerMass, sum_union hst, sum_eq_zero hs, hw₁, zero_add, inv_one, smul_add, |
| 42 | + one_smul, inv_zero, zero_smul, smul_zero, add_left_eq_self] |
| 43 | + exact sum_eq_zero fun i hi ↦ by simp [hs _ hi] |
| 44 | + obtain ht | ht := ht |
| 45 | + · simp only [sum_union hst, sum_eq_zero ht, add_zero] at hw₁ |
| 46 | + simp only [centerMass, sum_union hst, hw₁, sum_eq_zero ht, add_zero, inv_one, smul_add, |
| 47 | + one_smul, inv_zero, zero_smul, smul_zero, add_right_eq_self] |
| 48 | + exact sum_eq_zero fun i hi ↦ by simp [ht _ hi] |
| 49 | + · simp [centerMass, hs, ht, hst, sum_union, hw₁] |
| 50 | + |
| 51 | +lemma centerMass_union_of_ne_zero (hst : Disjoint s t) (hs : ∑ i ∈ s, w i ≠ 0) |
| 52 | + (ht : ∑ i ∈ t, w i ≠ 0) (hw₁ : ∑ i ∈ s ∪ t, w i = 1) : |
| 53 | + (s ∪ t).centerMass w x = |
| 54 | + (∑ i ∈ s, w i) • s.centerMass w x + (∑ i ∈ t, w i) • t.centerMass w x := |
| 55 | + centerMass_union hst (.inr hs) (.inr ht) hw₁ |
| 56 | + |
| 57 | +lemma centerMass_union_of_nonneg (hst : Disjoint s t) (hw₀ : ∀ i ∈ s ∪ t, 0 ≤ w i) |
| 58 | + (hw₁ : ∑ i ∈ s ∪ t, w i = 1) : |
| 59 | + (s ∪ t).centerMass w x = |
| 60 | + (∑ i ∈ s, w i) • s.centerMass w x + (∑ i ∈ t, w i) • t.centerMass w x := by |
| 61 | + refine centerMass_union hst ?_ ?_ hw₁ |
| 62 | + · rw [← sum_eq_zero_iff_of_nonneg fun j hj ↦ hw₀ _ <| subset_union_left hj] |
| 63 | + exact em _ |
| 64 | + · rw [← sum_eq_zero_iff_of_nonneg fun j hj ↦ hw₀ _ <| subset_union_right hj] |
| 65 | + exact em _ |
| 66 | + |
| 67 | +lemma lineMap_centerMass_centerMass (hst : Disjoint s t) |
| 68 | + (hs : (∀ i ∈ s, w i = 0) ∨ ∑ i ∈ s, w i ≠ 0) (ht : (∀ i ∈ t, w i = 0) ∨ ∑ i ∈ t, w i ≠ 0) |
| 69 | + (hw₁ : ∑ i ∈ s ∪ t, w i = 1) : |
| 70 | + lineMap (s.centerMass w x) (t.centerMass w x) (∑ i ∈ t, w i) = (s ∪ t).centerMass w x := by |
| 71 | + rw [lineMap_apply_module, ← hw₁, sum_union hst, add_sub_cancel_right, |
| 72 | + centerMass_union hst hs ht hw₁] |
| 73 | + |
| 74 | +lemma lineMap_centerMass_centerMass_of_ne_zero (hst : Disjoint s t) (hs : ∑ i ∈ s, w i ≠ 0) |
| 75 | + (ht : ∑ i ∈ t, w i ≠ 0) (hw₁ : ∑ i ∈ s ∪ t, w i = 1) : |
| 76 | + lineMap (s.centerMass w x) (t.centerMass w x) (∑ i ∈ t, w i) = (s ∪ t).centerMass w x := |
| 77 | + lineMap_centerMass_centerMass hst (.inr hs) (.inr ht) hw₁ |
| 78 | + |
| 79 | +lemma lineMap_centerMass_centerMass_of_nonneg (hst : Disjoint s t) (hw₀ : ∀ i ∈ s ∪ t, 0 ≤ w i) |
| 80 | + (hw₁ : ∑ i ∈ s ∪ t, w i = 1) : |
| 81 | + lineMap (s.centerMass w x) (t.centerMass w x) (∑ i ∈ t, w i) = (s ∪ t).centerMass w x := by |
| 82 | + rw [lineMap_apply_module, ← hw₁, sum_union hst, add_sub_cancel_right, |
| 83 | + centerMass_union_of_nonneg hst hw₀ hw₁] |
| 84 | + |
| 85 | +lemma lineMap_centerMass_sdiff (hi : i ∈ s) (hi₀ : w i ≠ 0) (hi₁ : w i ≠ 1) |
| 86 | + (hw₁ : ∑ i ∈ s, w i = 1) : |
| 87 | + lineMap ((s \ {i}).centerMass w x) (x i) (w i) = s.centerMass w x := by |
| 88 | + rw [← centerMass_singleton i x hi₀, ← sum_singleton w i, |
| 89 | + lineMap_centerMass_centerMass] <;> |
| 90 | + simp [*, union_eq_left.2, sub_eq_zero, eq_comm (b := w _)] |
| 91 | + |
| 92 | +lemma centerMass_sdiff_of_weight_eq_zero (hi : i ∈ s) (hi₀ : w i = 0) : |
| 93 | + (s \ {i}).centerMass w x = s.centerMass w x := by |
| 94 | + simp [hi₀, sum_sdiff_eq_sub (singleton_subset_iff.2 hi), centerMass] |
| 95 | + |
| 96 | +lemma lineMap_centerMass_sdiff_singleton_of_ne_one (hi : i ∈ s) (hi₁ : w i ≠ 1) |
| 97 | + (hw₁ : ∑ j ∈ s, w j = 1) : |
| 98 | + lineMap ((s \ {i}).centerMass w x) (x i) (w i) = s.centerMass w x := by |
| 99 | + obtain hi₀ | hi₀ := eq_or_ne (w i) 0 |
| 100 | + · simp [centerMass_sdiff_of_weight_eq_zero hi, hi₀] |
| 101 | + · rw [← centerMass_singleton i x hi₀, ← sum_singleton w i, lineMap_centerMass_centerMass] <;> |
| 102 | + simp [*, union_eq_left.2, sub_eq_zero, eq_comm (b := w _)] |
| 103 | + |
| 104 | +lemma lineMap_centerMass_sdiff_singleton_of_nonneg (hi : i ∈ s) (hw₀ : ∀ j ∈ s \ {i}, 0 ≤ w j) |
| 105 | + (hw₁ : ∑ j ∈ s, w j = 1) : |
| 106 | + lineMap ((s \ {i}).centerMass w x) (x i) (w i) = s.centerMass w x := by |
| 107 | + obtain hi₁ | hi₁ := eq_or_ne (w i) 1 |
| 108 | + · rw [← centerMass_singleton i x (w := w) (by simp [hi₁]), ← sum_singleton w i, |
| 109 | + lineMap_centerMass_centerMass] |
| 110 | + rotate_left 2 |
| 111 | + · rw [← sum_eq_zero_iff_of_nonneg hw₀] |
| 112 | + exact em _ |
| 113 | + all_goals simp [*, union_eq_left.2, sub_eq_zero, eq_comm (b := w _)] |
| 114 | + · exact lineMap_centerMass_sdiff_singleton_of_ne_one hi hi₁ hw₁ |
0 commit comments