When does $f(x) = g(x)$ for all $x$ imply $f=g$ for polynomials $f$ and $g$? Let $R = k[x_1, x_2, \dots, x_n]$ for some field $k$ and $n \in \mathbb{N}$. Suppose I have two polynomials $f, g \in R$ which satisfy $f(x) = g(x) \forall x \in k^n$. Under which conditions can we conclude that $f$ and $g$ are equal not only as functions, but as elements of $R$?
I know that the property I am looking for is equivalent to demanding that the ideal $I := \{ f \in R \vert f(x) = 0 \forall x \in k^n \}$ be the zero ideal.
 A: Given a commutative ring $R$, we always have a well-defined ring-homomorphism $\phi\colon R[x]\to R^R$, where $R^R$ is the ring of all functions $R\to R$ with pointwise addition and multiplication, given by mapping $p(x)\in R[x]$ to the function $p\colon R\to R$ that sends $a$ to $p(a)$.
Theorem. Let $R$ be an integral domain. The morphism $\phi$ is one-to-one if and only if $R$ is infinite.
Proof. Let $K$ be the field of quotients of $R$.
Assume first that $R$ is infinite, and that $p\in\ker(\phi)$. Then $p(x)$, viewed as an element of $K[x]$, has at least $|R|$ roots; since $R$ is infinite and $K$ is a field, the Factor Theorem and the fact that $K[x]$ is a UFD yield that $p(x)=0$. Thus, $\phi$ is one-to-one.
Conversely, assume that $R$ is finite. Then $K$ is finite of order $p^r$ for some $k$. By Lagrange's Theorem, we know that for every $a\in K$, if $a\neq 0$ then $a^{p^{r}-1} = 1$. Thus, every element of $K$ is a root of $q(x)=x^{p^r}-x$. In particular, $q\in\ker(\phi)$, but $q\neq 0$. Thus, $\phi$ is not one-to-one. $\Box$
Corollary. Let $n\geq 1$, $k$ be a field, and let $R=k[x_1,\ldots,x_n]$. Now let $\phi\colon R\to k^{k^n}$ be the morphism from $R$ to the ring of all functions from $k^n$ to $k$ (with pointwise addition and multiplication) given by $\phi(p)(a_1,\ldots,a_n) = p(a_1,\ldots,a_n)$. Then $\phi$ is one-to-one if and only if $k$ is infinite.
Proof. If $k$ is finite of order $p^r$, then $p(x_1,\ldots,x_n) = x_1^{p^r}-x_1$ has $\phi(p)(a_1,\ldots,a_n) = 0$ for all $(a_1,\ldots,a_n)\in k^n$, but $p\neq 0$. Thus, $\phi$ is not one-to-one.
Conversely, assume that $k$ is infinite, and let $p(x_1,\ldots,x_n)\neq 0$. If $p$ is constant, then clearly $\phi(p)$ is not the zero function, so it does not lie in $\ker(\phi)$. Thus, we may assume that $p$ has positive degree in at least one of the variables, and without loss of generality say it has  positive degree in $x_1$. That is, we can write $p(x_1,\ldots,x_n)$ as $q(x_1)$, with $q\in S[x_1]$, where $S=k[x_2,\ldots,x_n]$. Say
$$q(x_1) = p_s(x_2,\ldots,x_n)x_1^s + \cdots + p_1(x_2,\ldots,x_n)x_1 + p_0(x_2,\ldots,x_n),$$
where $p_s(x_2,\ldots,x_n)\neq 0$. Arguing inductively, we know that there exist $(a_2,\ldots,a_n)\in k^{n-1}$ such that $p_s(a_2,\ldots,a_n)\neq 0$. In particular, $p(x_1,a_2,\ldots,a_n)$ is a nonzero polynomial in $x_1$ of degree $s\gt 0$.
By the Theorem above, we know that there exists $a_1\in k$ at which this polynomial is not equal to $0$. Thus, there is an $n$-tuple $(a_1,\ldots,a_n)$ such that $p(a_1,\ldots,a_n)\neq 0$, proving that $\phi(p)\neq 0$. Thus, $\ker(\phi) = \{0\}$, proving that $\phi$ is one-to-one. $\Box$
A: If $k$ is finite, then $x_1^{|k|}$ and $x_1$ are polynomials which take equal values.
Now assume $k$ is infinite.
Prove by induction on $n$ that if $k$ is an infinite field and $p\in k[x_1,\dots,x_n]$ has the the property that $p(v)=0$ for all $v\in k^n$ that $p=0.$
For $n=1,$ this is a result that a non-zero polynomial of one variable over a field can only have finitely many roots.
General case: Write $$p=\sum_{j=0}^m p_jx_n^{j}$$ with each $p_j\in k[x_1,\dots,x_{n-1}].$ $p=0$ iff $p_j=0$ for all $j.$ So if $p\neq 0,$ then some $p_j\neq 0.$ Then the by induction, there are values such that $p_j(v_1,\dots,v_{n-1})\neq 0.$
But then $q(x_n)=p(v_1,\dots,v_{n-1},x_n)$ is a non-zero polynomial in one variable, so $q(v_n)$ can’t be zero for all $v_n\in k.$ Pick $v_n$ so that $q(v_n)\neq 0.$ Then $p(v_1,\dots,v_n)=q(v_n)\neq 0.$

Note this proves the case that $p_1,p_2\in R$ has $p_1(v)=p_2(v)$ for all $v\in k^n$ since $p=p_1-p_2$ would be a polynomial always zero and thus   the above shows (if $k$ is infinite) that $p_1-p_2=0,$ or $p_1=p_2.$
