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.Transvection

68 declarations. Mathlib docs · Source

Transvections

Transvections are matrices of the form 1 + single i j c, where single i j c is the basic matrix with a c at position (i, j). Multiplying by such a transvection on the left (resp. on the right) amounts to adding c times the j-th row to the i-th row (resp c times the i-th column to the j-th column). Therefore, they are useful to present algorithms operating on rows and columns.

Transvections are a special case of elementary matrices (according to most references, these also contain the matrices exchanging rows, and the matrices multiplying a row by a constant).

We show that, over a field, any matrix can be written as L * D * L', where L and L' are products of transvections and D is diagonal. In other words, one can reduce a matrix to diagonal form by operations on its rows and columns, a variant of Gauss' pivot algorithm.

Main definitions and results

  • transvection i j c is the matrix equal to 1 + single i j c.

  • TransvectionStruct n R is a structure containing the data of i, j, c and a proof that i ≠ j. These are often easier to manipulate than straight matrices, especially in inductive arguments.

  • exists_list_transvec_mul_diagonal_mul_list_transvec states that any matrix M over a field can be written in the form t_1 * ... * t_k * D * t'_1 * ... * t'_l, where D is diagonal and the t_i, t'_j are transvections.

  • diagonal_transvection_induction shows that a property which is true for diagonal matrices and transvections, and invariant under product, is true for all matrices.

  • diagonal_transvection_induction_of_det_ne_zero is the same statement over invertible matrices.

Implementation notes

The proof of the reduction results is done inductively on the size of the matrices, reducing an (r + 1) × (r + 1) matrix to a matrix whose last row and column are zeroes, except possibly for the last diagonal entry. This step is done as follows.

If all the coefficients on the last row and column are zero, there is nothing to do. Otherwise, one can put a nonzero coefficient in the last diagonal entry by a row or column operation, and then subtract this last diagonal entry from the other entries in the last row and column to make them vanish.

This step is done in the type Fin r ⊕ Unit, where Fin r is useful to choose arbitrarily some order in which we cancel the coefficients, and the sum structure is useful to use the formalism of block matrices.

To proceed with the induction, we reindex our matrices to reduce to the above situation.

Reducing matrices by left and right multiplication by transvections

In this section, we show that any matrix can be reduced to diagonal form by left and right multiplication by transvections (or, equivalently, by elementary operations on lines and columns). The main step is to kill the last row and column of a matrix in Fin r ⊕ Unit with nonzero last coefficient, by subtracting this coefficient from the other ones. The list of these operations is recorded in list_transvec_col M and list_transvec_row M. We have to analyze inductively how these operations affect the coefficients in the last row and the last column to conclude that they have the desired effect.

Once this is done, one concludes the reduction by induction on the size of the matrices, through a suitable reindexing to identify any fintype with Fin r ⊕ Unit.

theorem Matrix.transvection.congr_simp E1 #

∀ {n : Type u_1} {R : Type u₂} {inst : DecidableEq n} [inst_1 : DecidableEq n] [inst_2 : CommRing R] (i i_1 : n),
  i = i_1 →
    ∀ (j j_1 : n),
      j = j_1 →
        ∀ (c c_1 : R),
          c = c_1 →
            ∀ (a a_1 : n),
              a = a_1 →
                ∀ (a_2 a_3 : n), a_2 = a_3 → Matrix.transvection i j c a a_2 = Matrix.transvection i_1 j_1 c_1 a_1 a_3

def Matrix.TransvectionStruct.ctorIdx E1 #

{n : Type u_1} → {R : Type u₂} → Matrix.TransvectionStruct n R → ℕ

theorem Matrix.TransvectionStruct.toMatrix.congr_simp E1 #

∀ {n : Type u_1} {R : Type u₂} {inst : DecidableEq n} [inst_1 : DecidableEq n] [inst_2 : CommRing R]
  (t t_1 : Matrix.TransvectionStruct n R),
  t = t_1 → ∀ (a a_1 : n), a = a_1 → ∀ (a_2 a_3 : n), a_2 = a_3 → t.toMatrix a a_2 = t_1.toMatrix a_1 a_3

theorem Matrix.TransvectionStruct.mk.injEq E0 #

∀ {n : Type u_1} {R : Type u₂} (i j : n) (hij : i ≠ j) (c : R) (i_1 j_1 : n) (hij_1 : i_1 ≠ j_1) (c_1 : R),
  ({ i := i, j := j, hij := hij, c := c } = { i := i_1, j := j_1, hij := hij_1, c := c_1 }) =
    (i = i_1 ∧ j = j_1 ∧ c = c_1)

