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.
Main definitions #
RingOps: the arithmetic of a model's carrier.Model: the computation model of a ring, including the encode/decode between the ring element and the carrier representation, and an optional entry certifier.EntryCertifier: the functions that prove the ring arithmetic facts about single entries that a certificate needs.bareissDecomp: runs fraction-free elimination over a model's carrier.BareissData: raw data of the computed decomposition.bareiss_ext: the attribute registering a computation model.
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 #
- [Bareiss, Sylvester's identity and multistep integer-preserving Gaussian elimination][bareiss1968]
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
An entry certifier proves arithmetic facts about expressions of the ring α that the
certificates need. eq proves an equation a = b, such as an unreduced entry of a matrix
product equal to its computed value, and neZero proves a ≠ 0, such as for a pivot entry.
eq is typically built on a normalizer, while neZero may depend on bespoke methods if a
normalizer cannot provide a disequality proof.
- eq (a b : Q(«$α»)) : Lean.MetaM Q(«$a» = «$b»)
Prove
a = b. Prove
a ≠ 0, stated with the caller'sZeroinstancezα.
Instances For
A computation model of the ring α on the carrier V.
- ops : RingOps V
The arithmetic of the carrier.
- evalEntry : Q(«$α») → 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 Q(«$α»)
The expression of the ring denoting a value.
- entryCertifier? : Option (EntryCertifier α)
An optional certifier for the ring, or
noneto leave the conditions to the kernel. Withnone, the kernel checks the decomposition productL * A_σ = Uby evaluating the list-based form as a whole without assembling it from per-entry proofs, which is faster than applyingdecideCertifieron every entry. As a result this field is optional rather than taking a default value, so thatcertifyProductEqcan perform this optimization.
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
αand its carrier, ornoneif the extension does not handleα.
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.