Parameterized computation core for the Bareiss elimination #
bareissDecomp computes the transform L, the echelon form U, the row swaps and the pivot
columns of an echelon decomposition by fraction-free elimination on a carrier of values.
As an optimisation, rows are scaled to clear their denominators (when applicable) before the
elimination with the scales folded back into L afterwards.
A computation model supplies the carrier, its arithmetic operations (RingOps) and the
encoding between entry syntax and values, and the tactic selects a model through the bareiss_ext
extension registry.
Implementation notes #
The elimination in bareissDecomp maintains the invariant L * A_σ = W, where
A_σ := A.submatrix σ id is the input with its rows in the arrangement σ accumulated
so far and W is the working matrix. When the pivot search swaps the rows at positions
r < p, the invariant must be restored against the new A_σ' = S * A_σ, where S is
the permutation matrix of the transposition τ = (r, p):
S * W = S * L * (S⁻¹ * S) * A_σ = (S * L * S⁻¹) * A_σ'
so L is conjugated by the matrix of τ, as in LU factorisation with partial pivoting.
References #
Arithmetics on values of V.
- zero : V
The zero value.
- one : V
The one value.
- mul : V → V → V
Multiplication.
- sub : V → V → V
Subtraction.
- divExact : V → V → V
Exact division.
- isZero : V → Bool
The pivot zero test.
Instances For
The arithmetic of V on its literals with a decode-encode roundtrip per operation.
This is less efficient than performing the elimination directly on V, but is a workaround for
a restriction in the registry (see Carrier). Certificate construction is the bottleneck so
this does not lead to much overall performance degradation.
A literal decode rejects is read as 0 (should never happen for the literals provided by
encode).
Equations
- One or more equations did not get rendered due to their size.
Instances For
Decomposition data with entries in V, the carrier of the elimination or Expr once the
entries are encoded.
The lower-triangular transform.
The echelon form, the final working matrix
L * A_σof the elimination.The row swaps, in order. Swaps are infrequent in common cases, so their product is a smaller term for the kernel than a row permutation.
The pivot columns. The
k-th entry is the column of the pivot in rowkof the final echelon form.
Instances For
Map over the entries of the transform.
Equations
- One or more equations did not get rendered due to their size.
Instances For
The row arrangement of the swaps: the entry at position i is the original row index
that the swaps move to position i, that is, σ i.
Equations
Instances For
Core algorithm of fraction-free Gaussian elimination, with the arithmetic supplied by the model.
A single sweep accumulates the transform L alongside the working matrix W, maintaining
L * (A.submatrix σ id) = W for the row arrangement σ so far. The divisions are exact
by Sylvester's identity, although the data-only computation does not prove that.
Equations
- One or more equations did not get rendered due to their size.
Instances For
The carriers a model computes on, the integers or expressions of the ring.
The most direct method is for a model to name the carrier type directly as a field of the extension,
but that puts the model in a higher universe level, and the registry can only store Type 0
elements.
Instances For
The type of the values of a carrier.
Equations
Instances For
A computation model of a ring on the carrier V.
- ops : RingOps V
The arithmetic of the carrier.
- evalEntry : Lean.Expr → Lean.MetaM (V × Option V)
Evaluate an entry to a value with an optional denominator for the row scaling.
(n, some d)denotesn / dwithdnonzero, and(n, none)denotesn. - commonMultiple : V → V → V
A nonzero common multiple for eliminating the denominators (
ops.mulby default). A carrier type with a cheap lcm could supply it as an optimisation to keep the scaled entries small. - mkEntry : V → Lean.MetaM Lean.Expr
The expression of the ring denoting a value.
Instances For
Fold the row scales into the transform after the decomposition algorithm. Column j of
L is multiplied by the scale of the row that ends up in position j after permutation.
Equations
- One or more equations did not get rendered due to their size.
Instances For
An extension of the Bareiss ring computation model.
The model for the element type
Rand its carrier, ornoneif the extension does not handleR.
Instances For
Read a bareiss_ext extension from a declaration of the right type.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Environment extension for the bareiss_ext computation models.
Uses a simple array to store the name-extension pairs for now.