Documentation

CompPoly.Univariate.ToPoly.Core

Computable Univariate To Polynomial #

Conversions between computable univariate polynomials and mathlib Polynomial.

Convert a mathlib Polynomial to a CPolynomial.Raw by extracting coefficients up to the degree.

Instances For
    noncomputable def CompPoly.CPolynomial.Raw.toPoly {R : Type u_1} [Semiring R] (p : Raw R) :

    Convert a CPolynomial.Raw to a (mathlib) Polynomial.

    Instances For
      noncomputable def CompPoly.CPolynomial.Raw.toPoly' {R : Type u_1} [Semiring R] (p : Raw R) :

      Alternative definition of toPoly using Finsupp; currently unused.

      Instances For
        noncomputable def CompPoly.CPolynomial.toPoly {R : Type u_1} [Zero R] [Semiring R] (p : CPolynomial R) :

        Convert a canonical polynomial to a (mathlib) Polynomial.

        Instances For

          Alias of Polynomial.toImpl.


          Convert a mathlib Polynomial to a CPolynomial.Raw by extracting coefficients up to the degree.

          Instances For

            Evaluation is preserved by toPoly.

            theorem CompPoly.CPolynomial.Raw.coeff_toPoly {Q : Type u_2} [Semiring Q] {p : Raw Q} {n : } :

            The coefficients of p.toPoly match those of p.

            theorem CompPoly.CPolynomial.Raw.toImpl_elim {Q : Type u_2} [Semiring Q] (p : Polynomial Q) :
            p = 0 p.toImpl = #[] p 0 p.toImpl = Array.ofFn fun (i : Fin (p.natDegree + 1)) => p.coeff i

            Case analysis for toImpl: either the polynomial is zero or has a specific form.

            toImpl is a right-inverse of toPoly: the round-trip from Polynomial is the identity.

            This shows toPoly is surjective and toImpl is injective.

            Trimming doesn't change the toPoly image.

            toPoly preserves addition.

            theorem CompPoly.CPolynomial.Raw.toPoly_add {R : Type u_1} [Semiring R] [BEq R] [LawfulBEq R] (p q : Raw R) :
            (p + q).toPoly = p.toPoly + q.toPoly

            Non-zero polynomials map to non-empty arrays.

            theorem CompPoly.CPolynomial.Raw.getLast_toImpl {Q : Type u_2} [Semiring Q] {p : Polynomial Q} (hp : p 0) :
            have h := ; p.toImpl[Array.size p.toImpl - 1] = p.leadingCoeff

            The last coefficient of toImpl p is the leading coefficient of p.

            @[simp]

            toImpl lands in the semantic canonical carrier used by CPolynomial.

            @[simp]

            toImpl produces canonical polynomials (no trailing zeros).

            On canonical polynomials, toImpl is a left-inverse of toPoly.

            This shows toPoly is a bijection from CPolynomial R to Polynomial R.

            @[simp]

            The round-trip from CPolynomial.Raw to Polynomial and back yields the canonical form.

            toPoly maps a canonical polynomial to 0 iff the polynomial is 0.

            @[simp]

            Evaluation is preserved by toImpl.

            @[simp]
            theorem CompPoly.CPolynomial.Raw.eval_trim_eq_eval {R : Type u_1} [Semiring R] [BEq R] [LawfulBEq R] (x : R) (p : Raw R) :
            eval x p.trim = eval x p

            Evaluation is unchanged by trimming.