X^(p^k) - X reduced modulo f.
Equations
- Hex.Berlekamp.frobeniusDiffMod f hmonic k = f.frobeniusXPowMod hmonic k - f.modByMonic Hex.FpPoly.X hmonic
Instances For
Positive divisors of n below n, listed in ascending order.
These are the candidates from which Rabin's test extracts the maximal proper divisors.
Equations
- Hex.Berlekamp.properDivisors n = List.filter (fun (d : Nat) => decide (n % d = 0)) (List.map Nat.succ (List.range (n - 1)))
Instances For
true exactly when g is a nonzero constant polynomial.
Equations
- Hex.Berlekamp.isUnitPolynomial g = match Hex.DensePoly.degree? g with | some 0 => true | x => false
Instances For
Berlekamp's executable rank criterion: a nonconstant monic f passes when
rank(Q_f - I) = deg(f) - 1.
Equations
- Hex.Berlekamp.berlekampRankTest f hmonic = decide (0 < Hex.Berlekamp.basisSize f ∧ (Hex.Berlekamp.fixedSpaceMatrix f hmonic).rowReduce_rank = Hex.Berlekamp.basisSize f - 1)
Instances For
The divisibility leg of Rabin's criterion: f divides X^(p^n) - X, with
n = deg(f), exactly when the reduced remainder vanishes.
Equations
- Hex.Berlekamp.rabinDividesTest f hmonic = Hex.DensePoly.isZero (Hex.Berlekamp.frobeniusDiffMod f hmonic (Hex.Berlekamp.basisSize f))
Instances For
The gcd leg of Rabin's criterion at a single maximal proper divisor d of
deg(f).
Equations
- Hex.Berlekamp.rabinCoprimeTest f hmonic d = Hex.Berlekamp.isUnitPolynomial (Hex.DensePoly.gcd f (Hex.Berlekamp.frobeniusDiffMod f hmonic d))
Instances For
Record the per-divisor Rabin gcd checks so downstream factorization code can see which maximal proper divisor rejected a candidate polynomial.
Equations
- Hex.Berlekamp.rabinWitnesses f hmonic = List.map (fun (d : Nat) => (d, Hex.Berlekamp.rabinCoprimeTest f hmonic d)) (Hex.Berlekamp.maximalProperDivisors (Hex.Berlekamp.basisSize f))
Instances For
Self-describing certificate data for Rabin irreducibility checking.
The bezout array is indexed in the same order as maximalProperDivisors n.
Each witness proves coprimality of f and
X^(p^d) - X mod f by the executable identity
left * f + right * (X^(p^d) - X) = 1.
- p : Nat
The characteristic of the finite field.
- bounds : ZMod64.Bounds self.p
The modulus bound, carried so the certificate is self-describing.
- n : Nat
The degree claimed for the polynomial under test.
Successive Frobenius powers used by the Rabin checks.
- bezout : Array (RabinBezoutWitness self.p)
Bezout witnesses for the maximal proper divisors of
n.
Instances For
Read the certified X^(p^k) mod f witness, if present.
Instances For
Read the Bezout witness for the i-th maximal proper divisor, if present.
Instances For
Same-prime view of a self-contained certificate after its stored p has been
matched against the ambient field.
- n : Nat
The degree claimed for the polynomial under test.
Successive Frobenius powers used by the Rabin checks.
- bezout : Array (RabinBezoutWitness p)
Bezout witnesses for the maximal proper divisors of
n.
Instances For
Match a certificate's stored prime against the ambient p. Returns the
same-prime view on success, or none if the certificate is for a different
prime.
Equations
- One or more equations did not get rendered due to their size.
Instances For
The Rabin difference polynomial represented by a certificate pow-chain entry.
Equations
- Hex.Berlekamp.certifiedFrobeniusDiffMod f hmonic powWitness = powWitness - f.modByMonic Hex.FpPoly.X hmonic
Instances For
Check that a certificate's pow chain matches the committed Frobenius routine.
Equations
Instances For
Kernel-reducible pow-chain check for small closed polynomials. It checks the
same mathematical witnesses as checkPowChain, but compares against the
structural Frobenius evaluator so decide can reduce concrete certificates.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Check one Bezout witness for a Rabin maximal-proper-divisor leg.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Check all Bezout witnesses against maximalProperDivisors cert.n.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Executable checker for a Rabin irreducibility certificate.
It validates the self-described p and n, recomputes every pow-chain
entry, checks the divisibility leg X^(p^n) = X mod f, and verifies each
Bezout identity for the maximal proper divisors of n.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Kernel-reducible Rabin certificate checker. This is intended for small
record-literal polynomials where the theorem input
rabinTest f hmonic = true should be discharged by decide.
@[expose] because that is the whole point: without an exposed body, decide
in a downstream module file gets stuck on the unreduced application, and the
only way to discharge the check is a hand-written simp unfolding, which is
what this definition exists to avoid.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Rabin's executable irreducibility test: f must be nonconstant, divide
X^(p^n) - X, and be coprime to X^(p^d) - X for every maximal proper
divisor d of n = deg(f).
Equations
- Hex.Berlekamp.rabinTest f hmonic = (decide (0 < Hex.Berlekamp.basisSize f) && Hex.Berlekamp.rabinDividesTest f hmonic && (Hex.Berlekamp.rabinWitnesses f hmonic).all Prod.snd)
Instances For
Bezout witness that f and the Rabin difference X^(p^d) - X mod f are
coprime, computed by the extended Euclidean algorithm.
The extended gcd returns left₀ * f + right₀ * diff = g with g a nonzero
constant when the two are coprime; scaling both coefficients by g⁻¹ (as its
leading coefficient, i.e. its constant value) normalises the identity to
left * f + right * diff = 1, which is exactly the equation
checkRabinBezoutWitness verifies. This is compiled, never-in-kernel prep:
a wrong witness simply makes the downstream check return false.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Assemble a Rabin irreducibility certificate for the monic polynomial f, when
rabinTest accepts it.
The pow chain records X^(p^k) mod f for k = 0, …, deg f, matching
checkPowChain, and the Bezout array records one normalised
rabinBezoutWitness per maximal proper divisor of deg f, in the same order
as maximalProperDivisors, matching checkRabinBezoutWitnesses. Returns
none when f fails Rabin's test.
This is the prep half of the certifying-irreducibility pattern: the expensive
Frobenius-chain and extended-gcd work runs in compiled code here, so the kernel
only has to replay the cheap checkIrreducibilityCertificate reduction on the
finished data. The generator carries no soundness proof of its own; a wrong
certificate makes checkIrreducibilityCertificate return false, never a
false pass.
Equations
- One or more equations did not get rendered due to their size.
Instances For
berlekampRankTest succeeds exactly when the fixed-space matrix has rank
deg(f) - 1, the Berlekamp rank criterion.
rabinDividesTest reduces to checking that frobeniusDiffMod f _ n
vanishes, where n = deg(f).
If checkPowChain accepts, every entry cert.powChain[k] (for k ≤ cert.n)
agrees with the committed Frobenius routine FpPoly.frobeniusXPowMod.
Linear-kernel companion to checkPowChain_spec: if checkPowChainLinear
accepts, every entry agrees with FpPoly.frobeniusXPowMod, after rewriting
the structural Frobenius evaluator through
FpPoly.frobeniusXPowModLinear_eq_frobeniusXPowMod.
If checkIrreducibilityCertificate accepts a self-describing certificate,
the corresponding rabinTest succeeds. Downstream irreducibility soundness
(FpPoly.Irreducible) is then chained via
HexBerlekamp.RabinSoundness.rabinTest_imp_irreducible.
Kernel-reducible counterpart of checkIrreducibilityCertificate_rabinTest,
suited to decide-discharged certificates over small concrete polynomials.
The single-step recurrence: powChain[k+1] must equal
(powChain[k])^p mod f.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Kernel-reducible incremental pow-chain check. Validates that
powChain[0] = X mod f and that each successor is the previous entry's
p-th power modulo f. Total work is O(n · p) instead of O(Σ p^k).
Equations
- One or more equations did not get rendered due to their size.
Instances For
Quotient-witness checker for FpPoly 2 pow chains. Entry k of
quotients certifies
powChain[k] * powChain[k] = powChain[k+1] + quotients[k] * f, with both
chain entries already reduced modulo f.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Soundness of checkPowChainLinearIncrementalQuotientWitnessStep from
explicit chain and quotient entries: given powChain[k] = prev,
powChain[k+1] = curr, quotients[k] = quot, both entries reduced below
deg f, and the witnessed identity prev * prev = curr + quot * f on
coefficients, the checker returns true.
_of_entries restated with the two degree bounds and the coefficient
equality supplied as decide/== Booleans, matching the form the checker
itself evaluates.
A DensePoly whose coefficient size is at most n (with 0 < n) has
natDegree < n. Converts a coefficient-count bound into the degree
bound consumed by the quotient-witness step lemmas.
_of_entries restated with the two reducedness hypotheses replaced by
size bounds on the chain entries, discharged through
degree?_getD_lt_of_size_le.
Reinterpret the low width bits of bits as an FpPoly 2, with
coefficient i given by gf2BitCoeff bits i.
Equations
- Hex.Berlekamp.gf2WordPoly bits width = Hex.FpPoly.ofCoeffs (List.map (fun (i : Nat) => Hex.Berlekamp.gf2BitCoeff bits i) (List.range width)).toArray
Instances For
gf2WordPoly bits width has coefficient size at most width.
If width ≤ bound and 0 < bound, then
(gf2WordPoly bits width).natDegree < bound; the degree bound used
when feeding a bit-word polynomial to the witness step.
Coefficient i of gf2WordPoly bits width is gf2BitCoeff bits i when
i < width, and 0 otherwise.
true exactly when a and b agree on every coefficient 0 … bound-1;
the bounded executable prefix-equality check over List.range bound.
Equations
- Hex.Berlekamp.coeffsEqUpTo bound a b = (List.range bound).all fun (i : Nat) => Hex.DensePoly.coeff a i == Hex.DensePoly.coeff b i
Instances For
Bounded per-step quotient-witness test: prev * prev and curr + quot * f
agree on coefficients below bound.
Equations
- Hex.Berlekamp.quotientStepCoeffCheck bound prev curr quot f = Hex.Berlekamp.coeffsEqUpTo bound (prev * prev) (curr + quot * f)
Instances For
A passing coeffsEqUpTo yields coefficient equality on every index below
the bound.
If both polynomials have size at most bound and agree on coefficients
below bound, their full coefficient arrays are equal.
Upgrade a passing coeffsEqUpTo to full coefficient-array equality, given
that both polynomials have size at most bound.
A passing quotientStepCoeffCheck, with both sides bounded in size by
bound, certifies (prev * prev).coeffs = (curr + quot * f).coeffs.
quotientStepCoeffCheck specialised to GF(2) operands packed as UInt64
bit-words, decoded through gf2WordPoly.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Word-packed analogue of quotientStep_coeffs_eq_of_check: a passing
gf2WordQuotientStepCoeffCheck under the size bounds yields coefficient-array
equality of the decoded GF(2) polynomials.
Prefix-check entry point to checkRabinBezoutWitness: if the Bezout
combination left * f + right * diff agrees with 1 on every coefficient
up to bound (with both sides bounded by bound), the witness check
accepts. Used when the certifier carries a coeffsEqUpTo prefix comparison
rather than full polynomial equality.
Coefficient-equality entry point to checkRabinBezoutWitness: if the
Bezout combination left * f + right * diff has the same coefficient array
as 1, the witness check accepts.
Polynomial-equality entry point to checkRabinBezoutWitness: if the Bezout
combination left * f + right * diff equals 1 as a polynomial, the
witness check accepts. The terminal form the two coefficient-level entry
points reduce to.
Discharge the first-entry condition of
checkPowChainLinearIncrementalQuotientWitnesses from coefficient equality:
if powChain[0] has the same coefficient array as X mod f, then
powChain[0]? == some (X mod f).
Bool-valued variant of
checkPowChainLinearIncrementalQuotientWitnesses_first_of_coeffs: accepts
the first-entry condition from a == coefficient comparison that evaluates
to true.
Quotient-witness form of the incremental pow-chain check: validates the
chain size, that powChain[0] = X mod f, and every per-step witness via
checkPowChainLinearIncrementalQuotientWitnessStep. Avoids recomputing the
modular squarings by reading the quotients off the certificate.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Introduction rule for checkPowChainLinearIncrementalQuotientWitnesses:
assemble acceptance from the two size conditions, the first-entry condition,
and a per-step witness check for every k < cert.n.
Soundness of the quotient-witness chain check against the squaring-based
one: if checkPowChainLinearIncrementalQuotientWitnesses accepts, then so
does checkPowChainLinearIncremental. Each accepted quotient witness
prev * prev = curr + quot * f (both entries reduced) pins
curr = powModMonicLinear prev f _ 2, recovering the step recurrence.
Incremental Rabin certificate checker, suitable for (p, n) regimes where
p^n is too large for checkIrreducibilityCertificateLinear but n · p
remains in budget (e.g. (5, 6) or (7, 6)).
Equations
- One or more equations did not get rendered due to their size.
Instances For
Incremental companion to checkPowChain_spec: if
checkPowChainLinearIncremental accepts, every entry agrees with
FpPoly.frobeniusXPowMod. The proof inducts on k, using the chain
identity X^(p^(k+1)) ≡ (X^(p^k))^p (mod f).
Incremental counterpart of checkIrreducibilityCertificate_rabinTest,
suited to (p, n) regimes where the per-step O(n · p) cost fits the
decide kernel budget but the bulk O(Σ p^k) of the non-incremental
checker does not.
The incremental kernel checker implies the committed checker: a certificate
accepted by checkIrreducibilityCertificateLinearIncremental is accepted by
checkIrreducibilityCertificate. This lets kernel-replayed certificates feed
consumers stated over the committed checker without restating their soundness.