ZPoly is a multiplicative monoid for Std, so the shared
List.foldl_mul_* algebra and the standard List.foldl_assoc apply to fold-products
of integer polynomials.
Coefficientwise congruence modulo m.
Equations
- f.congr g m = ∀ (i : Nat), (Hex.DensePoly.coeff f i - Hex.DensePoly.coeff g i) % ↑m = 0
Instances For
The nonnegative gcd of the coefficients of f.
Equations
Instances For
Divide every coefficient by the content to obtain a primitive polynomial.
Equations
Instances For
Substitute the variable X ↦ c * X: the i-th coefficient is multiplied by
c ^ i.
On a monic transform c^(d-1) · core(X / c), this is the inverse of the
integer-scaling substitution: it maps a
monic factor g of the transform to g(c · X), an integer multiple of the
corresponding factor of core. Composing with
Hex.ZPoly.primitivePart recovers the
primitive integer factor of core. This is not the same as
Hex.DensePoly.scale, which multiplies the whole polynomial by a
constant.
Equations
- Hex.ZPoly.dilate c p = Hex.DensePoly.ofList (List.map (fun (i : Nat) => c ^ i * Hex.DensePoly.coeff p i) (List.range (Hex.DensePoly.size p)))
Instances For
The n-th coefficient of dilate c p is c ^ n times the n-th
coefficient of p.
Reflection in the origin preserves the stored coefficient count.
Reflection in the origin preserves the optional degree.
The reflected leading coefficient differs only by the degree-parity sign.
A Hex.ZPoly is a unit iff it is the constant polynomial 1 or
-1.
Equations
- f.IsUnit = (f = Hex.DensePoly.C 1 ∨ f = Hex.DensePoly.C (-1))
Instances For
Hex.ZPoly.IsUnit is decidable: it reduces to equality with the constant polynomials
C 1 or C (-1), both of which are decidable.
Equations
The Hex.ZPoly.IsUnit predicate is exactly equality with the constant polynomial 1
or the constant polynomial -1.
The polynomial 1 is a unit, since (1 : ZPoly) is the constant polynomial
C 1.
The constant polynomial C 1 is a unit.
The constant polynomial C (-1) is a unit.
View an integer polynomial as a rational polynomial.
Equations
- f.toRatPoly = Hex.DensePoly.ofCoeffs (Array.map (fun (coeff : Int) => ↑coeff) (Hex.DensePoly.toArray f))
Instances For
Coefficients of toRatPoly f are the rational casts of the coefficients of
f.
Rational conversion sends the zero integer polynomial to the zero rational polynomial. The simp normal form for the zero case.
Rational conversion sends the constant integer polynomial C c to the
constant rational polynomial C (c : Rat). The simp normal form for the
constant case.
Rational conversion sends the unit integer polynomial 1 to the rational
polynomial 1, since (1 : ZPoly) is the constant polynomial C 1. The simp
normal form for the one case.
Rational conversion commutes with scaling an integer polynomial by an integer.
Rational conversion preserves the dense size of an integer polynomial.
Negate f when its leading coefficient is negative, normalizing a primitive part to
have nonnegative leading sign.
Equations
- f.normalizePrimitiveSign = if Hex.DensePoly.leadingCoeff f < 0 then Hex.DensePoly.scale (-1) f else f
Instances For
Clear denominators in a rational polynomial and return the primitive integer representative of the resulting rational associate.
Equations
Instances For
A rational polynomial is a rational scalar multiple of the rationalization of its integer primitive part.
Executable primitive square-free decomposition data for integer-polynomial normalization.
primitive is the content-free input. squareFreeCore is computed over
Rat[x] as primitive / gcd(primitive, primitive'), then converted back to a
primitive integer representative. repeatedPart records the same rational gcd,
also converted to a primitive integer representative. The proof layer relates
these representatives back to the primitive input up to a rational unit.
- primitive : ZPoly
The input divided by its content and normalized to positive leading coefficient.
- squareFreeCore : ZPoly
A primitive representative of the product of the distinct irreducible factors.
- repeatedPart : ZPoly
A primitive representative of the gcd of the primitive polynomial and its derivative.
Instances For
Square-free over Rat[x], up to the executable rational gcd's unit factor.
Equations
- f.SquareFreeRat = ((f.toRatPoly.gcd f.toRatPoly.derivative).size ≤ 1)
Instances For
SquareFreeRat is by definition a Nat size inequality on the executable
rational gcd, so Nat.decLe decides it. Drivers branch on this instance for
their square-freeness precondition.
Compute the primitive square-free normalization data needed by the integer factorization computation.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Coefficientwise congruence modulo m is reflexive.
Scaling the primitive part by the content reconstructs the original integer polynomial.
The content of an integer polynomial divides every coefficient.
If a natural number divides every coefficient, then its integer cast divides the content.
Alias for dvd_content_of_nat_dvd_coeff with the divisibility conclusion
written for the natural number cast to Int.
If the content of f is nonzero, then the primitive part of f is
primitive.
A primitive integer polynomial is equal to its primitive part.
Hex.ZPoly-level wrapper for
Hex.DensePoly.primitivePart_mul (Gauss's lemma): the
primitive part of a product of integer polynomials is the product of their
primitive parts.
The top coefficient of a product of nonzero integer polynomials is the product of their top coefficients.
The size of a product of nonzero integer polynomials is one less than the sum of their sizes.
A nonzero integer polynomial has positive dense size.
The leading coefficient of a product of nonzero integer polynomials is the product of their leading coefficients.
A product of integer polynomials with positive leading coefficients has positive leading coefficient.
Multiplication by an integer constant agrees with coefficient scaling.
Nonzero integer scalar multiplication preserves the stored size.
Leading coefficient after nonzero integer scalar multiplication.
Shifting a nonzero polynomial by x^k preserves its leading coefficient.
A nonzero divisor of a nonzero integer polynomial has no larger dense size.
Euclidean reconstruction for a monic integer divisor: the executable
dense-polynomial division recomposes the dividend, quot * candidate + rem = target, for any dividend. This is the monic specialization over Int of
DensePoly.divMod_reconstruction; the leading-coefficient cancellation
invariant it requires holds because a monic divisor has leading coefficient 1.
Unlike divMod_eq_of_monic_mul_eq, no exact-multiple hypothesis is needed, so
the remainder may be nonzero.
If a monic positive-degree integer divisor has an exact product witness, the executable dense-polynomial division returns zero remainder.
If a monic positive-degree integer divisor has an exact product witness, the executable dense-polynomial division returns the witnessed quotient and zero remainder.
Non-monic exact-multiple divMod identity: if the divisor candidate has
positive leading coefficient and the dividend factors as
quotient * candidate, the executable dense-polynomial division returns the
witnessed quotient and zero remainder. Sits one level above
divMod_eq_of_monic_mul_eq, dropping the monic requirement at the cost of
needing 0 < candidate.leadingCoeff to discharge the integer-division exactness
side-conditions.