Correctness of the exact matrix factorizations (Cholesky and QR) #
This file sets up the formal correctness layer for the two exact, finite spec-layer factorizations
in NN.Spec.Core.Tensor.Factorizations (choleskySpec, qrSpec): the factorization predicates
over real matrices, and the first structural theorem about the executable Cholesky factor.
Architecture (refinement) #
- Specifications (
IsCholesky,IsQR) areProps on MathlibMatrix (Fin n) (Fin n) ℝ. Mathlib'sMatrix m n αis definitionallym → n → α, so the function representationSpec.toMatFnproduced by the executable specs bridges for free. - Fold-indexing lemmas (
length_foldl_snoc,getD_foldl_snoc_lt,getD_foldl_snoc_read,getD_foldl_finRange) read off the column produced at a given position of the left fold that bothcholeskyColsFnandgramSchmidtFnuse to build their output, bridging the executableList.foldlform to per-entry reasoning. They live here once and are reused byFactorizationsReconstruction. - Structural theorem. The executable Cholesky factor is lower-triangular
(
choleskyFn_lower_triangular, lifted to the tensor level ascholeskySpec_lower_triangular), proved directly from the column fold — the above-diagonal entry is forced to0by construction.
Scope #
This file proves only the predicates and the lower-triangularity fact. The exact algebraic
reconstructions — A = L · Lᵀ for Cholesky (under positive pivots) and A = Q · R with Qᵀ Q = 1
for Gram–Schmidt (under full column rank) — are proved in the companion modules
NN.Proofs.Tensor.Basic.FactorizationsReconstruction and
NN.Proofs.Tensor.Basic.FactorizationsOrthonormal. Everything here is an exact identity over ℝ;
the only hypotheses are the genuine success conditions of the algorithms.
Specifications #
The mathematical meaning of each factorization, as a predicate over real matrices. Over ℝ,
star = id so conjTranspose = transpose; we phrase everything with ᵀ.
Fold-indexing for the column-building specs #
choleskyColsFn and gramSchmidtFn build their output with a left fold that appends one column per
index. The lemmas here read off the column produced at a given position, bridging the executable
List.foldl form to per-entry reasoning. They are generic over the appended-value function g and
are the single home for these snoc-fold read lemmas — FactorizationsReconstruction reuses them.
Cholesky factor is lower-triangular #
A structural fact about the executable choleskyFn, proved directly from the column fold: the entry
above the diagonal is forced to 0 by the construction.
Tensor-level statement: the Cholesky factor choleskySpec A is lower-triangular.