Counting solutions mod p of a polynomial equation

Hello: Does somebody know if the following is true?: Let $f\in \mathbb{Z}[X]$ be a monic irreducible polynomial of degree $n$. Then there exists a positive integer $N$ and $a_0,a_1,\ldots,a_{N-1}\in\{0,1,\ldots,n\}$ such that if $p$ is a prime such that $p\equiv k\mod N$, then the reduction of $f$ mod $p$ has exactly $a_k$ roots in $\mathbb{F}_p$ (counting with multiplicities).

• While it is true for quadratics (presumably the motivation for your question) and I believe for cyclotomic polynomials as well, I suspect it's false in general, and perhaps false for every noncyclotomic monic irreducible polynomial of degree at least 3. A proof might use Galois theory and the Chebotarev density theorem to show that every residue class $k\mod N$ contains primes modulo which $f$ has different possible numbers of roots. – Greg Martin Jun 29 '14 at 5:50
• @Greg: that claim is too strong; the statement is true for any polynomial whose roots lie in a cyclotomic field. – Qiaochu Yuan Jun 29 '14 at 6:05

This is false. The factorization of $f \bmod p$ is describable by congruence conditions on $p$ (with finitely many exceptions) iff the splitting field of $f$ is abelian (in one direction by the Kronecker-Weber theorem, and I'm not sure about the other direction but I think the Chebotarev density theorem is involved).
The smallest counterexamples are irreducible cubics with Galois group $S_3$; their splitting behavior can (sometimes?) be described in terms of coefficients of modular forms instead (coming from the Langlands program). For example, as Matthew Emerton describes here, the behavior of $x^3 - x - 1 \bmod p$ is controlled by the coefficient of $q^p$ in the modular form
$$q \prod_{n \ge 1} (1 - q^n)(1 - q^{23n}).$$
• What is true is that each possible degree sequence for the factorization of $f \bmod p$ occurs with density an integer multiple of $\frac{1}{|G|}$ (possibly zero), $G$ the Galois group; this is a consequence of the Chebotarev density theorem, but it also follows from the simpler Frobenius density theorem. – Qiaochu Yuan Jun 29 '14 at 6:18