Documentation

Lean.Meta.Sym.Arith.SafePoly

Guarded polynomial computation #

The polynomial functions in Init (Expr.toPoly, Expr.toPolyC, Expr.toPolyS, and the operations they use) are pure and unbounded. The functions below compute the same results in SymM, so that the computation can be interrupted (checkSystem, withIncRecDepth), refuses exponents above the exp threshold (checkExp), and can be bounded by a budget on the number of monomials and the degree.

They must be case-by-case mirrors of the Init functions: proofs by reflection compare the kernel's evaluation of the Init function with the result computed here, so any divergence is a proof failure.

  • char? : Option Nat

    Nonzero characteristic. When some c, mirrors Expr.toPolyC c (or toPolyS, which has no characteristic support).

  • semiring : Bool

    When true, mirrors Expr.toPolyS (semiring: nonnegative coefficients, no subtraction).

  • commutative : Bool

    When false, mirrors the non-commutative functions (toPoly_nc, toPolyC_nc, toPolyS_nc).

  • maxTerms? : Option Nat

    Maximum number of monomials of any intermediate polynomial.

  • maxDegree? : Option Nat

    Maximum degree of any intermediate polynomial.

Instances For
    @[reducible, inline]

    Polynomial computations that may fail (budget, exponent threshold).

    Instances For
      def Lean.Meta.Sym.Arith.PolyM.run {α : Type} (x : PolyM α) (cfg : PolyConfig := { }) :
      Instances For
        Instances For

          Mirror of Poly.combine (Poly.combineC with a characteristic).

          Instances For

            Mirror of Poly.mul (Poly.mulC, Poly.mul_nc, Poly.mulC_nc); mulMon selects the variant.

            Instances For

              Mirror of the numeral cases (.num, .natCast, .intCast) of the toPoly functions.

              Instances For

                Mirror of the .pow a k case of the toPoly functions, given pa, the polynomial of a.

                Instances For

                  Converts e into a polynomial, mirroring Expr.toPoly, Expr.toPolyC c, Expr.toPolyS, or their non-commutative variants, depending on the configuration. Returns none if the computation exceeds the budget or the exponent threshold.

                  Instances For