This is a basic question about polynomial rings, but I can't find the precise proof of the following fact.
Theorem: Let $f, g $ be two polynomials in $\mathbb{R}[\overline x]$, where $\mathbb{R}$ are the reals and $\overline x = (x_1,\dots,x_n)$. Assume that $f(\overline a) = g(\overline a)$, for all $\overline a\in\mathbb{R}^n$. Prove that $f = g $ as formal polynomials (i.e., the coefficient vector of their monomials is the same).
Comment: over finite fields this is not necessarily the case. E.g., $x^2-x$ is not the zero polynomial but computes the zero function over $GF(2)$. See If two polynomials are equal as functions, are they necessarily equal as polynomials?.
Attempt 1: Use Schwartz-Zippel Lemma: Let $S\subseteq \mathbb{F}^n$. If $f-g$ is not always zero over $S$, then it has at most $|S|^{n-1}\cdot d~ $ roots from $S^n$ , with $d$ being the maximal (total) degree of $f-g$. But this doesn't seem to work, because even if we knew that $f-g$ is always zero over $S$, how can we conclude that $f-g$ is the zero polynomial (even for $S$ big enough)?
Comment 2: Note that if we change the formulation of Schwartz-Zippel Lemma to: If $f-g$ is not the zero polynomial, then it has at most $|S|^{n-1}\cdot d~ $ roots from $S^n$, then we finish the proof of the statement I'm after at. But this is not the formulation of Schwartz-Zippel Theorem I've seen.