TITLE: polynomials and symmetric functions
QUESTION [8 upvotes]: Suppose I have a polynomial function $f\in \mathbb{Z}[x_1, \dotsc, x_k],$ such that whenever $r_1, \dotsc, r_k$ are roots of a monic polynomial of degree $k$ with integer coefficients, we have $f(r_1, \dotsc, r_k) \in \mathbb{Z}.$ Is it true that $f$ is a symmetric function of its arguments?
Note: this was asked on MSE, but only resulted in an inconclusive discussion with Qiaochu...
EDIT Fedor Petrov's argument certainly answers the question quite elegantly, but I was thinking of the case where $r_1\dotsc, r_k$ are roots of an irreducible polynomial, so the reduction to $k=2$ is not quite so obvious. If there is an argument in that setting as well, that would be very much of interest.

REPLY [9 votes]: Consider the minimal polynomial $P$ of $f$ over the fixed field
$\mathbb Q(\sigma_1, \ldots, \sigma_k) = \mathbb Q(x_1, \ldots, x_k)^{S_k}$
(where the $\sigma_j$ are the elementary symmetric polynomials), so
$P$ is irreducible and $P(f) = 0$. Since $f$ is a polynomial,
the coefficients of $P$ will actually be polynomials in the $\sigma_j$.
By the Hilbert Irreducibility Theorem, $P$ will
remain irreducible when we specialize $\sigma_1, \ldots, \sigma_k$
to rational numbers, outside a thin set of such $k$-tuples.
But the set of $k$-tuples corresponding to $(x_1, \ldots, x_k)$ forming
a Galois orbit is not thin (its complement is thin: it consists of the
points $(a_1, \ldots, a_k)$ such that
$h(T) = T^k - a_1 T^{k-1} + \ldots \pm a_k$
is reducible; this set can be written as a finite union of images
of $\mathbb Q$-rational points under dominant morphisms that correspond
to the various possibilities of factoring $h$).
So there are (plenty of) integer (see this Wikipedia entry)
specializations $\boldsymbol{a}$ with irreducible $h$ such that the specialized $P_{\boldsymbol{a}}$
is irreducible. But by assumption, $P_{\boldsymbol{a}}$
has a rational root (since
$f$ evaluated at the roots $\boldsymbol{r}$ of $h$ is an integer):
$P_{\boldsymbol{a}}(f(\boldsymbol{r})) = 0$.
So $P$ must have degree 1,
and $f$ is in $\mathbb Q[\sigma_1, \ldots, \sigma_k]$.
In more detail: Write
$$P(X) = X^n + p_{n-1}(\sigma_1, \ldots, \sigma_k) X^{n-1} + \ldots + p_0(\sigma_1, \ldots, \sigma_k) .$$
Then there are integers $\boldsymbol{a} = (a_1, \ldots, a_k)$
such that $h_{\boldsymbol{a}} = T^n - a_1 T^{n-1} + \ldots \pm a_k$
is irreducible and
$$P_{\boldsymbol{a}}(X) = X^n + p_{n-1}(a_1, \ldots, a_k) X^{n-1} + \ldots + p_0(a_1, \ldots, a_k) \in {\mathbb Q}[X]$$
is also irreducible. Let $\boldsymbol{r} = (r_1, \ldots, r_k)$ be
the roots of $h_{\boldsymbol{a}}$.
Then $f(\boldsymbol{r}) = m \in \mathbb Z$. On the other hand,
$\sigma_j(\boldsymbol{r}) = a_j$, so
$$0 = P_{\boldsymbol{a}}(f(\boldsymbol{r}))
 = m^n + p_{n-1}(\boldsymbol{a}) m^{n-1} + \ldots + p_0(\boldsymbol{a}),$$
i.e., $m$ is a root of the irreducible polynomial $P_{\boldsymbol{a}}$.