Reference to complete proof that integral closure of $\mathbb{Z}$ in $\mathbb{Q}(i)$ is $\mathbb{Z}[i]$? Where can I find a complete proof to the fact that the integral closure of $\mathbb{Z}$ in $\mathbb{Q}(i)$ is $\mathbb{Z}[i]$ (the Gaussian integers are the integral closure of $\mathbb{Z}$ in the Gaussian rationals)? For such a seemingly standard fact, I can not seem to find a complete proof of this anywhere. Yes, I am aware that this question has been asked on math.stackexchange before, but there was no reference to a complete proof, nor was a complete proof ever supplied. Any help would be appreciated, thanks.
 A: If $z\in\mathbb Q[i]$ is integral over $\mathbb Z$, then it's integral over $\mathbb Z[i]$. But $\mathbb Z[i]$ is a UFD, so it's integrally closed. It follows $z\in\mathbb Z[i]$. (Recall or prove that $\mathbb Q[i]$ is the field of fractions of $\mathbb Z[i]$.)
Conversely, for $z\in\mathbb Z[i]$, $z=m+in$, $m,n\in\mathbb Z$, you can easily see that $z^2-2mz+m^2+n^2=0$, so $z$ is integral over $\mathbb Z$.
A: Here is an elementary proof from scratch. If $\alpha = a + bi$ is an algebraic integer, then $\overline{\alpha}$ will be as well, since any polynomial over $\mathbb{Q}$ having $\alpha$ as a root also has $\overline{\alpha}$ as a root.
Therefore its trace $\alpha + \overline{\alpha} = 2a$ and its norm $\alpha\overline{\alpha} = a^2 + b^2$ will be algebraic integers as well. Conversely, if this holds, then $\alpha$ is indeed an algebraic integer, because it satisfies the polynomial
$$
x^2 - Tr(\alpha)x + N(\alpha) \in \mathbb{Z}[x]
$$
Thus it is necessary and sufficient that $2a$ be an integer and that $a^2 + b^2$ be an integer. Clearly it suffices for $a, b \in \mathbb{Z}$, i.e., clearly $\mathbb{Z}[i]$ is contained in the integral closure, and we need only show the necessity. So we need to show: if $a, b$ are rational numbers such that $2a$ and $a^2 + b^2$ are integers, then $a$ and $b$ are themselves integers.
Let's write $a = m/2$ and $b = c/d$, where $m, c$, and $d$ are integers. We can assume that $c$ and $d$ have no common prime factors and $d$ is positive. Let $n = a^2 + b^2$, which we also know is an integer. So
$$
m^2/4 + c^2/d^2 = n
$$ 
and thus
$$
m^2d^2 + 4c^2 = 4nd^2.
$$
Work mod $d^2$. Since $c$ is prime to $d$, we know $c^2$ is prime to $d^2$ and therefore $4$ is equivalent to $0$ mod $d^2$, which shows that $d$ is either $1$ or $2$.
If $d$ is $1$, then working mod $4$ we see $m$ is even, so now both $a$ and $b$ are integers as desired. So suppose $d$ is two. We get
$$
m^2 + c^2 = 4n.
$$
Work mod $4$ again. Since the only square mod $4$ are $0$ and $1$, we see both $m^2$ and $c^2$ are 0 mod 4. But $c$ can't be even since it's prime to $d$, so we eliminate this case.
