Executable Bareiss–Jordan elimination over ℚ and coefficient bit-length bounds #
This module provides executable list-matrix Bareiss–Jordan elimination over ℤ and ℚ, proved
equivalent to the minor-scaled Bareiss–Jordan matrix Matrix.bareissMatrix from
CslibFrontier.Foundations.LinearAlgebra.Matrix.Bareiss.
References and local adaptations #
- Alexander Schrijver, Theory of Linear and Integer Programming (Wiley, 1986), Section 3.2, Theorem 3.2 (pp. 29–30, determinant encoding-size bound) and Section 3.3, Theorem 3.3 (pp. 32–33), Corollary 3.3a (pp. 33–34), and the Gauss–Jordan discussion with Equations (28)–(30) (p. 35).
- Local adaptation: Whereas Schrijver's Section 3.3 analyzes normalized rational Gaussian and
Gauss–Jordan elimination directly over
ℚ, this module clears row denominators upfront (clearDenoms) and runs fraction-free Sylvester–Bareiss minor-scaled Gauss–Jordan updates overℤ(bareissElimCols), bounding all intermediate integer entries and output numerators and denominators via the explicit Hadamard/factorial boundstageEntryBound.
Main definitions #
IntTable,RatTable,BareissState,RationalElimResult,LinearSystemInput,LinearSolveResult: explicit row-major matrix and elimination records.clearDenoms: clears row denominators of aRatTableto produce an exactIntTable.bareissStep,bareissElimCols,bareissElim: column-by-column fraction-free Bareiss–Jordan integer elimination.rationalElim,ratRref,ratRank,ratRowBasis,ratKernelBasis,ratSolve: rational reduced row echelon form, exact rank, linearly independent row and kernel bases, and canonical linear system solving with certified inconsistency.stageEntryBound: uniform Hadamard/factorial bound on intermediate integer entries and output rational numerators and denominators.
Main results #
bareissElimCols_inv: loop invariant equating executableInt.edivupdates withMatrix.bareissMatrixand certifying exact divisibility, echelon zeroes, and pivot determinants.rationalElim_spec,ratRref_isReducedRowEchelon,ratRank_eq:rationalElimproduces a genuineMatrix.IsPivotedBy/Matrix.IsReducedRowEchelonmatrix overℚpreserving row space and rank, with linearly independent spanning row and kernel bases.ratSolve_spec:ratSolvereturns a canonical solution vector iffA *ᵥ x = bis consistent.bareissInv_entry_bound,size_stageEntryBound_le,rationalElim_entry_bounds,ratSolve_entry_bounds: polynomial Hadamard/factorial entry magnitude andNat.sizebit-length bounds for all intermediate states and rational outputs.
Explicit table and elimination record types #
Explicit row-major integer matrix.
Explicit row-major rational matrix.
Intermediate state of column-by-column Bareiss–Jordan integer elimination.
- table : IntTable
Current minor-scaled integer table.
- pivotDet : ℤ
Current nonzero pivot determinant (
1initially). Ordered distinct pivot row indices selected so far.
Strictly increasing pivot column indices selected so far.
Instances For
Complete output of Bareiss–Jordan elimination on a rational matrix.
- rref : RatTable
Reduced row echelon rational matrix of the same shape, pivot rows first.
- rank : ℕ
Exact rank (
= pivotRows.length = pivotCols.length). Pivot row indices in the original matrix forming a basis of the row space.
Strictly increasing pivot column indices.
Non-pivot column indices in ascending order.
Kernel basis vectors, one per non-pivot column.
Instances For
Output of Bareiss–Jordan linear solving for A x = b.
Canonical solution vector supported on pivot columns if consistent, or
none.Pivot row indices selected during elimination.
Pivot column indices selected during elimination.
Instances For
Row denominator clearing #
Product of denominators of all entries in a rational row.
Scale a rational row by rowDenomProd r, producing an exact integer row.
Per-row positive integer multiplier produced by clearDenoms M.
Executable Bareiss–Jordan elimination over ℤ #
Find the first unpivoted row index < st.table.numRows with a nonzero entry in column c.
Perform one column step of Bareiss–Jordan elimination on column c.
Initial state of Bareiss–Jordan elimination on an integer table.
Run Bareiss–Jordan elimination across columns 0, …, colLimit - 1.
Run full Bareiss–Jordan elimination across all columns of T.
Loop invariant linking BareissState to Matrix.bareissMatrix.
- wellFormed : RowTable.WellFormed st.table
- table_eq (i : Fin T.numRows) (j : Fin T.numCols) : RowTable.entry st.table ↑i ↑j = (RowTable.toMatrix T).bareissMatrix (finSel st.pivotRows ⋯ ⋯) (finSel st.pivotCols ⋯ ⋯) i j
Correctness invariant for bareissElimCols across columns < colLimit ≤ T.numCols.
Correctness invariant for full bareissElim.
Executable rational RREF, rank, row basis, kernel basis, and linear solver #
Kernel basis vector associated with non-pivot column j.
Complete Bareiss–Jordan elimination on a rational matrix M: RREF, rank, row basis indices,
pivot/non-pivot columns, and kernel basis.
Executable rational reduced row echelon form.
Exact rational matrix rank via Bareiss–Jordan elimination.
Solve A x = b canonically via augmented Bareiss–Jordan elimination.
Row-scaling invariance and correctness of rationalElim / ratSolve #
Complete algebraic and reduced-echelon characterization of rationalElim M for any M.
Convenience projection: ratRref M is in Mathlib's Matrix.IsReducedRowEchelon.
Soundness and completeness of ratSolve sys with respect to sys.matrix.toMatrix *ᵥ x = b.
Bit-length and magnitude bounds #
Uniform Hadamard/factorial upper bound (min m n + 1)! * (B + 1) ^ (min m n + 1).
Every entry and pivot determinant in any state satisfying BareissInv T c st is bounded in
magnitude by stageEntryBound T.numRows T.numCols B.
Every rational entry produced in (rationalElim M).rref and (rationalElim M).kernelBasis has
magnitude and denominator bounded by stageEntryBound M.numRows M.numCols (2^((n+1)*b)).
Every entry of the canonical solution returned by ratSolve sys has numerator magnitude and
denominator bounded by stageEntryBound m (n + 1) (2 ^ ((n + 2) * b)).