[proofplan]
We argue by strong induction on $n = \deg(f)$. The base case $n = 0$ is handled by noting that a non-zero constant polynomial has no roots. For the inductive step, if $f$ has no roots we are done; otherwise pick any root $\alpha$ and apply the [Remainder Theorem](/theorems/1707) to factor $f(X) = (X - \alpha)f_1(X)$ with $\deg(f_1) = n - 1$. The integral-domain hypothesis is the crux: for any other root $\beta$, the identity $(\beta - \alpha)f_1(\beta) = 0$ forces $\beta = \alpha$ or $f_1(\beta) = 0$, with no third possibility. By induction $f_1$ has at most $n - 1$ roots, and adjoining $\alpha$ gives at most $n$ roots for $f$.
[/proofplan]
[step:Set up strong induction on the degree $n$]
We prove the statement by strong induction on $n := \deg(f) \geq 0$: for every integral domain $R$ and every non-zero $f \in R[X]$ of degree $n$, the set of roots $Z(f) := \{\alpha \in R : f(\alpha) = 0\}$ has cardinality $\#Z(f) \leq n$.
[/step]
[step:Establish the base case: a non-zero constant has no roots]
If $n = 0$, then $f(X) = c$ for some $c \in R \setminus \{0\}$. For any $\alpha \in R$, $f(\alpha) = c \neq 0$, so $\alpha$ is not a root. Therefore $Z(f) = \varnothing$ and $\#Z(f) = 0 \leq 0 = n$.
[/step]
[step:Factor out a root using the Remainder Theorem]
Fix $n \geq 1$ and assume the statement holds for every integral domain and every non-zero polynomial of degree $< n$. Let $f \in R[X]$ have degree $n$.
If $Z(f) = \varnothing$, then $\#Z(f) = 0 \leq n$ and there is nothing further to prove.
Otherwise pick any $\alpha \in Z(f)$. By the [Remainder Theorem](/theorems/1707), applied with root $\alpha$, there exists $f_1 \in R[X]$ with
\begin{align*}
f(X) &= (X - \alpha)\,f_1(X).
\end{align*}
Comparing leading coefficients: if $f$ has leading coefficient $a_n \in R \setminus \{0\}$ (non-zero by $\deg(f) = n$), then $f_1$ has leading coefficient $a_n$ and $\deg(f_1) = n - 1$. In particular $f_1 \neq 0$.
[guided]
We want to reduce the problem to a smaller polynomial so that we can invoke the inductive hypothesis. The natural way to "peel off" a root is the [Remainder Theorem](/theorems/1707), which says that if $f(\alpha) = 0$ then $(X - \alpha) \mid f(X)$. So write
\begin{align*}
f(X) = (X - \alpha)\,f_1(X)
\end{align*}
for some $f_1 \in R[X]$.
What is $\deg(f_1)$? Comparing leading coefficients on both sides: the right-hand side's leading term is (leading coefficient of $X - \alpha$) $\times$ (leading coefficient of $f_1$) $\times X^{1 + \deg f_1} = 1 \cdot a_1^{(1)} X^{1 + \deg f_1}$, where $a_1^{(1)}$ denotes the leading coefficient of $f_1$. In an integral domain this leading coefficient of the product is non-zero iff both factors have non-zero leading coefficients (no cancellation across multiplication — that is exactly what "integral domain" means for leading coefficients). So
\begin{align*}
\deg(f) = \deg(X - \alpha) + \deg(f_1) = 1 + \deg(f_1),
\end{align*}
giving $\deg(f_1) = n - 1$. In particular $f_1 \neq 0$ (it has a non-zero leading coefficient $a_n \neq 0$), so the inductive hypothesis applies to $f_1$.
[/guided]
[/step]
[step:Use the integral-domain property to split any other root into $\alpha$ or a root of $f_1$]
Let $\beta \in Z(f)$ be any root of $f$. Substituting $X = \beta$ into the factorisation:
\begin{align*}
0 = f(\beta) = (\beta - \alpha)\,f_1(\beta).
\end{align*}
Since $R$ is an integral domain (that is, $R$ has no zero divisors), a product $xy = 0$ forces $x = 0$ or $y = 0$. Applied here:
\begin{align*}
\beta - \alpha = 0 \quad \text{or} \quad f_1(\beta) = 0,
\end{align*}
i.e. $\beta = \alpha$ or $\beta \in Z(f_1)$. This proves the set inclusion
\begin{align*}
Z(f) \subseteq \{\alpha\} \cup Z(f_1).
\end{align*}
[guided]
This is the step that consumes the integral-domain hypothesis — and it is the only step that does. From the factorisation $f(X) = (X - \alpha)f_1(X)$, every root $\beta$ of $f$ satisfies
\begin{align*}
(\beta - \alpha)\,f_1(\beta) = 0.
\end{align*}
In a general commutative ring this equation allows a third possibility: $\beta - \alpha$ and $f_1(\beta)$ could be a pair of non-zero zero divisors whose product vanishes. That is exactly what could break the degree bound. For example, in $R = \mathbb{Z}/8\mathbb{Z}$ the polynomial $f(X) = X^2 - 1$ has degree $2$ but **four** roots: $1, 3, 5, 7$ (check: $3^2 = 9 \equiv 1$, $5^2 = 25 \equiv 1$, $7^2 = 49 \equiv 1$). Here $\mathbb{Z}/8\mathbb{Z}$ is not an integral domain, and indeed one can factor $X^2 - 1 = (X - 1)(X + 1) = (X - 3)(X + 3)$ and more — the factorisation is not unique.
Under the integral-domain hypothesis, however, the equation $(\beta - \alpha)f_1(\beta) = 0$ forces $\beta = \alpha$ or $f_1(\beta) = 0$, with no escape. So
\begin{align*}
Z(f) \subseteq \{\alpha\} \cup Z(f_1),
\end{align*}
which bounds the roots of $f$ in terms of roots of the smaller polynomial $f_1$.
[/guided]
[/step]
[step:Apply the inductive hypothesis to $f_1$ and conclude]
Since $f_1 \in R[X]$ is non-zero of degree $n - 1$ and $R$ is an integral domain, the inductive hypothesis yields $\#Z(f_1) \leq n - 1$. Combining with the inclusion from the previous step:
\begin{align*}
\#Z(f) \leq \#(\{\alpha\} \cup Z(f_1)) \leq 1 + \#Z(f_1) \leq 1 + (n - 1) = n.
\end{align*}
This completes the inductive step and proves that $f$ has at most $n$ roots in $R$.
[/step]