Documentation

CslibFrontier.Foundations.LinearAlgebra.Matrix.PosDef

Positive (semi)definiteness criteria #

A symmetric 2 × 2 real matrix !![a, b; b, c] with a, c ≥ 0 and b² ≤ ac is positive semidefinite (Matrix.posSemidef_fin_two), and so is a symmetric real matrix that is diagonally dominant, ∑_{j ≠ i} |R i j| ≤ R i i (Matrix.posSemidef_of_diagDominant). An LDLᴴ product L * diagonal d * Lᴴ with L unit lower triangular is positive definite exactly when every d i is positive, and positive semidefinite exactly when every d i is nonnegative. Since L is invertible, this is a case of Sylvester's law of inertia for the congruence by L. Conversely, over a field with trivial star, such as ℚ, every positive semidefinite (definite) matrix has such a factorization with d ≥ 0 (d > 0), found by symmetric elimination without pivoting; Mathlib's LDL.lower_conj_diag covers only positive definite matrices over RCLike fields.

Main results #

theorem Matrix.posSemidef_fin_two {a b c : ℝ} (ha : 0 ≤ a) (hc : 0 ≤ c) (h : b ^ 2 ≤ a * c) :
!![a, b; b, c].PosSemidef

A symmetric 2 × 2 real matrix with nonnegative diagonal and nonnegative determinant is positive semidefinite.

theorem Matrix.posSemidef_of_diagDominant {n : Type u_1} [Fintype n] [DecidableEq n] {R : Matrix n n ℝ} (hR : R.transpose = R) (h : ∀ (i : n), (∑ j : n, if i = j then 0 else |R i j|) ≤ R i i) :

Diagonal dominance. A symmetric real matrix with ∑_{j ≠ i} |R i j| ≤ R i i for every i is positive semidefinite.

theorem Matrix.posDef_mul_diagonal_mul_conjTranspose_iff {n : Type u_1} {R : Type u_2} [Fintype n] [DecidableEq n] [LinearOrder n] [CommRing R] {L : Matrix n n R} {d : n → R} [PartialOrder R] [StarRing R] [StarOrderedRing R] [NoZeroDivisors R] [Nontrivial R] (hL : L.IsLowerTriangular) (h1 : ∀ (i : n), L i i = 1) :
(L * diagonal d * L.conjTranspose).PosDef ↔ ∀ (i : n), 0 < d i

An LDLᴴ product with L unit lower triangular is positive definite exactly when every diagonal entry d i is positive.

theorem Matrix.posSemidef_mul_diagonal_mul_conjTranspose_iff {n : Type u_1} {R : Type u_2} [Fintype n] [DecidableEq n] [LinearOrder n] [CommRing R] {L : Matrix n n R} {d : n → R} [PartialOrder R] [StarRing R] [StarOrderedRing R] (hL : L.IsLowerTriangular) (h1 : ∀ (i : n), L i i = 1) :
(L * diagonal d * L.conjTranspose).PosSemidef ↔ ∀ (i : n), 0 ≤ d i

An LDLᴴ product with L unit lower triangular is positive semidefinite exactly when every diagonal entry d i is nonnegative.

theorem Matrix.mul_diagonal_mul_transpose_apply {m : Type u_2} {R : Type u_3} [Fintype m] [DecidableEq m] [NonUnitalNonAssocSemiring R] (L : Matrix m m R) (d : m → R) (i j : m) :
(L * diagonal d * L.transpose) i j = ∑ k : m, L i k * d k * L j k

Entry (i, j) of L * diagonal d * Lᵀ is ∑ₖ L i k * d k * L j k.

theorem Matrix.exists_LDL_of_posSemidef {K : Type u_1} [Field K] [PartialOrder K] [StarRing K] [StarOrderedRing K] [TrivialStar K] {n : ℕ} {M : Matrix (Fin n) (Fin n) K} :
M.PosSemidef → ∃ (L : Matrix (Fin n) (Fin n) K) (d : Fin n → K), L.IsLowerTriangular ∧ (∀ (i : Fin n), L i i = 1) ∧ (∀ (i : Fin n), 0 ≤ d i) ∧ M = L * diagonal d * L.transpose

Existence of LDLᵀ for positive semidefinite matrices. Over a field with trivial star and a star order, such as ℚ or ℝ, every positive semidefinite M factors as M = L * diagonal d * Lᵀ with L unit lower triangular and every d i ≥ 0, including a singular M.

The proof is symmetric Gaussian elimination without pivoting. With pivot a = M 0 0 ≥ 0 and first column b, set l = a⁻¹ • b. A zero pivot forces b = 0 (Matrix.PosSemidef.dotProduct_mulVec_zero_iff at the first basis vector), so b = a • l in both cases and L has the column l below its first entry. The Schur complement M i.succ j.succ - a * l i * l j is positive semidefinite, since its quadratic form at y is that of M at Fin.cons (-(l ⬝ᵥ y)) y, and it factors by induction.

theorem Matrix.exists_LDL_of_posDef {K : Type u_1} [Field K] [PartialOrder K] [StarRing K] [StarOrderedRing K] [TrivialStar K] {n : ℕ} {M : Matrix (Fin n) (Fin n) K} (hM : M.PosDef) :
∃ (L : Matrix (Fin n) (Fin n) K) (d : Fin n → K), L.IsLowerTriangular ∧ (∀ (i : Fin n), L i i = 1) ∧ (∀ (i : Fin n), 0 < d i) ∧ M = L * diagonal d * L.transpose

Existence of LDLᵀ for positive definite matrices. Every positive definite M factors as M = L * diagonal d * Lᵀ with L unit lower triangular and every d i > 0.