Integer to Power of p-1 over 2 Modulo p

Theorem
Let $a \in \Z$, and let $p$ be an odd prime.

Let $\left({\dfrac a p}\right) = a^{\frac{\left({p - 1}\right)} 2} \pmod p$ be the Legendre symbol.

Then:
 * $\left({\dfrac a p}\right) = \begin{cases}

0 & : a \equiv 0 \pmod p \\ +1 & : \exists x \in \Z_{\ne 0}: x^2 \equiv a \pmod p \\ -1 & : \text {otherwise} \end{cases}$

Proof
Let $b = a^{\frac{\left({p - 1}\right)} 2}$.

We have that $b^2 = a^{p - 1}$.

If $p$ divides $b^2$, then $b \pmod p = 0$.

Otherwise, from Fermat's Little Theorem, $b^2 \equiv 1 \pmod p$.

That is, $b^2 - 1 \equiv 0 \pmod p$.

Consider $b^2 - 1 = \left({b + 1}\right) \left({b - 1}\right)$ from Difference of Two Squares.

So $p$ divides $b + 1$ or it divides $b - 1$.

(It can't divide both, as they have a difference of $2$, and $p$ is an odd prime.)

From Congruence Modulo Negative Number‎, we have that $p - 1 \equiv -1 \pmod p$.

Hence the result.