Solution (source code)

= Solution

For the <basis> $w_1,\ldots,w_d$, its <discriminant> is
$$
\operatorname{disc}(B)=\det\big(\operatorname{Tr}_{K/\mathbb Q}(w_iw_j)\big)_{i,j}.
$$
Equivalently it is the square of the <determinant> of the <matrix> of the $d$ embeddings applied to the <basis> vectors. It is nonzero because <number fields> are separable. An <integral basis> is a <basis> of the <ring of integers> as a <free abelian group>; in particular it is a rational <basis> of the <field> and expresses every <algebraic integer> uniquely with <integer> coefficients.

To prove existence, start with any rational <basis> and multiply each vector by a suitable nonzero <integer> to make it integral. This is possible by clearing coefficients in its monic rational <minimal polynomial of an algebraic element> and rescaling the variable. Let $M$ be the <free abelian group>[lattice] spanned over $\mathbb Z$ by these integral vectors, and let $D\ne0$ be its <discriminant>. For any <algebraic integer> $\alpha=\sum_jc_jw_j$, each trace $\operatorname{Tr}(\alpha w_i)$ is an <integer>. The resulting <linear system> has integral coefficient <matrix> with <determinant> $D$. Its <adjugate matrix> shows $c_j\in D^{-1}\mathbb Z$. Thus
$$
M\subseteq\mathcal O_K\subseteq D^{-1}M.
$$
A <subgroup> of a finitely generated <free abelian group> is free and finitely generated. Here its rank is $d$, since it contains $M$ and is contained in a rank-$d$ <free abelian group>[lattice]. Its free generators are the required <integral basis>.

For squarefree $d\ne1$, the quadratic <integral basis> is
$$
\boxed{\{1,(1+\sqrt d)/2\}\quad(d\equiv1\pmod4),\qquad\{1,\sqrt d\}\quad(d\equiv2,3\pmod4).}
$$
The source allows squarefree nonzero <integers>, so the degenerate value $d=1$ gives $K=\mathbb Q$ and <basis> $\{1\}$ instead of a two-element <basis>.

In the biquadratic <field> define the three <automorphisms> by changing respectively the sign of $\sqrt r$, the sign of $\sqrt2$, and both signs. Their actions are
$$
\begin{aligned}
\sigma_1(\mu)&=a+b\sqrt2-c\sqrt r-d\sqrt{2r},\\
\sigma_2(\mu)&=a-b\sqrt2+c\sqrt r-d\sqrt{2r},\\
\sigma_3(\mu)&=a-b\sqrt2-c\sqrt r+d\sqrt{2r}.
\end{aligned}
$$
Hence the three sums are $2a+2b\sqrt2$, $2a+2c\sqrt r$ and $2a+2d\sqrt{2r}$. If $\mu$ is integral, each sum is integral and lies in its displayed quadratic subfield. Their radicands are squarefree and respectively congruent to two, three and two modulo four. The quadratic <basis> formula therefore forces all their two coefficients to be <integers>, proving
$$
\boxed{2a,2b,2c,2d\in\mathbb Z.}
$$