theorem Matrix.TransvectionStruct.mk.congr_simp E1 #

∀ {n : Type u_1} {R : Type u₂} (i i_1 : n) (e_i : i = i_1) (j j_1 : n) (e_j : j = j_1) (hij : i ≠ j) (c c_1 : R),
  c = c_1 → { i := i, j := j, hij := hij, c := c } = { i := i_1, j := j_1, hij := ⋯, c := c_1 }

theorem Matrix.TransvectionStruct.mk.inj E1 #

∀ {n : Type u_1} {R : Type u₂} {i j : n} {hij : i ≠ j} {c : R} {i_1 j_1 : n} {hij_1 : i_1 ≠ j_1} {c_1 : R},
  { i := i, j := j, hij := hij, c := c } = { i := i_1, j := j_1, hij := hij_1, c := c_1 } → i = i_1 ∧ j = j_1 ∧ c = c_1

def Matrix.transvection E1 #

{n : Type u_1} → {R : Type u₂} → [DecidableEq n] → [CommRing R] → n → n → R → Matrix n n R

The transvection matrix transvection i j c is equal to the identity plus c at position (i, j). Multiplying by it on the left (as in transvection i j c * M) corresponds to adding c times the j-th row of M to its i-th row. Multiplying by it on the right corresponds to adding c times the i-th column to the j-th column.

theorem Matrix.transvection_zero E0 #

∀ {n : Type u_1} {R : Type u₂} [inst : DecidableEq n] [inst_1 : CommRing R] (i j : n), Matrix.transvection i j 0 = 1

theorem Matrix.updateRow_eq_transvection E1 #

∀ {n : Type u_1} {R : Type u₂} [inst : DecidableEq n] [inst_1 : CommRing R] (i j : n) [Finite n] (c : R),
  Matrix.updateRow 1 i (1 i + c • 1 j) = Matrix.transvection i j c

A transvection matrix is obtained from the identity by adding c times the j-th row to the i-th row.

theorem Matrix.transvection_mul_transvection_same E1 #

∀ {n : Type u_1} {R : Type u₂} [inst : DecidableEq n] [inst_1 : CommRing R] (i j : n) [inst_2 : Fintype n],
  i ≠ j → ∀ (c d : R), Matrix.transvection i j c * Matrix.transvection i j d = Matrix.transvection i j (c + d)

theorem Matrix.transvection_mul_apply_same E0 #

∀ {n : Type u_1} {R : Type u₂} [inst : DecidableEq n] [inst_1 : CommRing R] (i j : n) [inst_2 : Fintype n]
  {m : Type u_4} (b : m) (c : R) (M : Matrix n m R), (Matrix.transvection i j c * M) i b = M i b + c * M j b

theorem Matrix.mul_transvection_apply_same E0 #

∀ {n : Type u_1} {R : Type u₂} [inst : DecidableEq n] [inst_1 : CommRing R] (i j : n) [inst_2 : Fintype n]
  {m : Type u_4} (a : m) (c : R) (M : Matrix m n R), (M * Matrix.transvection i j c) a j = M a j + c * M a i

theorem Matrix.transvection_mul_apply_of_ne E0 #

∀ {n : Type u_1} {R : Type u₂} [inst : DecidableEq n] [inst_1 : CommRing R] (i j : n) [inst_2 : Fintype n]
  {m : Type u_4} (a : n) (b : m), a ≠ i → ∀ (c : R) (M : Matrix n m R), (Matrix.transvection i j c * M) a b = M a b

theorem Matrix.mul_transvection_apply_of_ne E0 #

∀ {n : Type u_1} {R : Type u₂} [inst : DecidableEq n] [inst_1 : CommRing R] (i j : n) [inst_2 : Fintype n]
  {m : Type u_4} (a : m) (b : n), b ≠ j → ∀ (c : R) (M : Matrix m n R), (M * Matrix.transvection i j c) a b = M a b

theorem Matrix.det_transvection_of_ne E0 #

∀ {n : Type u_1} {R : Type u₂} [inst : DecidableEq n] [inst_1 : CommRing R] (i j : n) [inst_2 : Fintype n],
  i ≠ j → ∀ (c : R), (Matrix.transvection i j c).det = 1

structure Matrix.TransvectionStruct E1 #

