The Mathlib Handbook

The volumes of the handbook are not written yet. This site shows the map of Mathlib that they will follow, at Mathlib 4472534b60.

The areas / V07. Linear algebra

Mathlib.LinearAlgebra.Matrix.Determinant.Basic

94 declarations. Mathlib docs · Source

Determinant of a matrix

This file defines the determinant of a matrix, Matrix.det, and its essential properties.

Main definitions

  • Matrix.det: the determinant of a square matrix, as a sum over permutations
  • Matrix.detRowAlternating: the determinant, as an AlternatingMap in the rows of the matrix

Main results

  • det_mul: the determinant of A * B is the product of determinants
  • det_zero_of_row_eq: the determinant is zero if there is a repeated row
  • det_block_diagonal: the determinant of a block diagonal matrix is a product of the blocks' determinants

Implementation notes

It is possible to configure simp to compute determinants. See the file MathlibTest/matrix.lean for some examples.

det_zero section

Prove that a matrix with a repeated column has determinant equal to zero.

det_eq section

Lemmas showing the determinant is invariant under a variety of operations.

theorem Matrix.det.congr_simp E1 #

∀ {n : Type u_2} {inst : DecidableEq n} [inst_1 : DecidableEq n] [inst_2 : Fintype n] {R : Type v} [inst_3 : CommRing R]
  (M M_1 : Matrix n n R), M = M_1 → M.det = M_1.det

def Matrix.detRowAlternating E3 #

{n : Type u_2} → [DecidableEq n] → [Fintype n] → {R : Type v} → [inst : CommRing R] → (n → R) [⋀^n]→ₗ[R] R

det is an AlternatingMap in the rows of the matrix.

def Matrix.det E3 #

{n : Type u_2} → [DecidableEq n] → [Fintype n] → {R : Type v} → [CommRing R] → Matrix n n R → R

The determinant of a matrix given by the Leibniz formula.

This is available in bundled forms as:

  • Matrix.detMonoidHom
  • Matrix.detRowAlternating

theorem Matrix.det_apply E0 #

∀ {n : Type u_2} [inst : DecidableEq n] [inst_1 : Fintype n] {R : Type v} [inst_2 : CommRing R] (M : Matrix n n R),
  M.det = ∑ σ, Equiv.Perm.sign σ • ∏ i, M (σ i) i

theorem Matrix.det_apply' E1 #

∀ {n : Type u_2} [inst : DecidableEq n] [inst_1 : Fintype n] {R : Type v} [inst_2 : CommRing R] (M : Matrix n n R),
  M.det = ∑ σ, ↑↑(Equiv.Perm.sign σ) * ∏ i, M (σ i) i

theorem Matrix.det_eq_detp_sub_detp E1 #

∀ {n : Type u_2} [inst : DecidableEq n] [inst_1 : Fintype n] {R : Type v} [inst_2 : CommRing R] (M : Matrix n n R),
  M.det = Matrix.detp 1 M - Matrix.detp (-1) M

theorem Matrix.det_diagonal E0 #

∀ {n : Type u_2} [inst : DecidableEq n] [inst_1 : Fintype n] {R : Type v} [inst_2 : CommRing R] {d : n → R},
  (Matrix.diagonal d).det = ∏ i, d i

theorem Matrix.det_zero E0 #

∀ {n : Type u_2} [inst : DecidableEq n] [inst_1 : Fintype n] {R : Type v} [inst_2 : CommRing R] [Nonempty n],
  Matrix.det 0 = 0

theorem Matrix.det_one E0 #

∀ {n : Type u_2} [inst : DecidableEq n] [inst_1 : Fintype n] {R : Type v} [inst_2 : CommRing R], Matrix.det 1 = 1

theorem Matrix.det_isEmpty E1 #

∀ {n : Type u_2} [inst : DecidableEq n] [inst_1 : Fintype n] {R : Type v} [inst_2 : CommRing R] [IsEmpty n]
  {A : Matrix n n R}, A.det = 1

theorem Matrix.coe_det_isEmpty E0 #

∀ {n : Type u_2} [inst : DecidableEq n] [inst_1 : Fintype n] {R : Type v} [inst_2 : CommRing R] [IsEmpty n],
  Matrix.det = Function.const (Matrix n n R) 1

theorem Matrix.det_eq_one_of_card_eq_zero E1 #

∀ {n : Type u_2} [inst : DecidableEq n] [inst_1 : Fintype n] {R : Type v} [inst_2 : CommRing R] {A : Matrix n n R},
  Fintype.card n = 0 → A.det = 1

