Documentation

CslibFrontier.Algorithms.Algebra.CantorZassenhaus

Characteristic-Independent Cantor–Zassenhaus Finite-Field Root Finding #

This module implements randomized finite-field root finding via the degree-one specialization of Cantor–Zassenhaus splitting over an arbitrary finite field F (of either odd or even characteristic). Polynomials are represented as little-endian coefficient lists (Polynomial.CoeffList), and randomness is modeled as a Cslib.ProbComp computation drawing uniform field elements via Cslib.ProbComp.uniform F.

Given a coefficient list p : List F representing a nonzero univariate polynomial of degree at most d over a finite field F of cardinality q = Fintype.card F:

  1. Linear squarefree part (linearPartCL): computes g₀ = gcd(p, X^q - X mod p) using binary modular exponentiation (powModCL), isolating the squarefree product of distinct linear factors X - r (r ∈ F) and discarding irreducible factors of degree greater than 1 as well as root multiplicities ([vonZurGathenGerhard2013], §14.5).
  2. Degree-one characteristic-independent splitting (czSplitPoly, czRefineList): specializes equal-degree splitting to degree 1:
    • In odd characteristic (q % 2 = 1), splits factors using (X - a)^((q - 1)/2) - 1 mod g for a uniform a ∈ F ([Rabin1980b]; [CantorZassenhaus1981]; [vonZurGathenGerhard2013], §§14.3 and 14.5).
    • In characteristic 2 (q = 2^m with m = Nat.log 2 q), splits factors using the Frobenius trace polynomial ∑_{k < m} (a * X)^(2^k) mod g (tracePolyModCL) for a uniform a ∈ F ([vonZurGathenGerhard2013], Exercise 14.16). In both regimes, each independent uniform sample a ∈ F separates any fixed pair of distinct roots r₁ ≠ r₂ with probability at least 1 / 3 (at least 1 / 2 in characteristic 2 and (q - 1) / (2 * q) ≥ 1 / 3 for all odd prime powers q ≥ 3).
  3. Fixed-round sampling schedule & root extraction (czLoopFacs, extractLinearRoots, findRootsCZ): instead of a Las Vegas loop that retries until all factors are linear, findRootsCZ rounds p executes a fixed budget of rounds synchronous refinement rounds—making 0 queries and returning [] immediately when g₀.length ≤ 1, and otherwise drawing one uniform element a ← ProbComp.uniform F per round and applying it to every current factor of length greater than 2. Afterward, extractLinearRoots reads -c₀ / c₁ from each length-2 factor and drops any unsplit factors of degree at least 2.

Scope and guarantees #

This module delivers finite-field root finding (degree-one factors only); it does not return general equal-degree factors of degree greater than 1.

Main definitions #

Main results #

References #

@[irreducible]

Binary modular exponentiation base ^ e mod m on polynomial coefficient lists.

powModCL base e m represents (ofCoeffList base) ^ e % ofCoeffList m.

Trace polynomial ∑_{k=0}^{m-1} (a * X)^(2^k) mod g for characteristic-2 degree-one splitting ([vonZurGathenGerhard2013], Exercise 14.16).

Squarefree linear-factor part gcd(p, X^q - X mod p) of a univariate coefficient list p ([vonZurGathenGerhard2013], §14.5).

One degree-one Cantor–Zassenhaus splitting polynomial given field cardinality q and sample a : F: (X - a)^((q - 1)/2) - 1 mod g when q is odd ([Rabin1980b], [CantorZassenhaus1981], [vonZurGathenGerhard2013] §§14.3, 14.5), and the Frobenius trace polynomial tracePolyModCL (Nat.log 2 q) a g when q is even ([vonZurGathenGerhard2013], Exercise 14.16).

def Cslib.Algorithms.Algebra.CantorZassenhaus.czRefineList {F : Type u} [Field F] [DecidableEq F] (q : ℕ) (a : F) (factors : List (List F)) :

Refine a list of squarefree linear-splitting factors using one sample a : F.

Each factor g of length at most 2 is kept as is. For a factor g of length greater than 2, computes h = gcd(g, czSplitPoly q a g) and splits g into [h, g / h] when 1 < h.length and h.length < g.length, or retains [g] otherwise.

Extract the unique root -c₀ / c₁ from every linear (length-2) factor in a list, dropping factors of any other length.

Run r synchronous rounds of Cantor–Zassenhaus factor refinement, drawing one uniform sample from ProbComp.uniform F per round and applying czRefineList to the current factor list.

noncomputable def Cslib.Algorithms.Algebra.CantorZassenhaus.findRootsCZ {F : Type} [Field F] [DecidableEq F] [Fintype F] (rounds : ℕ) (p : List F) :

Fixed-round Cantor–Zassenhaus finite-field root finder over a finite field F.

Extracts the squarefree linear part g₀ = linearPartCL (Fintype.card F) p = gcd(p, X^q - X mod p) (discarding irreducible factors of degree greater than 1), runs rounds synchronous refinement rounds with one uniform draw from ProbComp.uniform F per round (or zero draws if g₀.length ≤ 1), and returns the roots extracted from all resulting linear factors.

findRootsCZ issues at most rounds uniform queries (one ProbComp.uniform F draw per refinement round, or zero when linearPartCL (Fintype.card F) p has length at most 1). This counts uniform samples only and makes no claim about algebraic operation count or running time.

theorem Cslib.Algorithms.Algebra.CantorZassenhaus.findRootsCZ_sound {F : Type} [Field F] [DecidableEq F] [Fintype F] (rounds : ℕ) (p : List F) {roots : List F} (hmem : roots ∈ (findRootsCZ rounds p).eval.support) (r : F) :

Soundness of findRootsCZ: every element in any supported output is a root of ofCoeffList p in F.

theorem Cslib.Algorithms.Algebra.CantorZassenhaus.findRootsCZ_complete {F : Type} [Field F] [DecidableEq F] [Fintype F] {d : ℕ} (rounds : ℕ) (p : List F) (hp : Polynomial.ofCoeffList p ≠ 0) (hdeg : (Polynomial.ofCoeffList p).natDegree ≤ d) :
(findRootsCZ rounds p).eval.toOuterMeasure {roots : List F | ∃ (r : F), Polynomial.eval r (Polynomial.ofCoeffList p) = 0 ∧ r ∉ roots} ≤ ↑d ^ 2 * (2 / 3) ^ rounds

Completeness of findRootsCZ: if ofCoeffList p ≠ 0 has degree at most d, then the probability that findRootsCZ misses at least one F-root is at most d^2 * (2 / 3)^rounds.