Type u_1 → Type u₂ → Type (max u_1 u₂)

A structure containing all the information from which one can build a nontrivial transvection. This structure is easier to manipulate than transvections as one has a direct access to all the relevant fields.

ctor Matrix.TransvectionStruct.mk E0 #

{n : Type u_1} → {R : Type u₂} → (i j : n) → i ≠ j → R → Matrix.TransvectionStruct n R

abbrev Matrix.TransvectionStruct.i E1 #

{n : Type u_1} → {R : Type u₂} → Matrix.TransvectionStruct n R → n

abbrev Matrix.TransvectionStruct.j E1 #

{n : Type u_1} → {R : Type u₂} → Matrix.TransvectionStruct n R → n

theorem Matrix.TransvectionStruct.hij E1 #

∀ {n : Type u_1} {R : Type u₂} (self : Matrix.TransvectionStruct n R), self.i ≠ self.j

abbrev Matrix.TransvectionStruct.c E1 #

{n : Type u_1} → {R : Type u₂} → Matrix.TransvectionStruct n R → R

instance Matrix.instNonemptyTransvectionStructOfNontrivial E0 #

∀ (n : Type u_1) (R : Type u₂) [CommRing R] [Nontrivial n], Nonempty (Matrix.TransvectionStruct n R)

def Matrix.TransvectionStruct.toMatrix E1 #

{n : Type u_1} → {R : Type u₂} → [DecidableEq n] → [CommRing R] → Matrix.TransvectionStruct n R → Matrix n n R

Associating to a transvection_struct the corresponding transvection matrix.

theorem Matrix.TransvectionStruct.toMatrix_mk E0 #

∀ {n : Type u_1} {R : Type u₂} [inst : DecidableEq n] [inst_1 : CommRing R] (i j : n) (hij : i ≠ j) (c : R),
  { i := i, j := j, hij := hij, c := c }.toMatrix = Matrix.transvection i j c

theorem Matrix.TransvectionStruct.det E0 #

∀ {n : Type u_1} {R : Type u₂} [inst : DecidableEq n] [inst_1 : CommRing R] [inst_2 : Fintype n]
  (t : Matrix.TransvectionStruct n R), t.toMatrix.det = 1

theorem Matrix.TransvectionStruct.det_toMatrix_prod E0 #

∀ {n : Type u_1} {R : Type u₂} [inst : DecidableEq n] [inst_1 : CommRing R] [inst_2 : Fintype n]
  (L : List (Matrix.TransvectionStruct n R)), (List.map Matrix.TransvectionStruct.toMatrix L).prod.det = 1

def Matrix.TransvectionStruct.inv E1 #

{n : Type u_1} → {R : Type u₂} → [CommRing R] → Matrix.TransvectionStruct n R → Matrix.TransvectionStruct n R

The inverse of a TransvectionStruct, designed so that t.inv.toMatrix is the inverse of t.toMatrix.

theorem Matrix.TransvectionStruct.inv_c E0 #

∀ {n : Type u_1} {R : Type u₂} [inst : CommRing R] (t : Matrix.TransvectionStruct n R), t.inv.c = -t.c

theorem Matrix.TransvectionStruct.inv_j E0 #

∀ {n : Type u_1} {R : Type u₂} [inst : CommRing R] (t : Matrix.TransvectionStruct n R), t.inv.j = t.j

theorem Matrix.TransvectionStruct.inv_i E0 #

∀ {n : Type u_1} {R : Type u₂} [inst : CommRing R] (t : Matrix.TransvectionStruct n R), t.inv.i = t.i

theorem Matrix.TransvectionStruct.inv_mul E1 #

∀ {n : Type u_1} {R : Type u₂} [inst : DecidableEq n] [inst_1 : CommRing R] [inst_2 : Fintype n]
  (t : Matrix.TransvectionStruct n R), t.inv.toMatrix * t.toMatrix = 1

theorem Matrix.TransvectionStruct.mul_inv E1 #

∀ {n : Type u_1} {R : Type u₂} [inst : DecidableEq n] [inst_1 : CommRing R] [inst_2 : Fintype n]
  (t : Matrix.TransvectionStruct n R), t.toMatrix * t.inv.toMatrix = 1

theorem Matrix.TransvectionStruct.reverse_inv_prod_mul_prod E1 #

