Documentation

LeanCert.Engine.Algebra.QPoly

Executable exact rational polynomials #

Polynomial ℚ is the semantic representation used by Mathlib, but its sparse implementation is not a suitable native certificate payload. QPoly stores ascending coefficients in an Array ℚ and supplies a small exact executable kernel. The toPoly lemmas connect successful computations to Mathlib.

An exact executable rational polynomial.

coeffs[i] is the coefficient of x^i. Trailing zero coefficients are allowed; use trim when a canonical certificate representation is useful.

Instances For
    def LeanCert.Engine.instDecidableEqQPoly.decEq (x✝ x✝¹ : QPoly) :
    Decidable (x✝ = x✝¹)
    Equations
    Instances For
      Equations
      • One or more equations did not get rendered due to their size.
      Instances For

        The semantic Mathlib polynomial represented by an executable QPoly.

        Equations
        Instances For

          The polynomial variable.

          Equations
          Instances For

            The exact rational antiderivative with constant coefficient zero.

            Equations
            Instances For

              Exact Horner evaluation over the rationals.

              Equations
              Instances For

                Exact definite integral between rational endpoints.

                Equations
                Instances For

                  Sparse products with 1 - X^n and monomial shifts #

                  mul is dense (O(deg p · deg q)), which is far too slow for products of a few hundred factors 1 - X^n of total degree in the hundreds of thousands. mulOneSubPow computes p · (1 - X^n) as p - X^n · p in linear time.

                  X^k · p, in linear time.

                  Equations
                  Instances For

                    Composition and coefficient sums #

                    Horner composition p ∘ q, exact over the rationals.

                    Equations
                    Instances For

                      Evaluating a composition evaluates the inner polynomial first.

                      The represented polynomial is the finite sum of its coefficient list.

                      Convert to a single-variable Horner expression in variable 0.

                      Equations
                      Instances For

                        The Horner Expr and Mathlib polynomial have identical real semantics.

                        theorem LeanCert.Engine.QPoly.cast_evalRat (p : QPoly) (x : ℚ) :
                        ↑(p.evalRat x) = Core.Expr.eval (fun (x_1 : ℕ) => ↑x) p.toExpr
                        theorem LeanCert.Engine.QPoly.integral_eval_toExpr (p : QPoly) (a b : ℚ) :
                        ∫ (x : ℝ) in ↑a..↑b, Core.Expr.eval (fun (x_1 : ℕ) => x) p.toExpr = ↑(p.integralRat a b)

                        The executable exact integral agrees with the interval integral of the represented polynomial.

                        The analytic derivative of the Horner expression agrees with the formal polynomial derivative.