Remove the initial zero-coefficient run from a dense integer polynomial.
Dense coefficients are stored in ascending degree order, so the initial zero
run is exactly the executable power of X dividing the polynomial.
Equations
- One or more equations did not get rendered due to their size.
Instances For
The integer leading coefficient reduced to the candidate prime field.
Equations
Instances For
The candidate prime does not divide the integer leading coefficient.
Equations
- Hex.leadingCoeffAdmissible f p = (f.leadingCoeffModP p ≠ 0)
Instances For
Executable test that a field-polynomial gcd is a unit.
DensePoly.gcd is the raw Euclidean representative, so over a field it may be
any nonzero constant associate of 1. In normalized dense representation,
nonzero constants are exactly the polynomials with one stored coefficient.
Equations
- Hex.gcdIsUnit g = (g.size == 1)
Instances For
The modular image is square-free according to the executable gcd-unit criterion.
Equations
- Hex.squareFreeModP f p = (Hex.gcdIsUnit (Hex.DensePoly.gcd (Hex.ZPoly.modP p f) (Hex.DensePoly.derivative (Hex.ZPoly.modP p f))) = true)
Instances For
Executable good-prime predicate for the Berlekamp-Zassenhaus computation.
It checks that the modulus is at least 3, that the integer leading coefficient
survives reduction modulo p, and that the modular image is square-free.
Equations
- Hex.isGoodPrime f p = (decide (3 ≤ p) && f.leadingCoeffModP p != 0 && Hex.gcdIsUnit (Hex.DensePoly.gcd (Hex.ZPoly.modP p f) (Hex.DensePoly.derivative (Hex.ZPoly.modP p f))))
Instances For
Compiled good-prime predicate using the inverse-cached finite-field GCD.
Equations
- Hex.isGoodPrimeImpl f p = (decide (3 ≤ p) && f.leadingCoeffModP p != 0 && Hex.gcdIsUnit ((Hex.ZPoly.modP p f).gcdCached (Hex.DensePoly.derivative (Hex.ZPoly.modP p f))))
Instances For
Proof-backed compiled implementation of good-prime testing that computes one leading-coefficient inverse per polynomial remainder pass.
Assemble the executable good-prime result from its three mathematical components.
The Berlekamp--Zassenhaus hot path uses the shared bundled prime supplied
by hex-mod-arith; it carries both the runtime modulus and its dependent
bounds and primality evidence.
Equations
Instances For
The committed table primes in [lo, hi), bundled with the bounds and
primality evidence required by ZMod64.
Equations
- One or more equations did not get rendered due to their size.
Instances For
The default small-prime prefix, represented by the committed table window
[3, 72).
Instances For
The remaining hot-path primes, represented by the committed table window
[72, 501).
Equations
Instances For
The direct planner's prime candidate list: the deterministic small-prime prefix
followed by every prime up to 499.
Instances For
Product of the fixed hot-path candidate primes.
Equations
- Hex.hotPathPrimorial = (List.map (fun (c : Hex.SmallPrimeCandidate) => c.m) Hex.hotPathCandidates).prod
Instances For
The fixed hot-path list contains no repeated prime values.
Soundness of the hot-path prime candidate list: every entry carries a
prime in the closed range [3, 500]. The primality conjunct is the structure
field; the bounds come from the two table windows.
Coerce an admissible nonzero modular image to its monic representative by
dividing by its leading coefficient. monicModularImage f = scale c⁻¹ f
where c = leadingCoeff f; the zero image maps to zero so the operation is
total.
Equations
Instances For
Normalizing a nonzero polynomial over a prime field produces a monic polynomial.
A nonzero FpPoly p translates to isZero = false.
monicModularImage of a nonzero polynomial is nonzero (it's a unit scalar of
the original).
monicModularImage is the identity on monic polynomials: dividing by a
leading coefficient of 1 is a no-op.
Multiplicativity of monicModularImage on nonzero polynomials. The leading
coefficient of a product is the product of leading coefficients (no-zero-divisors
over a prime field), so dividing both sides by their leading coefficients agrees
with dividing the product by its leading coefficient.
monicModularImage is multiplicative across Hex.Berlekamp.factorProduct
on lists of nonzero factors: pulling each factor through monicModularImage
before taking the product agrees with applying monicModularImage to the raw
product. Inductive consequence of monicModularImage_mul_of_nonzero plus
monicModularImage_eq_self_of_monic at the base case factorProduct [] = 1.
Return the sorted degrees of the Berlekamp factors of f mod p at an
explicit small prime supported by the executable prime-selection list.
This testing-facing surface deliberately reuses the production small-prime
computation. For complete linear splits, it records the explicit root-degree
evidence directly so pinned conformance checks are not sensitive to the current
Berlekamp witness splitting surface. It returns none if p is unsupported or
the leading coefficient vanishes modulo p; the Berlekamp branch also requires
the usual good-prime predicate.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Scan the fixed hot-path prime list and return the best admissible scored candidate, if any.
Equations
Instances For
Choose a small admissible prime for the Berlekamp-Zassenhaus computation.
The search is bounded to a fixed ascending list of small primes. Candidate scores use the currently available executable modular factor surface; strict score improvement replaces the incumbent, so equal scores keep the smaller earlier prime.
Instances For
Any score the hot-path walk returns records a prime that passes the
good-prime check for f.
When choosePrime returns the winning score's prime, that prime passes
the good-prime check for f.
A successful good-prime check certifies the modulus is at least three.
A successful good-prime check certifies leading-coefficient admissibility.
A successful good-prime check certifies the modular square-free precondition.
A successful good-prime check rules out a vanishing modular image: the leading
coefficient survives reduction modulo p, so the modular image retains at
least one stored coefficient.
leadingCoeffAdmissible forces the source polynomial to have at least one
stored coefficient: the empty coefficient array would force
leadingCoeffModP to vanish.
Under leadingCoeffAdmissible, the modular image is nonzero. Companion of
isGoodPrime_modP_isZero_false but with the weaker admissibility hypothesis
(no square-free or 3 ≤ p requirement).
Under leadingCoeffAdmissible, the modular image has the same size as the
input: the top coefficient survives reduction, so the trailing-zero trim does
nothing.
Under leadingCoeffAdmissible, the modular image has the same degree? as
the input.
Under leadingCoeffAdmissible, the leading coefficient of the modular
image matches leadingCoeffModP.