Skip to content
This repository was archived by the owner on Jul 24, 2024. It is now read-only.

Commit d6241cb

Browse files
committed
feat(linear_algebra/*): Use alternating maps for wedge and determinant (#5124)
This : * Adds `exterior_algebra.ι_multi`, where `ι_multi ![a, b ,c]` = `ι a * ι b * ι c` * Makes `det_row_multilinear` an `alternating_map` * Makes `is_basis.det` an `alternating_map`
1 parent 61f6364 commit d6241cb

File tree

3 files changed

+85
-6
lines changed

3 files changed

+85
-6
lines changed

src/linear_algebra/determinant.lean

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import data.fintype.card
88
import group_theory.perm.sign
99
import algebra.algebra.basic
1010
import tactic.ring
11-
import linear_algebra.multilinear
11+
import linear_algebra.alternating
1212

1313
universes u v w z
1414
open equiv equiv.perm finset function
@@ -274,14 +274,15 @@ begin
274274
simp [update_column_transpose, det_transpose]
275275
end
276276

277-
/-- `det` is a multilinear map over the rows of the matrix.
277+
/-- `det` is an alternating multilinear map over the rows of the matrix.
278278
279279
See also `is_basis.det`. -/
280280
@[simps apply]
281-
def det_row_multilinear : multilinear_map R (λ (i : n), n → R) R :=
281+
def det_row_multilinear : alternating_map R (n → R) R n:=
282282
{ to_fun := det,
283283
map_add' := det_update_row_add,
284-
map_smul' := det_update_row_smul }
284+
map_smul' := det_update_row_smul,
285+
map_eq_zero_of_eq' := λ M i j h hij, det_zero_of_row_eq hij h }
285286

286287
@[simp] lemma det_block_diagonal {o : Type*} [fintype o] [decidable_eq o] (M : o → matrix n n R) :
287288
(block_diagonal M).det = ∏ k, (M k).det :=

src/linear_algebra/exterior_algebra.lean

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ Authors: Zhangir Azerbayev, Adam Topaz, Eric Wieser.
66

77
import algebra.ring_quot
88
import linear_algebra.tensor_algebra
9+
import linear_algebra.alternating
910
import group_theory.perm.sign
1011

1112
/-!
@@ -31,6 +32,10 @@ of the exterior algebra.
3132
1. `ι_comp_lift` is fact that the composition of `ι R` with `lift R f cond` agrees with `f`.
3233
2. `lift_unique` ensures the uniqueness of `lift R f cond` with respect to 1.
3334
35+
## Definitions
36+
37+
* `ι_multi` is the `alternating_map` corresponding to the wedge product of `ι R m` terms.
38+
3439
## Implementation details
3540
3641
The exterior algebra of `M` is constructed as a quotient of the tensor algebra, as follows.
@@ -156,4 +161,58 @@ begin
156161
simp only [h],
157162
end
158163

164+
@[simp]
165+
lemma ι_add_mul_swap (x y : M) : ι R x * ι R y + ι R y * ι R x = 0 :=
166+
calc _ = ι R (x + y) * ι R (x + y) : by simp [mul_add, add_mul]
167+
... = _ : ι_square_zero _
168+
169+
lemma ι_mul_prod_list {n : ℕ} (f : fin n → M) (i : fin n) :
170+
(ι R $ f i) * (list.of_fn $ λ i, ι R $ f i).prod = 0 :=
171+
begin
172+
induction n with n hn,
173+
{ exact i.elim0, },
174+
{ rw [list.of_fn_succ, list.prod_cons, ←mul_assoc],
175+
by_cases h : i = 0,
176+
{ rw [h, ι_square_zero, zero_mul], },
177+
{ replace hn := congr_arg ((*) $ ι R $ f 0) (hn (λ i, f $ fin.succ i) (i.pred h)),
178+
simp only at hn,
179+
rw [fin.succ_pred, ←mul_assoc, mul_zero] at hn,
180+
refine (eq_zero_iff_eq_zero_of_add_eq_zero _).mp hn,
181+
rw [← add_mul, ι_add_mul_swap, zero_mul], } }
182+
end
183+
184+
variables (R)
185+
/-- The product of `n` terms of the form `ι R m` is an alternating map.
186+
187+
This is a special case of `multilinear_map.mk_pi_algebra_fin` -/
188+
def ι_multi (n : ℕ) :
189+
alternating_map R M (exterior_algebra R M) (fin n) :=
190+
let F := (multilinear_map.mk_pi_algebra_fin R n (exterior_algebra R M)).comp_linear_map (λ i, ι R)
191+
in
192+
{ map_eq_zero_of_eq' := λ f x y hfxy hxy, begin
193+
rw [multilinear_map.comp_linear_map_apply, multilinear_map.mk_pi_algebra_fin_apply],
194+
wlog h : x < y := lt_or_gt_of_ne hxy using x y,
195+
clear hxy,
196+
induction n with n hn generalizing x y,
197+
{ exact x.elim0, },
198+
{ rw [list.of_fn_succ, list.prod_cons],
199+
by_cases hx : x = 0,
200+
-- one of the repeated terms is on the left
201+
{ rw hx at hfxy h,
202+
rw [hfxy, ←fin.succ_pred y (ne_of_lt h).symm],
203+
exact ι_mul_prod_list (f ∘ fin.succ) _, },
204+
-- ignore the left-most term and induct on the remaining ones, decrementing indices
205+
{ convert mul_zero _,
206+
refine hn (λ i, f $ fin.succ i)
207+
(x.pred hx) (y.pred (ne_of_lt $ lt_of_le_of_lt x.zero_le h).symm)
208+
(fin.pred_lt_pred_iff.mpr h) _,
209+
simp only [fin.succ_pred],
210+
exact hfxy, } }
211+
end,
212+
to_fun := F, ..F}
213+
variables {R}
214+
215+
lemma ι_multi_apply {n : ℕ} (v : fin n → M) :
216+
ι_multi R n v = (list.of_fn $ λ i, ι R (v i)).prod := rfl
217+
159218
end exterior_algebra

src/linear_algebra/matrix.lean

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -210,10 +210,18 @@ begin
210210
contradiction }
211211
end
212212

213+
lemma linear_map.to_matrix_transpose_apply (f : M₁ →ₗ[R] M₂) (j : n) :
214+
(linear_map.to_matrix hv₁ hv₂ f)ᵀ j = hv₂.equiv_fun (f (v₁ j)) :=
215+
funext $ λ i, f.to_matrix_apply _ _ i j
216+
213217
lemma linear_map.to_matrix_apply' (f : M₁ →ₗ[R] M₂) (i : m) (j : n) :
214218
linear_map.to_matrix hv₁ hv₂ f i j = hv₂.repr (f (v₁ j)) i :=
215219
linear_map.to_matrix_apply hv₁ hv₂ f i j
216220

221+
lemma linear_map.to_matrix_transpose_apply' (f : M₁ →ₗ[R] M₂) (j : n) :
222+
(linear_map.to_matrix hv₁ hv₂ f)ᵀ j = hv₂.repr (f (v₁ j)) :=
223+
linear_map.to_matrix_transpose_apply hv₁ hv₂ f j
224+
217225
lemma matrix.to_lin_apply (M : matrix m n R) (v : M₁) :
218226
matrix.to_lin hv₁ hv₂ M v = ∑ j, M.mul_vec (hv₁.equiv_fun v) j • v₂ j :=
219227
show hv₂.equiv_fun.symm (matrix.to_lin' M (hv₁.equiv_fun v)) = _,
@@ -286,6 +294,9 @@ namespace is_basis
286294
lemma to_matrix_apply : he.to_matrix v i j = he.equiv_fun (v j) i :=
287295
rfl
288296

297+
lemma to_matrix_transpose_apply : (he.to_matrix v)ᵀ j = he.repr (v j) :=
298+
funext $ (λ _, rfl)
299+
289300
lemma to_matrix_eq_to_matrix_constr [decidable_eq ι] (v : ι → M) :
290301
he.to_matrix v = linear_map.to_matrix he he (he.constr v) :=
291302
by { ext, simp [is_basis.to_matrix_apply, linear_map.to_matrix_apply] }
@@ -409,8 +420,9 @@ def linear_equiv.of_is_unit_det {f : M →ₗ[R] M'} {hv : is_basis R v} {hv' :
409420

410421
variables {e : ι → M} (he : is_basis R e)
411422

412-
/-- The determinant of a family of vectors with respect to some basis, as a multilinear map. -/
413-
def is_basis.det : multilinear_map R (λ i : ι, M) R :=
423+
/-- The determinant of a family of vectors with respect to some basis, as an alternating
424+
multilinear map. -/
425+
def is_basis.det : alternating_map R M R ι :=
414426
{ to_fun := λ v, det (he.to_matrix v),
415427
map_add' := begin
416428
intros v i x y,
@@ -421,6 +433,13 @@ def is_basis.det : multilinear_map R (λ i : ι, M) R :=
421433
intros u i c x,
422434
simp only [he.to_matrix_update, algebra.id.smul_eq_mul, map_smul_of_tower],
423435
apply det_update_column_smul
436+
end,
437+
map_eq_zero_of_eq' := begin
438+
intros v i j h hij,
439+
rw [←function.update_eq_self i v, h, ←det_transpose, he.to_matrix_update,
440+
←update_row_transpose, ←he.to_matrix_transpose_apply],
441+
apply det_zero_of_row_eq hij,
442+
rw [update_row_ne hij.symm, update_row_self],
424443
end }
425444

426445
lemma is_basis.det_apply (v : ι → M) : he.det v = det (he.to_matrix v) := rfl

0 commit comments

Comments
 (0)