This topic collects mathematical existence and identity results for structured factors. Canonical algorithm pages explain how a particular factorization is used; implementation pages own execution, work, storage, and rounding guarantees.
Theorem (A matrix has a Cholesky factorization exactly when it is positive definite).
A matrix has a Cholesky factorization exactly when it is positive definite.
Lean statement and details
NLAlib.exists_isCholesky_iff_posDef.{u_1, u_2} {π : Type u_1} [RCLike π] {n : Type u_2}
[LinearOrder n] [Fintype n] (A : Matrix n n π) : (β L, IsCholesky A L) β A.PosDef
Theorem (Triangular coefficients of modified GramβSchmidt).
The product of \mathbf{q}_i with the residual of column j after the first i projections gives r_{ij} of classical GramβSchmidt. This holds at every step of \mathsf{mgsSweep}, also for dependent columns. [GolubVanLoan2013, Β§5.2.8].
For normalized generalized singular coordinates of \mathbf{A},\mathbf{B}, their common kernel is precisely the span of the columns of \mathbf{X} with c_i^2+s_i^2=0. This includes an empty common-kernel block and the case where every coordinate is inactive. [PaigeSaunders1981, pp. 398β405]; the block is stated as an indexed span, without permuting the inactive coordinates to the end.
Lean statement and details
NLAlib.IsGSVD.ker_inf_ker_eq_span.{u_1, u_2, u_3, u_4} {π : Type u_1} [RCLike π] {m : Type u_2}
{n : Type u_3} {p : Type u_4} [Fintype m] [Fintype n] [Fintype p] [DecidableEq n]
{A : Matrix m n π} {B : Matrix p n π} {X : Matrix n n π} {c s : n β β} (h : IsGSVD A B X c s) :
A.mulVecLin.ker β B.mulVecLin.ker = Submodule.span π (X.col '' {i | c i ^ 2 + s i ^ 2 = 0})
Every square matrix \mathbf{A} is unitarily similar to an upper Hessenberg matrix \mathbf{Q}^{\mathsf{H}}\mathbf{A}\mathbf{Q}, by a unitary \mathbf{Q} whose first column is the first coordinate vector \mathbf{e}_0. [GolubVanLoan2013, Β§7.4.3]; [HornJohnson2013, Β§2.5].
Lean statement and details
NLAlib.exists_isUpperHessenberg_conjTranspose_mul_mul.{u_1} {π : Type u_1} [RCLike π] {n : β}
(A : Matrix (Fin n) (Fin n) π) :
β Q,
HasOrthonormalCols Q β§
IsUpperHessenberg (Qα΄΄ * A * Q) β§ β (i : Fin n), βi = 0 β Q.col i = Pi.single i 1
If \mathbf{H}_1 = \mathbf{Q}_1^{\mathsf{H}}\mathbf{A}\mathbf{Q}_1 and \mathbf{H}_2 = \mathbf{Q}_2^{\mathsf{H}}\mathbf{A}\mathbf{Q}_2 are upper Hessenberg with \mathbf{Q}_1, \mathbf{Q}_2 unitary with the same first column, and the subdiagonal of \mathbf{H}_1 has no zero, then \mathbf{Q}_2 = \mathbf{Q}_1\mathbf{D} and \mathbf{H}_2 = \mathbf{D}^{\mathsf{H}}\mathbf{H}_1\mathbf{D} for a diagonal \mathbf{D} whose entries have unit modulus, the first one being 1. [GolubVanLoan2013, Theorem 7.4.2].
Lean statement and details
NLAlib.HasOrthonormalCols.exists_eq_mul_diagonal_of_isUpperHessenberg.{u_1} {π : Type u_1}
[RCLike π] {n : β} {A Qβ Qβ : Matrix (Fin (n + 1)) (Fin (n + 1)) π} (hQβ : HasOrthonormalCols Qβ)
(hQβ : HasOrthonormalCols Qβ) (hHβ : IsUnreducedHessenberg (Qβα΄΄ * A * Qβ))
(hHβ : IsUpperHessenberg (Qβα΄΄ * A * Qβ)) (hcol : Qβ.col 0 = Qβ.col 0) :
β d,
(β (i : Fin (n + 1)), βd iβ = 1) β§
d 0 = 1 β§
Qβ = Qβ * diagonal d β§ Qβα΄΄ * A * Qβ = diagonal (star d) * (Qβα΄΄ * A * Qβ) * diagonal d
When the diagonal of \mathbf{R} has no zero (full column rank), \mathbf{x} minimises \|\mathbf{A}\mathbf{x} - \mathbf{b}\| exactly when \mathbf{R}\mathbf{x} = \mathbf{Q}^{\mathsf{H}}\mathbf{b}. [GolubVanLoan2013, Β§5.3.3]; [TrefethenBau1997, Lecture 11].
Lean statement and details
NLAlib.IsQR.isLeastSquaresSolution_iff.{u_1, u_3, u_4} {π : Type u_1} [RCLike π] {m : Type u_3}
{n : Type u_4} [Fintype m] [Fintype n] [LinearOrder n] [DecidableEq n] {A Q : Matrix m n π}
{R : Matrix n n π} (h : IsQR A Q R) (hR : β (i : n), R i i β 0) {b : m β π} {x : n β π} :
IsLeastSquaresSolution A b x β R *α΅₯ x = Qα΄΄ *α΅₯ b
Theorem (A nonsingular matrix has an LU factorization exactly when its leading principal minors
are nonzero).
[HornJohnson2013, Corollary 3.5.4].
Lean statement and details
NLAlib.exists_isLU_iff_forall_principalMinor_ne_zero.{u_2, u_3} {K : Type u_2} {n : Type u_3}
[LinearOrder n] [Fintype n] [Field K] [DecidableEq n] [LocallyFiniteOrderBot n] {A : Matrix n n K}
(hA : IsUnit A.det) : (β L U, IsLU A L U) β β (i : n), principalMinor A (Finset.Iic i) β 0
Theorem (Row inclusion characterizes LU existence).
A square matrix factors as a unit lower triangular matrix times an upper triangular matrix exactly when, for each index i, row i restricted to columns before i lies in the span of the preceding rows on the same columns. This includes singular matrices and empty index types. [HornJohnson2013, Theorem 3.5.3].
Lean statement and details
NLAlib.exists_isLU_iff_forall_mem_span.{u_3, u_4} {ΞΉ : Type u_3} {R : Type u_4} [LinearOrder ΞΉ]
[Fintype ΞΉ] [CommRing R] (A : Matrix ΞΉ ΞΉ R) :
(β L U, IsLU A L U) β β (i : ΞΉ), (fun k β¦ A i βk) β Submodule.span R (Set.range fun j k β¦ A βj βk)
Theorem (The polar factor is the nearest matrix with orthonormal columns).
in every unitarily invariant norm (Fan and Hoffman): if \mathbf{U} has orthonormal columns and \mathbf{U}(\mathbf{A}^{\mathsf{H}}\mathbf{A})^{1/2} = \mathbf{A}, then \|\mathbf{A} - \mathbf{U}\|_{\Phi} \le \|\mathbf{A} - \mathbf{V}\|_{\Phi} for every \mathbf{V} with orthonormal columns. [Higham2008, Theorem 8.4]; [HornJohnson2013, Β§7.4.9 context].
Lean statement and details
NLAlib.SymmetricGauge.matrixNorm_sub_le_matrixNorm_sub_of_mul_sqrt_eq.{u_1, u_3, u_4} {π : Type u_1}
[RCLike π] {m : Type u_3} {n : Type u_4} [Fintype m] [Fintype n] [DecidableEq n]
(Ξ¦ : SymmetricGauge) {A U V : Matrix m n π} (hU : HasOrthonormalCols U)
(hA : U * CFC.sqrt (Aα΄΄ * A) = A) (hV : HasOrthonormalCols V) :
Ξ¦.matrixNorm (A - U) β€ Ξ¦.matrixNorm (A - V)
, singular-value form: for positive semidefinite \mathbf{H}, \sigma_k(\mathbf{H} - \mathsf{nystrom}(\mathbf{H}, \mathbf{\Omega})) \le \sigma_k((\mathbf{I} - \mathbf{P}_{\mathbf{\Omega}})\mathbf{H}) at every index k: the NystrΓΆm error is at most the error of projecting \mathbf{H} onto the orthogonal complement of the test space. At \mathbf{\Omega} = \mathbf{H}\mathbf{\Omega}_0 this compares NystrΓΆm from the sample \mathbf{H}\mathbf{\Omega}_0 with the randomized SVD of \mathbf{H} (NLAlib.sub_rsvd). [TroppWebber2023, Lemma 5.2]; there for unitarily invariant norms and by a block computation, here basis-free through \mathbf{H}/\mathbf{\Omega} \preceq (\mathbf{I} - \mathbf{P}_{\mathbf{\Omega}})\mathbf{H} (\mathbf{I} - \mathbf{P}_{\mathbf{\Omega}})\,.
For real or complex rectangular matrices \mathbf{A},\mathbf{B} of the same shape, the squared Frobenius distance equals the squared distance of their descending singular value lists exactly when \operatorname{Re}\operatorname{tr}(\mathbf{A}\mathbf{B}^{\mathsf{H}}) = \sum_i \sigma_i(\mathbf{A})\sigma_i(\mathbf{B})\,. Both sums extend to the smaller matrix dimension, including zero. [HornJohnson2013, Β§7.4.1], the Frobenius equality case of the singular-value inequalities. This extends the real statement in the original NLAlib formal library, NLAlib.Matrix.Factorizations.ProcrustesRotations, commit 77514ce42a0e437d837797a063ac161f41022730, to RCLike matrices.
General form: sizes are index types
Lean statement and details
NLAlib.frobNorm_sub_sq_eq_sum_singularValues_sub_sq_iff.{u_1, u_2, u_3} {π : Type u_1} [RCLike π]
{m : Type u_2} {n : Type u_3} [Fintype m] [Fintype n] (A B : Matrix m n π) :
frobNorm (A - B) ^ 2 =
β i β Finset.range (min (Fintype.card m) (Fintype.card n)),
(singularValues A i - singularValues B i) ^ 2 β
frobInner A B =
β i β Finset.range (min (Fintype.card m) (Fintype.card n)),
singularValues A i * singularValues B i
Every square matrix \mathbf{A} over an RCLike field has a row-permuted LU factorization \mathbf{L}\mathbf{U} in which the entries of \mathbf{L} are at most one in absolute value and the entries of \mathbf{U} exceed those of \mathbf{A} by a factor at most 2^{\lvert n \rvert - 1}: if \lvert \mathbf{A}_{i,j} \rvert \le M for all i, j, then \lvert \mathbf{L}_{i,j} \rvert \le 1 and \lvert \mathbf{U}_{i,j} \rvert \le 2^{\lvert n \rvert - 1} M. [GolubVanLoan2013, Β§3.4.5]; [Higham2002, Β§9.3].
General form: sizes are index types
Lean statement and details
NLAlib.exists_perm_isLU_norm_le.{u_3, u_4} {n : Type u_3} [LinearOrder n] [Fintype n] {π : Type u_4}
[RCLike π] (A : Matrix n n π) {M : β} (hM : β (i j : n), βA i jβ β€ M) :
β Ο L U,
IsLU (A.submatrix (βΟ) id) L U β§
(β (i j : n), βL i jβ β€ 1) β§ β (i j : n), βU i jβ β€ 2 ^ (Fintype.card n - 1) * M
In every positive dimension n+1, a matrix \mathbf{A} with entries of modulus at most one produces a last pivot of modulus 2^n: \mathbf{U} = \mathsf{luUpper}(\mathbf{B}), where \mathbf{B} permutes the rows of \mathbf{A} by \mathsf{luPartialPivotPerm}(\mathbf{A}). Wilkinson's example needs no exchanges under the first-maximum tie rule. [TrefethenBau1997, Lecture 22].
Lean statement and details
NLAlib.exists_norm_luUpper_apply_last_eq_two_pow.{u_3} (π : Type u_3) [RCLike π] (n : β) :
β A,
(β (i j : Fin (n + 1)), βA i jβ β€ 1) β§
βluUpper (A.submatrix (β(luPartialPivotPerm A)) id) (Fin.last n) (Fin.last n)β = 2 ^ n
Theorem (Partial pivoting succeeds exactly for nonsingular inputs).
All diagonal entries of \mathbf{U} = \mathsf{luUpper}(\mathbf{B}) are nonzero exactly when \mathbf{A} is invertible, where \mathbf{B} permutes its rows by \mathsf{luPartialPivotPerm}(\mathbf{A}). [TrefethenBau1997, Lecture 21]; [GolubVanLoan2013, Theorem 3.4.1].
Lean statement and details
NLAlib.forall_luUpper_apply_self_ne_zero_iff_isUnit_det.{u_2} {π : Type u_2} [RCLike π] {n : β}
(A : Matrix (Fin n) (Fin n) π) :
(β (i : Fin n), luUpper (A.submatrix (β(luPartialPivotPerm A)) id) i i β 0) β IsUnit A.det
Exactly the first \operatorname{rank} \mathbf{A} pivots of the computed factor are positive, including for singular positive semidefinite inputs. [Higham2002, Theorem 10.9].
Lean statement and details
Matrix.PosSemidef.choleskyLower_choleskyPivotPerm_apply_self_pos_iff.{u_1} {π : Type u_1} [RCLike π]
{n : β} {A : Matrix (Fin n) (Fin n) π} (hA : A.PosSemidef) (i : Fin n) :
0 < choleskyLower (A.submatrix β(choleskyPivotPerm A) β(choleskyPivotPerm A)) i i β βi < A.rank
Theorem (A matrix with at least as many rows as columns is an isometry times its absolute value).
if \lvert n \rvert \le \lvert m \rvert, then \mathbf{A} = \mathbf{U}(\mathbf{A}^{\mathsf{H}}\mathbf{A})^{1/2} for some \mathbf{U} with orthonormal columns. [HornJohnson2013, Theorem 7.3.1].
General form: sizes are index types
Lean statement and details
NLAlib.exists_hasOrthonormalCols_mul_sqrt_eq.{u_1, u_3, u_4} {π : Type u_1} [RCLike π]
{m : Type u_3} {n : Type u_4} [Fintype m] [Fintype n] [DecidableEq n] (A : Matrix m n π)
(h : Fintype.card n β€ Fintype.card m) : β U, HasOrthonormalCols U β§ U * CFC.sqrt (Aα΄΄ * A) = A
The least value of \|\mathbf{A} - \mathbf{U}\mathbf{B}\|_{\mathsf{F}}^2 over unitary \mathbf{U} is \|\mathbf{A}\|_{\mathsf{F}}^2 + \|\mathbf{B}\|_{\mathsf{F}}^2 - 2 \|\mathbf{A}\mathbf{B}^{\mathsf{H}}\|_*\,, attained at a polar factor of \mathbf{A}\mathbf{B}^{\mathsf{H}}. [GolubVanLoan2013, Β§6.4.1]; [HornJohnson2013, Β§7.4.5].
Lean statement and details
NLAlib.isLeast_frobNorm_sub_mul_sq.{u_1, u_2, u_3} {π : Type u_1} [RCLike π] {m : Type u_2}
{n : Type u_3} [Fintype m] [Fintype n] [DecidableEq m] (A B : Matrix m n π) :
IsLeast ((fun U β¦ frobNorm (A - U * B) ^ 2) '' {U | HasOrthonormalCols U})
(frobNorm A ^ 2 + frobNorm B ^ 2 - 2 * nuclearNorm (A * Bα΄΄))
Theorem (The nearest scaled isometry in Frobenius norm).
For \mathbf{A} \in \Bbbk^{m \times n} with \lvert n \rvert \le \lvert m \rvert, the least value of \|\mathbf{A} - c\mathbf{U}\|_{\mathsf{F}}^2 over all c \in \mathbb{R} and all \mathbf{U} \in \Bbbk^{m \times n} with orthonormal columns is \|\mathbf{A}\|_{\mathsf{F}}^2 - \frac{\|\mathbf{A}\|_*^2}{\lvert n \rvert}\,. It is attained by an isometric polar extension scaled by the average singular value. This includes negative competing scales and rank-deficient matrices. For empty columns the minimum is zero, with division by zero interpreted as zero. No uniqueness is asserted. [HornJohnson2013, Β§7.4.4], the square case; here generalized to rectangular matrices over any RCLike field and arbitrary finite index types, including empty columns. Generalizes NLAlib.isLeast_frobSq_sub_scaled_orthogonal and NLAlib.isLeast_frobSq_sub_scaled_orthogonal_of_isEmpty from the original NLAlib formal library, NLAlib.Matrix.Factorizations.ScaledOrthogonal, commit 77514ce42a0e437d837797a063ac161f41022730, from square real to rectangular RCLike matrices, combining the nonempty and empty cases.
General form: sizes are index types
Lean statement and details
NLAlib.isLeast_frobNorm_sub_smul_sq.{u_1, u_2, u_3} {π : Type u_1} [RCLike π] {m : Type u_2}
{n : Type u_3} [Fintype m] [Fintype n] [DecidableEq n] (A : Matrix m n π)
(hcard : Fintype.card n β€ Fintype.card m) :
IsLeast {z | β c U, HasOrthonormalCols U β§ frobNorm (A - c β’ U) ^ 2 = z}
(frobNorm A ^ 2 - nuclearNorm A ^ 2 / β(Fintype.card n))
Theorem (Every matrix with at least as many rows as columns has a QR factorization).
, with nonnegative diagonal: if \lvert n \rvert \le \lvert m \rvert, then \mathbf{A} = \mathbf{Q}\mathbf{R} with \mathbf{R}_{i,i} \ge 0. [HornJohnson2013, Theorem 2.1.14]; [GolubVanLoan2013, Theorem 5.2.3].
General form: sizes are index types
Lean statement and details
NLAlib.exists_isQR.{u_1, u_3, u_4} {π : Type u_1} [RCLike π] {m : Type u_3} {n : Type u_4}
[Fintype m] [Fintype n] [LinearOrder n] [DecidableEq n] (A : Matrix m n π)
(h : Fintype.card n β€ Fintype.card m) : β Q R, IsQR A Q R β§ β (i : n), 0 β€ R i i
\mathbf{H} \mapsto \mathbf{H}/\mathbf{\Omega}, as superadditivity with nonnegative weights: for positive semidefinite \mathbf{H}_i and w_i \ge 0, \sum_i w_i (\mathbf{H}_i/\mathbf{\Omega}) \preceq \Bigl(\sum_i w_i \mathbf{H}_i\Bigr)/\mathbf{\Omega}\,, where \mathbf{H}/\mathbf{\Omega} = \mathbf{H} - \mathsf{nystrom}(\mathbf{H}, \mathbf{\Omega}). Weights summing to one give concavity, equal weights the group average of a symmetrisation. [EpperlyWebber2026, Fact 6.1(c)]; there with weights summing to one.
Theorem (A strong rank-revealing selection exists).
For k \le \operatorname{rank} \mathbf{A} there are k distinct columns \mathbf{C} of \mathbf{A} that are locally of maximum volume with tolerance one (IsLocalMaxVolume A e 1); hence coefficients \mathbf{C}^{+}\mathbf{A} bounded by one in absolute value, \sigma_i(\mathbf{A}) \le \sqrt{1 + k (\lvert n \rvert - k)}\, \sigma_i(\mathbf{C}) for i < k, and residual \sigma_j\bigl((\mathbf{I} - \mathbf{P}_{\mathbf{C}})\mathbf{A}\bigr) \le \sqrt{1 + k (\lvert n \rvert - k)}\, \sigma_{k+j}(\mathbf{A}). [GuEisenstat1996, Theorem 3.2]; [GolubVanLoan2013, Β§5.4.6].
Lean statement and details
NLAlib.exists_embedding_isLocalMaxVolume.{u_1, u_2, u_3} {π : Type u_1} [RCLike π] {m : Type u_2}
{n : Type u_3} [Fintype m] [Fintype n] (A : Matrix m n π) {k : β} (hk : k β€ A.rank) :
β e, IsLocalMaxVolume A (βe) 1