Proving Wilson's theorem Wilson's theorem: if $p$ is prime then $(p-1)! \equiv -1(mod$ $ p)$
Approach: 
$$(p-1)!=1*2*3*....*p-1$$
My teacher said in class that the gcd of every integer less than p and p is 1, so every integer has a multiplicative inverse $(mod$ $ p)$. He also said that the multiplicative inverses of each integer less than p is in the same set of integers less than p (This idea seems to be right, but does it have to be proven?). the multiplicative inverses of 1 and p-1 are self inverses (Drawing different mod grids, it looks like it's right, but again how is that true?). He concluded the following:
$$1*(p-1)*(a_1a_1^{-1}*.....*a_{{p-3}/2}*{a_{{p-3}/2}}^{-1}) \equiv -1(mod\text{ } p)$$
So he is grouping all the elements with distinct multiplicative inverse. This makes sense because there are p-3 elements with distinct multiplicative inverses and p-3 is even, so we can group them in pairs. How do we know that one multiplicative inverse corresponds to just one number, so we can group them in such an easy way?.
 A: Note that if $x$ is a multiplicative inverse of $a$ modulo $p$ it's a solution to the follwoing linear diophantine equation: $xa + py = 1$. Adding and subtracting $ap$ we have: $a(x-p) + p(y+a) = 1$. So all solutions for $x$ are equivalent to each other modulo $p$, so therefore we can pick one from the residue class modulo $p$ (the set of non-negative integers less than $p$). 
For the other part to see why only $1$ and $p-1$ are self-inverses, note that such a number must satisfy $x^2 \equiv 1 \pmod p \implies p \mid (x-1)(x+1)$. So we have that $x \equiv \pm 1 \pmod p \implies x=1 \text{ or } x=p-1$
A: One has indeed an equivalence $$p\text{ is prime }\iff(p-1)!\equiv -1\pmod p$$
(1)$\space p\text{ is prime }\Rightarrow(p-1)!\equiv -1\pmod p$
By Fermat's little theorem and because each of $1,2,3,...(p-2),(p-1)$ is coprime with $p$ we have $(p-2)!\equiv((p-2)!)^{ p-1}\equiv 1 \pmod p\Rightarrow (p-1)!\equiv (p-1)\cdot 1\equiv -1\pmod p$.
(2)$\space (p-1)!\equiv -1\pmod p\Rightarrow p\text{ is prime }$.
Suppose $p$ is composed then its (positive) divisors are in $\{1,2,3,...,(p-2),(p-1)\}$. This implies that $\  g.c.d((p-1)!,p)\gt 1$. Now if $\space (p-1)!\equiv -1\pmod p$ then dividing by a (proper) divisor $d$ of $p$ and of $(p-1)!$ the equality 
$(p-1)!=-1+pm$ (equivalent to the congruence) one has $d$ must divide $-1$, absurde.Thus $p$ is not composed.
