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.
Nonzero characteristic. When
some c, mirrorsExpr.toPolyC c(ortoPolyS, which has no characteristic support).- semiring : Bool
When
true, mirrorsExpr.toPolyS(semiring: nonnegative coefficients, no subtraction). - commutative : Bool
When
false, mirrors the non-commutative functions (toPoly_nc,toPolyC_nc,toPolyS_nc). Maximum number of monomials of any intermediate polynomial.
Maximum degree of any intermediate polynomial.
Instances For
Polynomial computations that may fail (budget, exponent threshold).
Equations
Instances For
Mirror of Poly.combine (Poly.combineC with a characteristic).
Equations
- Lean.Meta.Sym.Arith.SafePoly.combine p₁ p₂ = do let p ← Lean.Meta.Sym.Arith.SafePoly.combineCore✝ p₁ p₂ Lean.Meta.Sym.Arith.SafePoly.checkBudget✝ p pure p
Instances For
Equations
- Lean.Meta.Sym.Arith.SafePoly.pow p k = do let __do_lift ← read if __do_lift.commutative = true then Lean.Meta.Sym.Arith.SafePoly.powComm✝ p k else Lean.Meta.Sym.Arith.SafePoly.powNC✝ p k
Instances For
Mirror of the numeral cases (.num, .natCast, .intCast) of the toPoly functions.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Mirror of the .pow a k case of the toPoly functions, given pa, the polynomial of a.
Equations
- Lean.Meta.Sym.Arith.SafePoly.powNode (Lean.Grind.CommRing.Expr.num n) pa k = if (k == 0) = true then pure (Lean.Grind.CommRing.Poly.num 1) else Lean.Meta.Sym.Arith.SafePoly.powNode.numPow✝ k n
- Lean.Meta.Sym.Arith.SafePoly.powNode (Lean.Grind.CommRing.Expr.intCast n) pa k = if (k == 0) = true then pure (Lean.Grind.CommRing.Poly.num 1) else Lean.Meta.Sym.Arith.SafePoly.powNode.numPow✝ k n
- Lean.Meta.Sym.Arith.SafePoly.powNode (Lean.Grind.CommRing.Expr.natCast n) pa k = if (k == 0) = true then pure (Lean.Grind.CommRing.Poly.num 1) else Lean.Meta.Sym.Arith.SafePoly.powNode.numPow✝ k ↑n
- Lean.Meta.Sym.Arith.SafePoly.powNode (Lean.Grind.CommRing.Expr.var x) pa k = if (k == 0) = true then pure (Lean.Grind.CommRing.Poly.num 1) else Lean.Meta.Sym.Arith.SafePoly.mkPowVar✝ x k
- Lean.Meta.Sym.Arith.SafePoly.powNode a pa k = if (k == 0) = true then pure (Lean.Grind.CommRing.Poly.num 1) else Lean.Meta.Sym.Arith.SafePoly.pow pa k
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.
Equations
- Lean.Meta.Sym.Arith.toPoly? e = do let __do_lift ← read if __do_lift.semiring = true then Lean.Meta.Sym.Arith.SafePoly.toPolySemiring✝ e else Lean.Meta.Sym.Arith.SafePoly.toPolyRing✝ e