Computable Euclidean division and GCD on polynomial coefficient lists over a field #
Over a field K with decidable equality, this module defines computable polynomial long division
(Polynomial.CoeffList.divMod, div, mod) and Euclidean greatest common divisor
(Polynomial.CoeffList.gcd) on little-endian coefficient lists (List K), and proves exact
correspondence with Euclidean division and GCD in K[X].
Division by an empty or all-zero divisor list returns ([], trim a), matching p / 0 = 0 and
p % 0 = p in K[X], so ofCoeffList_div, ofCoeffList_mod, mod_eq_nil_iff_dvd, and
ofCoeffList_gcd hold unconditionally for all a b : List K.
Main definitions #
Polynomial.CoeffList.divModStep,Polynomial.CoeffList.divMod: iterative long division on coefficient lists overK.Polynomial.CoeffList.div,Polynomial.CoeffList.mod,Polynomial.CoeffList.negMod: Euclidean quotient, remainder, and negated remainder lists.Polynomial.CoeffList.gcdStep,Polynomial.CoeffList.gcd: iterative Euclidean GCD on coefficient lists overK.
Main results #
Polynomial.CoeffList.ofCoeffList_div,Polynomial.CoeffList.ofCoeffList_mod,Polynomial.CoeffList.ofCoeffList_negMod,Polynomial.CoeffList.eq_divMod_of_isTrimmed:div,mod, andnegModcompute/,%, and-(·) % ·inK[X], with canonical trimmed uniqueness.Polynomial.CoeffList.length_mod_lt:(mod a b).length < (trim b).lengthwhenofCoeffList b ≠ 0.Polynomial.CoeffList.mod_eq_nil_iff_dvd:mod a b = [] ↔ ofCoeffList b ∣ ofCoeffList a.Polynomial.CoeffList.ofCoeffList_gcd,Polynomial.CoeffList.ofCoeffList_gcd_dvd_left,Polynomial.CoeffList.ofCoeffList_gcd_dvd_right,Polynomial.CoeffList.dvd_ofCoeffList_gcd:gcdcomputesEuclideanDomain.gcdinK[X]and satisfies the universal GCD divisibility laws.
Euclidean long division #
Computable Euclidean (quotient, remainder) of a divided by b in K[X].
Computable Euclidean quotient of a divided by b in K[X], as a trimmed list.
Computable Euclidean remainder of a modulo b in K[X], as a trimmed list.
Length preservation across one step of divModStep.
Length and trimming invariants along iterations of divModStep.
Subtracting the leading-term multiple smul (r.getLastD 0 / b.getLastD 0) (shift d b) from a
trimmed dividend r (b.length ≤ r.length) strictly reduces the trimmed list length.
div a b is trimmed.
mod a b is trimmed.
(div a b).length ≤ a.length.
(mod a b).length ≤ a.length.
Division identity
ofCoeffList (div a b) * ofCoeffList b + ofCoeffList (mod a b) = ofCoeffList a
for all a b : List K.
When ofCoeffList b ≠ 0, the remainder list mod a b is strictly shorter than trim b.
div a b represents Euclidean quotient ofCoeffList a / ofCoeffList b in K[X].
mod a b represents Euclidean remainder ofCoeffList a % ofCoeffList b in K[X].
Uniqueness of Euclidean division on trimmed coefficient lists when ofCoeffList b ≠ 0:
any pair of trimmed lists (q, r) with r.length < (trim b).length and
ofCoeffList q * ofCoeffList b + ofCoeffList r = ofCoeffList a equals divMod a b.
mod a b = [] if and only if ofCoeffList b divides ofCoeffList a in K[X].
Computable negated Euclidean remainder -(ofCoeffList a) % ofCoeffList b in K[X], as a
trimmed list.
negMod a b is trimmed.
(negMod a b).length ≤ a.length.
When ofCoeffList b ≠ 0, negMod a b is strictly shorter than trim b.
negMod a b represents -(ofCoeffList a) % ofCoeffList b in K[X].
Euclidean greatest common divisor #
Computable Euclidean GCD of two polynomial coefficient lists over K, as a trimmed list.
gcd a b is trimmed.
gcd a b computes EuclideanDomain.gcd (ofCoeffList b) (ofCoeffList a) in K[X].
ofCoeffList (gcd a b) divides ofCoeffList a.
ofCoeffList (gcd a b) divides ofCoeffList b.
Every common divisor of ofCoeffList a and ofCoeffList b divides ofCoeffList (gcd a b).
ofCoeffList (gcd a b) ≠ 0 whenever either input represents a nonzero polynomial.