@@ -147,6 +147,12 @@ begin
147
147
exact b.coord_apply_combination_of_mem (finset.mem_univ i) hw,
148
148
end
149
149
150
+ lemma ext_elem [fintype ι] {q₁ q₂ : P} (h : ∀ i, b.coord i q₁ = b.coord i q₂) : q₁ = q₂ :=
151
+ begin
152
+ rw [← b.affine_combination_coord_eq_self q₁, ← b.affine_combination_coord_eq_self q₂],
153
+ simp only [h],
154
+ end
155
+
150
156
@[simp] lemma coe_coord_of_subsingleton_eq_one [subsingleton ι] (i : ι) :
151
157
(b.coord i : P → k) = 1 :=
152
158
begin
@@ -203,7 +209,57 @@ begin
203
209
rw [to_matrix_apply, coord_apply, matrix.one_eq_pi_single, pi.single_apply],
204
210
end
205
211
206
- variables [fintype ι] (b₂ : affine_basis ι k P)
212
+ variables {ι' : Type *} [fintype ι'] [fintype ι] (b₂ : affine_basis ι k P)
213
+
214
+ lemma to_matrix_row_sum_one {ι' : Type *} (q : ι' → P) (i : ι') :
215
+ ∑ j, b.to_matrix q i j = 1 :=
216
+ by simp
217
+
218
+ /-- Given a family of points `p : ι' → P` and an affine basis `b`, if the matrix whose rows are the
219
+ coordinates of `p` with respect `b` has a right inverse, then `p` is affine independent. -/
220
+ lemma affine_independent_of_to_matrix_right_inv [decidable_eq ι']
221
+ (p : ι' → P) {A : matrix ι ι' k} (hA : (b.to_matrix p) ⬝ A = 1 ) : affine_independent k p :=
222
+ begin
223
+ rw affine_independent_iff_eq_of_fintype_affine_combination_eq,
224
+ intros w₁ w₂ hw₁ hw₂ hweq,
225
+ have hweq' : (b.to_matrix p).vec_mul w₁ = (b.to_matrix p).vec_mul w₂,
226
+ { ext j,
227
+ change ∑ i, (w₁ i) • (b.coord j (p i)) = ∑ i, (w₂ i) • (b.coord j (p i)),
228
+ rw [← finset.univ.affine_combination_eq_linear_combination _ _ hw₁,
229
+ ← finset.univ.affine_combination_eq_linear_combination _ _ hw₂,
230
+ ← finset.univ.map_affine_combination p w₁ hw₁,
231
+ ← finset.univ.map_affine_combination p w₂ hw₂, hweq], },
232
+ replace hweq' := congr_arg (λ w, A.vec_mul w) hweq',
233
+ simpa only [matrix.vec_mul_vec_mul, ← matrix.mul_eq_mul, hA, matrix.vec_mul_one] using hweq',
234
+ end
235
+
236
+ /-- Given a family of points `p : ι' → P` and an affine basis `b`, if the matrix whose rows are the
237
+ coordinates of `p` with respect `b` has a left inverse, then `p` spans the the entire space. -/
238
+ lemma affine_span_eq_top_of_to_matrix_left_inv [decidable_eq ι] [nontrivial k]
239
+ (p : ι' → P) {A : matrix ι ι' k} (hA : A ⬝ b.to_matrix p = 1 ) : affine_span k (range p) = ⊤ :=
240
+ begin
241
+ suffices : ∀ i, b.points i ∈ affine_span k (range p),
242
+ { rw [eq_top_iff, ← b.tot, affine_span_le],
243
+ rintros q ⟨i, rfl⟩,
244
+ exact this i, },
245
+ intros i,
246
+ have hAi : ∑ j, A i j = 1 ,
247
+ { calc ∑ j, A i j = ∑ j, (A i j) * ∑ l, b.to_matrix p j l : by simp
248
+ ... = ∑ j, ∑ l, (A i j) * b.to_matrix p j l : by simp_rw finset.mul_sum
249
+ ... = ∑ l, ∑ j, (A i j) * b.to_matrix p j l : by rw finset.sum_comm
250
+ ... = ∑ l, (A ⬝ b.to_matrix p) i l : rfl
251
+ ... = 1 : by simp [hA, matrix.one_apply, finset.filter_eq], },
252
+ have hbi : b.points i = finset.univ.affine_combination p (A i),
253
+ { apply b.ext_elem,
254
+ intros j,
255
+ rw [b.coord_apply, finset.univ.map_affine_combination _ _ hAi,
256
+ finset.univ.affine_combination_eq_linear_combination _ _ hAi],
257
+ change _ = (A ⬝ b.to_matrix p) i j,
258
+ simp_rw [hA, matrix.one_apply, @eq_comm _ i j],
259
+ congr, },
260
+ rw hbi,
261
+ exact affine_combination_mem_affine_span hAi p,
262
+ end
207
263
208
264
/-- A change of basis formula for barycentric coordinates.
209
265
@@ -235,6 +291,20 @@ lemma is_unit_to_matrix :
235
291
val_inv := b.to_matrix_mul_to_matrix b₂,
236
292
inv_val := b₂.to_matrix_mul_to_matrix b, }, rfl⟩
237
293
294
+ lemma is_unit_to_matrix_iff [nontrivial k] (p : ι → P) :
295
+ is_unit (b.to_matrix p) ↔ affine_independent k p ∧ affine_span k (range p) = ⊤ :=
296
+ begin
297
+ split,
298
+ { rintros ⟨⟨B, A, hA, hA'⟩, (rfl : B = b.to_matrix p)⟩,
299
+ rw matrix.mul_eq_mul at hA hA',
300
+ exact ⟨b.affine_independent_of_to_matrix_right_inv p hA,
301
+ b.affine_span_eq_top_of_to_matrix_left_inv p hA'⟩, },
302
+ { rintros ⟨h_tot, h_ind⟩,
303
+ let b' : affine_basis ι k P := ⟨p, h_tot, h_ind⟩,
304
+ change is_unit (b.to_matrix b'.points),
305
+ exact b.is_unit_to_matrix b', },
306
+ end
307
+
238
308
end ring
239
309
240
310
section comm_ring
0 commit comments