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.
Interpret a normalized dense coefficient array as a Mathlib polynomial.
Equations
- HexPolyMathlib.toPolynomial p = ∑ i ∈ Finset.range p.size, (Polynomial.monomial i) (p.coeff i)
Instances For
Rebuild a normalized dense polynomial from the coefficients of a Mathlib polynomial.
Equations
- HexPolyMathlib.ofPolynomial p = Hex.DensePoly.ofList (List.map p.coeff (List.range (p.natDegree + 1)))
Instances For
Rebuilding via ofPolynomial preserves coefficients: the nth coefficient
of ofPolynomial p agrees with the nth coefficient of p.
Converting via toPolynomial preserves coefficients: the nth coefficient
of toPolynomial p agrees with the nth coefficient of the dense polynomial p.
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.
ofPolynomial sends Mathlib's zero polynomial to the executable zero.
ofPolynomial sends Mathlib's polynomial 1 to the executable constant 1.
ofPolynomial sends Mathlib's polynomial constant to the executable constant.
ofPolynomial commutes with polynomial negation.
ofPolynomial commutes with polynomial subtraction.
ofPolynomial commutes with polynomial addition.
ofPolynomial sends Mathlib's monomial to the executable monomial.
toPolynomial sends the executable zero to Mathlib's zero polynomial.
toPolynomial sends the executable constant to Mathlib's polynomial constant.
toPolynomial sends the executable constant 1 to Mathlib's polynomial 1.
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.
toPolynomial sends executable coefficient scaling to multiplication by
the corresponding constant polynomial.
toPolynomial sends the executable monomial to Mathlib's monomial.
HexPolyMathlib.toPolynomial commutes with polynomial addition.
toPolynomial commutes with executable polynomial negation.
toPolynomial commutes with executable polynomial subtraction.
HexPolyMathlib.toPolynomial commutes with polynomial
multiplication.
HexPolyMathlib.toPolynomial intertwines the executable derivative
with Mathlib's polynomial derivative.
Converting a Mathlib polynomial into the executable representation and back
recovers the original: HexPolyMathlib.toPolynomial is a left inverse of
HexPolyMathlib.ofPolynomial.
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
- HexPolyMathlib.equiv = { toFun := HexPolyMathlib.toPolynomial, invFun := HexPolyMathlib.ofPolynomial, left_inv := ⋯, right_inv := ⋯, map_mul' := ⋯, map_add' := ⋯ }
Instances For
The ring isomorphism equiv is computed by toPolynomial in the forward
direction.
The inverse of the ring isomorphism equiv is computed by ofPolynomial.
Apply a coefficient-ring equivalence to a dense polynomial.
Equations
Instances For
ofPolynomial commutes with polynomial multiplication.
HexPolyMathlib.toPolynomial transports the executable degree to Mathlib's natDegree,
with the zero polynomial mapping to 0.
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.
toPolynomial intertwines the executable Horner composition with Mathlib's
polynomial composition.