∀ {n : Type u_1} {R : Type u₂} [inst : DecidableEq n] [inst_1 : CommRing R] [inst_2 : Fintype n]
  (L : List (Matrix.TransvectionStruct n R)),
  (List.map (Matrix.TransvectionStruct.toMatrix ∘ Matrix.TransvectionStruct.inv) L.reverse).prod *
      (List.map Matrix.TransvectionStruct.toMatrix L).prod =
    1

theorem Matrix.TransvectionStruct.prod_mul_reverse_inv_prod E1 #

∀ {n : Type u_1} {R : Type u₂} [inst : DecidableEq n] [inst_1 : CommRing R] [inst_2 : Fintype n]
  (L : List (Matrix.TransvectionStruct n R)),
  (List.map Matrix.TransvectionStruct.toMatrix L).prod *
      (List.map (Matrix.TransvectionStruct.toMatrix ∘ Matrix.TransvectionStruct.inv) L.reverse).prod =
    1

theorem Matrix.TransvectionStruct.isUnit_prod_comp_inverse E1 #

∀ {n : Type u_1} {R : Type u₂} [inst : DecidableEq n] [inst_1 : CommRing R] [inst_2 : Fintype n]
  (L : List (Matrix.TransvectionStruct n R)),
  IsUnit (List.map (Matrix.TransvectionStruct.toMatrix ∘ Matrix.TransvectionStruct.inv) L).prod

theorem Matrix.mem_range_scalar_of_commute_transvectionStruct E0 #

∀ {n : Type u_1} {R : Type u₂} [inst : DecidableEq n] [inst_1 : CommRing R] [inst_2 : Fintype n] {M : Matrix n n R},
  (∀ (t : Matrix.TransvectionStruct n R), Commute t.toMatrix M) → M ∈ Set.range ⇑(Matrix.scalar n)

M is a scalar matrix if it commutes with every nontrivial transvection (elementary matrix).

theorem Matrix.mem_range_scalar_iff_commute_transvectionStruct E0 #

∀ {n : Type u_1} {R : Type u₂} [inst : DecidableEq n] [inst_1 : CommRing R] [inst_2 : Fintype n] {M : Matrix n n R},
  M ∈ Set.range ⇑(Matrix.scalar n) ↔ ∀ (t : Matrix.TransvectionStruct n R), Commute t.toMatrix M

def Matrix.TransvectionStruct.sumInl E1 #

{n : Type u_1} → (p : Type u_2) → {R : Type u₂} → Matrix.TransvectionStruct n R → Matrix.TransvectionStruct (n ⊕ p) R

Given a TransvectionStruct on n, define the corresponding TransvectionStruct on n ⊕ p using the identity on p.

theorem Matrix.TransvectionStruct.toMatrix_sumInl E1 #

∀ {n : Type u_1} (p : Type u_2) {R : Type u₂} [inst : DecidableEq n] [inst_1 : DecidableEq p] [inst_2 : CommRing R]
  (t : Matrix.TransvectionStruct n R),
  (Matrix.TransvectionStruct.sumInl p t).toMatrix = Matrix.fromBlocks t.toMatrix 0 0 1

theorem Matrix.TransvectionStruct.sumInl_toMatrix_prod_mul E0 #

∀ {n : Type u_1} (p : Type u_2) {R : Type u₂} [inst : DecidableEq n] [inst_1 : DecidableEq p] [inst_2 : CommRing R]
  {m : Type u_4} {q : Type u_5} [inst_3 : Fintype n] [inst_4 : Fintype p] (M : Matrix n m R)
  (L : List (Matrix.TransvectionStruct n R)) (N : Matrix p q R),
  (List.map (Matrix.TransvectionStruct.toMatrix ∘ Matrix.TransvectionStruct.sumInl p) L).prod *
      Matrix.fromBlocks M 0 0 N =
    Matrix.fromBlocks ((List.map Matrix.TransvectionStruct.toMatrix L).prod * M) 0 0 N

theorem Matrix.TransvectionStruct.mul_sumInl_toMatrix_prod E0 #

∀ {n : Type u_1} (p : Type u_2) {R : Type u₂} [inst : DecidableEq n] [inst_1 : DecidableEq p] [inst_2 : CommRing R]
  {m : Type u_4} {q : Type u_5} [inst_3 : Fintype n] [inst_4 : Fintype p] (M : Matrix m n R)
  (L : List (Matrix.TransvectionStruct n R)) (N : Matrix q p R),
  Matrix.fromBlocks M 0 0 N *
      (List.map (Matrix.TransvectionStruct.toMatrix ∘ Matrix.TransvectionStruct.sumInl p) L).prod =
    Matrix.fromBlocks (M * (List.map Matrix.TransvectionStruct.toMatrix L).prod) 0 0 N

