Documentation

AlgebraicCombinatorics.DeterminantsBasic

Determinants: Basic Properties #

This file formalizes the basic properties of determinants from Section "Determinants" (sec.sign.det) of the source.

Main definitions #

The determinant is already defined in Mathlib as Matrix.det. This file provides:

Main results #

Definition (Definition def.det.det) #

The determinant of an n×n matrix A is defined as: det A = ∑{σ ∈ Sₙ} (-1)^σ · A{1,σ(1)} · A_{2,σ(2)} · ... · A_{n,σ(n)}

Basic Properties #

Propositions #

References #

Implementation notes #

Mathlib already provides Matrix.det with most of the basic properties. This file adds:

  1. Documentation connecting Mathlib API to the textbook
  2. Specific examples and exercises from the source
  3. Some additional lemmas in the style of the textbook

Note: Mathlib uses 0-indexing for matrices (Fin n), while the source uses 1-indexing. The Mathlib definition uses A(σ(i), i) rather than A(i, σ(i)), but these are equivalent by reindexing the permutation.

Convention (conv.det.K) #

We work over a commutative ring K. In most examples, K will be ℤ, ℚ, or a polynomial ring.

Convention (conv.det.matrices) #

(a) For an n×m matrix A, A_{i,j} denotes the (i,j)-th entry. (b) We write (a_{i,j}){1≤i≤n, 1≤j≤m} for the matrix with entries a{i,j}. (c) K^{n×m} denotes the set of n×m matrices over K. (d) A^T denotes the transpose of A.

In Mathlib:

Definition of Determinant (Definition def.det.det) #

The determinant of an n×n matrix A is: det A = ∑{σ ∈ Sₙ} (-1)^σ · ∏{i=1}^n A_{i,σ(i)}

In Mathlib, this is Matrix.det A, defined as: det A = ∑{σ ∈ Sₙ} (-1)^σ · ∏{i} A_{σ(i),i}

These are equivalent by substituting σ ↦ σ⁻¹.

theorem AlgebraicCombinatorics.Det.det_eq_sum_sign_prod {K : Type u_1} [CommRing K] {n : } (A : Matrix (Fin n) (Fin n) K) :
A.det = σ : Equiv.Perm (Fin n), Equiv.Perm.sign σ i : Fin n, A (σ i) i

The determinant formula from Definition def.det.det. Note: Mathlib uses A(σ(i), i) rather than A(i, σ(i)).

theorem AlgebraicCombinatorics.Det.det_eq_sum_sign_prod_textbook {K : Type u_1} [CommRing K] {n : } (A : Matrix (Fin n) (Fin n) K) :
A.det = σ : Equiv.Perm (Fin n), Equiv.Perm.sign σ i : Fin n, A i (σ i)

Alternative form with A(i, σ(i)) matching the textbook. This is obtained by substituting σ ↦ σ⁻¹ in the Mathlib definition.

This is the formalization of Definition def.det.det from the source: det A = ∑{σ ∈ Sₙ} (-1)^σ · ∏{i=1}^n A_{i,σ(i)}

The Mathlib definition uses A(σ(i), i) rather than A(i, σ(i)), but these are equivalent by substituting σ ↦ σ⁻¹.

Examples of small determinants #

For n = 0: det() = 1 (empty product) For n = 1: det(a) = a For n = 2: det [[a, b], [a', b']] = a·b' - b·a' For n = 3: The 6-term expansion over S₃

theorem AlgebraicCombinatorics.Det.det_fin_zero' {K : Type u_1} [CommRing K] (A : Matrix (Fin 0) (Fin 0) K) :
A.det = 1

Determinant of 0×0 matrix is 1

theorem AlgebraicCombinatorics.Det.det_fin_one' {K : Type u_1} [CommRing K] (A : Matrix (Fin 1) (Fin 1) K) :
A.det = A 0 0

Determinant of 1×1 matrix is its single entry

theorem AlgebraicCombinatorics.Det.det_fin_two' {K : Type u_1} [CommRing K] (A : Matrix (Fin 2) (Fin 2) K) :
A.det = A 0 0 * A 1 1 - A 0 1 * A 1 0

Determinant of 2×2 matrix: ad - bc

@[simp]

The determinant of the identity matrix is 1. This is a basic API lemma for working with determinants.

