Let $R$ be an integral domain and $R[x]$ the polynomial ring over $R$. Let $f,g \in R[x]$ such that $\max(\deg f, \deg g)< \#R$. Show that $f=g \iff f(x)= g(x), \forall x \in R$.
$\bf Attempt:$ Since $f,g \in R[x]$, $$f(x)=a_0+a_1x +a_2x^2+ \dots + a_nx^n \\ g(x)=b_0+b_1x+b_2x^2+\dots+b_mx^m,$$ for some $a_i,b_j \in R \ (\text{with} \ 1\leq i \leq n, 1\leq j \leq m$). WLOG, $n<m$.
Assume that $f(x) = g(x)$ for all $x \in R$. Then $$a_0+a_1x +a_2x^2+ \dots + a_nx^n = b_0+b_1x+b_2x^2+\dots+b_mx^m.$$ In particular if $x=0$, this implies $a_0 = b_0$.
So $$a_1x +a_2x^2+ \dots + a_nx^n =b_1x+b_2x^2+\dots+b_mx^m \\ (a_1-b_1)x +(a_2-b_2)x^2+ \dots + (a_n-b_n)x^n-b_{n+1}x^{n+1} \dots -b_mx^m = 0. $$
After this point, I tried to make some argument that $n=m$ but ran into the problem that I could possibly have that $x^p=x^q$ for all $x \in R.$ So I can't claim that each of the coefficients is zero. I'm certain that I need to use the condition regarding the degrees of $f$ and $g$ but I'm not sure how to.
Equivalently, $\,h := f-g = 0 \iff h(x)=0\,\ \forall x\in R.\ $ If $\,h\ne 0\,$ had more roots $\,r_i$ than its degree then, by the Factor Theorem, it would be divisible by the nonassociate primes $\,x-r_i,\,$ hence also divisible by their lcm = product, a polynomial of greater degree than $\,h,\,$ a contradiction.
Remark $\ $ Note that $\,x\!-\!r\,$ is prime by $\,R[x]/(x\!-\!r) \cong R\,$ is a domain. $ $ Furthermore
Lemma $\,\ \color{#c00}{\rm nonassociate}\,$ primes $\,p_i\mid a\, \Rightarrow\ p_1\cdots p_n\mid a\ \ \ $ [lcm = product]
Proof $\ $ Induct on $\,n.\,$ Clear if $\,n=1.\,$ By induction $\,p_1\mid a,\ldots,p_{n-1}\mid a\,\Rightarrow\, a = p_1\cdots p_{n-1} a_1.\,$ $\,\color{#c00}{p_n\nmid p_i}\,$ for $\,i< n\ $ so $\ p_n\mid p_1\cdots p_{n-1}a_1\Rightarrow\,p_n\mid a_1,\ $ so $\ a_1 = p_n a_2,\,$ hence $\ a = p_1\cdots p_n a_2\ \ $
Generally, $\, D\,$ is a domain $\!\iff\!$ every polynomial $\,f(x)\neq 0\in D[x]\, $ has at most $\, \deg f $ roots in $\,D.\,$ For the simple proof see my here, where I illustrate it constructively in $\,\Bbb Z/m\, $ by showing that given any $\,f(x)\,$ with more roots than its degree,$\:$ we can quickly compute a nontrivial factor of $\,m\,$ via a simple gcd computation. The quadratic case of this result is at the heart of many integer factorization algorithms, which factor $\:m\:$ by searching for a square root of $1$ that's $\not\equiv \pm1\,$ in $\: \mathbb Z/m$.