6

We've got Fermat's primality test to test if a number is probable prime. Is there an analogous test for polynomials in $\mathbb{F}_{p^n}[X]$ and irreducibility?

0xbadf00d
  • 13,422
  • If $f\in\Bbb{F}_p[x]$ is of degree $m$, then a necessary condition for primality is that $x^{p^m}\equiv x\pmod f$. This is fast to test, but gives less useful evidence than the Fermat test in $\Bbb{Z}$ (read: it is much easier to find false positives). – Jyrki Lahtonen Jul 01 '14 at 18:39
  • @JyrkiLahtonen What about $f\in\mathbb{F}_{p^n}$[X]? – 0xbadf00d Jul 01 '14 at 18:44
  • The same works. If $f\in\Bbb{F}_q[x]$, $q=p^n$, $\deg f=m$, then if $f$ is irreducible we must have $f\mid x^{q^m}-x$. BUT, this test only tells you that all the factors of $f$ are simple and of degrees that are factors of $m$ - plenty of false positives. It may occasionally be useful in conclusively proving that a polynomial is NOT irreducible (such as Fermat's test). – Jyrki Lahtonen Jul 01 '14 at 18:50
  • @JyrkiLahtonen When do you call a factor (polynomial) "simple"? – 0xbadf00d Jul 01 '14 at 18:54
  • If it is not a multiple factor, i.e. when its square does not divide $f$. I may have used the wrong term there? Anyway, $x^{q^m}-x$ has no multiple factors, because it has no common factors with its derivative $-1$. Therefore no $f$ divisible by the square of any polynomial will pass this test. – Jyrki Lahtonen Jul 01 '14 at 19:00

2 Answers2

3

Part of the point of Fermat's primality test is that $n$ is prime if and only if $\mathbb{Z}/(n)$ is a field. When the latter is a field, its multiplicative group has order $n - 1$, so any representative from ${1,\dots,n-1}$ should have order dividing $n - 1$ mod $n$.

Analogously, a polynomial $f \in \mathbb{F}_q[x]$ ($q = p^n$) is irreducible if and only if the ring $\mathbb{F}_q[x]/(f)$ is a field. The latter has order $q^m$, with a unique set of representatives being given by the polynomials of degree strictly less than $m$ (thanks to the Euclidean algorithm). So if it's a field, then its multiplicative group has order $q^m - 1$, and the order of every element divides this value. (Notice that every nonzero constant polynomial has order $q-1 = |\mathbb{F}_q^*|$, which divides $q^m - 1$, so there would be no need to test these.)

Thus it seems to me that the best analogue for Fermat's primality test would be:

  • Randomly choose a polynomial $a(x) \in \mathbb{F}_q[x]$ with $\deg(a)\in \{1,\dots,m-1\}$.
  • If $a^{q^m-1} \not\equiv 1 \pmod{f}$, meaning $f \nmid (a^{q^m-1}-1)$, then $f$ is composite.
Manny Reyes
  • 2,992
  • Could you give an example of a false positive of your test? – 0xbadf00d Jul 01 '14 at 19:54
  • 1
    @oxbadfood: Because $q^2-1\mid q^4-1$, if $f=gh$ for two distinct quadratic irreducible polynomials $g,h$, then $f$ will pass this test for any $a$ such that $a$ is not divisible by either $g$ or $h$. Proof: Chinese remainder theorem. Conclusion: False positives are easier to find here than in $\Bbb{Z}$. – Jyrki Lahtonen Jul 01 '14 at 20:05
  • @JyrkiLahtonen Could you give a concrete example for $g,h$ and $\alpha$ – 0xbadf00d Jul 01 '14 at 20:10
  • 1
    @JyrkiLahtonen Thank you for the example! I assume that the strongest sort of "false positive" would be a polynomial $f$ such that every $a(x)$ with strictly smaller degree satisfies $f \mid (a^{q^m-1}-1)$ (analogous to Carmichael numbers). I don't know of any such examples right now. – Manny Reyes Jul 01 '14 at 20:35
  • Still not sure if I've understand what you mean: If $f$ is irreducible, $\mathbb{K}:=\mathbb{F}[X]/(f)$ is a field of order $q^m$ for some $m$ (maybe we can say more about $m$, maybe it's equal to $\deg f$). Since $\mathbb{K}$ is a field, its multiplicative group is cyclic of order $q^m-1$. Since $\mathbb{K}^\times$ is cyclic every element can be written in the form $\alpha^k$ for some generator $\alpha\in\mathbb{K}^\times$. Moreover, every element is of order $q^m-1$. So, I still don't understand why $f\nmid \alpha^{q^m-1}-1$ yields that $f$ is composite – 0xbadf00d Jul 01 '14 at 20:41
  • 1
    @oxbadfood Don't think of $a \in \mathbb{K}^\times$ as a cyclic generator, think of it as an arbitrary element. Then since $\mathbb{K}$ is a field, it must be the case that $a^{q^m-1} = 1$ in $\mathbb{K}$. Thus if the congruence fails, it must be the case that $\mathbb{F}[x]/(f)$ is not a field, so that $f$ is not irreducible. – Manny Reyes Jul 01 '14 at 20:54
  • @MannyReyes Okay, so it's mostly related to the fact, that every element is of order $q^m-1$. I'm still looking for an easy example for a false positive - nothing fancy needed (for the beginning). – 0xbadf00d Jul 01 '14 at 21:02
  • @JyrkiLahtonen You mentioned false positives are easier to find here. However, I'm unable to find one at all. Could you please give a simple example? – 0xbadf00d Jul 01 '14 at 22:47
  • @0xbadf00d, read the proof of Korselt's criterion for Carmichael numbers and check it carries through to $\mathbf F_q[x]$ for any finite field $\mathbf F_q$: calling $f \in \mathbf F_q[x]$ "Carmichael" if $f$ is reducible and $a^{{\rm N}(f)-1} \equiv 1 \bmod f$ for all $a \in \mathbf F_q[x]$ relatively prime to $f$, where ${\rm N}(f) = q^{\deg f}$, a reducible $f$ is Carmichael iff it's squarefree and for any irreducible $\pi$ dividing $f$ we have $({\rm N}(\pi)-1)\mid ({\rm N}(f)-1)$. In particular, a product of two or more monic irreducibles of the same degree is Carmichael, as Jyrki wrote. – KCd Jul 18 '15 at 15:13
  • @0xbadf00d, can't you find examples yourself of different monic irreducibles of the same degree in some $\mathbf F_q[x]$ to check numerically that their product is a false positive? – KCd Jul 18 '15 at 15:14
1

Yes, over finite fields there is a polynomial irreducibility test that is an an efficient analog of the impractical Pocklington-Lehmer integer primality test (see also Section 3.4.3 and Section 8.3.1 of Henri Cohen's book A Course in Computational Algebraic Number Theory). Below is a description of one form of this algorithm, from this Wikipedia page.

enter image description here

Bill Dubuque
  • 272,048
  • Do I read correctly that this is based upon a necessary and sufficient condition for irreducibility (unlike Fermat's primality test)? Very nice, thank you for sharing! – Manny Reyes Jul 01 '14 at 21:00
  • @Manny Yes, for both the polynomial and integer tests. The classical proofs are quite elementary, e.g. see Cohen's book (the links are to the exact pages). – Bill Dubuque Jul 01 '14 at 21:21