theorem Matrix.det_unique E0 #

∀ {R : Type v} [inst : CommRing R] {n : Type u_3} [inst_1 : Unique n] [inst_2 : DecidableEq n] [inst_3 : Fintype n]
  (A : Matrix n n R), A.det = A default default

If n has only one element, the determinant of an n by n matrix is just that element. Although Unique implies DecidableEq and Fintype, the instances might not be syntactically equal. Thus, we need to fill in the args explicitly.

theorem Matrix.det_eq_elem_of_subsingleton E1 #

∀ {n : Type u_2} [inst : DecidableEq n] [inst_1 : Fintype n] {R : Type v} [inst_2 : CommRing R] [Subsingleton n]
  (A : Matrix n n R) (k : n), A.det = A k k

theorem Matrix.det_eq_elem_of_card_eq_one E1 #

∀ {n : Type u_2} [inst : DecidableEq n] [inst_1 : Fintype n] {R : Type v} [inst_2 : CommRing R] {A : Matrix n n R},
  Fintype.card n = 1 → ∀ (k : n), A.det = A k k

theorem Matrix.det_mul_aux E0 #

∀ {n : Type u_2} [inst : DecidableEq n] [inst_1 : Fintype n] {R : Type v} [inst_2 : CommRing R] {M N : Matrix n n R}
  {p : n → n}, ¬Function.Bijective p → ∑ σ, ↑↑(Equiv.Perm.sign σ) * ∏ x, M (σ x) (p x) * N (p x) x = 0

theorem Matrix.det_mul E3 #

∀ {n : Type u_2} [inst : DecidableEq n] [inst_1 : Fintype n] {R : Type v} [inst_2 : CommRing R] (M N : Matrix n n R),
  (M * N).det = M.det * N.det

def Matrix.detMonoidHom E1 #

{n : Type u_2} →
  [inst : DecidableEq n] → [inst_1 : Fintype n] → {R : Type v} → [inst_2 : CommRing R] → Matrix n n R →* R

The determinant of a matrix, as a monoid homomorphism.

theorem Matrix.coe_detMonoidHom E0 #

∀ {n : Type u_2} [inst : DecidableEq n] [inst_1 : Fintype n] {R : Type v} [inst_2 : CommRing R],
  ⇑Matrix.detMonoidHom = Matrix.det

theorem Matrix.det_mul_comm E1 #

∀ {m : Type u_1} [inst : DecidableEq m] [inst_1 : Fintype m] {R : Type v} [inst_2 : CommRing R] (M N : Matrix m m R),
  (M * N).det = (N * M).det

On square matrices, mul_comm applies under det.

theorem Matrix.det_mul_left_comm E1 #

∀ {m : Type u_1} [inst : DecidableEq m] [inst_1 : Fintype m] {R : Type v} [inst_2 : CommRing R] (M N P : Matrix m m R),
  (M * (N * P)).det = (N * (M * P)).det

On square matrices, mul_left_comm applies under det.

theorem Matrix.det_mul_right_comm E1 #

∀ {m : Type u_1} [inst : DecidableEq m] [inst_1 : Fintype m] {R : Type v} [inst_2 : CommRing R] (M N P : Matrix m m R),
  (M * N * P).det = (M * P * N).det

On square matrices, mul_right_comm applies under det.

theorem Matrix.det_units_conj E1 #

∀ {m : Type u_1} [inst : DecidableEq m] [inst_1 : Fintype m] {R : Type v} [inst_2 : CommRing R] (M : (Matrix m m R)ˣ)
  (N : Matrix m m R), (↑M * N * ↑M⁻¹).det = N.det

theorem Matrix.det_units_conj' E1 #

∀ {m : Type u_1} [inst : DecidableEq m] [inst_1 : Fintype m] {R : Type v} [inst_2 : CommRing R] (M : (Matrix m m R)ˣ)
  (N : Matrix m m R), (↑M⁻¹ * N * ↑M).det = N.det

theorem Matrix.det_transpose E0 #

∀ {n : Type u_2} [inst : DecidableEq n] [inst_1 : Fintype n] {R : Type v} [inst_2 : CommRing R] (M : Matrix n n R),
  M.transpose.det = M.det

Transposing a matrix preserves the determinant.

theorem Matrix.det_permute E1 #

∀ {n : Type u_2} [inst : DecidableEq n] [inst_1 : Fintype n] {R : Type v} [inst_2 : CommRing R] (σ : Equiv.Perm n)
  (M : Matrix n n R), (M.submatrix (⇑σ) id).det = ↑↑(Equiv.Perm.sign σ) * M.det