def Matrix.TransvectionStruct.reindexEquiv E1 #

{n : Type u_1} → {p : Type u_2} → {R : Type u₂} → n ≃ p → Matrix.TransvectionStruct n R → Matrix.TransvectionStruct p R

Given a TransvectionStruct on n and an equivalence between n and p, define the corresponding TransvectionStruct on p.

theorem Matrix.TransvectionStruct.toMatrix_reindexEquiv E1 #

∀ {n : Type u_1} {p : Type u_2} {R : Type u₂} [inst : DecidableEq n] [inst_1 : DecidableEq p] [inst_2 : CommRing R]
  [inst_3 : Fintype n] [inst_4 : Fintype p] (e : n ≃ p) (t : Matrix.TransvectionStruct n R),
  (Matrix.TransvectionStruct.reindexEquiv e t).toMatrix = (Matrix.reindexAlgEquiv R R e) t.toMatrix

theorem Matrix.TransvectionStruct.toMatrix_reindexEquiv_prod E1 #

∀ {n : Type u_1} {p : Type u_2} {R : Type u₂} [inst : DecidableEq n] [inst_1 : DecidableEq p] [inst_2 : CommRing R]
  [inst_3 : Fintype n] [inst_4 : Fintype p] (e : n ≃ p) (L : List (Matrix.TransvectionStruct n R)),
  (List.map (Matrix.TransvectionStruct.toMatrix ∘ Matrix.TransvectionStruct.reindexEquiv e) L).prod =
    (Matrix.reindexAlgEquiv R R e) (List.map Matrix.TransvectionStruct.toMatrix L).prod

def Matrix.Pivot.listTransvecCol E1 #

{𝕜 : Type u_3} →
  [Field 𝕜] → {r : ℕ} → Matrix (Fin r ⊕ Unit) (Fin r ⊕ Unit) 𝕜 → List (Matrix (Fin r ⊕ Unit) (Fin r ⊕ Unit) 𝕜)

A list of transvections such that multiplying on the left with these transvections will replace the last column with zeroes.

def Matrix.Pivot.listTransvecRow E1 #

{𝕜 : Type u_3} →
  [Field 𝕜] → {r : ℕ} → Matrix (Fin r ⊕ Unit) (Fin r ⊕ Unit) 𝕜 → List (Matrix (Fin r ⊕ Unit) (Fin r ⊕ Unit) 𝕜)

A list of transvections such that multiplying on the right with these transvections will replace the last row with zeroes.

theorem Matrix.Pivot.length_listTransvecCol E0 #

∀ {𝕜 : Type u_3} [inst : Field 𝕜] {r : ℕ} (M : Matrix (Fin r ⊕ Unit) (Fin r ⊕ Unit) 𝕜),
  (Matrix.Pivot.listTransvecCol M).length = r

theorem Matrix.Pivot.listTransvecCol_getElem E1 #

∀ {𝕜 : Type u_3} [inst : Field 𝕜] {r : ℕ} (M : Matrix (Fin r ⊕ Unit) (Fin r ⊕ Unit) 𝕜) {i : ℕ}
  (h : i < (Matrix.Pivot.listTransvecCol M).length),
  (Matrix.Pivot.listTransvecCol M)[i] =
    Matrix.transvection (Sum.inl ⟨i, ⋯⟩) (Sum.inr ()) (-M (Sum.inl ⟨i, ⋯⟩) (Sum.inr ()) / M (Sum.inr ()) (Sum.inr ()))

theorem Matrix.Pivot.length_listTransvecRow E0 #

∀ {𝕜 : Type u_3} [inst : Field 𝕜] {r : ℕ} (M : Matrix (Fin r ⊕ Unit) (Fin r ⊕ Unit) 𝕜),
  (Matrix.Pivot.listTransvecRow M).length = r

theorem Matrix.Pivot.listTransvecRow_getElem E1 #

∀ {𝕜 : Type u_3} [inst : Field 𝕜] {r : ℕ} (M : Matrix (Fin r ⊕ Unit) (Fin r ⊕ Unit) 𝕜) {i : ℕ}
  (h : i < (Matrix.Pivot.listTransvecRow M).length),
  (Matrix.Pivot.listTransvecRow M)[i] =
    Matrix.transvection (Sum.inr ()) (Sum.inl ⟨i, ⋯⟩) (-M (Sum.inr ()) (Sum.inl ⟨i, ⋯⟩) / M (Sum.inr ()) (Sum.inr ()))

