Exact reconstruction of the finite factorizations (Cholesky and QR) #
This file proves the exact algebraic reconstruction of the finite executable Cholesky and QR
factorizations from NN.Spec.Core.Tensor.Factorizations, building on the predicates and
fold-indexing lemmas of NN.Proofs.Tensor.Basic.Factorizations. Because Cholesky and Gram–Schmidt
are direct, finite constructions — no iteration, no convergence caveat — over ℝ they reconstruct
their input on the nose under the success hypotheses (positive pivots / full column rank), an exact
identity rather than an a-posteriori bound.
Main results #
isCholesky_of_pos: for a symmetricA : Fin n → Fin n → ℝwhose executable Cholesky pivots are all positive (0 < choleskyFn A j j, the exact condition under which the algorithm succeeds overℝ), the factorL = choleskyFn Asatisfies the specSpec.Factorization.IsCholesky: lower-triangular andA = L · Lᵀ.choleskySpec_reconstructionis the tensor-level corollary.qr_mul_eq: forA : Fin m → Fin n → ℝwhose executable Gram–SchmidtR-pivots are positive (0 < Rmat A j j, full column rank), the factorsQ = gramSchmidtFn AandRsatisfyA = Q · R, withRupper-triangular (Rmat_upper_triangular).qrSpec_reconstructionis the tensor-level corollary.
Method #
Each executable factor is built by a List.foldl that snocs one column per index. The core technical
device is getD_foldl_snoc_read, a general lemma reading the j-th element of such a fold as the step
function applied to the length-j prefix. From it, prefix_eq_map/qsPrefix_eq_map identify the
prefix with the first j columns of the final factor, and take_map_sum_eq turns the code's
List.foldl sums into masked Finset partial sums. The QR fold threads a GSState that snocs onto
both the Q-list and the R-list at once; gs_proj_qs and gs_fold_split/rTail_getD recover the
single-list read lemmas for each projection (the step depends only on the Q-history). The
positive-pivot hypotheses discharge the √-radicand and divisor side conditions.
Scope #
This file proves A = L · Lᵀ and A = Q · R purely algebraically. The remaining QR property —
orthonormality of the Q factor, Qᵀ Q = 1 — is proved in the companion file
NN.Proofs.Tensor.Basic.FactorizationsOrthonormal by bridging the executable Gram–Schmidt to
Mathlib's gramSchmidt, completing the full Spec.Factorization.IsQR predicate (isQR_of_pos).
List/Finset bridges #
Cholesky: the column-building step #
choleskyColsFn is a left fold that snocs one column per index. cholStep names the function it
appends, so that the read lemmas above can be specialized to it.
The prefix of Cholesky columns is exactly the first j columns of the final factor L,
each presented as the function r ↦ L r k.
List/Finset partial-sum bridges #
Every element of a finRange prefix has index below the cut.
Every element of a finRange tail has index at least the cut.
The Cholesky cross-sum equals the masked partial dot product of rows i and j of L.
The Cholesky diagonal sum-of-squares equals the masked partial squared norm of row j of L.
Closed-form entries of the executable Cholesky factor #
The diagonal entry of L in closed form: L[j,j] = √(A[j,j] − Σ_{k<j} L[j,k]²).
The below-diagonal entry of L in closed form:
L[i,j] = (A[i,j] − Σ_{k<j} L[i,k]·L[j,k]) / L[j,j] for i > j.
Reconstruction A = L · Lᵀ #
The diagonal of the rotated/peeled product is reconstructed using the closed-form entries and the
positive-pivot hypothesis (0 < L[j,j]), which is exactly the condition under which the executable
Cholesky succeeds over ℝ.
Per-entry reconstruction for the lower part (j ≤ i): the (i, j) entry of L · Lᵀ is A i j.
Exact Cholesky reconstruction. For a symmetric A whose executable Cholesky pivots are all
positive (0 < L[j,j], the success condition over ℝ), the factor L = choleskyFn A is a genuine
Cholesky factor: lower-triangular with A = L · Lᵀ.
Tensor-level Cholesky reconstruction. For a symmetric tensor A whose choleskySpec pivots
are positive, every entry of A is reconstructed by L · Lᵀ:
A[i,j] = Σ_k L[i,k] · L[j,k], with L = choleskySpec A.
QR (classical Gram–Schmidt): exact reconstruction A = Q · R #
gramSchmidtFn threads a GSState that snocs a column onto both the Q-list and the R-list at
each index. The appended values depend only on the Q-history (st.qs), never on the
R-history, so the Q-list is itself a single-list snoc-fold (gs_proj_qs) and the R-list is the
Q-prefix-indexed tail rTail.
The R column at column index j, as a function of the row index k (so the value is the
matrix entry R[k, j]). With R indexed row-then-column, the nonzero part is on and above the
diagonal: rₖⱼ for k < j (strictly above the diagonal), rⱼⱼ for k = j, and 0 for k > j
(strictly below the diagonal).
Instances For
Semantics of the Context > test over ℝ.
Entries of the executable Q and R factors #
Exact reconstruction A = Q · R #
Per-entry QR reconstruction. When every R pivot is positive (0 < R[j,j], the full
column-rank success condition), A[i,j] = Σ_k Q[i,k]·R[k,j].
Tensor-level QR reconstruction. For a tensor A whose qrSpec R-pivots are positive
(full column rank), every entry of A is reconstructed by Q · R:
A[i,j] = Σ_k Q[i,k]·R[k,j], with Q = qrQSpec A, R = qrRSpec A.