Skip to content

Commit 84dd31c

Browse files
committed
routine golfs + docstring edits
1 parent 4b07499 commit 84dd31c

1 file changed

Lines changed: 28 additions & 48 deletions

File tree

  • Mathlib/LinearAlgebra/AffineSpace/AffineSubspace

Mathlib/LinearAlgebra/AffineSpace/AffineSubspace/Shift.lean

Lines changed: 28 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -97,28 +97,26 @@ theorem shift_one (s : AffineSubspace k P) (c : P) : s.shift c 1 = s := by
9797
have h : Nonempty s := by simpa using! h
9898
simp [shift, h]
9999

100-
/-- For a point $A$ with barycentric coordinates associated with a collection of points $P$, if one
101-
of the coordinate associated with $P_i$ is $r$, then the point $A$ is on the span by the rest of
102-
$P_j$ shifted towards $P_i$ with parameter $(1 - r)$. -/
100+
/-- Consider a point `A` with barycentric coordinates associated to a collection of points `P`.
101+
If the coordinate associated to one of the points `Pᵢ` is `r`, then the point `A` is on the span
102+
of `P \ {Pᵢ}` shifted towards `Pᵢ` with parameter `1 - r`. -/
103103
theorem affineCombination_mem_shift {ι : Type*} [Fintype ι] [Nontrivial ι]
104104
(p : ι → P) (i : ι) {w : ι → k} (hw : ∑ i, w i = 1) :
105105
affineCombination k univ p w ∈ (affineSpan k <| p '' {i}ᶜ).shift (p i) (1 - w i) := by
106-
rcases subsingleton_or_nontrivial k with _ | _
106+
cases subsingleton_or_nontrivial k
107107
· suffices (affineSpan k <| p '' {i}ᶜ) = ⊤ by simp [this]
108108
have : Subsingleton P := (AddTorsor.subsingleton_iff V P).mp <| Module.subsingleton k V
109109
simp
110110
classical
111-
obtain ⟨j, hj⟩ : Set.Nonempty {i}ᶜ := by
112-
by_contra
113-
simp at this
111+
obtain ⟨j, hj⟩ := exists_ne i
114112
rw [shift_eq ⟨p j, mem_affineSpan k <| Set.mem_image_of_mem _ hj⟩]
115113
suffices ∃ q ∈ affineSpan k (p '' {i}ᶜ), w i • (p i -ᵥ p j) +ᵥ q = affineCombination k univ p w by
116114
simpa
117115
refine ⟨-(w i • (p i -ᵥ p j)) +ᵥ affineCombination k univ p w, ?_, by simp⟩
118116
rw [← affineCombination_piSingle k _ p (mem_univ i),
119117
← affineCombination_piSingle k _ p (mem_univ j), affineCombination_vsub, ← map_smul, ← map_neg,
120118
weightedVSub_vadd_affineCombination]
121-
refine affineCombination_mem_affineSpan_image ?_ (fun i' _ hi ↦ (by aesop)) _
119+
refine affineCombination_mem_affineSpan_image ?_ (fun i' _ hi ↦ by aesop) _
122120
simp [sum_add_distrib, ← mul_sum, hw]
123121

124122
/-- The iff version of `affineCombination_mem_shift` for affine independent points. -/
@@ -129,16 +127,13 @@ theorem _root_.AffineIndependent.affineCombination_mem_shift_iff
129127
w i = 1 - c := by
130128
classical
131129
refine ⟨?_, fun h ↦ by simpa [h] using affineCombination_mem_shift p i hw⟩
132-
obtain ⟨j, hj⟩ : Set.Nonempty {i}ᶜ := by
133-
by_contra
134-
simp at this
130+
obtain ⟨j, hj⟩ := exists_ne i
135131
rw [shift_eq ⟨p j, mem_affineSpan k <| Set.mem_image_of_mem _ hj⟩]
136132
suffices ∀ q ∈ affineSpan k (p '' {i}ᶜ),
137133
(1 - c) • (p i -ᵥ p j) +ᵥ q = affineCombination k univ p w → w i = 1 - c by simpa
138134
intro q hqmem heq
139135
obtain ⟨t, w', ht, hw', rfl⟩ := eq_affineCombination_of_mem_affineSpan_image hqmem
140136
have ht : (t : Set ι).indicator w' i = 0 := Set.indicator_of_notMem (by simpa using ht) w'
141-
have hj : j ≠ i := by simpa using hj
142137
rw [affineCombination_indicator_subset _ _ t.subset_univ,
143138
← affineCombination_piSingle k _ p (mem_univ i),
144139
← affineCombination_piSingle k _ p (mem_univ j), affineCombination_vsub, ← map_smul,
@@ -186,36 +181,32 @@ section Ring
186181
variable [Ring k] [PartialOrder k] [IsOrderedAddMonoid k] [AddCommGroup V] [AddTorsor V P]
187182
[Module k V] {n : ℕ} [NeZero n] (s : Affine.Simplex k P n) (i : Fin (n + 1))
188183

189-
/-- The base of a simplex shifted with parameter 0 intersects with the closed interior only at the
184+
/-- The base of a simplex shifted with parameter 0 intersects the closed interior only at the
190185
vertex. -/
191186
theorem closedInterior_inter_shift_zero [ZeroLEOneClass k] :
192-
s.closedInterior ∩ (affineSpan k (Set.range (s.faceOpposite i).points)).shift (s.points i) 0 =
187+
s.closedInterior ∩ (affineSpan k <| s.points '' {i}ᶜ).shift (s.points i) 0 =
193188
{s.points i} := by
194-
refine Set.Subset.antisymm ?_ (by simp [s.point_mem_closedInterior i])
195-
suffices ∀ p ∈ s.closedInterior, p ∈ (affineSpan k (s.points '' {i}ᶜ)).shift (s.points i) 0
196-
p = s.points i by
197-
simpa
198-
intro p hp hshift
189+
refine subset_antisymm (fun p ⟨hp, hshift⟩ ↦ ?_) (by simp [s.point_mem_closedInterior i])
199190
obtain ⟨w, hw, rfl⟩ := eq_affineCombination_of_mem_affineSpan_of_fintype <|
200-
Set.mem_of_mem_of_subset hp s.closedInterior_subset_affineSpan
191+
s.closedInterior_subset_affineSpan hp
201192
suffices w = Pi.single i 1 by simp [this]
202193
rw [affineCombination_mem_closedInterior_iff hw] at hp
203-
rw [s.independent.affineCombination_mem_shift_iff i hw, sub_zero] at hshift
194+
rw [SetLike.mem_coe, s.independent.affineCombination_mem_shift_iff i hw, sub_zero] at hshift
204195
ext j
205196
by_cases hj : j = i
206197
· aesop
207198
rw [← univ.sum_erase_add w (mem_univ i), hshift, add_eq_right,
208199
sum_eq_zero_iff_of_nonneg fun j _ ↦ (hp j).1] at hw
209200
simp [hw j (by simpa using hj), hj]
210201

211-
/-- The base of a simplex shifted with parameter outside $[0, 1]$ does not intersect with the closed
202+
/-- The base of a simplex shifted with parameter outside $[0, 1]$ does not intersect the closed
212203
interior. -/
213204
theorem disjoint_closedInterior_shift {x : k} (hx : x < 01 < x) :
214205
Disjoint s.closedInterior <|
215206
(affineSpan k (Set.range (s.faceOpposite i).points)).shift (s.points i) x := by
216207
refine Set.disjoint_left.mpr fun p hleft hright ↦ ?_
217208
obtain ⟨w, hw, rfl⟩ := eq_affineCombination_of_mem_affineSpan_of_fintype <|
218-
Set.mem_of_mem_of_subset hleft s.closedInterior_subset_affineSpan
209+
s.closedInterior_subset_affineSpan hleft
219210
rw [range_faceOpposite_points, SetLike.mem_coe,
220211
s.independent.affineCombination_mem_shift_iff i hw] at hright
221212
rw [affineCombination_mem_closedInterior_iff hw] at hleft
@@ -230,53 +221,42 @@ private theorem closedInterior_inter_shift_aux {n : ℕ} (i : Fin n) {x : k} (hx
230221
(hx1 : x ≤ 1) {w : Fin n → k} (hw : ∑ i, w i = 1) :
231222
(∀ j, w j ∈ Set.Icc 0 1) ∧ w i = 1 - x ↔
232223
(∀ j, j ≠ i → x⁻¹ * w j ∈ Set.Icc 0 1) ∧ x⁻¹ * (w i - 1) + 1 = 0 := by
233-
have : x⁻¹ * (w i - 1) + 1 = 0 ↔ w i = 1 - x := by grind
234-
rw [this]
224+
rw [show x⁻¹ * (w i - 1) + 1 = 0 ↔ w i = 1 - x by grind]
235225
refine and_congr_left fun hi ↦ ⟨fun hj j hji ↦ ⟨?_, ?_⟩, fun hj ↦ ?_⟩
236226
· exact mul_nonneg (by simpa using hxpos.le) (hj j).1
237227
· rw [eq_sub_iff_add_eq, add_comm, ← eq_sub_iff_add_eq] at hi
238228
rw [inv_mul_le_one₀ hxpos, hi, le_sub_iff_add_le, ← hw]
239229
exact add_le_sum (fun i _ ↦ (hj i).1) (mem_univ j) (mem_univ i) hji
240-
· suffices ∀ j, 0 ≤ w j by
241-
refine fun j ↦ ⟨this j, ?_⟩
242-
rw [← hw]
243-
exact Finset.single_le_sum (fun j _ ↦ this j) (mem_univ j)
230+
· suffices ∀ j, 0 ≤ w j from
231+
fun j ↦ ⟨this j, hw ▸ Finset.single_le_sum (fun j _ ↦ this j) (mem_univ j)⟩
244232
intro j
245233
by_cases hji : j = i <;> aesop
246234

247-
/-- The parallel cross-section of a simplex is the homothety of the base. -/
235+
/-- A parallel cross-section of a simplex is the image of the base under a homothety. -/
248236
theorem closedInterior_inter_shift {n : ℕ} [NeZero n] (s : Affine.Simplex k P n)
249237
(i : Fin (n + 1)) {x : k} (hx : x ∈ Set.Icc 0 1) :
250-
s.closedInterior ∩ (affineSpan k (Set.range (s.faceOpposite i).points)).shift (s.points i) x =
238+
s.closedInterior ∩ (affineSpan k (s.points '' {i}ᶜ)).shift (s.points i) x =
251239
homothety (s.points i) x '' (s.faceOpposite i).closedInterior := by
252-
rcases eq_or_lt_of_le hx.1 with hx0 | hxpos
253-
· simpa [hx0.symm, (s.faceOpposite i).nonempty_closedInterior]
254-
using s.closedInterior_inter_shift_zero i
240+
rcases hx.1.eq_or_lt with hx0 | hxpos
241+
· simpa [hx0.symm, nonempty_closedInterior] using s.closedInterior_inter_shift_zero i
255242
ext p
256-
by_cases hp : p ∈ affineSpan k (Set.range s.points)
243+
by_cases hp : p ∈ affineSpan k (.range s.points)
257244
· obtain ⟨w, hw, rfl⟩ := eq_affineCombination_of_mem_affineSpan_of_fintype hp
258-
rw [Set.mem_inter_iff, range_faceOpposite_points, SetLike.mem_coe,
259-
s.independent.affineCombination_mem_shift_iff i hw,
245+
rw [Set.mem_inter_iff, SetLike.mem_coe, s.independent.affineCombination_mem_shift_iff i hw,
260246
affineCombination_mem_closedInterior_iff hw, Set.mem_image]
261247
simp_rw [AffineMap.homothety_eq_iff_of_mul_eq_one (mul_inv_cancel₀ hxpos.ne.symm),
262248
univ.homothety_affineCombination _ _ (mem_univ i)]
263249
simp only [↓existsAndEq, and_true]
264-
rw [faceOpposite, affineCombination_mem_closedInterior_face_iff_mem_Icc _ _ ?_,
250+
rw [faceOpposite, affineCombination_mem_closedInterior_face_iff_mem_Icc,
265251
closedInterior_inter_shift_aux i hxpos hx.2 hw]
266252
· simp only [mem_compl, mem_singleton, not_not, forall_eq]
267253
congrm (∀ j, (hj : _) → $(by simp [lineMap_apply, hj])) ∧ $(by simp [lineMap_apply])
268254
· simp [AffineMap.lineMap_apply, Finset.sum_add_distrib, ← Finset.mul_sum,
269255
Finset.sum_sub_distrib, hw]
270-
· apply iff_of_false
271-
· apply not_and_of_not_left
272-
contrapose hp
273-
exact Set.mem_of_mem_of_subset hp s.closedInterior_subset_affineSpan
274-
· contrapose hp
275-
rw [Set.mem_image] at hp
276-
obtain ⟨q, hq, rfl⟩ := hp
277-
apply homothety_mem (mem_affineSpan _ (by simp))
278-
obtain hq := Set.mem_of_mem_of_subset hq (s.faceOpposite i).closedInterior_subset_affineSpan
279-
exact Set.mem_of_mem_of_subset hq (affineSpan_mono _ (by simp))
256+
· apply iff_of_false (hp <| s.closedInterior_subset_affineSpan ·.1)
257+
rintro ⟨q, hq, rfl⟩
258+
exact hp <| homothety_mem (mem_affineSpan _ (by simp)) _ <|
259+
affineSpan_mono _ (by simp) ((s.faceOpposite i).closedInterior_subset_affineSpan hq)
280260

281261
end Field
282262
end Affine.Simplex

0 commit comments

Comments
 (0)