Documentation

Formalizations.Reusable.LinearAlgebra

Reusable layer: linear algebra #

Stable names for matrix results of the archive: rank bounds, the Cauchy–Binet formula and Jacobi's formula. Each theorem is proved by the archive theorem it re-exposes (no proof is copied). The modules imported here are general linear algebra; none is a paper of the archive.

Main results #

theorem Formalizations.Reusable.rank_fromBlocks_zero₂₁_le_card_add_rank {l : Type u_1} {n : Type u_2} {o : Type u_3} {p : Type u_4} {K : Type u_5} [Field K] [Fintype n] [Fintype o] [Fintype l] [Finite p] (A : Matrix l n K) (B : Matrix l o K) (D : Matrix p o K) :

Rank of a block upper-triangular matrix. Over a field K, for blocks A : l × n, B : l × o and D : p × o, rank !![A, B; 0, D] ≤ |l| + rank D. The proof splits the block matrix as fromBlocks A B 0 0 + fromBlocks 0 0 0 D and uses subadditivity of the rank (also in the archive, Matrix.rank_add_le, which Mathlib states only for linear maps).

theorem Formalizations.Reusable.matrix_rank_add_le {m : Type u_1} {n : Type u_2} {K : Type u_3} [Field K] [Fintype n] (A B : Matrix m n K) :
(A + B).rank ≤ A.rank + B.rank

Subadditivity of the rank. Over a field K, for matrices A B : Matrix m n K, rank (A + B) ≤ rank A + rank B. Mathlib states this for linear maps (LinearMap.rank_add_le); this is the Matrix.rank form.