@[simp]
theorem AlgebraicCombinatorics.Det.det_zero_eq_zero {K : Type u_1} [CommRing K] {n : } (hn : 0 < n) :

The determinant of the zero matrix is 0 (for n ≥ 1). This is a basic API lemma for working with determinants.

Note: For n = 0, the zero matrix is the empty matrix, and det(∅) = 1 by convention (empty product).

Example: Hollow 5×5 matrix (Example exa.det.hollow5x5) #

A 5×5 matrix with a 3×3 block of zeros in the middle has determinant 0. The proof uses the pigeonhole principle: any permutation must map some element of {2,3,4} to {2,3,4}, hitting a zero entry.

theorem AlgebraicCombinatorics.Det.det_hollow_core_eq_zero {K : Type u_1} [CommRing K] (A : Matrix (Fin 5) (Fin 5) K) (hA : ∀ (i j : Fin 5), i {1, 2, 3}j {1, 2, 3}A i j = 0) :
A.det = 0

A matrix with a "hollow core" of zeros has determinant zero. Label: exa.det.hollow5x5

More precisely: if A_{i,j} = 0 whenever i, j ∈ {1, 2, 3} (0-indexed), then det A = 0. This is because any permutation σ must have some i ∈ {1,2,3} with σ(i) ∈ {1,2,3} by pigeonhole.

Proposition: det(xᵢyⱼ) = 0 (Proposition prop.det.xiyj) #

For n ≥ 2, if we form the n×n matrix with (i,j)-entry xᵢ·yⱼ, then its determinant is 0.

The proof uses ∑_{σ ∈ Sₙ} (-1)^σ = 0 for n ≥ 2.

def AlgebraicCombinatorics.Det.outerProductMatrix {K : Type u_1} [CommRing K] {n : } (x y : Fin nK) :
Matrix (Fin n) (Fin n) K

The matrix with entries x_i * y_j. Label: prop.det.xiyj