Permuting the columns changes the sign of the determinant.

theorem Matrix.det_permute' E1 #

∀ {n : Type u_2} [inst : DecidableEq n] [inst_1 : Fintype n] {R : Type v} [inst_2 : CommRing R] (σ : Equiv.Perm n)
  (M : Matrix n n R), (M.submatrix id ⇑σ).det = ↑↑(Equiv.Perm.sign σ) * M.det

Permuting the rows changes the sign of the determinant.

theorem Matrix.det_submatrix_equiv_self E0 #

∀ {m : Type u_1} {n : Type u_2} [inst : DecidableEq n] [inst_1 : Fintype n] [inst_2 : DecidableEq m]
  [inst_3 : Fintype m] {R : Type v} [inst_4 : CommRing R] (e : n ≃ m) (A : Matrix m m R),
  (A.submatrix ⇑e ⇑e).det = A.det

Permuting rows and columns with the same equivalence does not change the determinant.

theorem Matrix.abs_det_submatrix_equiv_equiv E0 #

∀ {m : Type u_1} {n : Type u_2} [inst : DecidableEq n] [inst_1 : Fintype n] [inst_2 : DecidableEq m]
  [inst_3 : Fintype m] {R : Type u_3} [inst_4 : CommRing R] [inst_5 : LinearOrder R] [IsStrictOrderedRing R]
  (e₁ e₂ : n ≃ m) (A : Matrix m m R), |(A.submatrix ⇑e₁ ⇑e₂).det| = |A.det|

Permuting rows and columns with two equivalences does not change the absolute value of the determinant.

theorem Matrix.det_reindex_self E1 #

∀ {m : Type u_1} {n : Type u_2} [inst : DecidableEq n] [inst_1 : Fintype n] [inst_2 : DecidableEq m]
  [inst_3 : Fintype m] {R : Type v} [inst_4 : CommRing R] (e : m ≃ n) (A : Matrix m m R),
  ((Matrix.reindex e e) A).det = A.det

Reindexing both indices along the same equivalence preserves the determinant.

For the simp version of this lemma, see det_submatrix_equiv_self; this one is unsuitable because Matrix.reindex_apply unfolds reindex first.

theorem Matrix.det_reindex E1 #