theorem Matrix.Pivot.listTransvecCol_mul_last_row_drop E1 #

∀ {𝕜 : Type u_3} [inst : Field 𝕜] {r : ℕ} (M : Matrix (Fin r ⊕ Unit) (Fin r ⊕ Unit) 𝕜) (i : Fin r ⊕ Unit) {k : ℕ},
  k ≤ r → ((List.drop k (Matrix.Pivot.listTransvecCol M)).prod * M) (Sum.inr ()) i = M (Sum.inr ()) i

Multiplying by some of the matrices in listTransvecCol M does not change the last row.

theorem Matrix.Pivot.listTransvecCol_mul_last_row E1 #

∀ {𝕜 : Type u_3} [inst : Field 𝕜] {r : ℕ} (M : Matrix (Fin r ⊕ Unit) (Fin r ⊕ Unit) 𝕜) (i : Fin r ⊕ Unit),
  ((Matrix.Pivot.listTransvecCol M).prod * M) (Sum.inr ()) i = M (Sum.inr ()) i

Multiplying by all the matrices in listTransvecCol M does not change the last row.

theorem Matrix.Pivot.listTransvecCol_mul_last_col E1 #

∀ {𝕜 : Type u_3} [inst : Field 𝕜] {r : ℕ} (M : Matrix (Fin r ⊕ Unit) (Fin r ⊕ Unit) 𝕜),
  M (Sum.inr ()) (Sum.inr ()) ≠ 0 →
    ∀ (i : Fin r), ((Matrix.Pivot.listTransvecCol M).prod * M) (Sum.inl i) (Sum.inr ()) = 0

Multiplying by all the matrices in listTransvecCol M kills all the coefficients in the last column but the last one.

theorem Matrix.Pivot.mul_listTransvecRow_last_col_take E1 #

∀ {𝕜 : Type u_3} [inst : Field 𝕜] {r : ℕ} (M : Matrix (Fin r ⊕ Unit) (Fin r ⊕ Unit) 𝕜) (i : Fin r ⊕ Unit) {k : ℕ},
  k ≤ r → (M * (List.take k (Matrix.Pivot.listTransvecRow M)).prod) i (Sum.inr ()) = M i (Sum.inr ())

Multiplying by some of the matrices in listTransvecRow M does not change the last column.

theorem Matrix.Pivot.mul_listTransvecRow_last_col E1 #

∀ {𝕜 : Type u_3} [inst : Field 𝕜] {r : ℕ} (M : Matrix (Fin r ⊕ Unit) (Fin r ⊕ Unit) 𝕜) (i : Fin r ⊕ Unit),
  (M * (Matrix.Pivot.listTransvecRow M).prod) i (Sum.inr ()) = M i (Sum.inr ())

Multiplying by all the matrices in listTransvecRow M does not change the last column.

theorem Matrix.Pivot.mul_listTransvecRow_last_row E1 #

∀ {𝕜 : Type u_3} [inst : Field 𝕜] {r : ℕ} (M : Matrix (Fin r ⊕ Unit) (Fin r ⊕ Unit) 𝕜),
  M (Sum.inr ()) (Sum.inr ()) ≠ 0 →
    ∀ (i : Fin r), (M * (Matrix.Pivot.listTransvecRow M).prod) (Sum.inr ()) (Sum.inl i) = 0

Multiplying by all the matrices in listTransvecRow M kills all the coefficients in the last row but the last one.

theorem Matrix.Pivot.listTransvecCol_mul_mul_listTransvecRow_last_col E1 #

∀ {𝕜 : Type u_3} [inst : Field 𝕜] {r : ℕ} (M : Matrix (Fin r ⊕ Unit) (Fin r ⊕ Unit) 𝕜),
  M (Sum.inr ()) (Sum.inr ()) ≠ 0 →
    ∀ (i : Fin r),
      ((Matrix.Pivot.listTransvecCol M).prod * M * (Matrix.Pivot.listTransvecRow M).prod) (Sum.inr ()) (Sum.inl i) = 0

Multiplying by all the matrices either in listTransvecCol M and listTransvecRow M kills all the coefficients in the last row but the last one.

