Proof (primes in integers and Gaussian integers)

Let $N(z) = |z|^2$.

Sum of squares $\implies$ not prime in $\Z[i]$

If $p = a^2 + b^2$ for $a,b\in \Z$, then $$ \begin{align*} p = (a+ib)(a-ib), \end{align*} $$ with $(a+ib),(a-ib)$ non-zero non-units (since $N(a\pm ib) = p\neq 0,1$).

Not prime in $\Z[i]$ $\implies$ sum of squares

Let $p=uv$ where $u,v\in \Z[i]$ are non-units. Then $$ \begin{align*} p^2 = N(p) = N(u) N(v) \qquad \text{(in $\Z_{\geq 0}$)}. \end{align*} $$ Since $N(u), N(v) \neq 1$ and $p$ is prime in $\Z$, we have $N(u) = p = N(v)$, so $$ \begin{align*} p = u\bar u = (\Re u)^2 + (\Im u)^2. \end{align*} $$

Sum of squares $\implies$ $p\equiv 1,2\pmod 4$

Since $a^2 \equiv 0$ or $1\pmod 4$ by arithmetic, $p = a^2 + b^2 \equiv 0, 1, 2\pmod 4$. $p$ is prime so $4\not\mid p$.

$p\equiv 1,2\pmod 4$ $\implies$ not prime in $\Z[i]$

If $p\equiv 2\pmod 4$, then $p=2=1^2 + 1^2$.

If $p\equiv 1\pmod 4$, we can solve $x^2 \equiv -1 \pmod p$. To see this, note a consequence of the classification of finite abelian group is

Lemma (multiplicative group of integers mod p is cyclic) open_in_new

Let $p$ be a prime number.

The group $\mathbb{F}_p^\times$ of non-zero integers mod $p$ under multiplication is cyclic, i.e. $\mathbb{F}_p^\times \isom C_{p-1}$.

Proof

Then $-1$ is the unique element in $\mathbb{F}_p^\times$ with order 2, and so by picking $x$ to be an order 4 element, we have $x^2 \equiv -1\pmod 4$.

This can also be shown by Wilson's theorem $$ \begin{align*} -1 \equiv{}& (p-1)! \\ \equiv{}& 1 \cdot 2 \cdot \ldots \cdot \frac{p-1}{2} \cdot \frac{p+1}{2} \cdot \ldots \cdot (p-2) \cdot (p-1) \\ \equiv{}& \left(1\cdot 2\cdot \ldots \cdot \frac{p-1}{2}\right)^2 (-1)^{(p-1)/2} \\ \equiv{}& \left(1\cdot 2\cdot \ldots \cdot \frac{p-1}{2}\right)^2 &\pmod p \end{align*} $$ since $(p-1)/2$ is even.

Therefore $$ \begin{align*} p\mid x^2+1 = (x+i)(x-i) \qquad \text{(in $\Z[i]$)} \end{align*} $$ but $p\not\mid x\pm i$, so $p$ is not a prime in $\Z[i]$.