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 be a finite field with elements and let be monic of degree (line L1 makes the input monic; this does not change irreducibility). Let be the set of prime divisors of .
Lemma. For every , is the product of all monic irreducible polynomials in whose degree divides , each taken once.
Proof. Let .
(a) is square-free. Its derivative is , because in . So , and a repeated factor would give , which is impossible.
(b) Each monic irreducible of degree divides . The ring is a field with elements. Its nonzero elements form a group of order , so for every . Applying this times gives . For this says .
(c) Each monic irreducible has degree dividing . Let and , with , so . The map is a ring homomorphism of (the binomial coefficients for are divisible by the characteristic) that fixes , because for by the group order argument of (b). The set is therefore closed under addition and multiplication and contains and ; every element of is a polynomial in with coefficients in , so is the identity on . Let be the least with . Then by (b), and , because every element of is a root of , a polynomial with at most roots in the field , and has elements. So , and gives : write with ; then , so .
By unique factorization in and (a), (b), (c), is the stated product.
The loop. Line L3 sets . By induction, after line L5 in pass , : raising to the power commutes with reduction modulo , since . Line L6 is true exactly when for a prime , and then line L7 tests , because when . Line L8 tests . So the algorithm returns true exactly when
- , and
- for every prime .
If is irreducible, both conditions hold. Condition 1 is part (b) of the lemma with . For condition 2, is a monic divisor of the irreducible , so it is or . If it were , then , and by part (c), , which is false for . So the gcd is .
If both conditions hold, is irreducible. By condition 1 and the lemma, is a product of distinct monic irreducible polynomials whose degrees divide . Suppose is reducible; then one of these factors, , has degree with . Then has a prime divisor , and . By part (b) of the lemma with , , so divides , which contradicts condition 2.
The implementation works over the prime field, .