Documentation

Mathlib.Tactic.Echelon.Core

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
    def Mathlib.Tactic.Echelon.RingOps.lift {V : Type} (ops : RingOps V) (decode : Lean.Expr → Option V) (encode : V → Lean.Expr) :

    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.

      • L : Array (Array V)

        The lower-triangular transform.

      • U : Array (Array V)

        The echelon form, the final working matrix L * A_σ of the elimination.

      • swaps : Array (Nat × Nat)

        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.

      • pivot : Array Nat

        The pivot columns. The k-th entry is the column of the pivot in row k of 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
                @[reducible, inline]

                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) denotes n / d with d nonzero, and (n, none) denotes n.

                  • commonMultiple : V → V → V

                    A nonzero common multiple for eliminating the denominators (ops.mul by 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
                    def Mathlib.Tactic.Echelon.scaleRows {V : Type} (ops : RingOps V) (commonMultiple : V → V → V) (rows : Array (Array (V × Option V))) :

                    Clear the denominators of the rows before the decomposition algorithm.

                    Equations
                    • One or more equations did not get rendered due to their size.
                    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.

                        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.