theorem Matrix.Pivot.listTransvecCol_mul_mul_listTransvecRow_last_row E1 #

∀ {𝕜 : Type u_3} [inst : Field 𝕜] {r : ℕ} (M : Matrix (Fin r ⊕ Unit) (Fin r ⊕ Unit) 𝕜),
  M (Sum.inr ()) (Sum.inr ()) ≠ 0 →
    ∀ (i : Fin r),
      ((Matrix.Pivot.listTransvecCol M).prod * M * (Matrix.Pivot.listTransvecRow M).prod) (Sum.inl i) (Sum.inr ()) = 0

Multiplying by all the matrices either in listTransvecCol M and listTransvecRow M kills all the coefficients in the last column but the last one.

theorem Matrix.Pivot.isTwoBlockDiagonal_listTransvecCol_mul_mul_listTransvecRow E1 #

∀ {𝕜 : Type u_3} [inst : Field 𝕜] {r : ℕ} (M : Matrix (Fin r ⊕ Unit) (Fin r ⊕ Unit) 𝕜),
  M (Sum.inr ()) (Sum.inr ()) ≠ 0 →
    ((Matrix.Pivot.listTransvecCol M).prod * M * (Matrix.Pivot.listTransvecRow M).prod).IsTwoBlockDiagonal

Multiplying by all the matrices either in listTransvecCol M and listTransvecRow M turns the matrix in block-diagonal form.

theorem Matrix.Pivot.exists_isTwoBlockDiagonal_of_ne_zero E1 #

