Euler's Criterion/Proof 2

Theorem
Let $p$ be an odd prime.

Let $a \not \equiv 0 \pmod p$.

Then:

Proof

 * Let $a$ be a quadratic non-residue of $p$.

Let $b \in \left\{{1, 2, \ldots, p-1}\right\}$.

The congruence $b x \equiv a \pmod p$ has a unique solution $b'$ such that $b' \in \left\{{1, 2, \ldots, p-1}\right\}$.

Note that $b' \ne b$ otherwise we would have $b^2 \equiv a \pmod p$ and $a$ would be a quadratic residue of $p$. And we'd just said it's not.

It follows that the integers in $\left\{{1, 2, \ldots, p-1}\right\}$ fall into $\frac {p-1} 2$ pairs $b, b'$ such that $bb' \equiv a \pmod p$.

Hence:
 * $\left({p-1}\right)! = 1 \times 2 \times \cdots \times \left({p-1}\right) \equiv a \times a \times \cdots \times a \equiv a^{\frac{p-1}2} \pmod p$

From Wilson's Theorem, we have $\left({p-1}\right)! \equiv -1 \pmod p$.

And so:
 * $a^{\frac{p-1}2} \equiv -1 \pmod p$ for any quadratic non-residue of $p$.


 * Now let $a$ be a quadratic residue of $p$.

This time the congruence $x^2 \equiv a \pmod p$ has a solution.

By Lagrange's Theorem it has at most $2$ solutions.

If $c$ is one solution in $\left\{{1, 2, \ldots, p-1}\right\}$ then $p - c$ is another, since:
 * $\left({p - c}\right)^2 \equiv \left({- c}\right)^2 \equiv c^2 \equiv a \pmod p$.

Also $c \ne p - c$ as $p = 2 c$ is impossible ($p$ is an odd prime).

Now, let us remove $c$ and $p - c$ from $\left\{{1, 2, \ldots, p-1}\right\}$.

The remaining integers fall into $\frac {p - 3} 2$ pairs $b, b'$ such that $b b' \equiv a \pmod p$.

So this time:

Substituting $-1$ for $\left({p-1}\right)!$ (by Wilson's Theorem again) and dividing by $-1$, we get:
 * $a^{\frac{p-1}2} \equiv 1 \pmod p$

for any quadratic residue $a$ of $p$.


 * The "only if" part follows:

Suppose that $a^{\frac{p-1}2} \equiv 1 \pmod p$.

As $a \not \equiv 0 \pmod p$, $a$ is either a quadratic residue or a quadratic non-residue.

Suppose $a$ is a quadratic non-residue.

Then from above $a^{\frac{p-1}2} \equiv -1 \pmod p$.

So we would have $1 \equiv -1 \pmod p$ which is false for an odd prime.

So if $a^{\frac{p-1}2} \equiv 1 \pmod p$ then $a$ is a quadratic residue.

The quadratic non-residue case follows similarly.

Alternate Proof
First note that the square-roots of $1$ are $1, -1 \pmod p$ and that $a^{p-1}$ is equal to $1 \pmod p$.

From this we see that $a^{(p-1)/2}$ is either $1, -1 \pmod p$.

Therefore, Euler's criterion is equivalent to stating that $a$ is a quadratic residue modulo $p$ if and only if $a^{\frac{p-1}{2}} = 1 \pmod p$ because all quadratic non-residues must be congruent to $-1 \pmod p$.

We prove each direction separately:


 * $\implies$ direction

Assume $a$ is a quadratic residue modulo $p$. We pick $k$ such that $k^2 = a \pmod p$.

Then $a^{\frac{p-1}{2}} = k^{p-1} = 1 \pmod p$ by Congruence of Powers and Fermat's Little Theorem.


 * $\Longleftarrow$ direction

Assume $a^{\frac{p-1}{2}} = 1 \pmod p$.

Then let $y$ be a primitive root modulo $p$, so that $a$ can be written as $y^j$. In particular, $y^{j\frac{p-1}{2}} = 1 \pmod p$.

By Fermat's Little Theorem, $p-1 \backslash j\frac{p-1}{2}$, so $j$ must be even.

Let $k = y^{j/2} \pmod p$.

We have $k^2 = y^j = a \pmod p$.