Incorrect proof of Wilson's Theorem?

While looking for alternative proofs for the theorem, I came across the following link

The proof

Let $$p$$ be a prime number. By Fermat's little theorem, all non-zero elements of the field must be the roots of the polynomial $$P(x)=x^{p-1}-1$$.

$$x^{p-1}-1= \prod_{r = 1}^{p-1}(x-r)$$

Now, either $$p=2$$, in which case $$a \equiv -a \pmod 2$$ for any integer $$a$$, or $$p-1$$ is even. In either case, $$(-1)^{p-1} \equiv 1 \pmod{p}$$, so that

$$x^{p-1}-1=\prod_{ r=1}^{p-1}(x-r)=\prod(r-x)$$

If we set $$x=0$$ then we get the theorem.

My question is, if we have assumed that $$x$$ is non-zero in the beginning, how can we substitute it back in the end to get the theorem?

Can someone verify if this proof is correct or not and, if it is, explain why doing this is allowed?

• You've proved that the polynomial $P(x)$ has the $p-1$ roots modulo $p,$ so that $P(x)=(x-1)(x-2)(x-3)\cdots(x-(p-1))$ modulo $p.$ This equality is an equality of polynomials, not just functions on $1,2,\dots,p-1$, so it has to be true for $x=0$ too. – Thomas Andrews Mar 6 at 18:06
• Do you understand the difference between polynomial functions and formal polynomials, e.g. over $\,\Bbb F_p,\,$ by $\,\mu$Fermat, $\, x^p -x \,$ equals the constant function $\,0,\,$ but it is not equal to $\,0\,$ as a formal polynomial since, by definition, formal polyomials are equal iff their corresponding coefficients are equal. – Bill Dubuque Mar 6 at 18:17
• @BillDubuque I did not know the difference. Thanks. So basically, $P(x) = (x−1)(x−2)(x−3)⋯(x−(p−1)) \forall x \in \mathbb{F}_p$ since degree of $P$ = number of roots in $\mathbb{F}_p$. Meaning that at least in $\mathbb{F}_p$, they are equal. Is my understanding correct? – Star Platinum ZA WARUDO Mar 6 at 18:28
• Have you yet studied fields? – Bill Dubuque Mar 6 at 19:07
• @BillDubuque No. I've studied group theory but not fields. Was my comment incorrect? – Star Platinum ZA WARUDO Mar 6 at 19:21

Theorem  Suppose $$f(x)$$ and $$g(x)$$ are polynomials of degree $$n$$ whose coefficients lie in a field $$F$$ (e.g. $$\Bbb Q,\, \Bbb R$$ or $$\Bbb Z_p =$$ integers $$\bmod p$$). If $$f$$ and $$g$$ have equal degree $$n$$ and equal lead coefs and they have equal values at $$n$$ distinct points $$\in F$$ then they have equal corresponding coefs $$\,f_i = g_i\,$$ for all $$\,i\,$$ (i.e. $$f = g$$ as formal polynomials), therefore $$f$$ and $$g$$ have equal values at all points $$\in F$$.
Proof $$\$$ By hypothesis $$f$$ and $$g$$ have equal lead terms which cancel in $$\,h := f-g\,$$ so $$\,\color{#c00}{\deg h < n}.\,$$ Thus $$\,h\,$$ is zero at the $$\color{#c00}{n > \deg h}\,$$ distinct points where $$f$$ and $$g$$ have equal values. By a well-known theorem, if a polynomial over a field has $$\rm\color{#c00}{more\ roots}$$ than its degree then it is the zero polynomial, i.e. all its coefs are zero, so $$\, h_i = f_i - g_i = 0$$.