Long division of binary coefficient lists #
significantLength discards high zero padding numerically: it is one past the
highest true coefficient, or zero for the zero polynomial. Every nonzero
binary polynomial is monic, independently of its list's high zero padding.
For a modulus of degree d, remainderScan processes the dividend from its
highest coefficient to its constant coefficient, keeping exactly d bits.
Each step shifts the current remainder, inserts the next coefficient, and
cancels the possible degree-d term with the supplied modulus. Constant-one
moduli have d = 0 and produce the empty list.
remainderBits returns its dividend unchanged for a zero modulus, agreeing
with Mathlib's convention for remainder by a nonmonic zero polynomial. Both
operands are runtime inputs, and every definition is total.
One past the highest true coefficient, or zero for an all-false list.
Equations
Instances For
Scan a little-endian dividend from its high coefficients to its low coefficients.
Equations
- Complexity.BitPolynomial.remainderScan modulus [] = List.replicate (Complexity.BitPolynomial.significantLength modulus - 1) false
- Complexity.BitPolynomial.remainderScan modulus (bit :: tail) = Complexity.BitPolynomial.remainderStep modulus bit (Complexity.BitPolynomial.remainderScan modulus tail)
Instances For
Remainder by a runtime binary modulus, allowing high zeros and the zero polynomial.
Equations
- Complexity.BitPolynomial.remainderBits a modulus = if Complexity.BitPolynomial.significantLength modulus = 0 then a else Complexity.BitPolynomial.remainderScan modulus a
Instances For
The total paired-input evaluator for binary-polynomial remainder.