Interpret a normalized dense coefficient array as a Mathlib polynomial.
7.8. The Mathlib correspondence
Everything above is executable and Mathlib-free. HexPolyTheory
connects it to Mathlib: every Hex.DensePoly corresponds to a
Mathlib Polynomial with the same coefficients. The two transfer maps
go each way.
HexPolyTheory.toPolynomial.{u} {R : Type u} [Semiring R] [DecidableEq R] (p : Hex.DensePoly R) : Polynomial RHexPolyTheory.toPolynomial.{u} {R : Type u} [Semiring R] [DecidableEq R] (p : Hex.DensePoly R) : Polynomial R
HexPolyTheory.ofPolynomial.{u} {R : Type u} [Semiring R] [DecidableEq R] (p : Polynomial R) : Hex.DensePoly RHexPolyTheory.ofPolynomial.{u} {R : Type u} [Semiring R] [DecidableEq R] (p : Polynomial R) : Hex.DensePoly R
Rebuild a normalized dense polynomial from the coefficients of a Mathlib polynomial.
They are mutually inverse:
HexPolyTheory.toPolynomial_ofPolynomial.{u} {R : Type u} [Semiring R] [DecidableEq R] (p : Polynomial R) : HexPolyTheory.toPolynomial (HexPolyTheory.ofPolynomial p) = pHexPolyTheory.toPolynomial_ofPolynomial.{u} {R : Type u} [Semiring R] [DecidableEq R] (p : Polynomial R) : HexPolyTheory.toPolynomial (HexPolyTheory.ofPolynomial p) = p
Converting a Mathlib polynomial into the executable representation and back
recovers the original: HexPolyTheory.toPolynomial is a left inverse of
HexPolyTheory.ofPolynomial.
HexPolyTheory.ofPolynomial_toPolynomial.{u} {R : Type u} [Semiring R] [DecidableEq R] (p : Hex.DensePoly R) : HexPolyTheory.ofPolynomial (HexPolyTheory.toPolynomial p) = pHexPolyTheory.ofPolynomial_toPolynomial.{u} {R : Type u} [Semiring R] [DecidableEq R] (p : Hex.DensePoly R) : HexPolyTheory.ofPolynomial (HexPolyTheory.toPolynomial p) = p
Converting an executable polynomial into a Mathlib polynomial and back
recovers the original: HexPolyTheory.ofPolynomial is a left inverse of
HexPolyTheory.toPolynomial.
HexPolyTheory.toPolynomial is a degree-preserving ring homomorphism. Addition,
multiplication, and the degree transfer:
HexPolyTheory.toPolynomial_add.{u} {R : Type u} [Semiring R] [DecidableEq R] (p q : Hex.DensePoly R) : HexPolyTheory.toPolynomial (p + q) = HexPolyTheory.toPolynomial p + HexPolyTheory.toPolynomial qHexPolyTheory.toPolynomial_add.{u} {R : Type u} [Semiring R] [DecidableEq R] (p q : Hex.DensePoly R) : HexPolyTheory.toPolynomial (p + q) = HexPolyTheory.toPolynomial p + HexPolyTheory.toPolynomial q
HexPolyTheory.toPolynomial commutes with polynomial addition.
HexPolyTheory.toPolynomial_mul.{u} {R : Type u} [Semiring R] [DecidableEq R] (p q : Hex.DensePoly R) : HexPolyTheory.toPolynomial (p * q) = HexPolyTheory.toPolynomial p * HexPolyTheory.toPolynomial qHexPolyTheory.toPolynomial_mul.{u} {R : Type u} [Semiring R] [DecidableEq R] (p q : Hex.DensePoly R) : HexPolyTheory.toPolynomial (p * q) = HexPolyTheory.toPolynomial p * HexPolyTheory.toPolynomial q
HexPolyTheory.toPolynomial commutes with polynomial
multiplication.
HexPolyTheory.natDegree_toPolynomial.{u} {R : Type u} [Semiring R] [DecidableEq R] (p : Hex.DensePoly R) : (HexPolyTheory.toPolynomial p).natDegree = p.natDegreeHexPolyTheory.natDegree_toPolynomial.{u} {R : Type u} [Semiring R] [DecidableEq R] (p : Hex.DensePoly R) : (HexPolyTheory.toPolynomial p).natDegree = p.natDegree
HexPolyTheory.toPolynomial transports the executable degree to Mathlib's natDegree,
with the zero polynomial mapping to 0.
The maps and laws bundle into a ring equivalence, and divisibility transfers through it:
HexPolyTheory.equiv.{u} {R : Type u} [Semiring R] [DecidableEq R] : Hex.DensePoly R ≃+* Polynomial RHexPolyTheory.equiv.{u} {R : Type u} [Semiring R] [DecidableEq R] : Hex.DensePoly R ≃+* Polynomial R
The executable dense-polynomial representation is ring-equivalent to Mathlib polynomials.
HexPolyTheory.toPolynomial_dvd_iff.{u} {R : Type u} [Semiring R] [DecidableEq R] {p q : Hex.DensePoly R} : HexPolyTheory.toPolynomial p ∣ HexPolyTheory.toPolynomial q ↔ p ∣ qHexPolyTheory.toPolynomial_dvd_iff.{u} {R : Type u} [Semiring R] [DecidableEq R] {p q : Hex.DensePoly R} : HexPolyTheory.toPolynomial p ∣ HexPolyTheory.toPolynomial q ↔ p ∣ q
HexPolyTheory.toPolynomial both preserves and reflects divisibility: executable
polynomials divide one another exactly when their Mathlib images do.