Algorithm Search⌘K

Proofs: Rabin's irreducibility test

These are the human proofs of Rabin's irreducibility test, at full length.

Rabin's test accepts exactly the irreducible polynomials over a finite field full

This proof shows: correctness.

Let Fq\mathbb{F}_q be a finite field with qq elements and let f∈Fq[x]f \in \mathbb{F}_q[x] be monic of degree n≥1n \ge 1 (line L1 makes the input monic; this does not change irreducibility). Let PP be the set of prime divisors of nn.

Lemma. For every m≥1m \ge 1, xqm−xx^{q^m} - x is the product of all monic irreducible polynomials in Fq[x]\mathbb{F}_q[x] whose degree divides mm, each taken once.

Proof. Let u=xqm−xu = x^{q^m} - x.

(a) uu is square-free. Its derivative is qmxqm−1−1=−1q^m x^{q^m - 1} - 1 = -1, because q=0q = 0 in Fq\mathbb{F}_q. So gcd⁡(u,u′)=1\gcd(u, u') = 1, and a repeated factor g2∣ug^2 \mid u would give g∣u′g \mid u', which is impossible.

(b) Each monic irreducible gg of degree d∣md \mid m divides uu. The ring K=Fq[x]/(g)K = \mathbb{F}_q[x]/(g) is a field with qdq^d elements. Its nonzero elements form a group of order qd−1q^d - 1, so βqd=β\beta^{q^d} = \beta for every β∈K\beta \in K. Applying this m/dm/d times gives βqm=β\beta^{q^m} = \beta. For β=x mod g\beta = x \bmod g this says g∣xqm−xg \mid x^{q^m} - x.

(c) Each monic irreducible g∣ug \mid u has degree dividing mm. Let d=deg⁡gd = \deg g and K=Fq[x]/(g)K = \mathbb{F}_q[x]/(g), with α=x mod g\alpha = x \bmod g, so αqm=α\alpha^{q^m} = \alpha. The map φ(β)=βq\varphi(\beta) = \beta^q is a ring homomorphism of KK (the binomial coefficients (qi)\binom{q}{i} for 0<i<q0 < i < q are divisible by the characteristic) that fixes Fq\mathbb{F}_q, because cq=cc^q = c for c∈Fqc \in \mathbb{F}_q by the group order argument of (b). The set {β:φm(β)=β}\{\beta : \varphi^m(\beta) = \beta\} is therefore closed under addition and multiplication and contains Fq\mathbb{F}_q and α\alpha; every element of KK is a polynomial in α\alpha with coefficients in Fq\mathbb{F}_q, so φm\varphi^m is the identity on KK. Let tt be the least j≥1j \ge 1 with φj=id\varphi^j = \mathrm{id}. Then t≤dt \le d by (b), and t≥dt \ge d, because every element of KK is a root of xqt−xx^{q^t} - x, a polynomial with at most qtq^t roots in the field KK, and KK has qdq^d elements. So t=dt = d, and φm=id\varphi^m = \mathrm{id} gives d∣md \mid m: write m=sd+rm = s d + r with 0≤r<d0 \le r < d; then φr=φm(φd)−s=id\varphi^r = \varphi^m (\varphi^{d})^{-s} = \mathrm{id}, so r=0r = 0.

By unique factorization in Fq[x]\mathbb{F}_q[x] and (a), (b), (c), uu is the stated product. □\square

The loop. Line L3 sets h=x mod fh = x \bmod f. By induction, after line L5 in pass jj, h=xqj mod fh = x^{q^j} \bmod f: raising to the power qq commutes with reduction modulo ff, since (a mod f)q≡aq(modf)(a \bmod f)^q \equiv a^q \pmod f. Line L6 is true exactly when j=n/rj = n / r for a prime r∈Pr \in P, and then line L7 tests gcd⁡(xqn/r−x,f)=1\gcd(x^{q^{n/r}} - x, f) = 1, because gcd⁡(h−x,f)=gcd⁡(xqn/r−x,f)\gcd(h - x, f) = \gcd(x^{q^{n/r}} - x, f) when h≡xqn/r(modf)h \equiv x^{q^{n/r}} \pmod f. Line L8 tests xqn≡x(modf)x^{q^n} \equiv x \pmod f. So the algorithm returns true exactly when

  1. f∣xqn−xf \mid x^{q^n} - x, and
  2. gcd⁡(xqn/r−x,f)=1\gcd(x^{q^{n/r}} - x, f) = 1 for every prime r∣nr \mid n.

If ff is irreducible, both conditions hold. Condition 1 is part (b) of the lemma with m=nm = n. For condition 2, gcd⁡(xqn/r−x,f)\gcd(x^{q^{n/r}} - x, f) is a monic divisor of the irreducible ff, so it is 11 or ff. If it were ff, then f∣xqn/r−xf \mid x^{q^{n/r}} - x, and by part (c), n∣n/rn \mid n/r, which is false for r≥2r \ge 2. So the gcd is 11.

If both conditions hold, ff is irreducible. By condition 1 and the lemma, ff is a product of distinct monic irreducible polynomials whose degrees divide nn. Suppose ff is reducible; then one of these factors, gg, has degree d<nd < n with d∣nd \mid n. Then n/d>1n / d > 1 has a prime divisor rr, and d∣n/rd \mid n / r. By part (b) of the lemma with m=n/rm = n / r, g∣xqn/r−xg \mid x^{q^{n/r}} - x, so gg divides gcd⁡(xqn/r−x,f)\gcd(x^{q^{n/r}} - x, f), which contradicts condition 2.

The implementation works over the prime field, q=pq = p. ■\blacksquare

Back to Rabin's irreducibility test