When $p=2$ or $p$ prime, with $p=1\pmod{4}$, $x^2\equiv -1\pmod{p}$ is soluble - trouble understanding proof Theorem: When $p=2$ or $p$ prime, with $p=1\pmod{4}$, $x^2\equiv -1\pmod{p}$ is soluble
Proof: When $p=2$, the statement is clear.
Assume $p\equiv 1\pmod{4}$, let $r=\frac{p-1}{2}$ and $x=r!$
Then since $r$ is even $x^2\equiv (1\cdot 2\cdot...\cdot r)((p-1)\cdot(p-2)\cdot...\cdot(p-r))\equiv (p-1)!\equiv -1\pmod{p}$
Thus, when $p\equiv 1\pmod{4}$, the congruence $x^2\equiv -1\pmod{p}$ is soluble.
Point of contention: I understand the general argument
I understand the relation
$(1\cdot 2\cdot...\cdot r)((p-1)\cdot(p-2)\cdot...\cdot(p-r))\equiv (p-1)!\equiv -1\pmod{p}$
But I cant work out how $x^2\equiv(1\cdot 2\cdot...\cdot r)((p-1)\cdot(p-2)\cdot...\cdot(p-r))\pmod{p}$
How is $((\frac{p-1}{2})!)^2\equiv(1\cdot 2\cdot...\cdot r)((p-1)\cdot(p-2)\cdot...\cdot(p-r))\pmod{p}$
 A: For any $i$, $p-i\equiv -i\pmod{p}$, so the right-hand side of your final congruence is
\begin{equation*}
  (1\cdot 2\cdot...\cdot r)((p-1)\cdot(p-2)\cdot...\cdot(p-r))
    \equiv (1\cdot 2\cdot...\cdot r)((-1)\cdot(-2)\cdot...\cdot(-r))
    \equiv r!(-1)^rr! \equiv (-1)^r(r!)^2\pmod{p}.
\end{equation*}
But since $p\equiv 1\pmod{4}$, it follows that $r = \frac{p-1}{2}$ is even, so this is just $(r!)^2 = \left(\left(\frac{p-1}{2}\right)!\right)^2\pmod{p}$.
A: You can see it the following way:
$$\begin{align}(1\cdot 2\cdot...\cdot r)\underbrace{((p-1)\cdot(p-2)\cdot...\cdot(p-r))}_{\equiv (-1)(-2)(-3)\cdots(-r)}\pmod{p}
\end{align}$$
so every $i$ appears two times in this product so this product is equivalent to $r!(-1)^r r!$ and this gives you $r!^2$
A: Since there are an even number of terms:
$$\begin{align}1\cdot 2\cdots r &= (-1)(-2)\cdots (-r)\\
&\equiv (p-1)(p-2)\cdots(p-r)\pmod p\\
&=(r+1)(r+2)\cdots(p-1)
\end{align}$$
A: Suppose $\;p=4k+1\;$ , so that
$$\frac{p-1}2=2k\implies\;\; \text{since}\;\;j=p-j\pmod p\;\;\text{for}\;\;0\le j\le p \,, $$
we get that
$$\frac{p-1}2+1=\frac{p-1}2-1\pmod p\;,\;\;\frac{p-1}2+2=\frac{p-1}2-2\pmod p\,,\ldots$$
so that
$$1\cdot2\cdot\ldots\cdot k\cdot\ldots\cdot\left(\frac{p-1}2-1\right)\cdot\left(\frac{p-1}2\right)\cdot\left(\frac{p-1}2-1\right)\cdot\ldots\cdot k\cdot\ldots \cdot1=\left[\left(\frac{p-1}2\right)!\right]^2$$
If you know some basic group theory things can possibly go easier than the above.
A: If the general case proves obfuscatory, it often proves enlightening to first examine a few small special cases in order to help grasp the general idea, e.g. let's examine the two smallest cases first $\,p=5,13.\,$  mod $\, p = 5\!:\,\ \color{#0a0}{4\equiv -1},\ 3\equiv \color{#c00}{ -2}\ $ so substituting these into Wilson's formula  
$\qquad\qquad \begin{align} {\rm mod}\ 5\!:\,\ {-}1\, \equiv& \ \ \ \ \color{#0a0}{(4)}\cdot \color{}{(3)}\cdot 2\cdot 1\\
\equiv&\, \color{#0a0}{(-1)}(-\color{#c00}2)\cdot\color{#c00} 2\cdot 1\,\equiv\, \color{#c00}2!^2\end{align}$  
$\qquad\quad\ \ \begin{align} {\rm mod}\ 13\!:\,\ {-}1\, \equiv& \ \  \color{#0a0}{(12)}\cdot\,(11)\,\cdots\ \ (7)\ \cdot 6\cdot 5\cdots 1\\
\equiv&\, \color{#0a0}{(-1)}\cdot(-2)\cdots (-\color{#c00}6)\cdot\color{#c00} 6\cdot 5\cdots 1\,\equiv\, \color{#c00}6!^2 \end{align}$
$\qquad\qquad\quad\overset{\vdots}{\phantom{c}}\qquad\qquad\qquad\qquad\qquad\qquad\qquad\qquad\qquad\quad\ \overset{\ddots}{\phantom{c}}$
$\qquad\begin{align} {\rm mod}\ 4k\!+\!1\!:\,\ {-}1\, \equiv& \ \  \color{#0a0}{(4k)}(4k\!-\!1)\cdots (2k\!+\!1)\ \  (2k)(2k\!-\!1)\cdots 1\\
\equiv&\, \underbrace{\color{#0a0}{(-1)}\,\cdot\,(-2)\, \cdots\  \,(-\color{#c00}{2k})}_{\Large (-1)^{2k}(2k)!\ =\ (2k)!} \ \ \,\underbrace{(\color{#c00}{2k})(2k\!-\!1)\cdots 1}_{\Large(2k)!}\equiv (2k)!^2 \end{align}$
