The linear factor corresponding to a prime-field residue.
Equations
Instances For
The listed prime-field linear factors are genuinely degree-one candidates.
No listed prime-field linear factor is the zero polynomial.
Each prime-field linear factor has size 2 (it is genuinely degree 1).
Each prime-field linear factor is monic.
Each prime-field linear factor has degree exactly one.
Distinct residues give distinct linear factors.
Distinct prime-field linear factors are coprime: any common divisor is a unit.
Foldl-shape divisibility: if every linear factor in xs divides f,
the cumulative (acc * ∏ (X - C cᵢ)) divides f as long as acc is coprime
with each new linear factor.
The constant polynomial 1 over a prime modulus is nonzero.
The constant polynomial 1 over a prime modulus has size 1.
The constant polynomial 1 over a prime modulus is monic.
Foldl induction: size grows by one for each linear factor multiplied in.
The roots of f among the residues ofNat p k for k < n, listed in
increasing k and consed onto acc.
Counting down and consing keeps the loop tail-recursive and allocates only the
roots it keeps, so the scan holds deg f residues rather than the whole of
F_p. Filtering ZMod64.values p instead would allocate p residues, and the
budget in Hex.Berlekamp.rootScanBudget only bounds the scan against the
kernel computation it replaces, not in the absolute.
Equations
- Hex.Berlekamp.rootsBelow f 0 x✝ = x✝
- Hex.Berlekamp.rootsBelow f n.succ x✝ = Hex.Berlekamp.rootsBelow f n (if Hex.DensePoly.evalImpl f (Hex.ZMod64.ofNat p n) = 0 then Hex.ZMod64.ofNat p n :: x✝ else x✝)
Instances For
The roots of f in F_p, listed in canonical residue order.
One Horner evaluation per residue, so p * f.size modular multiplications.
Callers gate the scan on the field size; see
Hex.Berlekamp.rootScanBudget.
Equations
Instances For
The scan enumerates exactly the vanishing residues of the canonical residue list: the loop is the filter, without materializing the list.
Membership in rootsIn is exactly vanishing of the evaluation.
The root list has no duplicates: it enumerates the duplicate-free residue list.
Distinct residues give a duplicate-free list of monic linear factors.
Every listed root contributes its monic linear factor as a divisor of f.
A monic divisor of a monic polynomial of the same size is that polynomial.
Reconstruction from roots. When the residue scan finds deg f distinct
roots of a monic f, the corresponding monic linear factors multiply back to
f: their product divides f (pairwise coprime divisors), is monic, and has
the same size, so it is f itself.