Documentation

HexPolyMathlib.PolynomialEquivalence

theorem HexPolyMathlib.list_getD_map_range_zero {R : Type u} [Zero R] (size n : ) (f : R) :

Reading a mapped List.range with default zero returns the mapped index inside the range and zero outside it. This is the coefficient-array lookup fact used by coeff_ofPolynomial when rebuilding dense polynomials from Mathlib coefficients.

noncomputable def HexPolyMathlib.toPolynomial {R : Type u} [Semiring R] [DecidableEq R] (p : Hex.DensePoly R) :

Interpret a normalized dense coefficient array as a Mathlib polynomial.

Equations
Instances For

    Rebuild a normalized dense polynomial from the coefficients of a Mathlib polynomial.

    Equations
    Instances For
      @[simp]

      Rebuilding via ofPolynomial preserves coefficients: the nth coefficient of ofPolynomial p agrees with the nth coefficient of p.

      @[simp]

      Converting via toPolynomial preserves coefficients: the nth coefficient of toPolynomial p agrees with the nth coefficient of the dense polynomial p.

      theorem HexPolyMathlib.eval₂_toPolynomial {R : Type u} {S : Type u_1} [Semiring R] [DecidableEq R] [Semiring S] (f : R →+* S) (p : Hex.DensePoly R) (x : S) :
      Polynomial.eval₂ f x (toPolynomial p) = iFinset.range p.size, f (p.coeff i) * x ^ i

      Coefficient-sum evaluation correspondence: evaluating toPolynomial p through a ring hom f at x is the degree-indexed sum ∑ f (p.coeff i) * x ^ i. For a literal ofCoeffs array this unfolds via Finset.sum_range_succ into an explicit polynomial in x, which ring/norm_num can then discharge.

      @[simp]

      ofPolynomial sends Mathlib's zero polynomial to the executable zero.

      @[simp]

      ofPolynomial sends Mathlib's polynomial 1 to the executable constant 1.

      @[simp]

      ofPolynomial sends Mathlib's polynomial constant to the executable constant.

      @[simp]

      ofPolynomial commutes with polynomial negation.

      @[simp]

      ofPolynomial commutes with polynomial subtraction.

      @[simp]

      ofPolynomial commutes with polynomial addition.

      @[simp]

      ofPolynomial sends Mathlib's monomial to the executable monomial.

      @[simp]

      toPolynomial sends the executable zero to Mathlib's zero polynomial.

      @[simp]

      toPolynomial sends the executable constant to Mathlib's polynomial constant.

      @[simp]

      toPolynomial sends the executable constant 1 to Mathlib's polynomial 1.

      @[simp]

      toPolynomial reads a raw coefficient array off as the obvious sum, ascending. This is what makes a concrete #p[...] literal readable on the Mathlib side: with Finset.sum_range_succ to expand the range, toPolynomial #p[1, 1, 1] becomes C 1 * X ^ 0 + C 1 * X ^ 1 + C 1 * X ^ 2.

      Stated with C _ * X ^ i rather than monomial i _ because that is the form a reader writes a polynomial in, so a use site needs no C_mul_X_pow_eq_monomial rewrite of its own.

      @[simp]

      toPolynomial sends executable coefficient scaling to multiplication by the corresponding constant polynomial.

      @[simp]

      toPolynomial sends the executable monomial to Mathlib's monomial.

      @[simp]

      HexPolyMathlib.toPolynomial commutes with polynomial addition.

      @[simp]

      toPolynomial commutes with executable polynomial negation.

      @[simp]

      toPolynomial commutes with executable polynomial subtraction.

      @[simp]

      HexPolyMathlib.toPolynomial commutes with polynomial multiplication.

      @[simp]

      HexPolyMathlib.toPolynomial intertwines the executable derivative with Mathlib's polynomial derivative.

      @[simp]

      Converting a Mathlib polynomial into the executable representation and back recovers the original: HexPolyMathlib.toPolynomial is a left inverse of HexPolyMathlib.ofPolynomial.

      @[simp]

      Converting an executable polynomial into a Mathlib polynomial and back recovers the original: HexPolyMathlib.ofPolynomial is a left inverse of HexPolyMathlib.toPolynomial.

      The executable dense-polynomial representation is ring-equivalent to Mathlib polynomials.

      Equations
      Instances For
        @[simp]

        The ring isomorphism equiv is computed by toPolynomial in the forward direction.

        @[simp]

        The inverse of the ring isomorphism equiv is computed by ofPolynomial.

        noncomputable def HexPolyMathlib.mapEquiv {R : Type u} {S : Type v} [Semiring R] [DecidableEq R] [Semiring S] [DecidableEq S] (e : R ≃+* S) :

        Apply a coefficient-ring equivalence to a dense polynomial.

        Equations
        Instances For
          @[simp]

          ofPolynomial commutes with polynomial multiplication.

          @[simp]

          HexPolyMathlib.toPolynomial transports the executable degree to Mathlib's natDegree, with the zero polynomial mapping to 0.

          @[simp]

          toPolynomial transports the executable leading coefficient to Mathlib's leadingCoeff.

          toPolynomial preserves divisibility: a divisibility in the executable representation transfers to the corresponding Mathlib polynomials.

          ofPolynomial preserves divisibility: a divisibility of Mathlib polynomials transfers to the corresponding executable representations.

          HexPolyMathlib.toPolynomial both preserves and reflects divisibility: executable polynomials divide one another exactly when their Mathlib images do.

          @[simp]

          toPolynomial intertwines the executable Horner composition with Mathlib's polynomial composition.