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

Commit d62a461

Browse files
committed
feat(linear_algebra/determinant): det (M ⬝ N) = det (N ⬝ M) if M is invertible (#8720)
If `M` is a square or invertible matrix, then `det (M ⬝ N) = det (N ⬝ M)`. This is basically just using `mul_comm` on `det M * det N`, except for some tricky rewriting to handle the invertible case. Co-authored-by: Anne Baanen <Vierkantor@users.noreply.github.com>
1 parent 7ccf463 commit d62a461

File tree

1 file changed

+23
-17
lines changed

1 file changed

+23
-17
lines changed

src/linear_algebra/determinant.lean

Lines changed: 23 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -64,33 +64,39 @@ def equiv_of_pi_lequiv_pi {R : Type*} [integral_domain R]
6464
(e : (m → R) ≃ₗ[R] (n → R)) : m ≃ n :=
6565
basis.index_equiv (basis.of_equiv_fun e.symm) (pi.basis_fun _ _)
6666

67+
namespace matrix
68+
6769
/-- If `M` and `M'` are each other's inverse matrices, they are square matrices up to
6870
equivalence of types. -/
69-
def matrix.index_equiv_of_inv [decidable_eq m] [decidable_eq n]
71+
def index_equiv_of_inv [decidable_eq m] [decidable_eq n]
7072
{M : matrix m n A} {M' : matrix n m A}
7173
(hMM' : M ⬝ M' = 1) (hM'M : M' ⬝ M = 1) :
7274
m ≃ n :=
73-
equiv_of_pi_lequiv_pi (matrix.to_lin'_of_inv hMM' hM'M)
75+
equiv_of_pi_lequiv_pi (to_lin'_of_inv hMM' hM'M)
76+
77+
lemma det_comm [decidable_eq n] (M N : matrix n n A) : det (M ⬝ N) = det (N ⬝ M) :=
78+
by rw [det_mul, det_mul, mul_comm]
79+
80+
/-- If there exists a two-sided inverse `M'` for `M` (indexed differently),
81+
then `det (N ⬝ M) = det (M ⬝ N)`. -/
82+
lemma det_comm' [decidable_eq m] [decidable_eq n]
83+
{M : matrix n m A} {N : matrix m n A} {M' : matrix m n A}
84+
(hMM' : M ⬝ M' = 1) (hM'M : M' ⬝ M = 1) :
85+
det (M ⬝ N) = det (N ⬝ M) :=
86+
-- Although `m` and `n` are different a priori, we will show they have the same cardinality.
87+
-- This turns the problem into one for square matrices, which is easy.
88+
let e := index_equiv_of_inv hMM' hM'M in
89+
by rw [← det_minor_equiv_self e, minor_mul_equiv _ _ _ (equiv.refl n) _, det_comm,
90+
← minor_mul_equiv, equiv.coe_refl, minor_id_id]
7491

7592
/-- If `M'` is a two-sided inverse for `M` (indexed differently), `det (M ⬝ N ⬝ M') = det N`. -/
76-
lemma matrix.det_conj
77-
[decidable_eq m] [decidable_eq n]
93+
lemma det_conj [decidable_eq m] [decidable_eq n]
7894
{M : matrix m n A} {M' : matrix n m A} {N : matrix n n A}
7995
(hMM' : M ⬝ M' = 1) (hM'M : M' ⬝ M = 1) :
8096
det (M ⬝ N ⬝ M') = det N :=
81-
begin
82-
-- Although `m` and `n` are different a priori, we will show they have the same cardinality.
83-
-- This turns the problem into one for square matrices (`matrix.det_units_conj`), which is easy.
84-
let e : m ≃ n := matrix.index_equiv_of_inv hMM' hM'M,
85-
let U : units (matrix n n A) :=
86-
⟨M.minor e.symm (equiv.refl _),
87-
M'.minor (equiv.refl _) e.symm,
88-
by rw [mul_eq_mul, ←minor_mul_equiv, hMM', minor_one_equiv],
89-
by rw [mul_eq_mul, ←minor_mul_equiv, hM'M, minor_one_equiv]⟩,
90-
rw [← matrix.det_units_conj U N, ← det_minor_equiv_self e.symm],
91-
simp only [minor_mul_equiv _ _ _ (equiv.refl n) _, equiv.coe_refl, minor_id_id,
92-
units.coe_mk, units.inv_mk]
93-
end
97+
by rw [← det_comm' hM'M hMM', ← matrix.mul_assoc, hM'M, matrix.one_mul]
98+
99+
end matrix
94100

95101
end conjugate
96102

0 commit comments

Comments
 (0)