∀ {𝕜 : Type u_3} [inst : Field 𝕜] {r : ℕ} (M : Matrix (Fin r ⊕ Unit) (Fin r ⊕ Unit) 𝕜),
  M (Sum.inr ()) (Sum.inr ()) ≠ 0 →
    ∃ L L',
      ((List.map Matrix.TransvectionStruct.toMatrix L).prod * M *
          (List.map Matrix.TransvectionStruct.toMatrix L').prod).IsTwoBlockDiagonal

There exist two lists of TransvectionStruct such that multiplying by them on the left and on the right makes a matrix block-diagonal, when the last coefficient is nonzero.

theorem Matrix.Pivot.exists_isTwoBlockDiagonal_list_transvec_mul_mul_list_transvec E1 #

∀ {𝕜 : Type u_3} [inst : Field 𝕜] {r : ℕ} (M : Matrix (Fin r ⊕ Unit) (Fin r ⊕ Unit) 𝕜),
  ∃ L L',
    ((List.map Matrix.TransvectionStruct.toMatrix L).prod * M *
        (List.map Matrix.TransvectionStruct.toMatrix L').prod).IsTwoBlockDiagonal

There exist two lists of TransvectionStruct such that multiplying by them on the left and on the right makes a matrix block-diagonal.

theorem Matrix.Pivot.exists_list_transvec_mul_mul_list_transvec_eq_diagonal_induction E1 #

∀ {𝕜 : Type u_3} [inst : Field 𝕜] {r : ℕ},
  (∀ (M : Matrix (Fin r) (Fin r) 𝕜),
      ∃ L₀ L₀' D₀,
        (List.map Matrix.TransvectionStruct.toMatrix L₀).prod * M *
            (List.map Matrix.TransvectionStruct.toMatrix L₀').prod =
          Matrix.diagonal D₀) →
    ∀ (M : Matrix (Fin r ⊕ Unit) (Fin r ⊕ Unit) 𝕜),
      ∃ L L' D,
        (List.map Matrix.TransvectionStruct.toMatrix L).prod * M *
            (List.map Matrix.TransvectionStruct.toMatrix L').prod =
          Matrix.diagonal D

Inductive step for the reduction: if one knows that any size r matrix can be reduced to diagonal form by elementary operations, then one deduces it for matrices over Fin r ⊕ Unit.

theorem Matrix.Pivot.reindex_exists_list_transvec_mul_mul_list_transvec_eq_diagonal E1 #

∀ {n : Type u_1} {p : Type u_2} {𝕜 : Type u_3} [inst : Field 𝕜] [inst_1 : DecidableEq n] [inst_2 : DecidableEq p]
  [inst_3 : Fintype n] [inst_4 : Fintype p] (M : Matrix p p 𝕜) (e : p ≃ n),
  (∃ L L' D,
      (List.map Matrix.TransvectionStruct.toMatrix L).prod * (Matrix.reindexAlgEquiv 𝕜 𝕜 e) M *
          (List.map Matrix.TransvectionStruct.toMatrix L').prod =
        Matrix.diagonal D) →
    ∃ L L' D,
      (List.map Matrix.TransvectionStruct.toMatrix L).prod * M * (List.map Matrix.TransvectionStruct.toMatrix L').prod =
        Matrix.diagonal D

Reduction to diagonal form by elementary operations is invariant under reindexing.

theorem Matrix.Pivot.exists_list_transvec_mul_mul_list_transvec_eq_diagonal_aux E0 #

∀ {𝕜 : Type u_3} [inst : Field 𝕜] (n : Type) [inst_1 : Fintype n] [inst_2 : DecidableEq n] (M : Matrix n n 𝕜),
  ∃ L L' D,
    (List.map Matrix.TransvectionStruct.toMatrix L).prod * M * (List.map Matrix.TransvectionStruct.toMatrix L').prod =
      Matrix.diagonal D

Any matrix can be reduced to diagonal form by elementary operations. Formulated here on Type 0 because we will make an induction using Fin r. See exists_list_transvec_mul_mul_list_transvec_eq_diagonal for the general version (which follows from this one and reindexing).

theorem Matrix.Pivot.exists_list_transvec_mul_mul_list_transvec_eq_diagonal E3 #

∀ {n : Type u_1} {𝕜 : Type u_3} [inst : Field 𝕜] [inst_1 : DecidableEq n] [inst_2 : Fintype n] (M : Matrix n n 𝕜),
  ∃ L L' D,
    (List.map Matrix.TransvectionStruct.toMatrix L).prod * M * (List.map Matrix.TransvectionStruct.toMatrix L').prod =
      Matrix.diagonal D

Any matrix can be reduced to diagonal form by elementary operations.

theorem Matrix.Pivot.exists_list_transvec_mul_diagonal_mul_list_transvec E1 #

∀ {n : Type u_1} {𝕜 : Type u_3} [inst : Field 𝕜] [inst_1 : DecidableEq n] [inst_2 : Fintype n] (M : Matrix n n 𝕜),
  ∃ L L' D,
    M =
      (List.map Matrix.TransvectionStruct.toMatrix L).prod * Matrix.diagonal D *
        (List.map Matrix.TransvectionStruct.toMatrix L').prod

Any matrix can be written as the product of transvections, a diagonal matrix, and transvections.

theorem Matrix.diagonal_transvection_induction E2 #

∀ {n : Type u_1} {𝕜 : Type u_3} [inst : Field 𝕜] [inst_1 : DecidableEq n] [inst_2 : Fintype n] (P : Matrix n n 𝕜 → Prop)
  (M : Matrix n n 𝕜),
  (∀ (D : n → 𝕜), (Matrix.diagonal D).det = M.det → P (Matrix.diagonal D)) →
    (∀ (t : Matrix.TransvectionStruct n 𝕜), P t.toMatrix) → (∀ (A B : Matrix n n 𝕜), P A → P B → P (A * B)) → P M

Induction principle for matrices based on transvections: if a property is true for all diagonal matrices, all transvections, and is stable under product, then it is true for all matrices. This is the useful way to say that matrices are generated by diagonal matrices and transvections.

We state a slightly more general version: to prove a property for a matrix M, it suffices to assume that the diagonal matrices we consider have the same determinant as M. This is useful to obtain similar principles for SLₙ or GLₙ.

theorem Matrix.diagonal_transvection_induction_of_det_ne_zero E2 #

∀ {n : Type u_1} {𝕜 : Type u_3} [inst : Field 𝕜] [inst_1 : DecidableEq n] [inst_2 : Fintype n] (P : Matrix n n 𝕜 → Prop)
  (M : Matrix n n 𝕜),
  M.det ≠ 0 →
    (∀ (D : n → 𝕜), (Matrix.diagonal D).det ≠ 0 → P (Matrix.diagonal D)) →
      (∀ (t : Matrix.TransvectionStruct n 𝕜), P t.toMatrix) →
        (∀ (A B : Matrix n n 𝕜), A.det ≠ 0 → B.det ≠ 0 → P A → P B → P (A * B)) → P M

Induction principle for invertible matrices based on transvections: if a property is true for all invertible diagonal matrices, all transvections, and is stable under product of invertible matrices, then it is true for all invertible matrices. This is the useful way to say that invertible matrices are generated by invertible diagonal matrices and transvections.