Solution (source code)

= Solution

Use the given integer $u$ satisfying $u^2\equiv-1\pmod p$. The <Euclidean lattice> under consideration has basis $(1,u),(0,p)$, because every vector in it is uniquely $(a,ua+bp)$ with $a,b\in\mathbb Z$. Its fundamental parallelogram therefore has area
$$
\left|\det\begin{pmatrix}1&0\\u&p\end{pmatrix}\right|=p.
$$
We use the following two-dimensional form of the <Minkowski convex body theorem>: a convex, centrally symmetric measurable subset of $\mathbb R^2$ of area strictly greater than four times the covolume of a full-rank <Euclidean lattice> contains a nonzero vector of that lattice. Apply it to the closed disk of squared radius $3p/2$. Its area is $3\pi p/2>4p$, so it contains a nonzero lattice vector $(a,b)$ satisfying
$$
0<a^2+b^2\leq\frac{3p}{2}<2p.
$$
On the other hand the defining <modular congruence> and $u^2\equiv-1\pmod p$ imply
$$
a^2+b^2\equiv a^2+(ua)^2=(1+u^2)a^2\equiv0\pmod p.
$$
There is exactly one positive multiple of $p$ strictly below $2p$, so $\boxed{p=a^2+b^2}$. Neither coordinate can be zero, since a prime is not the square of an integer. This <congruence lattice proof of the prime sum of two squares> proves the required case of the <sum of two squares theorem> without assuming any conclusion at the critical area $4p$.