Equations
Instances For
    @[simp]
    theorem AlgebraicCombinatorics.Det.outerProductMatrix_apply {K : Type u_1} [CommRing K] {n : } (x y : Fin nK) (i j : Fin n) :
    outerProductMatrix x y i j = x i * y j
    theorem AlgebraicCombinatorics.Det.sum_sign_eq_zero {K : Type u_1} [CommRing K] {n : } (hn : 2 n) :
    σ : Equiv.Perm (Fin n), (Equiv.Perm.sign σ) = 0

    Sum of signs over Sₙ is 0 for n ≥ 2. This is eq.cor.perm.num-even.sum-sign from the source.

    The proof uses a sign-reversing involution: multiply by a fixed transposition. For n ≥ 2, we can pick two distinct elements and their transposition t. Then σ ↦ t * σ pairs up permutations with opposite signs.

    theorem AlgebraicCombinatorics.Det.det_outerProduct_eq_zero {K : Type u_1} [CommRing K] {n : } (x y : Fin nK) (hn : 2 n) :

    Determinant of outer product matrix is 0 for n ≥ 2. Label: prop.det.xiyj

    theorem AlgebraicCombinatorics.Det.det_const_matrix_eq_zero {K : Type u_1} [CommRing K] {n : } (c : K) (hn : 2 n) :
    (Matrix.of fun (x x_1 : Fin n) => c).det = 0

    Corollary: Matrix with all entries equal has det = 0 for n ≥ 2. Label: eq.prop.det.xiyj.cor-x

    Proposition: det(xᵢ + yⱼ) = 0 (Proposition prop.det.xi+yj) #

    For n ≥ 3, if we form the n×n matrix with (i,j)-entry xᵢ + yⱼ, then its determinant is 0.

    The proof uses a cancellation argument involving transpositions.

    def AlgebraicCombinatorics.Det.sumMatrix {K : Type u_1} [CommRing K] {n : } (x y : Fin nK) :
    Matrix (Fin n) (Fin n) K

    The matrix with entries x_i + y_j. Label: prop.det.xi+yj

    Equations
    Instances For
      @[simp]
      theorem AlgebraicCombinatorics.Det.sumMatrix_apply {K : Type u_1} [CommRing K] {n : } (x y : Fin nK) (i j : Fin n) :
      sumMatrix x y i j = x i + y j
      def AlgebraicCombinatorics.Det.sumMatrix_factorA {K : Type u_1} [CommRing K] {n : } (x : Fin nK) :
      Matrix (Fin n) (Fin n) K

      The matrix A in the factorization of sumMatrix: first column is x_i, second column is 1, rest are 0. Used in the second proof of prop.det.xi+yj.

      Equations
      Instances For
        def AlgebraicCombinatorics.Det.sumMatrix_factorB {K : Type u_1} [CommRing K] {n : } (y : Fin nK) :
        Matrix (Fin n) (Fin n) K

        The matrix B in the factorization of sumMatrix: first row is 1, second row is y_j, rest are 0. Used in the second proof of prop.det.xi+yj.

        Equations
        Instances For
          theorem AlgebraicCombinatorics.Det.sumMatrix_factorA_has_zero_col {K : Type u_1} [CommRing K] {n : } (x : Fin nK) (hn : 3 n) (i : Fin n) :

          The matrix A in the factorization has a zero column when n ≥ 3 (column index 2).

          theorem AlgebraicCombinatorics.Det.det_sumMatrix_factorA_eq_zero {K : Type u_1} [CommRing K] {n : } (x : Fin nK) (hn : 3 n) :

          The determinant of the factor matrix A is 0 when n ≥ 3.

          The matrix (x_i + y_j) factors as A * B where A = sumMatrix_factorA and B = sumMatrix_factorB.

          theorem AlgebraicCombinatorics.Det.det_sumMatrix_eq_zero {K : Type u_1} [CommRing K] {n : } (x y : Fin nK) (hn : 3 n) :
          (sumMatrix x y).det = 0

          Determinant of sum matrix is 0 for n ≥ 3. Label: prop.det.xi+yj

          The proof uses matrix factorization: (x_i + y_j) = A * B where A has a zero column.

          Theorem: Transposes preserve determinants (Theorem thm.det.transp) #

          det(A^T) = det(A)

          theorem AlgebraicCombinatorics.Det.det_transpose' {K : Type u_1} [CommRing K] {n : } (A : Matrix (Fin n) (Fin n) K) :

          Transposes preserve determinants. Label: thm.det.transp

          Theorem: Determinants of triangular matrices (Theorem thm.det.triang) #

          If A is upper-triangular or lower-triangular, then det A = ∏ᵢ Aᵢᵢ.

          theorem AlgebraicCombinatorics.Det.det_upperTriangular {K : Type u_1} [CommRing K] {n : } (A : Matrix (Fin n) (Fin n) K) (hA : ∀ (i j : Fin n), j < iA i j = 0) :
          A.det = i : Fin n, A i i

          Determinant of upper triangular matrix is product of diagonal. Label: thm.det.triang

          theorem AlgebraicCombinatorics.Det.det_lowerTriangular {K : Type u_1} [CommRing K] {n : } (A : Matrix (Fin n) (Fin n) K) (hA : ∀ (i j : Fin n), i < jA i j = 0) :
          A.det = i : Fin n, A i i

          Determinant of lower triangular matrix is product of diagonal. Label: thm.det.triang

          theorem AlgebraicCombinatorics.Det.det_diagonal' {K : Type u_1} [CommRing K] {n : } (d : Fin nK) :
          (Matrix.diagonal d).det = i : Fin n, d i

          Determinant of diagonal matrix is product of diagonal entries

          Theorem: Row operation properties (Theorem thm.det.rowop) #

          (a) Swapping rows multiplies det by -1 (b) Zero row implies det = 0 (c) Equal rows implies det = 0 (d) Scaling a row by λ scales det by λ (e) Adding a row to another preserves det (f) Adding λ times a row to another preserves det (g) Multilinearity: det is additive in each row

          theorem AlgebraicCombinatorics.Det.det_swap_rows {K : Type u_1} [CommRing K] {n : } (A : Matrix (Fin n) (Fin n) K) (i j : Fin n) (hij : i j) :
          (Matrix.of (A (Equiv.swap i j))).det = -A.det

          (a) Swapping two rows multiplies determinant by -1. Label: thm.det.rowop (a)

          theorem AlgebraicCombinatorics.Det.det_zero_row {K : Type u_1} [CommRing K] {n : } (A : Matrix (Fin n) (Fin n) K) (i : Fin n) (hi : ∀ (j : Fin n), A i j = 0) :
          A.det = 0

          (b) A matrix with a zero row has determinant 0. Label: thm.det.rowop (b)

          theorem AlgebraicCombinatorics.Det.det_eq_rows {K : Type u_1} [CommRing K] {n : } (A : Matrix (Fin n) (Fin n) K) (i j : Fin n) (hij : i j) (hrows : A i = A j) :
          A.det = 0

          (c) A matrix with two equal rows has determinant 0. Label: thm.det.rowop (c)

          theorem AlgebraicCombinatorics.Det.det_scale_row {K : Type u_1} [CommRing K] {n : } (A : Matrix (Fin n) (Fin n) K) (i : Fin n) (c : K) :
          (A.updateRow i (c A i)).det = c * A.det

          (d) Scaling a row by λ scales the determinant by λ. Label: thm.det.rowop (d)

          theorem AlgebraicCombinatorics.Det.det_add_row {K : Type u_1} [CommRing K] {n : } (A : Matrix (Fin n) (Fin n) K) (i j : Fin n) (hij : i j) :
          (A.updateRow i (A i + A j)).det = A.det

          (e) Adding one row to another preserves determinant (special case of (f)). Label: thm.det.rowop (e)

          theorem AlgebraicCombinatorics.Det.det_add_smul_row {K : Type u_1} [CommRing K] {n : } (A : Matrix (Fin n) (Fin n) K) (i j : Fin n) (hij : i j) (c : K) :
          (A.updateRow i (A i + c A j)).det = A.det

          (f) Adding λ times one row to another preserves determinant. Label: thm.det.rowop (f)

          theorem AlgebraicCombinatorics.Det.det_row_add {K : Type u_1} [CommRing K] {n : } (A B C : Matrix (Fin n) (Fin n) K) (k : Fin n) (hk : C k = A k + B k) (hother : ∀ (i : Fin n), i kC i = A i A i = B i) :
          C.det = A.det + B.det

          (g) Multilinearity: determinant is additive in row k. Label: thm.det.rowop (g)

          Theorem: Column operation properties (Theorem thm.det.colop) #

          The column analogues of Theorem thm.det.rowop follow from the row versions using det(A^T) = det(A).

          theorem AlgebraicCombinatorics.Det.det_swap_cols {K : Type u_1} [CommRing K] {n : } (A : Matrix (Fin n) (Fin n) K) (i j : Fin n) (hij : i j) :
          (A.submatrix id (Equiv.swap i j)).det = -A.det

          (a) Swapping two columns multiplies determinant by -1. Label: thm.det.colop (a)

          theorem AlgebraicCombinatorics.Det.det_zero_col {K : Type u_1} [CommRing K] {n : } (A : Matrix (Fin n) (Fin n) K) (j : Fin n) (hj : ∀ (i : Fin n), A i j = 0) :
          A.det = 0

          A matrix with a zero column has determinant 0. Label: thm.det.colop (b)

          theorem AlgebraicCombinatorics.Det.det_eq_cols {K : Type u_1} [CommRing K] {n : } (A : Matrix (Fin n) (Fin n) K) (i j : Fin n) (hij : i j) (hcols : ∀ (k : Fin n), A k i = A k j) :
          A.det = 0

          (c) A matrix with two equal columns has determinant 0. Label: thm.det.colop (c)

          theorem AlgebraicCombinatorics.Det.det_scale_col {K : Type u_1} [CommRing K] {n : } (A : Matrix (Fin n) (Fin n) K) (j : Fin n) (c : K) :
          (Matrix.of fun (i k : Fin n) => if k = j then c * A i k else A i k).det = c * A.det

          Scaling a column by λ scales the determinant by λ. Label: thm.det.colop (d)

          theorem AlgebraicCombinatorics.Det.det_add_col {K : Type u_1} [CommRing K] {n : } (A : Matrix (Fin n) (Fin n) K) (i j : Fin n) (hij : i j) :
          (A.updateCol i fun (k : Fin n) => A k i + A k j).det = A.det

          (e) Adding one column to another preserves determinant (special case of (f)). Label: thm.det.colop (e)

          theorem AlgebraicCombinatorics.Det.det_add_smul_col {K : Type u_1} [CommRing K] {n : } (A : Matrix (Fin n) (Fin n) K) (i j : Fin n) (hij : i j) (c : K) :
          (A.updateCol i fun (k : Fin n) => A k i + c * A k j).det = A.det

          (f) Adding λ times one column to another preserves determinant. Label: thm.det.colop (f)

          theorem AlgebraicCombinatorics.Det.det_col_add {K : Type u_1} [CommRing K] {n : } (A B C : Matrix (Fin n) (Fin n) K) (k : Fin n) (hk : ∀ (i : Fin n), C i k = A i k + B i k) (hother : ∀ (i j : Fin n), j kC i j = A i j A i j = B i j) :
          C.det = A.det + B.det

          (g) Multilinearity: determinant is additive in column k. Label: thm.det.colop (g)

          Corollary: Permuting rows/columns (Corollary cor.det.sig-row-col) #

          When we permute the rows or columns of a matrix by τ ∈ Sₙ, the determinant gets multiplied by sign(τ).

          theorem AlgebraicCombinatorics.Det.det_permute_rows {K : Type u_1} [CommRing K] {n : } (A : Matrix (Fin n) (Fin n) K) (τ : Equiv.Perm (Fin n)) :
          (A.submatrix (⇑τ) id).det = (Equiv.Perm.sign τ) * A.det

          Permuting rows multiplies determinant by sign of permutation. Label: eq.cor.det.sig-row-col.row

          theorem AlgebraicCombinatorics.Det.det_permute_cols {K : Type u_1} [CommRing K] {n : } (A : Matrix (Fin n) (Fin n) K) (τ : Equiv.Perm (Fin n)) :
          (A.submatrix id τ).det = (Equiv.Perm.sign τ) * A.det

          Permuting columns multiplies determinant by sign of permutation. Label: eq.cor.det.sig-row-col.col

          Theorem: Multiplicativity of the determinant (Theorem thm.det.detAB) #

          det(AB) = det(A) · det(B)

          theorem AlgebraicCombinatorics.Det.det_mul' {K : Type u_1} [CommRing K] {n : } (A B : Matrix (Fin n) (Fin n) K) :
          (A * B).det = A.det * B.det

          Multiplicativity of determinant. Label: thm.det.detAB

          Corollary: Scaling rows/columns (Corollary cor.det.scale-row-col) #

          Scaling each row i by dᵢ (or each column j by dⱼ) multiplies the determinant by ∏ᵢ dᵢ.

          theorem AlgebraicCombinatorics.Det.det_scale_rows {K : Type u_1} [CommRing K] {n : } (A : Matrix (Fin n) (Fin n) K) (d : Fin nK) :
          (Matrix.of fun (i j : Fin n) => d i * A i j).det = (∏ i : Fin n, d i) * A.det

          Scaling row i by d_i multiplies determinant by ∏ d_i. Label: eq.cor.det.scale-row-col.row

          theorem AlgebraicCombinatorics.Det.det_scale_cols {K : Type u_1} [CommRing K] {n : } (A : Matrix (Fin n) (Fin n) K) (d : Fin nK) :
          (Matrix.of fun (i j : Fin n) => d j * A i j).det = (∏ j : Fin n, d j) * A.det

          Scaling column j by d_j multiplies determinant by ∏ d_j. Label: eq.cor.det.scale-row-col.col

          Alternative proofs using multiplicativity #

          The source provides alternative proofs of Proposition prop.det.xiyj and Proposition prop.det.xi+yj using matrix factorization and det(AB) = det(A)·det(B).

          theorem AlgebraicCombinatorics.Det.det_outerProduct_eq_zero' {K : Type u_1} [CommRing K] {n : } (x y : Fin nK) (hn : 2 n) :

          Second proof of det_outerProduct_eq_zero using matrix factorization. The matrix (xᵢyⱼ) factors as A·B where A has only first column nonzero and B has only first row nonzero. Since n ≥ 2, A has a zero column, so det(A) = 0. Label: prop.det.xiyj (second proof)

          theorem AlgebraicCombinatorics.Det.det_sumMatrix_eq_zero' {K : Type u_1} [CommRing K] {n : } (x y : Fin nK) (hn : 3 n) :
          (sumMatrix x y).det = 0

          Second proof of det_sumMatrix_eq_zero using matrix factorization. The matrix (xᵢ + yⱼ) factors as A·B where A has only first two columns nonzero and B has only first two rows nonzero. Since n ≥ 3, A has a zero column, so det(A) = 0. Label: prop.det.xi+yj (second proof)