Executable array/loop machinery for the integer scaled Gram-Schmidt pass in
hex-gram-schmidt.
This module defines the integer-determinant surface (gramDet and
independent, the leading Gram matrices (leadingGramMatrixInt/Rat),
scaledCoeffMatrix, lattice membership memLattice, and the no-pivot Bareiss
determinant reader gramDetVecEntry) together with the mutable row-major array
kernel that computes the scaled coefficients fraction-free. The kernel includes the
nested-array storage (gramRows, zeroRows, getArrayEntry/setArrayEntry,
rowsToMatrix), the Bareiss-style elimination sweep stepScaledRows and
column-writer writeScaledColumn, the driver scaledCoeffArrayLoop, the two
formulations scaledCoeffRows (reference) and scaledCoeffRowsSchur (live
per-row Schur recurrence, with schurSigma/schurScaledCoeffEntry), and a
large body of frame/size bookkeeping lemmas plus the per-step correspondence
rowsToMatrix_stepScaledRows_eq between the array update and Matrix.stepMatrix.
Promote an index into a shorter prefix to the ambient matrix height.
Equations
- Hex.GramSchmidt.liftFinLE i hk = ⟨↑i, ⋯⟩
Instances For
Leading principal Gram matrix of the first k rows of an integer basis.
Equations
- Hex.GramSchmidt.leadingGramMatrixInt b k hk = Hex.Matrix.ofFn fun (i j : Fin k) => (b.row (Hex.GramSchmidt.liftFinLE i hk)).dotProduct (b.row (Hex.GramSchmidt.liftFinLE j hk))
Instances For
The Gram-Schmidt leading Gram matrix is the leading prefix of the full
Gram matrix. This is the shape equation between the public gramDet API and
the one-pass gramDetVec implementation.
Leading principal Gram matrix of the first k rows of a rational basis.
Equations
- Hex.GramSchmidt.leadingGramMatrixRat b k hk = Hex.Matrix.ofFn fun (i j : Fin k) => (b.row (Hex.GramSchmidt.liftFinLE i hk)).dotProduct (b.row (Hex.GramSchmidt.liftFinLE j hk))
Instances For
Determinant matrix used by the integral scaledCoeffs entry formula:
take the leading j + 1 Gram matrix and replace its last column by the inner
products with row i.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Integer lattice membership in the row span of b. This mirrors the LLL
predicate without making hex-gram-schmidt depend on the downstream LLL
library.
Instances For
The k-th Gram determinant: the determinant of the k × k leading
principal Gram matrix of the integer input.
The bound hk : k ≤ n defaults to by omega, so callers with a concrete k
and n (as in #guards and examples) can omit it.
Equations
- Hex.GramSchmidt.Int.gramDet b k hk = (Hex.GramSchmidt.leadingGramMatrixInt b k hk).bareiss.toNat
Instances For
Linear independence of the row prefix determinants used by the
Gram-Schmidt theorem surface, stated over the Mathlib-free executable
gramDet data.
Equations
- Hex.GramSchmidt.Int.independent b = ∀ (k : Fin n), 0 < Hex.GramSchmidt.Int.gramDet b (↑k + 1) ⋯
Instances For
Read a diagonal entry from a Bareiss elimination matrix as a natural determinant value.
Instances For
Read the k-th leading-principal determinant from one no-pivot Bareiss
elimination pass over the full Gram matrix. This helper is only used for Gram
matrices: once a leading row prefix is singular, every larger leading prefix is
also singular, so all later leading determinants are zero.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Specialization of the encoded zero-tail fact to the no-pivot executable data used by the Gram determinant vector pass.
Mutable loop state for the integer scaled Gram-Schmidt pass: the current step, the working matrix and coefficient arrays, and the previous Bareiss pivot.
Instances For
An n × n row-major nested array initialised to all zeros.
Equations
Instances For
The Gram matrix of b packaged as a row-major nested integer array.
Equations
- Hex.GramSchmidt.Int.gramRows b = Array.ofFn fun (i : Fin n) => Array.ofFn fun (j : Fin n) => (b.row i).dotProduct (b.row j)
Instances For
Reconstruct an n × n integer matrix from a row-major nested array, reading
entry (i, j) as rows[i]![j]! (getArrayEntry). This converts the executable
array passes back to the Matrix API; for the Gram rows it inverts gramRows,
so rowsToMatrix (gramRows b) n = gramMatrix b.
Equations
- Hex.GramSchmidt.Int.rowsToMatrix rows n = Hex.Matrix.ofFn fun (i j : Fin n) => Hex.GramSchmidt.Int.getArrayEntry rows ↑i ↑j
Instances For
Equations
- One or more equations did not get rendered due to their size.
- Hex.GramSchmidt.Int.scaledCoeffArrayLoop n 0 state = state
Instances For
Run one no-pivot fraction-free Gram elimination and record each scaled coefficient column immediately before the elimination step zeroes it.
This is the reference formulation of the scaled-coefficient matrix, kept
for proofs rather than execution. The live algorithm runs scaledCoeffRowsSchur
(the per-row Schur recurrence below); getArrayEntry_scaledCoeffRowsSchur_eq
proves the two agree entry-for-entry, and that bridge is what connects
scaledCoeffRowsSchur to gramDet / scaledCoeffs. Do not remove this
formulation as "unused": deleting it breaks the correctness proof of the live
path.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Schur-complement σ-chain for the fraction-free scaled Gram-Schmidt
recurrence. Each step divides by the previous diagonal pivot rows[p-1][p-1]
via Matrix.exactDiv; that division is exact — the fraction-free Bareiss
invariant guarantees the numerator is divisible by the pivot, so sigma stays
an integer bounded by a minor determinant rather than growing as an unreduced
fraction.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Per-row Schur-complement scaled Gram-Schmidt coefficient kernel.
Rows are filled from top to bottom; within row i, entries 0..i are written
left to right. For j < i this writes the scaled coefficient ν[i][j]; for
j = i the same recurrence writes the diagonal Gram determinant d_{i+1}.
Equations
- One or more equations did not get rendered due to their size.