∀ {m : Type u_1} {n : Type u_2} [inst : DecidableEq n] [inst_1 : Fintype n] [inst_2 : DecidableEq m]
  [inst_3 : Fintype m] {R : Type v} [inst_4 : CommRing R] (e e' : m ≃ n) (M : Matrix m m R),
  ((Matrix.reindex e e') M).det = ↑↑(Equiv.Perm.sign (e'.trans e.symm)) * M.det

theorem Matrix.abs_det_reindex E1 #

∀ {m : Type u_1} {n : Type u_2} [inst : DecidableEq n] [inst_1 : Fintype n] [inst_2 : DecidableEq m]
  [inst_3 : Fintype m] {R : Type u_3} [inst_4 : CommRing R] [inst_5 : LinearOrder R] [IsStrictOrderedRing R]
  (e₁ e₂ : m ≃ n) (A : Matrix m m R), |((Matrix.reindex e₁ e₂) A).det| = |A.det|

Reindexing both indices along equivalences preserves the absolute of the determinant.

For the simp version of this lemma, see abs_det_submatrix_equiv_equiv; this one is unsuitable because Matrix.reindex_apply unfolds reindex first.

theorem Matrix.det_smul E1 #

∀ {n : Type u_2} [inst : DecidableEq n] [inst_1 : Fintype n] {R : Type v} [inst_2 : CommRing R] (A : Matrix n n R)
  (c : R), (c • A).det = c ^ Fintype.card n * A.det

theorem Matrix.det_smul_of_tower E0 #

∀ {n : Type u_2} [inst : DecidableEq n] [inst_1 : Fintype n] {R : Type v} [inst_2 : CommRing R] {α : Type u_3}
  [inst_3 : Monoid α] [inst_4 : MulAction α R] [IsScalarTower α R R] (c : α) (A : Matrix n n R),
  (c • A).det = c ^ Fintype.card n • A.det

theorem Matrix.det_neg E1 #

∀ {n : Type u_2} [inst : DecidableEq n] [inst_1 : Fintype n] {R : Type v} [inst_2 : CommRing R] (A : Matrix n n R),
  (-A).det = (-1) ^ Fintype.card n * A.det

theorem Matrix.det_neg_eq_smul E1 #

∀ {n : Type u_2} [inst : DecidableEq n] [inst_1 : Fintype n] {R : Type v} [inst_2 : CommRing R] (A : Matrix n n R),
  (-A).det = (-1) ^ Fintype.card n • A.det

A variant of Matrix.det_neg with scalar multiplication by Units ℤ instead of multiplication by R.

theorem Matrix.det_mul_row E1 #

∀ {n : Type u_2} [inst : DecidableEq n] [inst_1 : Fintype n] {R : Type v} [inst_2 : CommRing R] (v : n → R)
  (A : Matrix n n R), (Matrix.of fun i j ↦ v j * A i j).det = (∏ i, v i) * A.det

Multiplying each row by a fixed v i multiplies the determinant by the product of the vs.

theorem Matrix.det_mul_column E1 #

∀ {n : Type u_2} [inst : DecidableEq n] [inst_1 : Fintype n] {R : Type v} [inst_2 : CommRing R] (v : n → R)
  (A : Matrix n n R), (Matrix.of fun i j ↦ v i * A i j).det = (∏ i, v i) * A.det

Multiplying each column by a fixed v j multiplies the determinant by the product of the vs.

theorem Matrix.det_pow E0 #

∀ {m : Type u_1} [inst : DecidableEq m] [inst_1 : Fintype m] {R : Type v} [inst_2 : CommRing R] (M : Matrix m m R)
  (n : ℕ), (M ^ n).det = M.det ^ n

theorem RingHom.map_det E0 #

∀ {n : Type u_2} [inst : DecidableEq n] [inst_1 : Fintype n] {R : Type v} [inst_2 : CommRing R] {S : Type w}
  [inst_3 : CommRing S] (f : R →+* S) (M : Matrix n n R), f M.det = (f.mapMatrix M).det

theorem RingHom.map_det_submatrix E0 #

∀ {R : Type v} [inst : CommRing R] {S : Type w} [inst_1 : CommRing S] {m : Type u_3} {n : Type u_4} {t : Type u_5}
  [inst_2 : Fintype t] [inst_3 : DecidableEq t] (f : R →+* S) (A : Matrix m n R) (row : t → m) (col : t → n),
  f (A.submatrix row col).det = ((A.map ⇑f).submatrix row col).det

The determinant of submatrices are natural with respect to a ring homomorphism.

theorem RingEquiv.map_det E0 #

∀ {n : Type u_2} [inst : DecidableEq n] [inst_1 : Fintype n] {R : Type v} [inst_2 : CommRing R] {S : Type w}
  [inst_3 : CommRing S] (f : R ≃+* S) (M : Matrix n n R), f M.det = (f.mapMatrix M).det

theorem AlgHom.map_det E0 #

∀ {n : Type u_2} [inst : DecidableEq n] [inst_1 : Fintype n] {R : Type v} [inst_2 : CommRing R] {S : Type w}
  [inst_3 : CommRing S] [inst_4 : Algebra R S] {T : Type z} [inst_5 : CommRing T] [inst_6 : Algebra R T] (f : S →ₐ[R] T)
  (M : Matrix n n S), f M.det = (f.mapMatrix M).det

theorem AlgEquiv.map_det E0 #

∀ {n : Type u_2} [inst : DecidableEq n] [inst_1 : Fintype n] {R : Type v} [inst_2 : CommRing R] {S : Type w}
  [inst_3 : CommRing S] [inst_4 : Algebra R S] {T : Type z} [inst_5 : CommRing T] [inst_6 : Algebra R T] (f : S ≃ₐ[R] T)
  (M : Matrix n n S), f M.det = (f.mapMatrix M).det

theorem Int.cast_det E1 #

∀ {n : Type u_2} [inst : DecidableEq n] [inst_1 : Fintype n] {R : Type v} [inst_2 : CommRing R] (M : Matrix n n ℤ),
  ↑M.det = (M.map fun x ↦ ↑x).det

theorem Rat.cast_det E1 #

∀ {n : Type u_2} [inst : DecidableEq n] [inst_1 : Fintype n] {F : Type u_3} [inst_2 : Field F] [CharZero F]
  (M : Matrix n n ℚ), ↑M.det = (M.map fun x ↦ ↑x).det

theorem Matrix.det_conjTranspose E0 #

∀ {m : Type u_1} [inst : DecidableEq m] [inst_1 : Fintype m] {R : Type v} [inst_2 : CommRing R] [inst_3 : StarRing R]
  (M : Matrix m m R), M.conjTranspose.det = star M.det

theorem Matrix.fst_det E0 #

∀ {n : Type u_2} [inst : DecidableEq n] [inst_1 : Fintype n] {R : Type v} [inst_2 : CommRing R] {S : Type u_3}
  [inst_3 : CommRing S] (M : Matrix n n (R × S)), M.det.1 = (M.map Prod.fst).det

theorem Matrix.snd_det E0 #

∀ {n : Type u_2} [inst : DecidableEq n] [inst_1 : Fintype n] {R : Type v} [inst_2 : CommRing R] {S : Type u_3}
  [inst_3 : CommRing S] (M : Matrix n n (R × S)), M.det.2 = (M.map Prod.snd).det

theorem Matrix.det_prodRingEquiv_symm E1 #

∀ {n : Type u_2} [inst : DecidableEq n] [inst_1 : Fintype n] {R : Type v} [inst_2 : CommRing R] {S : Type u_3}
  [inst_3 : CommRing S] (M : Matrix n n R × Matrix n n S),
  ((Matrix.prodRingEquiv n R S).symm M).det = (M.1.det, M.2.det)

theorem Matrix.det_eq_zero_of_row_eq_zero E1 #

∀ {n : Type u_2} [inst : DecidableEq n] [inst_1 : Fintype n] {R : Type v} [inst_2 : CommRing R] {A : Matrix n n R}
  (i : n), (∀ (j : n), A i j = 0) → A.det = 0

theorem Matrix.det_eq_zero_of_column_eq_zero E1 #

∀ {n : Type u_2} [inst : DecidableEq n] [inst_1 : Fintype n] {R : Type v} [inst_2 : CommRing R] {A : Matrix n n R}
  (j : n), (∀ (i : n), A i j = 0) → A.det = 0

theorem Matrix.det_zero_of_row_eq E3 #

∀ {n : Type u_2} [inst : DecidableEq n] [inst_1 : Fintype n] {R : Type v} [inst_2 : CommRing R] {M : Matrix n n R}
  {i j : n}, i ≠ j → M i = M j → M.det = 0

If a matrix has a repeated row, the determinant will be zero.

theorem Matrix.det_zero_of_column_eq E0 #

∀ {n : Type u_2} [inst : DecidableEq n] [inst_1 : Fintype n] {R : Type v} [inst_2 : CommRing R] {M : Matrix n n R}
  {i j : n}, i ≠ j → (∀ (k : n), M k i = M k j) → M.det = 0

If a matrix has a repeated column, the determinant will be zero.

theorem Matrix.det_updateRow_eq_zero E1 #

∀ {n : Type u_2} [inst : DecidableEq n] [inst_1 : Fintype n] {R : Type v} [inst_2 : CommRing R] {M : Matrix n n R}
  {i j : n}, i ≠ j → (M.updateRow j (M i)).det = 0

If we repeat a row of a matrix, we get a matrix of determinant zero.

theorem Matrix.det_updateCol_eq_zero E1 #

∀ {n : Type u_2} [inst : DecidableEq n] [inst_1 : Fintype n] {R : Type v} [inst_2 : CommRing R] {M : Matrix n n R}
  {i j : n}, i ≠ j → (M.updateCol j fun k ↦ M k i).det = 0

If we repeat a column of a matrix, we get a matrix of determinant zero.

theorem Matrix.det_updateRow_add E1 #

∀ {n : Type u_2} [inst : DecidableEq n] [inst_1 : Fintype n] {R : Type v} [inst_2 : CommRing R] (M : Matrix n n R)
  (j : n) (u v : n → R), (M.updateRow j (u + v)).det = (M.updateRow j u).det + (M.updateRow j v).det

theorem Matrix.det_updateCol_add E1 #

∀ {n : Type u_2} [inst : DecidableEq n] [inst_1 : Fintype n] {R : Type v} [inst_2 : CommRing R] (M : Matrix n n R)
  (j : n) (u v : n → R), (M.updateCol j (u + v)).det = (M.updateCol j u).det + (M.updateCol j v).det

theorem Matrix.det_updateRow_smul E1 #

∀ {n : Type u_2} [inst : DecidableEq n] [inst_1 : Fintype n] {R : Type v} [inst_2 : CommRing R] (M : Matrix n n R)
  (j : n) (s : R) (u : n → R), (M.updateRow j (s • u)).det = s * (M.updateRow j u).det

theorem Matrix.det_updateCol_smul E1 #

∀ {n : Type u_2} [inst : DecidableEq n] [inst_1 : Fintype n] {R : Type v} [inst_2 : CommRing R] (M : Matrix n n R)
  (j : n) (s : R) (u : n → R), (M.updateCol j (s • u)).det = s * (M.updateCol j u).det

theorem Matrix.det_updateRow_smul_left E1 #

∀ {n : Type u_2} [inst : DecidableEq n] [inst_1 : Fintype n] {R : Type v} [inst_2 : CommRing R] (M : Matrix n n R)
  (j : n) (s : R) (u : n → R), ((s • M).updateRow j u).det = s ^ (Fintype.card n - 1) * (M.updateRow j u).det

theorem Matrix.det_updateCol_smul_left E1 #

∀ {n : Type u_2} [inst : DecidableEq n] [inst_1 : Fintype n] {R : Type v} [inst_2 : CommRing R] (M : Matrix n n R)
  (j : n) (s : R) (u : n → R), ((s • M).updateCol j u).det = s ^ (Fintype.card n - 1) * (M.updateCol j u).det

theorem Matrix.det_updateRow_sum_aux E0 #

∀ {n : Type u_2} [inst : DecidableEq n] [inst_1 : Fintype n] {R : Type v} [inst_2 : CommRing R] (M : Matrix n n R)
  {j : n} (s : Finset n), j ∉ s → ∀ (c : n → R) (a : R), (M.updateRow j (a • M j + ∑ k ∈ s, c k • M k)).det = a • M.det

theorem Matrix.det_updateRow_sum E1 #

∀ {n : Type u_2} [inst : DecidableEq n] [inst_1 : Fintype n] {R : Type v} [inst_2 : CommRing R] (A : Matrix n n R)
  (j : n) (c : n → R), (A.updateRow j (∑ k, c k • A k)).det = c j • A.det

If we replace a row of a matrix by a linear combination of its rows, then the determinant is multiplied by the coefficient of that row.

theorem Matrix.det_updateCol_sum E1 #

∀ {n : Type u_2} [inst : DecidableEq n] [inst_1 : Fintype n] {R : Type v} [inst_2 : CommRing R] (A : Matrix n n R)
  (j : n) (c : n → R), (A.updateCol j fun k ↦ ∑ i, c i • A k i).det = c j • A.det

If we replace a column of a matrix by a linear combination of its columns, then the determinant is multiplied by the coefficient of that column.

theorem Matrix.det_eq_of_eq_mul_det_one E1 #

∀ {n : Type u_2} [inst : DecidableEq n] [inst_1 : Fintype n] {R : Type v} [inst_2 : CommRing R] {A B : Matrix n n R}
  (C : Matrix n n R), C.det = 1 → A = B * C → A.det = B.det

theorem Matrix.det_eq_of_eq_det_one_mul E1 #

∀ {n : Type u_2} [inst : DecidableEq n] [inst_1 : Fintype n] {R : Type v} [inst_2 : CommRing R] {A B : Matrix n n R}
  (C : Matrix n n R), C.det = 1 → A = C * B → A.det = B.det

theorem Matrix.det_updateRow_add_self E1 #

∀ {n : Type u_2} [inst : DecidableEq n] [inst_1 : Fintype n] {R : Type v} [inst_2 : CommRing R] (A : Matrix n n R)
  {i j : n}, i ≠ j → (A.updateRow i (A i + A j)).det = A.det

theorem Matrix.det_updateCol_add_self E1 #

∀ {n : Type u_2} [inst : DecidableEq n] [inst_1 : Fintype n] {R : Type v} [inst_2 : CommRing R] (A : Matrix n n R)
  {i j : n}, i ≠ j → (A.updateCol i fun k ↦ A k i + A k j).det = A.det

theorem Matrix.det_updateRow_add_smul_self E1 #

∀ {n : Type u_2} [inst : DecidableEq n] [inst_1 : Fintype n] {R : Type v} [inst_2 : CommRing R] (A : Matrix n n R)
  {i j : n}, i ≠ j → ∀ (c : R), (A.updateRow i (A i + c • A j)).det = A.det

theorem Matrix.det_updateCol_add_smul_self E1 #

∀ {n : Type u_2} [inst : DecidableEq n] [inst_1 : Fintype n] {R : Type v} [inst_2 : CommRing R] (A : Matrix n n R)
  {i j : n}, i ≠ j → ∀ (c : R), (A.updateCol i fun k ↦ A k i + c • A k j).det = A.det

theorem Matrix.det_eq_zero_of_not_linearIndependent_rows E1 #

∀ {m : Type u_1} [inst : DecidableEq m] [inst_1 : Fintype m] {R : Type v} [inst_2 : CommRing R] [IsDomain R]
  {A : Matrix m m R}, ¬LinearIndependent R A.row → A.det = 0

theorem Matrix.linearIndependent_rows_of_det_ne_zero E1 #

∀ {m : Type u_1} [inst : DecidableEq m] [inst_1 : Fintype m] {R : Type v} [inst_2 : CommRing R] [IsDomain R]
  {A : Matrix m m R}, A.det ≠ 0 → LinearIndependent R A.row

theorem Matrix.linearIndependent_cols_of_det_ne_zero E1 #

∀ {m : Type u_1} [inst : DecidableEq m] [inst_1 : Fintype m] {R : Type v} [inst_2 : CommRing R] [IsDomain R]
  {A : Matrix m m R}, A.det ≠ 0 → LinearIndependent R A.col

theorem Matrix.det_eq_zero_of_not_linearIndependent_cols E1 #

∀ {m : Type u_1} [inst : DecidableEq m] [inst_1 : Fintype m] {R : Type v} [inst_2 : CommRing R] [IsDomain R]
  {A : Matrix m m R}, ¬LinearIndependent R A.col → A.det = 0

theorem Matrix.det_vecMulVec E1 #

∀ {n : Type u_2} [inst : DecidableEq n] [inst_1 : Fintype n] {R : Type v} [inst_2 : CommRing R] [Nontrivial n]
  (u v : n → R), (Matrix.vecMulVec u v).det = 0

theorem Matrix.det_eq_of_forall_row_eq_smul_add_const_aux E0 #

∀ {n : Type u_2} [inst : DecidableEq n] [inst_1 : Fintype n] {R : Type v} [inst_2 : CommRing R] {A B : Matrix n n R}
  {s : Finset n} (c : n → R), (∀ i ∉ s, c i = 0) → ∀ k ∉ s, (∀ (i j : n), A i j = B i j + c i * B k j) → A.det = B.det

theorem Matrix.det_eq_of_forall_row_eq_smul_add_const E1 #

∀ {n : Type u_2} [inst : DecidableEq n] [inst_1 : Fintype n] {R : Type v} [inst_2 : CommRing R] {A B : Matrix n n R}
  (c : n → R) (k : n), c k = 0 → (∀ (i j : n), A i j = B i j + c i * B k j) → A.det = B.det

If you add multiples of row B k to other rows, the determinant doesn't change.

theorem Matrix.det_eq_of_forall_row_eq_smul_add_pred_aux E0 #

∀ {R : Type v} [inst : CommRing R] {n : ℕ} (k : Fin (n + 1)) (c : Fin n → R),
  (∀ (i : Fin n), k < i.succ → c i = 0) →
    ∀ {M N : Matrix (Fin n.succ) (Fin n.succ) R},
      (∀ (j : Fin n.succ), M 0 j = N 0 j) →
        (∀ (i : Fin n) (j : Fin n.succ), M i.succ j = N i.succ j + c i * M i.castSucc j) → M.det = N.det

theorem Matrix.det_eq_of_forall_row_eq_smul_add_pred E1 #

∀ {R : Type v} [inst : CommRing R] {n : ℕ} {A B : Matrix (Fin (n + 1)) (Fin (n + 1)) R} (c : Fin n → R),
  (∀ (j : Fin (n + 1)), A 0 j = B 0 j) →
    (∀ (i : Fin n) (j : Fin (n + 1)), A i.succ j = B i.succ j + c i * A i.castSucc j) → A.det = B.det

If you add multiples of previous rows to the next row, the determinant doesn't change.

theorem Matrix.det_eq_of_forall_col_eq_smul_add_pred E1 #

∀ {R : Type v} [inst : CommRing R] {n : ℕ} {A B : Matrix (Fin (n + 1)) (Fin (n + 1)) R} (c : Fin n → R),
  (∀ (i : Fin (n + 1)), A i 0 = B i 0) →
    (∀ (i : Fin (n + 1)) (j : Fin n), A i j.succ = B i j.succ + c j * A i j.castSucc) → A.det = B.det

If you add multiples of previous columns to the next columns, the determinant doesn't change.

theorem Matrix.det_blockDiagonal E0 #

∀ {n : Type u_2} [inst : DecidableEq n] [inst_1 : Fintype n] {R : Type v} [inst_2 : CommRing R] {o : Type u_3}
  [inst_3 : Fintype o] [inst_4 : DecidableEq o] (M : o → Matrix n n R), (Matrix.blockDiagonal M).det = ∏ k, (M k).det

theorem Matrix.det_fromBlocks_zero₂₁ E0 #

∀ {m : Type u_1} {n : Type u_2} [inst : DecidableEq n] [inst_1 : Fintype n] [inst_2 : DecidableEq m]
  [inst_3 : Fintype m] {R : Type v} [inst_4 : CommRing R] (A : Matrix m m R) (B : Matrix m n R) (D : Matrix n n R),
  (Matrix.fromBlocks A B 0 D).det = A.det * D.det

The determinant of a 2×2 block matrix with the lower-left block equal to zero is the product of the determinants of the diagonal blocks. For the generalization to any number of blocks, see Matrix.det_of_isUpperTriangular.

theorem Matrix.det_fromBlocks_zero₁₂ E0 #

∀ {m : Type u_1} {n : Type u_2} [inst : DecidableEq n] [inst_1 : Fintype n] [inst_2 : DecidableEq m]
  [inst_3 : Fintype m] {R : Type v} [inst_4 : CommRing R] (A : Matrix m m R) (C : Matrix n m R) (D : Matrix n n R),
  (Matrix.fromBlocks A 0 C D).det = A.det * D.det

The determinant of a 2×2 block matrix with the upper-right block equal to zero is the product of the determinants of the diagonal blocks. For the generalization to any number of blocks, see Matrix.det_of_isLowerTriangular.

theorem Matrix.det_succ_column_zero E1 #

∀ {R : Type v} [inst : CommRing R] {n : ℕ} (A : Matrix (Fin n.succ) (Fin n.succ) R),
  A.det = ∑ i, (-1) ^ ↑i * A i 0 * (A.submatrix i.succAbove Fin.succ).det

Laplacian expansion of the determinant of an n+1 × n+1 matrix along column 0.

theorem Matrix.det_succ_row_zero E1 #

∀ {R : Type v} [inst : CommRing R] {n : ℕ} (A : Matrix (Fin n.succ) (Fin n.succ) R),
  A.det = ∑ j, (-1) ^ ↑j * A 0 j * (A.submatrix Fin.succ j.succAbove).det

Laplacian expansion of the determinant of an n+1 × n+1 matrix along row 0.

theorem Matrix.det_succ_row E1 #

∀ {R : Type v} [inst : CommRing R] {n : ℕ} (A : Matrix (Fin n.succ) (Fin n.succ) R) (i : Fin n.succ),
  A.det = ∑ j, (-1) ^ (↑i + ↑j) * A i j * (A.submatrix i.succAbove j.succAbove).det

Laplacian expansion of the determinant of an n+1 × n+1 matrix along row i.

theorem Matrix.det_succ_column E1 #

∀ {R : Type v} [inst : CommRing R] {n : ℕ} (A : Matrix (Fin n.succ) (Fin n.succ) R) (j : Fin n.succ),
  A.det = ∑ i, (-1) ^ (↑i + ↑j) * A i j * (A.submatrix i.succAbove j.succAbove).det

Laplacian expansion of the determinant of an n+1 × n+1 matrix along column j.

theorem Matrix.det_fin_zero E0 #

∀ {R : Type v} [inst : CommRing R] {A : Matrix (Fin 0) (Fin 0) R}, A.det = 1

Determinant of 0x0 matrix

theorem Matrix.det_fin_one E1 #

∀ {R : Type v} [inst : CommRing R] (A : Matrix (Fin 1) (Fin 1) R), A.det = A 0 0

Determinant of 1x1 matrix

theorem Matrix.det_fin_one_of E1 #

∀ {R : Type v} [inst : CommRing R] (a : R), !![a].det = a

theorem Matrix.det_fin_two E1 #

∀ {R : Type v} [inst : CommRing R] (A : Matrix (Fin 2) (Fin 2) R), A.det = A 0 0 * A 1 1 - A 0 1 * A 1 0

Determinant of 2x2 matrix

theorem Matrix.det_fin_two_of E0 #

∀ {R : Type v} [inst : CommRing R] (a b c d : R), !![a, b; c, d].det = a * d - b * c

theorem Matrix.det_fin_three E1 #

∀ {R : Type v} [inst : CommRing R] (A : Matrix (Fin 3) (Fin 3) R),
  A.det =
    A 0 0 * A 1 1 * A 2 2 - A 0 0 * A 1 2 * A 2 1 - A 0 1 * A 1 0 * A 2 2 + A 0 1 * A 1 2 * A 2 0 +
        A 0 2 * A 1 0 * A 2 1 -
      A 0 2 * A 1 1 * A 2 0

Determinant of 3x3 matrix