theorem Formalizations.Reusable.det_mul_eq_sum_det_submatrix_mul_det_submatrix {R : Type u_1} {m : Type u_2} {n : Type u_3} [CommRing R] [Fintype m] [DecidableEq m] [Fintype n] [LinearOrder n] (A : Matrix m n R) (B : Matrix n m R) :
(A * B).det = ∑ S : { s : Finset n // s.card = Fintype.card m }, (A.submatrix ⇑(Fintype.equivFin m).symm ⇑((↑S).orderEmbOfFin ⋯)).det * (B.submatrix ⇑((↑S).orderEmbOfFin ⋯) ⇑(Fintype.equivFin m).symm).det

The Cauchy–Binet formula. Over a commutative ring R, for A : Matrix m n R and B : Matrix n m R with n linearly ordered, det (A * B) is the sum, over the subsets S of n with |S| = |m|, of det A[:, S] · det B[S, :], the columns of A and the rows of B taken in the increasing order of S (S.orderEmbOfFin) and the rows of A, columns of B through Fintype.equivFin m. When |n| < |m| the sum is empty and det (A * B) = 0.

  • Archive: Matrix.det_mul_cauchyBinet (Formalizations.LinearAlgebra.Matrix.CauchyBinet, the tool for Kirchhoff's matrix-tree theorem in the same archive); the module cites no paper DOI of ours.
  • Classical reference: A.-L. Cauchy (1815), J. Binet (1815); F. R. Gantmacher, The Theory of Matrices, vol. 1.
  • Example: for A : Matrix (Fin 1) (Fin 2) ℚ, B : Matrix (Fin 2) (Fin 1) ℚ it gives det (A * B) = A 0 0 * B 0 0 + A 0 1 * B 1 0, a sum of two 1 × 1 minors.

Jacobi's formula. For a square matrix A with entries in R[X] (R a commutative ring), derivative (det A) = trace (adjugate A * A.map derivative). With A = X • 1 − M it gives charpoly′ = trace (adjugate (X − M)), the sum of the characteristic polynomials of the principal submatrices. Mathlib has only the special case derivative_det_one_add_X_smul (the first-order term of det (1 + X M)).

  • Archive: Matrix.derivative_det (Formalizations.LinearAlgebra.Matrix.Charpoly.Jacobi, a tool for the Ihara trace formula in the same archive); the module cites no paper DOI of ours.
  • Classical reference: C. G. J. Jacobi, De formatione et proprietatibus determinantium, J. Reine Angew. Math. 22 (1841); R. A. Horn, C. R. Johnson, Matrix Analysis, 2nd ed. (2013).
  • Example: for A = !![X, 1; 0, X] over ℚ, it gives derivative (X²) = 2 X.
theorem Formalizations.Reusable.matrix_rank_add_rank_le_rank_fromBlocks {l : Type u_1} {n : Type u_2} {o : Type u_3} {p : Type u_4} {K : Type u_5} [Field K] [Fintype n] [Fintype o] (A : Matrix l n K) (B : Matrix l o K) (D : Matrix p o K) :

Lower bound for the rank of a block upper-triangular matrix. Over a field K, for blocks A : l × n, B : l × o and D : p × o, rank A + rank D ≤ rank !![A, B; 0, D]. Together with rank_fromBlocks_zero₂₁_le_card_add_rank it pins the rank of a block-triangular certificate between rank A + rank D and |l| + rank D; with A invertible both bounds agree.

  • Archive: Matrix.rank_add_rank_le_rank_fromBlocks_zero₂₁ (Formalizations.LinearAlgebra.Matrix.Rank, used by the free-locus certificates of the same archive); proved through the nullity bound for block triangular matrices.
  • Classical reference: textbook (e.g. G. Marsaglia, G. P. H. Styan, Equalities and inequalities for ranks of matrices, Linear and Multilinear Algebra 2 (1974) 269–292).
  • Example: with A = D = 1 : Matrix (Fin 2) (Fin 2) ℚ, any B gives 4 ≤ rank !![1, B; 0, 1], so the 4 × 4 block matrix is invertible.
theorem Formalizations.Reusable.matrix_rank_kronecker {m : Type u_1} {n : Type u_2} {p : Type u_3} {q : Type u_4} {K : Type u_5} [Field K] [Fintype m] [Fintype n] [Fintype p] [Fintype q] [DecidableEq m] [DecidableEq n] [DecidableEq p] [DecidableEq q] (A : Matrix m n K) (B : Matrix p q K) :
(Matrix.kroneckerMap (fun (x1 x2 : K) => x1 * x2) A B).rank = A.rank * B.rank

The rank of a Kronecker product is the product of the ranks. Over a field K, for A : Matrix m n K and B : Matrix p q K, rank (A ⊗ₖ B) = rank A · rank B. The proof identifies A ⊗ₖ B with the tensor product of the linear maps of A and B and uses that vector spaces are flat.

  • Archive: Matrix.rank_kronecker (Formalizations.LinearAlgebra.Matrix.Rank.Kronecker, used by the free-locus certificates and the orbifold products of the same archive); the module cites no paper DOI of ours.
  • Classical reference: R. A. Horn, C. R. Johnson, Topics in Matrix Analysis (1991), ch. 4.
  • Example: the adjacency matrix of a tensor product of graphs is a Kronecker product, so its rank is the product of the ranks of the factors.

Diagonal entries of the adjugate are principal minors. For a square matrix A over a commutative ring, indexed by any finite type n, adjugate A i i is the determinant of the principal submatrix obtained by deleting row and column i (indexed by the subtype {j // j ≠ i}). Mathlib has the statement for all entries when n = Fin k.succ (Matrix.adjugate_fin_succ_eq_det_submatrix); this form needs no reindexing. With Jacobi's formula (derivative_det_eq_trace_adjugate_mul) it gives charpoly′ = Σᵢ charpoly (A with row and column i deleted).

Alternating characteristic polynomial ⇒ positive semidefinite. A real symmetric matrix whose characteristic polynomial has coefficients alternating in sign, (-1)^(n-k) · c_k ≥ 0, is positive semidefinite. The polynomial rule behind it (alternating coefficients ⇒ no negative root) is a corollary of Descartes' rule of signs in Mathlib (Polynomial.roots_countP_pos_le_signVariations).

theorem Formalizations.Reusable.psd_quadForm_eq_sum_rank_sq {n : Type u_1} [Fintype n] [DecidableEq n] {A : Matrix n n ℝ} (hA : A.PosSemidef) {k : ℕ} (hk : A.rank = k) :
∃ (v : Fin k → n → ℝ), ∀ (u : n → ℝ), u ⬝ᵥ A.mulVec u = ∑ i : Fin k, (v i ⬝ᵥ u) ^ 2

A positive semidefinite matrix of rank k is a sum of k squares. Its quadratic form is a sum of exactly k squares of linear forms: uᵀ A u = Σ_{i < k} (v_i · u)². Mathlib only factors a PSD matrix as Bᴴ B with B square; this keeps exactly rank A terms. The same statement, as a factorization B = Aᴴ A with rank B ≤ card m rows, is in TauCeti (Matrix.PosSemidef.exists_eq_conjTranspose_mul_self_of_rank_le, TauCeti/Analysis/Matrix/ GramFactorization.lean); ours depends on Mathlib only.

theorem Formalizations.Reusable.rank_fromBlocks_of_isUnit₁₁ {m : Type u_1} {n : Type u_2} {K : Type u_3} [Fintype m] [Fintype n] [DecidableEq m] [DecidableEq n] [Field K] (A : Matrix m m K) (B : Matrix m n K) (C : Matrix n m K) (D : Matrix n n K) (hA : IsUnit A) :

Rank through the Schur complement. Over a field, if the top-left block A of a block matrix is invertible, then rank (fromBlocks A B C D) = card m + rank (D - C * A⁻¹ * B). With A ≻ 0 and a zero Schur complement this is the exact certificate "this PSD Gram matrix has rank card m" (Matrix.posSemidef_rank_of_schur_eq_zero in the archive). Mathlib has the PSD half (Matrix.PosDef.fromBlocks₁₁) and the LDU factorization, not the rank.

theorem Formalizations.Reusable.biquadratic_sos_transport {R : Type u_1} {n : Type u_2} {ι : Type u_3} [CommRing R] [Fintype n] [DecidableEq n] [Fintype ι] {H D : Matrix n n R} (hD : D.transpose * D = 1) (B : ι → Matrix (Fin 2) n R) (h : ∀ (x : Fin 2 → R) (y : n → R), BiquadraticSOS.P H x y = ∑ i : ι, (x ⬝ᵥ (B i).mulVec y) ^ 2) (x : Fin 2 → R) (y : n → R) :
BiquadraticSOS.P (D.transpose * H * D) x y = ∑ i : ι, (x ⬝ᵥ (B i * D).mulVec y) ^ 2

Sums of squares of bilinear forms under orthogonal congruence. For the biquadratic form P_H(x, y) = (x₀² + x₁²) (y ⬝ᵥ y) + 2 x₀ x₁ (y ⬝ᵥ H y) over a commutative ring and Dᵀ D = 1, every representation P_H = ∑ i (x ⬝ᵥ B i y)² gives P_{Dᵀ H D} = ∑ i (x ⬝ᵥ (B i D) y)² with the same number of squares; so the sum-of-squares length of P_H is invariant under H ↦ Dᵀ H D (signed-graph switching is D = diagonal s, s i² = 1: BiquadraticSOS.P_switching).

theorem Formalizations.Reusable.int_columns_of_transpose_mul_self {m : Type u_1} {n : Type u_2} [Fintype m] [DecidableEq m] [Fintype n] [DecidableEq n] {A : Matrix m n ℤ} (hA : A.transpose * A = 1) :
∃ (f : n → m), Function.Injective f ∧ ∀ (j : n), (fun (i : m) => A i j) = Pi.single (f j) 1 ∨ (fun (i : m) => A i j) = Pi.single (f j) (-1)

Integer orthonormal columns are signed unit vectors. If an integer m × n matrix satisfies Aᵀ A = 1, then every column j is ± Pi.single (f j) 1 for an injective f : n → m: the nonzero entries of distinct columns lie in distinct rows. The one-vector case (an integer vector with v ⬝ᵥ v = 1 is ± Pi.single i 1) is IntOrthonormal.eq_single_of_dotProduct_self_eq_one. False over ℚ: (3/5, 4/5) has norm one.

theorem Formalizations.Reusable.schur_commuting_finrank_le {K : Type u_1} [Field K] {n : ℕ} (S : Submodule K (Matrix (Fin n) (Fin n) K)) (hS : ∀ A ∈ S, ∀ B ∈ S, A * B = B * A) :
Module.finrank K ↥S ≤ n ^ 2 / 4 + 1

Schur's bound on commutative subspaces. A subspace S of M_n(K) over a field K whose elements pairwise commute has dim S ≤ ⌊n² / 4⌋ + 1. The bound is attained for n ≥ 1 (SchurCommuting.finrank_le_and_attained).

  • Archive: SchurCommuting.finrank_le (Formalizations.LinearAlgebra.Matrix.SchurCommuting; the sharpness is SchurCommuting.finrank_le_and_attained); the module cites no paper DOI of ours.
  • Classical reference: I. Schur, Zur Theorie der vertauschbaren Matrizen, J. Reine Angew. Math. 130 (1905) 66–76 66–76; N. Jacobson, Schur's theorems on commutative matrices, Bull. Amer. Math. Soc. 50 (1944) 431–436; M. Mirzakhani, A simple proof of a theorem of Schur, Amer. Math. Monthly 105 (1998) 260–262.
  • Example: a commutative subspace of M₂(ℚ) has dimension at most 2.
theorem Formalizations.Reusable.schur_commuting_finrank_attained {K : Type u_1} [Field K] {n : ℕ} (hn : 1 ≤ n) :
∃ (S : Submodule K (Matrix (Fin n) (Fin n) K)), (∀ A ∈ S, ∀ B ∈ S, A * B = B * A) ∧ Module.finrank K ↥S = n ^ 2 / 4 + 1

Schur's bound is sharp. For every field K and n ≥ 1 there is a subspace of M_n(K) whose elements pairwise commute and whose dimension is exactly ⌊n² / 4⌋ + 1: the scalar matrices plus the block of matrices supported on a ⌈n/2⌉ × ⌊n/2⌋ corner (any two of them multiply to zero).

theorem Formalizations.Reusable.hua_identity {K : Type u_1} [DivisionRing K] {a b : K} (ha : a ≠ 0) (hb : b ≠ 0) (hab : a * b ≠ 1) :
a - (a⁻¹ + (b⁻¹ - a)⁻¹)⁻¹ = a * b * a

Hua's identity. In a division ring K, for a ≠ 0, b ≠ 0 and a b ≠ 1, a − (a⁻¹ + (b⁻¹ − a)⁻¹)⁻¹ = a b a. It holds with no commutativity assumption.

  • Archive: DGH.hua_classical (Formalizations.RingTheory.DGH.Absorb); the module cites no paper DOI of ours.
  • Classical reference: L.-K. Hua, On the automorphisms of a sfield, Proc. Nat. Acad. Sci. USA 35 (1949) 386–389.
  • Example: over ℚ with a = 2, b = 1: 2 − (1/2 + (1 − 2)⁻¹)⁻¹ = 4 = 2 · 1 · 2.

Newton's identity for traces. For a square matrix M over a commutative ring R, with charpolyRev M = det (1 − X • M) viewed in R⟦X⟧, d/dX (charpolyRev M) = − charpolyRev M · ∑ₖ trace (Mᵏ⁺¹) Xᵏ: the logarithmic derivative of the reversed characteristic polynomial is minus the generating function of the traces of the powers of M. No eigenvalues and no hypothesis on R.

theorem Formalizations.Reusable.mul_add_mul_eq_trace_smul_add_trace_smul_fin_two {R : Type u_1} [CommRing R] (A B : Matrix (Fin 2) (Fin 2) R) :
A * B + B * A = A.trace • B + B.trace • A + ((A * B).trace - A.trace * B.trace) • 1

The polarized Cayley–Hamilton identity for two-by-two matrices over a commutative ring. Archive: Matrix.mul_add_mul_eq_trace_smul_add_trace_smul_fin_two.

The diagonal series of matrix powers times the reversed characteristic polynomial equals the reversed characteristic polynomial of the principal submatrix with that index removed. Archive: Matrix.resolventSeries_diag_mul_coe_charpolyRev.