polynomials and symmetric functions 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.
 A: 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}}$.
A: I think, yes by some boring reasons. At first, we may suppose that $k=2$. Indeed, this partial case implies (if we take all but two $r_i$'s integer) that polynomial is symmetric in any two variables. For $k=2$ we may subtract from $f$ some symmetric polynomial and get a polynomial with monomials $x_1^{a}x_2^b$ only for $b>a$. Now fix integer value of $x_1x_2$ and choose $x_2$ very close to 0.
A: I would argue this way. For $k=2$  it's true. For general $k$ and $f$, and for any choice of $k-2$ integers $m_1,\dots,m_{k-2}$, the two variables polynomial  $f(x_1 ,x_2, m_1,m_2, \dots,m_{k-2})$ is symmetric in $(x_1,x_2)$ because of the case $k=2$. But since this is true for any $m_1,\dots,m_{k-2}$, this implies $f(x_1,x_2,x_3\dots, x_k)=f(x_2,x_1,x_3\dots, x_k)$. The same for any other transposition of a pair of variables $x_i,x_j$.
edit. Details on the last implication. Writing $f(x_1,x_2,\dots, x_k)=\sum_{ij}f_{ij}(x_3,\dots,x_k)x_1^ix_2^j$,  the two variables case implies
that for any $(i,j)$ the $(k-2)$-variables polynomial  $f_{ij}-f_{ji}$ vanishes 
on $\mathbb{Z}^{k-2}$, so it is the zero polynomial.
