\documentclass[a4paper]{article}

\input{temp}

\setcounter{section}{-2}

\begin{document}

\title{Number Fields}

\maketitle

\newpage

\tableofcontents

\newpage

\section{Miscellaneous}

Book: Number Fields, Marcus

Course notes: www.dpmms.ac.uk/~jat58/nfl2018

\newpage

\section{Motivation}
\begin{thm}
If $p$ is an odd prime, then $p=a^2+b^2$ for $a,b \in \Z \iff p \equiv 1 \pmod 4$.
\begin{proof}
If $p=a^2+b^2$, then $p\equiv 0,1,2 \pmod 4$. So this condition on $p$ is necessary.\\
Suppose instead $p \equiv 1 \pmod 4$. Then $\left(\frac{-1}{p}\right) = 1$. Thus $\exists a \in \Z$ such that $a^2 \equiv -1 \pmod p$, or $p|a^2+1$. We can factor $a^2+1=(a+i)(a-i)$ in the ring $\Z[i]$. Here we introduce a notation: if $R \subseteq S$ are rings and $\alpha \in S$, then $$R[\alpha] = \{\sum_{i=0}^n a_i \alpha^i \in S | a_i \in R\}$$, the smallest subring of $S$ containing both $R$ and $\alpha$.

We know from IB GRM that $\Z[i]$ is a UFD. Now $p|(a+i)(a-i)$. If $p$ is irreducible in $\Z[i]$ then $p|a+i$ or $p|a-i$, contradiction. Thus $p$ is reducible in $\Z[i]$, hence $p=z_1z_2$ with $z_1,z_2 \in \Z[i]$. If $z_1 = A+Bi$, $A,B\in \Z$, then $A^2+B^2 = p$.
\end{proof}
\end{thm}

Another example is when $p$ is an odd prime. Does the equation $$x^p+y^p=z^p$$ have solutions with $x,y,z\in \Z$ and $xyz \neq 0$?

\begin{thm} (Kummer, 1850)\\
If $\Z[e^{2\pi i/p}]$ is a UFD, then there are no solutions.\\
Strategy: factor $x^p+y^p = \prod_{j=0}^{p-1} (x+e^{2\pi ij/p}y)$ in $\Z[e^{2\pi i/p}]$.
\end{thm}

However, we now know $\Z[e^{2\pi i/p}]$ is a UFD $\iff$ $p \leq 19$.

\begin{thm} (Kummer, 1850)\\
If $p$ is a \emph{regular} prime, then there are no solutions.\\
If $p<100$, then $p$ is regular $\iff$ $p \neq 37,59,67$.
\end{thm}

We have seen various examples such as $\Z \subseteq \Q$, $\Z[i] \subseteq \Q[i]$, $\Z[e^{2\pi i/p}] \subseteq \Q[e^{2\pi i/p}]$, or in general, $\mathcal{O}_L\subseteq L$, where a ring of "integers" lies in a number field.

\newpage

\section{Ring of integers}
Recall: A field extension $L/K$ is an inclusion $K \leq L$ of fields. The degree of $L/K$ is $[L:K] = \dim_K L$. We say $L/K$ is finite if $[L:K]<\infty$.

\begin{defi} (1.1)\\
A number field is a finite extension $L/\Q$. Here are two ways to construct number fields:\\
(1) Let $\alpha \in \C$ be an algebraic number. Then $L=\Q(\alpha)$ is a number field;\\
(2) Let $K$ be a number field, and let $f(X) \in K[X]$ be an irreducible polynomial. Then $L=K[X]/(f(X))$ is a number field.\\
(Recall Tower Law: $[L:Q] = [L:K][K:Q] < \infty$).
\end{defi}

\begin{defi} (1.2)\\
(1) Let $L/K$ be a field extension. Then we say $\alpha \in L$ is algebraic over $K$ if there exists a monic $f(X) \in K[X]$ such that $f(\alpha) = 0$;\\
(2) Let $L/\Q$ be a field extension. Then we say $\alpha \in L$ is an algebraic integer if there exists a monic $f(X) \in Z[X]$ such that $f(\alpha) = 0$.
\end{defi}

\begin{defi} (1.3)\\
Let $L/K$ be a field extension, and let $\alpha \in L$ be algebraic over $K$. We call the minimal polynomial of $\alpha$ over $K$ the monic polynomial $f_\alpha(X) \in K[X]$ of least degree such that $f_\alpha(\alpha)=0$.
\end{defi}

We recall why $f_\alpha(X)$ is well-defined: there exists some monic $f(X) \in K[X]$ with $f(\alpha)=0$ as $\alpha$ is algebraic. If $f_\alpha(\alpha),f'_\alpha(\alpha) \in K[X]$ both satisfy the definition of minimal polynomial, then we apply the polynomial division algorithm to write $$f_\alpha(X) = p(X) f'_\alpha(X) + r(X)$$ where $p(X),r(X) \in K[X]$, and $\deg r < \deg f'_\alpha$. Evaluate at $X=\alpha$, we have $0=f_\alpha(\alpha) = p(\alpha)f'_\alpha(\alpha)+r(\alpha)=r(\alpha)$. By minimality of $\deg f'_\alpha$, we must have $r=0$. Then $\deg f_\alpha = \deg f'_\alpha$, and $f_\alpha(X),f'(\alpha)$ are both monic, i.e. $p(X) = 1$ and $f_\alpha(X) = f'_\alpha(X)$.

\begin{lemma}(1.4)\\
Let $L/\Q$ be a field extension, and let $\alpha \in L$ be an algebraic integer. Then:\\
(1) The minimal polynomial $f_\alpha(X)$ of $\alpha$ over $\Q$ lies in $\Z[X]$;\\
(2) If $g(X) \in \Z[X]$ satisfies $g(\alpha) = 0$, then there exists $q(X) \in \Z[X]$ such that $g(X) = f_\alpha(X) q(X)$;\\
(3) The kernel of the ring homomorphism $\Z[X] \to L$ by $f(X) \to f(\alpha)$ equals $(f_\alpha(X))$, the ideal generated by $f_\alpha(X)$.
\begin{proof}
(1) Recall that if $f(X) = a_n X^n + ... + a_0 \in \Z[X]$, then we define from GRM, the content $c(f) = \gcd(a_n,...,a_0)$. Recall Gauss' Lemma: If $f(X), g(X) \in \Z[X]$, then $c(fg) = c(f)c(g)$. Since $\alpha \in L$ is an algebraic integer, there exists monic $f(X) \in \Z[X]$ such that $f(\alpha) = 0$, i.e. $c(f) = 1$. Apply polynomial division in $\Q[X]$ to get $f(X) = p(X) f_\alpha(X) +r(X)$, where $p(X),r(X) \in \Q[X]$, $\deg r < \deg f_\alpha$. The definition of $f_\alpha(X)$ implies that $r(X) = 0$, hence $f(X) = p(X) f_\alpha(X)$. Now choose integers $n,m \geq 1$ such that $np(X) \in \Z[X]$, $c(np) = 1$, and $mf_\alpha(X) \in \Z[x]$, $c(mf_\alpha) = 1$. Then $nmf(x) = (np(x))(mf_\alpha(x)) \implies c(nmf(x)) = nm = 1$. So $n=m=1$, hence $f_\alpha(x) \in \Z[X]$.\\
(2) Let $g(X) \in \Z[X]$ be such that $g(\alpha) =0 $. WLOG $g(x) \neq 0$ and $c(g) = 1$. Now apply polynomial division to write $g(x) = q(x) f_\alpha(x) + s(x)$ where $q(x),s(x) \in \Q[x]$, $\deg s < \deg f_\alpha$. Again by definition we have $s(x) = 0$. Choose an integer $k \geq 1$ such that $kq(x) \in Z[x]$ and $c(kq) =1$. Then $kg(x) = kq(x) f_\alpha(x) \implies k=c(kg) = c(kq) c(f_\alpha) = 1$. So $k=1$, hence $q(x) \in \Z[x]$.\\
(3) is a reformulation of (2).
\end{proof}
\end{lemma}

Let $L/\Q$ be a field extension. Last time we said $\alpha \in L$ is an algebraic integer if $\exists$ monic polynomial $f(x) \in \Z[x]$ such that $f(\alpha) = 0$. We proved that if $\alpha \in L$ is an algebraic integer and $f_\alpha(x) \in \Q[x]$ is the minimal polynomial of $\alpha$ over $\Q$, then $f_\alpha(x) \in \Z[x]$. However there is a small problem, so we'll prove again.
\begin{proof}
Choose $f(x) \in \Z[x]$ monic with $f(\alpha) = 0$, and write $$f(x) = q(x) f_\alpha(x) + r(x)$$ where $q(x),r(x) \in \Q[x]$, $\deg r < \deg f_\alpha$. Then $r(\alpha) = 0 \implies r(x) = 0$, by minimality of $\deg f_\alpha$. I said that we can find integer $n,m \geq 1$ s.t. $nf\alpha(x) \in \Z[x]$, $c(nf\alpha) = 1$, $mq(x) \in \Z[x]$, $c(mq) = 1$. However we need to explain why do they exist. Note $f_\alpha(x)$ and $q(x)$ are both monic. Choose integers $N,M \geq 1$ such that $Nf_\alpha(x) \in \Z[x]$, $Mq(x) \in \Z[x]$. Then $c(Nf_\alpha) | N$, $c(Mq)|M$ as those are the leading term of the polynomial. Now let $N/c(Nf\alpha) = n \in \Z$, $M/c(Mq) = m \in \Z$. Now $nmf(x) = (nf\alpha(x)) (mq(x))$, so $c(nmf(x)) = nm = 1 \implies n=m=1$.
\end{proof}

\begin{coro} (1.5)\\
If $\alpha \in \Q$, then $\alpha$ is an algebraic integer $\iff$ $\alpha \in \Z$.
\begin{proof}
By lemma 1.4, $\alpha$ is an algebraic integer $\iff f_\alpha(x) \in \Z[x]$. But if $\alpha \in \Q$, then $f_\alpha(x) = x-\alpha$, and the first needs to divide the second polynomial.
\end{proof}
\end{coro}

\begin{notation}
If $L/\Q$ is any field extension, we write $\mathcal{O}_L =\{\alpha \in L | \alpha$ is an algebraic integer$\}$.
\end{notation}

Now we proceed to the first non-trivial result of the course:

\begin{prop} (1.6)\\
If $L/\Q$ is a field extension, $\mathcal{O}_L$ is a ring.
\begin{proof}
Clearly $0,1 \in \mathcal{O}_L$. Now if $\alpha \in \mathcal{O}_L$, then $f_{-\alpha}(x) = (-1)^{\deg f_\alpha} f_\alpha (-x) \implies -\alpha \in \mathcal{O}_L$.\\
The hard part is to show that if $\alpha,\beta \in \mathcal{O}_L$, then $\alpha+\beta \in \mathcal{O}_L$ and $\alpha\beta \in \mathcal{O}_L$.\\
Observe that if $\alpha \in \mathcal{O}_L$, then $\Z[\alpha] \subseteq L$ is a finitely generated $\Z$-module. By definition, $\Z[\alpha]$ is generated by $1,\alpha,\alpha^2,\alpha^3,...$. Let $f_\alpha(x) = x^d + a_1 x^{d-1} + ... + ad$, $a_i \in \Z$. Then $\alpha^d = -(a_1 \alpha^{d-1} + ... + ad)$, so $\alpha^d \in \sum_{i=0}^{d-1} \Z \alpha^i$. By induction, we see that $\alpha^n \in \sum_{i=0}^{d-1} \Z \alpha^i$ for all $n \geq d$. Hence $\Z[\alpha] = \sum_{i=0}^{d-1} \Z \alpha^i$. Now take $\alpha,\beta \in \mathcal{O}_L$ and let $d = \deg f_\alpha$, $e = \deg f_\beta$.\\
By definition, $\Z[\alpha,\beta] =\Z[\alpha][\beta]$ is generated as a $\Z$-module by $\{\alpha^i\beta^j\}_{i,j \in \N}$. The same argument show that in fact this ring is generated as a $\Z$-module by $\{\alpha^i \beta^j\}$ for $0\leq i\leq d-1, 0 \leq j \leq e-1$. So $\Z[\alpha,\beta]$ is finitely generated. From GRM we know the classification of finitely generated $\Z$-modules implies that there's an isomorphism $\Z[\alpha,\beta] \cong \Z^r \oplus T$ for some $r \geq 1$ and finite abelian group $T$. In fact, $T=0$: if $\gamma \in T$, then $|T|\gamma = 0$, by Lagrange's theorem. But $\Z[\alpha,\beta] \subseteq L$, a $\Q$-vector space, so this forces $\gamma = 0$. Now we can therefore fix an isomorphism $\Z[\alpha,\beta] \cong \Z^r$ ($r \geq 1$. There's an endomorphism $m_{\alpha\beta}: \Z[\alpha,\beta] \to \Z[\alpha,\beta]$ by $\gamma \to \alpha\beta\gamma$ (as a $\Z$-module). $m_{\alpha\beta}$ corredponds to an $r \times r$ matrx $A_{\alpha\beta} \in M_{r \times r} (\Z)$.\\
Let $F_{\alpha\beta}(x) = \det (x\cdot 1_r -A_{\alpha\beta}) \in \Z[x]$, a monic polynomial. By the Cayley-Hamilton theorem, $F_{\alpha\beta}(m_{\alpha\beta}) = 0$ as endomorphisms of $\Z[\alpha,\beta]$. Write $F_{\alpha\beta}(x) = x^r + b_1x^{r-1} + ... + b_r$ for $b_i \in \Z$. Thus $m^r_{\alpha\beta} + b_1 m^{r-1}_{\alpha\beta} + ... + b_r \cdot 1_r = 0$ as endomorphisms of $\Z[\alpha,\beta]$.\\
Now the image of $1$ is $(\alpha\beta)^r+b_1(\alpha\beta)^{r-1} + ... + b_r = F_{\alpha\beta}(\alpha\beta) = 0$. So $\alpha\beta \in \mathcal{O}_L$.\\
The argument to show $\alpha+\beta \in \mathcal{O}_L$ is identical, replacing $m_{\alpha\beta}$ by $m_{\alpha+\beta}: \Z[\alpha,\beta] \to \Z[\alpha,\beta]$ by $\gamma \to (\alpha+\beta)\gamma$. The detail is omitted here.
\end{proof}
\end{prop}

We call $\mathcal{O}_L$ the ring of algebraic integers of $L$.

\begin{lemma} (1.7)\\
Let $L/\Q$ be a number field, and let $\alpha \in L$. Then $\exists n \geq 1$ an integer such that $n\alpha \in \mathcal{O}_L$.
\begin{proof}
Let $f(x) \in \Q[x]$ be a monic polynomial such that $f(\alpha) = 0$. Then $\exists n\in \Z, n \geq 1$ such that $g(x) = n^{\deg f} f(x/n) \in \Z[x]$ is monic. But then $g(n\alpha) = n^{\deg f} f(\alpha) = 0$. So $n\alpha \in \mathcal{O}_L$.
\end{proof}
\end{lemma}

\newpage

\section{Complex embeddings}
Let $L$ be a number field.
\begin{defi} (2.1)\\
A \emph{complex embedding} of $L$ is a field homomorphism $\sigma: L \to \C$. Note: in this case, $\sigma$ is injective, and $\sigma|_\Q$ is the usual embedding $\Q \to \C$.
\end{defi}

\begin{prop} (2.2)\\
Let $L/K$ be an extension of number fields, and let $\sigma_0:K \to \C$ be a complex embedding. Then there exist exactly $[L:K]$ embeddings $\sigma:L \to \C$ which extends $\sigma_0$ ($\sigma|_K = \sigma_0$).
\begin{proof}
Induction on $[L:K]$. If $[L:K] = 1$, then $L=K$, so $\sigma_0$ determines $\sigma$.\\
In general, choose $\alpha \in L-K$ and consider $L/K(\alpha)/K$. By the Tower law, $[L:K] = [L:K(\alpha)][K(\alpha):K]$ and $[K(\alpha):K]>1$. By induction, it's enough to show there are exactly $[K(\alpha):K]$ embeddings $\sigma:K(\alpha) \to \C$ extending $\sigma_0$.\\
Let $f_\alpha(x) \in K[x]$ be the minimal polynomial of $\alpha$ over $K$. Observe there's an isomorphism $K[x] / (f_\alpha(x)) \to K(\alpha)$ by sending $x \to \alpha$. To give a complex embedding $\sigma:K(\alpha) \to \C$ extending $\sigma_0$, it's equivalent to give a root $\beta$ of $(\sigma_0 f)(x)$ in $\C$ ($\sigma_0 f(x) \in \C[x]$ means apply $\sigma_0$ to the coefficients of $f(x)$). Dictionary: $\sigma \to \beta = \sigma (\alpha)$. We have $[K(\alpha):K] = \deg f_\alpha = \deg \sigma_0 f_\alpha$. It's enough to show $\sigma_0 f_\alpha$ has distinct roots in $\C$. The polynomial $f_\alpha(x) \in K[x]$ is irreducible, so is prime to its derivative $f'_\alpha(x)$ ($char\ K =0$). So $\alpha$ is separable over $K$.
\end{proof}
\end{prop}

Recall from last lecture, let $L$ be a number field, a complex embedding is a field homomorphism $\sigma:L \to \C$. The number of such embeddings is $[L:\Q$]. If $L = \Q(\alpha)$, and $f_\alpha(x) \in \Q[x]$ is the minimal polynomial, then there is a bijection $\{\sigma:L \to \C \} \leftrightarrow \{$ roots $\beta \in \C$ of $f_\alpha(x)\}$ by sending $\sigma \to \beta = \sigma(alpha)$.

Notation: if $\sigma:L \to \C$ is a complex embedding, then $\bar{\sigma} : L \to \C$ is also a complex embedding, where $\bar{\sigma}(\alpha) = \overline{\sigma(\alpha)}$ (complex conjugation). If $\sigma = \bar{\sigma}$, then $\sigma(L) \subseteq \R$. Otherwise $\sigma \neq \bar{\sigma}$ and $\sigma(L) \not\subseteq \R$.

We write $r$ for the number of complex embedding $\sigma$ such that $\sigma = \bar{\sigma}$, $s$ for the number of pairs of embeddings $\{\sigma,\bar{\sigma}\}$ where $\sigma \neq \bar{\sigma}$. Then $r+2s = [L:\Q]$.

\begin{eg}
Let $d \in \Z$ be square-free, $d \neq 0,1$. Let $\Q(\sqrt{d}) = \Q[x] / (x^2-d)$. If $d>0$, then $r=2,s=0$ (real quadratic field).\\
If $d<0$, then $r=0,s=1$ (imaginary quadratic field).
\end{eg}

\begin{eg}
Let $m \in \Z$ cube-free, $m \neq 0,1,-1$. Let $\Q(\sqrt[3]{m}) =\Q[x]/(x^3-m)$. Then $r=1,s=1$, since $x^3-m$ has one real and two complex roots.
\end{eg}

\begin{defi} (2.3)\\
Let $L/K$ be an extension of number fields, and let $\alpha \in L$. Let $m_\alpha:L\to L$ be the $K$-linear map defined by $m_\alpha(\beta) = \alpha\beta$. Then we define
\begin{equation*}
\begin{aligned}
\tr_{L/K}(\alpha) = \tr m_\alpha \in K\\
N_{L/K}(\alpha) = \det m_\alpha \in K
\end{aligned}
\end{equation*}
the trace and norm of $\alpha$ respectively.
\end{defi}

\begin{lemma} (2.4)\\
If $L/K$ is an extension of number fields and $\alpha \in L$, then
\begin{equation*}
\begin{aligned}
\tr_{L/K}(\alpha) = [L:K(\alpha)] \tr_{K(\alpha)/K}(\alpha)\\
N_{L/K}(\alpha) = N_{K(\alpha)/K} (\alpha)^{[L:K(\alpha)]}
\end{aligned}
\end{equation*}
\begin{proof}
There's an isomorphism $L \cong K(\alpha)^{[L:K(\alpha)]}$ of $K(\alpha)$-vector spaces(?).
\end{proof}
\end{lemma}

\begin{lemma} (2.5)\\
Let $L/K$ be an extension of number fields and let $\alpha \in L$. Let $\sigma_0:K \to \C$ be a complex embedding, and let $\sigma_1,...,\sigma_n:L \to \C$ be the embeddings of $L$ extending $\sigma_0$.\\
Then
\begin{equation*}
\begin{aligned}
\sigma_0(\tr_{L/K} (\alpha)) = \sigma_1(\alpha) + ... + \sigma_n(\alpha)\\
\sigma_0(N_{L/K}(\alpha)) = \sigma_1(\alpha)...\sigma_n(\alpha).
\end{aligned}
\end{equation*}
\begin{proof}
WLOG let $L=K(\alpha)$. Let $f_\alpha(x) \in K[x]$ be the minimal polynomial of $\alpha$ over $K$. Then $$(\sigma_0 f_\alpha)(x) = (x-\sigma_1(\alpha))(x-\sigma_2(\alpha))...(x-\sigma_n(\alpha))$$
If $f(\alpha) = x^n+a_1x^{n-1}+...+a_n$, then $\sigma_0(a_1) = -(\sigma_1(\alpha)+...+\sigma_n(\alpha))$, $\sigma_0(a_n) = (-1)^n \sigma_1(\alpha)...\sigma_n(\alpha)$.\\
Let $g(x) \in K[x]$ be the characteristic polynomial of $m_\alpha$. If $g(x) = x^n+b_1x^{n-1}+...+b_n$, then $b_1 = -\tr m_\alpha = -\tr_{L/K}(\alpha)$, $b_n = (-1)^n \det m_\alpha = (-1)^n N_{L/K}(\alpha)$.By Cayley-Hamilton, $g(m_\alpha) = 0 \implies g(\alpha) = 0 \implies f_\alpha(x) = g(x)$.
\end{proof}
\end{lemma}

\begin{coro} (2.6)\\
If $\alpha \in \mathcal{O}_L$, then $\tr_{L/K}(\alpha)$, $N_{L/K}(\alpha) \in \mathcal{O}_K$.
\begin{proof}
If $\beta \in K$ then $\beta \in \mathcal{O}_K$ $\iff$ $\sigma_0(\beta) \in \mathcal{O}_\C$ (as $\forall f(x) \in \Z[x], f(\beta) = 0 \iff f(\sigma_0(\beta)) = 0$).\\
By the lemma, $\sigma_0 \tr_{L/K} (\alpha) = \sigma_1(\alpha)+...+\sigma_n(\alpha)$. If $\alpha \in \mathcal{O}_L$, then $\sigma_1(\alpha),...,\sigma_n(\alpha) \in \mathcal{O}_\C \implies \sigma_1(\alpha)+...+\sigma_n(\alpha) \in \mathcal{O}_\C$ $\implies \sigma_0 \tr_{L/K}(\alpha) \in \mathcal{O}_\C$ $\implies \tr_{L/K}(\alpha) \in \mathcal{O}_K$.

The same argument works for the norm.
\end{proof}
\end{coro}

\begin{prop} (2.7)\\
Let $d \in \Z$ be squarefree, $d \neq 0,1$, and let $L = \Q(\sqrt{d})$. Then
\begin{equation*}
\begin{aligned}
\mathcal{O}_L = \left\{\begin{array}{ll}
\Z[\sqrt{d}] & d \equiv 2,3 \pmod 4\\
\Z[\frac{1+\sqrt{d}}{2}] & d \equiv 1 \pmod 4
\end{array}
\right.
\end{aligned}
\end{equation*}
\begin{proof}
If $\alpha \in L$, then $\alpha \in \mathcal{O}_L$ if and only if both trace and norm (over $L/\Q$) of $\alpha$ is in $\Z$. Why? Forward direction is the previous corollary; if $\alpha \in L$, then $f(\alpha) = 0$, where $f(x) = (x-\sigma_1(\alpha))(x-\sigma_2(\alpha)) = x^2 - \tr_{L/\Q}(\alpha)x+N_{L/\Q}(\alpha) \in \Q[x]$, where $\sigma_1,\sigma_2$ are complex embeddings of $L$. So backward holds too.

Let $\alpha \in L$. Write $\alpha = \frac{u}{2} + \frac{v}{2}\sqrt{d}$ where $u,v \in \Q$. If $\alpha \in \mathcal{O}_L$, then $\tr_{L/\Q}(\alpha) = u \in \Z$, and $N_{L/\Q}(\alpha) = \frac{1}{4} (u+\sqrt{d} v) (u-\sqrt{d} v) = \frac{1}{4} (u^2-dv^2) \in \Z$ $\implies u^2-dv^2 \in 4\Z$ $\implies dv^2\in\Z$.\\
Write $v=\frac{r}{s}$ where $r,s \in \Z, s \neq 0, (r,s) = 1$. Then we get $dr^2 \in s^2\Z$ $\implies s^2 | dr^2$.\\
If $p$ is a prime and $p|s$ then $p^2|d$. But we assumed $d$ is square-free. So $s=1$, so $v \in \Z$.

We've shown if $\alpha \in \mathcal{O}_L$, then $\alpha = \frac{u}{2} + \frac{v}{2}\sqrt{d}$ where $u,v \in \Z$ and $u^2 \equiv d^2 \pmod 4$.\\

Case 1: $d \equiv 2,3 \pmod 4$. Then $u^2,v^2 \equiv 0,1 \pmod 4$. Considering the congruence $u^2\equiv dv^2 \pmod 4$ shows that both $u,v \in 2\Z$. Hence $\alpha \in \Z[\sqrt{d}] = \{a+b\sqrt{d} | a,b \in \Z\}$, and $\mathcal{O}_L = \Z[\sqrt{d}]$.

Case 2: $d \equiv 1 \pmod 4$. Hence $u^2\equiv v^2 \pmod 4$, so $u \equiv v \pmod 2$. Hence $\mathcal{O}_L \subseteq \{\frac{u}{2}+\frac{v}{2}\sqrt{d} | u,v \in \Z, u \equiv 1 \pmod 2\} =\Z \oplus \Z(\frac{1+\sqrt{d}}{2})$. It remains to show that $\frac{1+\sqrt{d}}{2}$ is an algebraic integer.\\
We have $\tr_{L/\Q}(\frac{1+\sqrt{d}}{2}) = 1$, $N_{L/\Q}(\frac{1+\sqrt{d}}{2}) = \frac{1-d}{4} \in \Z$.
\end{proof}
\end{prop}

Recall that if $R$ is a ring, then a unit in $R$ is an element $u \in R$ such that there exists $v \in R$ such that $uv = 1$.

The set $\R^* = \{u \in R | u $ is a unit$\}$ forms a group under multiplication.

\begin{lemma} (2.8)\\
If $L$ is a number field, then the units in $\mathcal{O}_L$ are $\mathcal{O}_L^* = \{\alpha \in \mathcal{O}_L| N_{L/\Q}(\alpha) = \pm 1\}$.
\begin{proof}
next time.

It's next time now! Let's prove this lemma.\\
$N_{L/\Q}(\alpha\beta)=N_{L/\Q}(\alpha)N_{L/\Q}(\beta)$ for any $\alpha,\beta \in L$.\\
If $\alpha \in \mathcal{O}_L^*$, then $\exists \beta \in \mathcal{O}_L$ such that $\alpha\beta = 1 \implies N_{L/\Q}(\alpha) N_{L/\Q}(\beta) = 1$. Since $N_{L/\Q}(\alpha),N_{L/\Q}(\beta) \in \Z$, we get $N_{L/\Q}(\alpha) \in \{\pm 1\}$.\\
Conversely, suppose $\alpha \in \mathcal{O}_L$ and $N_{L/\Q} (\alpha) = \pm 1$. Then $\alpha^{-1} \in L$. Let $\sigma_1,...,\sigma_n:L \to \C$ be the distinct complex embeddings of $L$. Then
\begin{equation*}
\begin{aligned}
N_{L/\Q}(\alpha) = \sigma_1(\alpha)...\sigma_n(\alpha) = \pm 1\\
\implies \sigma_1(\alpha^{-1}) = \pm \sigma_2(\alpha)...\sigma_n(\alpha) \in \mathcal{O}_\C\\
\implies \alpha^{-1} \in \mathcal{O}_L
\end{aligned}
\end{equation*}
\end{proof}
\end{lemma}

\begin{rem}
We'll prove later in the course that $\mathcal{O}_L^*$ is a finite group $\iff$ either $L=\Q$ or $L$ is an imaginary quadratic field.
\end{rem}

\newpage

\section{Discriminants and integral bases}
Let $L$ be a number field, $n=[L:\Q]$, $\sigma_1,...,\sigma_n:L \to \C$ be distinct complex embeddings.

\begin{defi} (3.1)\\
Let $\alpha_1,...,\alpha_n \in L$. Then their discriminant is $disc(\alpha_1,...,\alpha_n) = \det(D)^2$, where $D=M_{n\times n}(F)$ is $D_{ij} = \sigma_i (\alpha_j)$. Note: this is independent of the choice of ordering of $\sigma_1,...,\sigma_n$ and $\alpha_1,...,\alpha_n$, as that's just permuting the rows or columns, hence changing only possibly signs; but we took a square in the definition.
\end{defi}

\begin{lemma} (3.2)\\
Let $\alpha_1,...,\alpha_n \in L$. Then $disc(\alpha_1,...,\alpha_n) = \det(T)$, where $T \in M_{n \times n}(\Q)$ is $T_{ij} = \tr_{L/\Q}(\alpha_i\alpha_j)$.
\begin{proof}
$T_{ij} = \sum_{k=1}^n \sigma_k (\alpha_i\alpha_j) = \sum_{k=1}^n D_{ki} D_{kj} = (D^T D)_{ij}$.
\end{proof}
\end{lemma}

\begin{coro} (3.3)\\
$disc(\alpha_1,...,\alpha_n) \in \Q$. If $\alpha_1,...,\alpha_n \in \mathcal{O}_L$, then $disc(\alpha_1,...,\alpha_n) \in \Z$.
\begin{proof}
$disc(\alpha_1,...,\alpha_n) = \det(T)$, and entries of $T$ is trace of some elements of $L$ (over $\Q$) so is in the base field $\Q$ (think a bit). So this must be rational. If $\alpha_1,...,\alpha_n \in \mathcal{O}_L$, then $\forall i,j$, $D_{ij} \in \mathcal{O}_\C \implies disc(\alpha_1,...,\alpha_n) \in \mathcal{O}_\C \cap \Q =\Z$.
\end{proof}
\end{coro}

\begin{prop} (3.4)\\
Let $\alpha_1,...,\alpha_n \in L$. Then $disc(\alpha_1,...,\alpha_n) \neq 0 \iff \alpha_1,...,\alpha_n$ form a basis of $L$ as $\Q$-vector space.\\
\begin{proof}
First suppose $\alpha_1,...,\alpha_n$ are linearly dependent. Then the columns of the matrix $D_{ij} = \sigma_i(\alpha_j)$ are linearly depnedent $\implies disc(\alpha_1,...,\alpha_n) = 0$ (determinant is 0).\\
Now suppose $\alpha_1,...,\alpha_n$ are linearly independent. Then $disc(\alpha_1,...,\alpha_n) \neq 0$ $\iff \det (T) \neq 0$ $\iff$ the symmetric bilinear form $\phi:L \times L \to \Q$ by $\phi(\alpha,\beta) = \tr_{L/\Q}(\alpha\beta)$ is non-degenerate, i.e. $\forall \alpha \in L^*, \exists \beta \in L$ such that $\phi(\alpha,\beta) \neq 0$.\\
If $\alpha \in L^*$, then $\phi(\alpha,\alpha^{-1}) = \tr_{L/\Q}(1) = n \neq 0$.
\end{proof}
\end{prop}

\begin{defi} (3.5)\\
We say elements $\alpha_1,...,\alpha_n \in L$ form an \emph{integral basis for $\mathcal{O}_L$}, if:\\
(i) $\alpha_1,...,\alpha_n \in \mathcal{O}_L$;\\
(ii) $\alpha_1,...,\alpha_n$ generate $\mathcal{O}_L$ as a $\Z$-module.
\end{defi}

\begin{lemma} (3.6)\\
If $\alpha_1,...,\alpha_n$ form an integral basis for $\mathcal{O}_L$, then the function
\begin{equation*}
\begin{aligned}
f: \Z^n &\to \mathcal{O}_L\\
(m_1,...,m_n) &\to \sum_{i=1}^n m_i\alpha_i
\end{aligned}
\end{equation*}
is an isomorphism of $\Z$-module.
\begin{proof}
$f$ is a homomorphism, we must show it's bijective. Observe that $\alpha_1,...,\alpha_n$ form a basis of $L$ as $\Q$-vector space. We know that if $\beta \in L$, then $\exists N \in \Z^+$ such that $N\beta \in \mathcal{O}_L$ (I think (1.7)). So we can write $N\beta = \sum_{i=1}^n m_i \alpha_i$ for some $m_1 \in \Z$ $\implies \beta = \sum_{i=1}^n \frac{m_i}{N}\alpha_i$. Hence $\alpha_1,...,\alpha_n$ span $L$, so they form a basis of $L$.\\
If $f(m_1,...,m_n) = 0$, then $\sum_{i=1}^n m_i \alpha_i = 0 \implies (m_1,...,m_n) = (0,...,0)$, as $\alpha_1,...,\alpha_n$ are independent over $\Q$. This shows $f$ is injective. It's surjecitve by definition.
\end{proof}
\end{lemma}

\begin{lemma} (3.7, sandwich lemma)\\
(i) If $H \leq G$ are groups and $G \cong \Z^a$ for some $a \geq 0$, then $H \cong \Z^b$ for some $b \leq a$.\\
(ii) If $K \leq H \leq G$ are groups and $K \cong \Z^a$, $G \cong \Z^a$ for some $a \geq 0$, then $H \cong \Z^a$.\\
(iii) If $H \leq G$ are groups and $H \cong \Z^a$, $G \cong \Z^a$ for some $a \geq 0$, then $G/H$ is finite.
\begin{proof}
(i) $H \leq G$, $G \cong \Z^a$. Then $G/H$ is f.g abelian group. By the classification, there's an isomorphism $G/H \cong \Z^N \oplus A$, $A$ finite abelian group. Choose $p$ prime, $p \not\mid |A|$. Then the map $f:G/H \to G/H$ by $x+H \to px + H$ is injective, so $f':H/pH \to G/pG$ by $x+pH \to x+pG$ is injecitve -- why? If $x \in H, x \in pG$, then $x = py$ for some $y \in G$; then $y+H \in \ker(f) =H$. Hence $x \in pH$. So indeed $f'$ is injective. By the classification, $H \cong \Z^b$. $f'$ injective $\implies |H/pH| \leq |G/pG|$, i.e. $p^b \leq p^a$ so $b\leq a$.\\
(ii) Apply (i) to $K \leq H$ and $H \leq G$ to get $H \cong \Z^b$ where $a\leq b\leq a$.\\
(iii) $H \leq G$, $H \cong \Z^a, G \cong \Z^a$. Again $G/H$ is finitely generated, so by the classification $G/H \cong \Z^N \oplus A$ where $A$ is a finite abelian group.\\
Let $p$ be a prime, $p \not\mid |A|$. same proof as in (i) shows that $f':H/pH \to G/pG$ is injecitve. Since $|H/pH| = |G/pG| = p^a$, $f'$ is a group isomorphism $G/H + pG \cong (\Z/p\Z)^N$. There's a surjective homomorphism $G/pG \to G/H+pG$ which has kernel containing the image of $f'$. Hence $G/pG \to G/H + pG$ is surjective with kernel $G/pG$. This forces $N=0$.
\end{proof}
\end{lemma}

Let $L$ be a number field, $n = [L:\Q]$, $\sigma_1,...,\sigma_n:L \to \C$ be distinct complex embeddings; $\alpha_1,...,\alpha_n \in L$, we defined $disc(\alpha_1,...,\alpha_n) = \det(\sigma_i(\alpha_j))^2$. An alternative notation is $\Delta(\alpha_1,...,\alpha_n)$. We also said $\alpha_1,...,\alpha_n$ form an integral basis for $\mathcal{O}_L$ if they generate $\mathcal{O}_L$ as a $\Z$-module.

\begin{prop} (3.8)\\
There exists an integral basis for $\mathcal{O}_L$.
\begin{proof}
Let $\beta_1,...,\beta_n \in L$ be a basis for $L$ as $\Q$-vector space. WLOG, $\beta_1,...,\beta_n \in \mathcal{O}_L$. Then $\mathcal{O}_L \supset \oplus_{i=1}^n \Z \beta_i$.\\
Recall $\phi:L \times L \to \Q$ by sending $(\alpha,\beta) \to \tr_{L/\Q} (\alpha\beta)$ is a non-degenerate symmetric bilinear form (we showed that last time). Let $\beta_1^*,...,\beta_n^*$ be the dual basis. Then $\tr_{L/\Q(\beta_i \beta_j^*)} = \delta_{ij}$ (why?).\\
If $\alpha \in \mathcal{O}_L$, then we can write $\alpha = \sum_{i=1}^n a_i \beta_i^*$ where $a_i \in \Q$. We know $\alpha\beta_i \in \mathcal{O}_L$, hence $\tr_{L/\Q} (\alpha\beta) \in \Z$. However LHS = $\sum_{j=1}^n \tr_{L/\Q} (a_j \beta_j^* \beta_i) = \sum_{j=1}^n a_j \tr_{L/\Q} (\beta_j^* \beta_i) = a_j$. So $\mathcal{O}_L \subseteq \oplus_{i=1}^n \Z \beta_i^*$. By sandwich lemma there is an isomorphism between $\Z^n$ and $\mathcal{O}_L$.
\end{proof}
\end{prop}

If $\alpha_1,...,\alpha_n$, $\beta_1,...,\beta_n$ are both integral bases for $\mathcal{O}_L$, then there exists $A \in M_{n \times n} (\Z)$ such that $\beta_j = \sum_{i=1}^n A_{ij}\alpha_i$ for each $j=1,...,n$. Moreover, we must have $\det(A) \in \{\pm 1\}$, and $A \in GL_n(\Z)$. Then $disc(\beta_1,...,\beta_n) = \det(D')^2$, where $D'_{ij} = \sigma_i(\beta_j), D_{ij} = \sigma_i(\alpha_j)$. We have $D'_{ij} = \sum_{k=1}^n \sigma_i (A_{kj} \alpha_k) = \sum_{k=1}^n \sigma_i (\alpha_k) A_{kj} = (DA)_{ij}$.

We find $disc(\beta_1,...,\beta_n) = \det(D')^2 = \det(DA)^2 = \det(D)^2 = disc(\alpha_1,...,\alpha_n)$. Therefore we could define:

\begin{defi} (3.9)\\
The discriminant $D_L$ of the number field $L$ is $disc(\alpha_1,...,\alpha_n)$, where $\alpha_1,...,\alpha_n$ is any integral basis for $\mathcal{O}_L$.
\end{defi}

\begin{prop} (3.10)\\
Let $L=\Q(\alpha)$, and let $f(x) \in \Q[x]$ be the minimal polynomial of $\alpha$ over $\Q$. Then
\begin{equation*}
\begin{aligned}
disc (1,\alpha,\alpha^2,...,\alpha^{n-1}) = \prod_{i<j} (\sigma_i(\alpha)-\sigma_j(\alpha))^2 = (-1)^{n(n-1)/2} N_{L/\Q}(f'(\alpha))
\end{aligned}
\end{equation*}
In part II Galois theory, we defined the discrimant of a polynomial, $disc f = \prod_{i<j} (\sigma_i(\alpha) - \sigma_j(\alpha))^2$ where $\alpha_i$'s are the roots of $f$.
\begin{proof}
If $D_{ij} = \sigma_i(\alpha^{j-1})$, $D \in M_{n\times n} (\C)$, then $disc(1,\alpha,...,\alpha^{n-1}) = \det(D)^2$. $D$ is a Vandermonde matrix, so we know $\det(D) = \prod_{i<j} (\sigma_j(\alpha) - \sigma_i(\alpha))$.\\
On the other hand, $N_{L/\Q} (f'(\alpha)) = \prod_{i=1}^n \sigma_i (f'(\alpha)) = \prod_{i=1}^n f'(\sigma_i(\alpha))$.\\
Using $f(x) = \prod_{j=1}^n (x-\sigma_j(\alpha))$, we get RHS = $\prod_{i=1}^n \prod_{j \neq i} (\sigma_i(\alpha) - \sigma_j(\alpha)) = (-1)^{n \choose 2} \prod_{i < j} (\sigma_i(\alpha) - \sigma_j(\alpha))^2$.
\end{proof}
\end{prop}

Note: if $\alpha \in \mathcal{O}_L$ and $\Z[\alpha] = \mathcal{O}_L$, then $1,\alpha,...,\alpha^{n-1}$ is an integral basi for $\mathcal{O}_L$. We can then use proposition to calculate $D_L$.

\begin{eg}
Let $d\in \Z$ square-free, $d \neq 0,1$, $L = \Q(\sqrt{d})$. Then
\begin{equation*}
\begin{aligned}
D_L = \left\{\begin{array}{ll}
4d & d \equiv 2,3 \pmod 4\\
d & d \equiv 1 \pmod 4
\end{array}
\right.
\end{aligned}
\end{equation*}
To see this, if $d \equiv 2,3 \pmod 4$, then $\mathcal{O}_L = \Z[\sqrt{d}]$ (shown previously). Apply proposition to $x^2-d = f(x)$, we get $D_L = disc(1,\sqrt{d}) = -N_{L/\Q}(2\sqrt{d}) = 4d$.\\
On the other hand, if $d \equiv 1 \pmod 4$, then $\mathcal{O}_L = \Z[\frac{1+\sqrt{d}}{2}]$. Apply proposition to the minimal polynomial of this element, $f(x) = x^2-x+\frac{1-d}{4}$, so $f'(x) = 2x-1$, so $f'(\alpha) = \sqrt{d}$. Therefore $D_L = -N_{L/\Q}(\sqrt{d}) = \sqrt{d}$.
\end{eg}

\begin{prop}
If $\alpha_1,...,\alpha_n \in \mathcal{O}_L$ are such that $disc(\alpha_1,...,\alpha_n)$ is a non-zero square-free integer, then $\alpha_1,...,\alpha_n$ form an integral basis for $\mathcal{O}_L$.\\
Note: this is a sufficient condition, but is not necessary (the previous example).\\
\begin{proof}
Let $\beta_1,...,\beta_n$ be an integral basis for $\mathcal{O}_L$. There exists $A \in M_{n \times n} (\Z)$ such that $\alpha_j = \sum_{i=1}^n A_{ij} \beta_i$ $\forall j = 1,...,n$. Then $disc(\alpha_1,...,\alpha_n) = \det(A)^2 disc(\beta_1,...,\beta_n)$ (we proved this in the beginning of lecture: $D'=DA$). In particular, if this is square-free and non-zero, then $\det(A)$ must be $\{\pm 1\}$. So $A \in GL_n(\Z)$. Hence $\alpha_1,...,\alpha_n$ generate $\mathcal{O}_L$ (as they can generate $\beta_i$) and form an integral basis.
\end{proof}
\end{prop}

This could save a lot of calculation if we are lucky.
\begin{eg}
Let $f(x) = x^3-x-1$. Then $disc f = -4a^3 - 27b^2 = -23$. This is square-free! If $L=\Q(\alpha)$, $\alpha$ a root of $f(x)$, then $\mathcal{O}_L = \Z[\alpha]$.
\end{eg}

\begin{defi} (3.12)\\
Let $I \subseteq \mathcal{O}_L$ be a no-zero ideal. Then elements $\alpha_1,...,\alpha_n \in L$ form an integral basis for $I$ if:\\
(i) $\alpha_1,...,\alpha_n \in I$;\\
(ii) $\alpha_1,...,\alpha_n$ generate $I$ as a $\Z$-module.
\end{defi}

\begin{prop} (3.13)\\
Let $I \subseteq \mathcal{O}_L$ be a non-zero ideal. Then there exists an integral basis for $I$.
\begin{defi}
By definition, $I \subseteq \mathcal{O}_L \cong \Z^n$. Let $\alpha_1,...,\alpha_n \in \mathcal{O}_L$ be an integral basis for $\mathcal{O}_L$. Let $\alpha \in I$ be non-zero. Then $(\alpha)\subseteq I$, hence $\oplus_{i=1}^n \Z \alpha \alpha_i \subseteq I \subseteq \mathcal{O}_L$. So by sandwich lemma, there is an isomorphism between $I$ and $\Z^n$ as $\Z$-module. Hence there exists an integral basis for $I$.
\end{defi}
\end{prop}

An interesting consequence of the proof:
\begin{defi} (3.14)\\
If $I \subseteq \mathcal{O}_L$ is a non-zero ideal, then we define its norm
\begin{equation*}
\begin{aligned}
N(I) = [\mathcal{O}_L:I]
\end{aligned}
\end{equation*}
which is finite by the sandwich lemma.
\end{defi}

\begin{defi} (3.15)\\
If $I \subset \mathcal{O}_L$ is a non-zero ideal then we define $disc(I) = disc(\alpha_1,...,\alpha_n)$ where $\alpha_1,...,\alpha_n$ is an integral basis for $I$. (same argument shows $disc(I)$ depends only on $I$).
\end{defi}

\begin{lemma} (3.16)\\
If $I \subseteq \mathcal{O}_L$ is a non-zero ideal, then $disc(I) = disc(\mathcal{O}_L) N(I)^2$.
\begin{proof}
Let $\alpha_1,...,\alpha_n$, $\beta_1,...,\beta_n$ be integral bases for $\mathcal{O}_L$ and $I$ respectively. Then $\exists A \in M_{n \times n} (\Z)$ such that $\beta_j = \sum_{i=1}^n A_{ij} \alpha_i$ $\forall j = 1,...n$, and $disc (\alpha_1,...,\alpha_n) \det(A)^2 = disc(\beta_1,...,\beta_n)$. We must show $\det(A)^2 = [\mathcal{O}_L:I]^2$.

In fact, we'll show if $B \in M_{n \times n} (\Z)$ and $\det(B) \neq 0$, then $|\Z^n / B\Z^n| = |\det(B)|$. This suffices after identify $\mathcal{O}_L \cong \Z^n$.

Recall: $\exists P,Q \in GL_n(\Z)$ such that $PBQ = D = Diag(d_1,...,d_n)$, $d_i \in \Z$ (Smith normal form). Hence we have $\Z^n/B\Z^n \cong \Z^n/D\Z^n \cong \oplus_{i=1}^n \Z/d_i \Z \implies |\Z^n / B\Z^n| = |\Z^n / D\Z^n| = \prod_{i=1}^n |d_i|$.\\
On the other hand, $|\det(B)| = |\det(D)| = \prod_{i=1}^n |d_i|$.
\end{proof}
\end{lemma}

Remember we have $L$ a number field, $n=[L:\Q]$, $\sigma_1,...,\sigma_n:L \to \C$ are distinct complex embeddings of $L$.

\begin{lemma} (3.17)\\
Let $\alpha \in \mathcal{O}_L \setminus\{0\}$. Then $N((\alpha)) = |N_{L/\Q}(\alpha)|$ (Note that's an ideal).
\begin{proof}
Let $\alpha_1,...,\alpha_n$ be an integral basis for $\mathcal{O}_L$. Then $\alpha\alpha_1,...,\alpha\alpha_n$ is an integral basis for $I=(\alpha)$. So
\begin{equation*}
\begin{aligned}
disc(I) &= disc(\alpha\alpha_1,...,\alpha\alpha_n)\\
&= \det(\sigma_i(\alpha\alpha_j))^2\\
&= \det(\sigma_i(\alpha)\sigma_i(\alpha_j))^2\\
&= (\prod_{i=1}^n \sigma_i(\alpha))^2 \det(\sigma_i(\alpha_j))^2\\
&= N_{L/\Q}(\alpha)^2 disc(\mathcal{O}_L)
\end{aligned}
\end{equation*}
And we showed last time that for any non-zero ideal $J \subseteq \mathcal{O}_L$, $disc(J) = N(J)^2 disc(\mathcal{O}_L)$.
\end{proof}
\end{lemma}

Notation: If $\alpha \in \mathcal{L}-\{0\}$, we let $N(\alpha) = N((\alpha)) N(0) = 0$.\\
Then $\forall \alpha,\beta \in \mathcal{O}_L$, $N(\alpha\beta) = N(\alpha)N(\beta)$.

\newpage
\section{Unique factorisation in $\mathcal{O}_L$}
Recall: we say a ring $R$ is a unique factorisation domain (UFD) if\\
(i) $R$ is an integral domain;\\
(ii) if $x \in R$ is non-zero and not a unit, then there exists an expression $x=p_1...p_r$ where $p_i \in R$ are irreducible elements. This expression is unique in the sense that if $x = q_1...q_s$ is another such expression, then $r=s$ and after re-ordering, each $q_i$ is an associate of $p_i$ (i.e. $q_i \in R^* p_i$, where $R^*$ is the field of units).

After 2 years of Cambridge Maths we certainly know $\Z$ is a UFD. However, if $L$ is a number field, $\mathcal{O}_L$ need not be a UFD.

In fact, any non-zero $x \in \mathcal{O}_L$ which is not a unit can be expressed as a product of irreducible elements.

If $x \in \mathcal{O}_L$, then $x$ is a no-zero non-unit $\iff N(x)>1$. Suppose $x \in \mathcal{O}_L$ is a non-zero non-unit which cannot be written as a product of irreducible elements, and with $N(x)$ minimal among elements with this property. Then $x=yz$ with $N(y) >1$, $N(z)>1$, hence $N(y)<N(x)$, $N(z)<N(x)$. By minimality of $N(x)$, both $y,z$ can be written as products of irreducible; contradiction.

\begin{eg}
Consider $L=\Q(\sqrt{-5}$, $\mathcal{O}_L = \Z[\sqrt{-5}]$, and $\mathcal{O}_L^* = \{\pm 1\}$. In $\mathcal{O}_L$ we have $6 = 2 \times 3 = (1+\sqrt{-5})(1-\sqrt{-5})$, and all of the four are irreducibles, and no two are associates (norms). So $\mathcal{O}_L$ is not a UFD (famous example).
\end{eg}

Idea: introduce ideal multiplication in order to reduce elements further.

Recall that if $R$ is a ring and $I,J$ are ideals of $R$, then we define
\begin{equation*}
\begin{aligned}
IJ = \{\sum_{i=1}^k a_ib_i | a_i \in I, b_i \in J\},\\
I+J = \{a+b|a\in I, b \in J\}
\end{aligned}
\end{equation*}
We can define an ideal $I \subsetneq R$ to be irreducible if it does not admit an expression $I=JK$ where $J,K$ are proper ideals of $R$.

Key point: even if $\alpha \in \mathcal{O}_L$ is irreducible, the ideal $(\alpha)$ need not be irreducible. For example in $\Z[\sqrt{-5}]$, we have $(2) = (2,1+\sqrt{-5})^2$, $(3) = (3,1+\sqrt{-5})(3,1-\sqrt{-5})$.

\begin{defi} (4.1)\\
If $R$ is a ring, we say that an ideal $P \subsetneq R$ is prime if $\forall x,y \in R$, $xy \in P$ $\implies x \in P$ or $y \in P$.
\end{defi}

\begin{lemma} (4.2)\\
Let $R$ be a ring, and let $I,J,P \subseteq R$ be ideals, and suppose $P$ is prime and $IJ \subseteq P$. Then $I \subseteq P$ or $J \subseteq P$.
\begin{proof}
WLOG $I \not\subseteq P$. Choose some $x \in I \setminus P$. If $y \in J$, is any element, then $xy \in IJ \subseteq P$. So $y \in P$. So $J \subseteq P$.
\end{proof}
\end{lemma}

From now on, $L$ is a number field.

\begin{lemma} (4.3)\\
Any non-zero prime ideal $P \subseteq \mathcal{O}_L$ is a maximal ideal.
\begin{proof}
Recall: if $R$ is a ring and $I \subsetneq R$ is an ideal, then $I$ is prime $\iff R/I$ is an integral domain, and $I$ is maximal $\iff R/I$ is a field. If you don't remember these statements then I strongly encourage you to review GRM. If $p \subseteq \mathcal{O}_L$ is a non-zero prime ideal, then $\mathcal{O}_L/P$ is a finite integral domain (of cardinality $N(P)$); any such ring is a field, so $P$ is also maximal.
\end{proof}
\end{lemma}

\begin{lemma} (4.4)\\
If $I \subsetneq \mathcal{O}_L$ is a non-zero ideal, then there exist non-zero prime ideals $P_1,...,P_r \subseteq \mathcal{O}_L$ such that $P_1...P_r \subseteq I$.
\begin{proof}
For contradiction, let $I \subsetneq \mathcal{O}_L$ be an ideal whicih does not have this property, and such that $N(I)$ is minimal among ideals not having this property. Then $I$ is not prime, so there exist elements $x,y \in \mathcal{O}_L$ such that $xy \in I$ but $x \not\in I$, $y \not\in I$. But then it follows that $I \subsetneq I+(x)$ and $I \subsetneq I+(y)$. So $N(I+(x)), N(I+(y)) < N(I)$. By minimality of $N(I)$, we can find non-zero prime ideals $P_1...P_r \subseteq I+(x)$ and $Q_1...Q_r \subseteq I+(y)$. Then $P_1 ... P_rQ_1...Q_r \subseteq (I+(x))(I+(y)) \subseteq I^2 +xI+yI+(xy) \subseteq I$. Contradiction.
\end{proof}
\end{lemma}

\begin{lemma} (4.5)\\
If $I \subsetneq \mathcal{O}_L$ is a non-zero ideal, then there exists $\gamma \in L\setminus \mathcal{O}_L$ such that $\gamma I \subseteq \mathcal{O}_L$.
\begin{proof}
Let $\alpha \in I \setminus \{0\}$. Let $P_1,...,P_r \subseteq \mathcal{O}_L$ be non-zero prime ideals such that $P_1...P_r \subseteq (\alpha)$. WLOG $r$ is minimal with this property. Let $P$ be a minimal ideal containing $I$. Then $P \supseteq I \supseteq (\alpha) \supseteq P_1...P_r$, hence $P \supset P_i$ for some $i$. After relabelling assume $P \supset P_1$. Since non-zero prime ideals are maximla, we have $P=P_1$. Since $r$ is minimal, we have $P_2...P_r \not\subseteq(\alpha)$. Choose $\beta \in P_2...P_r \setminus (\alpha)$.\\
Claim: the element $\gamma = \beta/\alpha$ has the desired property.\\
If $\gamma \in \mathcal{O}_L$, then $\beta = \alpha\gamma \in (\alpha)$, contradiction;\\
$\gamma I = \frac{\beta}{\alpha} I \subseteq \frac{1}{\alpha} P_2...P_r \cdot I \subseteq \frac{1}{\alpha} P_1P_2...P_r \subseteq \mathcal{O}_L$.
\end{proof}
\end{lemma}

Let $L$ be a number field. Last lecture we proved that if $I \subsetneq \mathcal{O}_L$ is a non-zero ideal, then there exist $\gamma \in L\setminus \mathcal{O}_L$ such that $\gamma I \subseteq \mathcal{O}_L$.

\begin{prop} (4.6)\\
If $I \subseteq \mathcal{O}_L$ is a non-zero ideal, there exists a non-zero ideal $J \subseteq \mathcal{O}_L$, such that $IJ$ is principal.
\begin{proof}
Choose $\alpha \in I \setminus \{0\}$. Define $J = \{\beta \in \mathcal{O}_L | \beta I \subseteq (\alpha)\}$. $J$ is a non-zero ideal, as $\alpha \in J$. We have $IJ \subseteq (\alpha)$. We will show $IJ = (\alpha$.\\
Let $K = \frac{1}{\alpha}IJ \subseteq \mathcal{O}_L$. We will show in fact that $K=\mathcal{O}_L$. Suppose otherwise, that $K \neq \mathcal{O}_L$, then $\exists \gamma \in L \setminus \mathcal{O}_L$ such that $\gamma K \subseteq \mathcal{O}_L$.\\
We have $(\alpha) \subseteq I$, hence $\frac{1}{\alpha} I \supseteq \mathcal{O}_L$, hence $underbrace{\frac{1}{\alpha} IJ}_{K} \supset J$. Hence $\gamma J \subseteq \gamma K \subseteq \mathcal{O}_L$.\\
Another observation is that, we also have $\gamma IJ = \gamma \alpha K \subseteq (\alpha)$.\\
If we have $\beta \in \gamma J$, on one hand $\beta \in \mathcal{O}_L$; on the other hand, $\beta I \subseteq (\alpha)$. So $\beta \in J$, hence $\gamma J \subseteq J$.\\
Recall that $J$ admits an integral basis, so ther's an isomorphism $J \cong \Z^n$. If $A \in M_{n \times n} (\Z)$ is the matrix representing multiplication by $\gamma$, and if $f(x) \in \Z[x]$ is the characteristic polynomial of $A$, then $f(\gamma) = 0$.\\
Hence $\gamma \in \mathcal{O}_L$. Contradiction. So $K = \mathcal{O}_L$.
\end{proof}
\end{prop}

\begin{coro} (4.7)\\
If $I,J,K \subseteq \mathcal{O}_L$ are non-zero ideals and $IJ = IK$, then $J=K$.
\begin{proof}
Choose a non-zero ideal $A \subseteq \mathcal{O}_L$ such that $AI = (\alpha)$ is principal. Then $AIJ = \alpha J = AIK = \alpha K \implies J=K$.
\end{proof}
\end{coro}

If $I,J \subseteq \mathcal{O}_L$ are non-zero ideals, say $I$ divides $J$ (or $I | J$) if there exists an ideal $K \subseteq \mathcal{O}_L$ such that $IK = J$.

\begin{coro} (4.8)\\
If $I,J \subseteq \mathcal{O}_L$ are non-zero ideals, then $I|J \iff I \supseteq J$.
\begin{proof}
If $IK=J$, then $J \subseteq I$.\\
Suppose instead that $I \supseteq J$. Choose a non-zero ideal $A \mathcal{O}_L$ such that $AI = (\alpha)$ is principal (by 4.6). Then $AI =(\alpha) \supseteq AJ$, hence $\mathcal{O}_L \supseteq \frac{1}{\alpha} AJ$. So $K=\frac{1}{\alpha} AJ$ is a non-zero ideal of $\mathcal{O}_L$, and $IK = \frac{1}{\alpha} AIJ = J$.
\end{proof}
\end{coro}

\begin{thm} (4.9)\\
If $I \subseteq \mathcal{O}_L$ is a non-zero ideal, then there exist prime ideals $P_1,...,P_r \subseteq \mathcal{O}_L$ such that $I = P_1P_2...P_r$. Moreover, this expression is unique up to re-ordering of terms.
\begin{proof}
We show existence by contradiction. Suppose $I$ is an ideal which cannot be written as product of primes, and with $N(I)$ minimal subject to this condition. We can find a maximal ideal $P \supset I$. $P$ is also prime. Then $P|I$, so we can write $I=PJ$ for some ideal $J\subseteq \mathcal{O}_L$. Then $J|I$, hence $J \supset I$. If $J=I$, then we get $I=IP$, hence $\mathcal{O}_L = P$ as we can cancel, but that's a contradiction as prime ideals by definition cannot be $\mathcal{O}_L$.\\
Therefore $J \supsetneq I$, hence $N(J) < N(I)$. By minimality, we can write $J$ as $J=P_2...P_r$ where each $P_i\subseteq \mathcal{O}_L$ are prime ideals. Then we have $I=PJ$. Contradiction. This shows existence.

For uniqueness, suppose $P_1,...,P_r$, $Q_1,...,Q_s$ are non-zero prime ideals in $\mathcal{O}_L$ such that $P_1...P_r = Q_1...Q_s$. Then $P_1 | Q_1...Q_r$, so $P_1 \supseteq Q_i$ for some $i=1,...,s$. WLOG $P_1 \supset Q_1$. Since both $P_1,Q_1$ are maximal, $P_1 = Q_1$. Then we cancel to obtain $P_2...P_r = Q_2...Q_s$; continue this to get $r=s$ and $P_i = Q_i$ after re-ordering.
\end{proof}
\end{thm}

\begin{defi} (4.10)\\
The ideal class group $Cl(\mathcal{O}_L) = \{I\subseteq \mathcal{O}_L$ non-zero ideal$\}$. $I \sim J$ if $\exists \alpha \in L^*$ such that $\alpha I = J$.\\
We write $[I]$ for the equivalence class containing $I$.
\end{defi}

\begin{lemma} (4.11)\\
$Cl(\mathcal{O}_L$ is a group under the operation
\begin{equation*}
\begin{aligned}
[I][J] = [IJ]
\end{aligned}
\end{equation*}
with identity $[\mathcal{O}_L]$.
\begin{proof}
If $I,J \subseteq \mathcal{O}_L$ are non-zero ideals and $\alpha,\beta \in L^*$ are such that $\alpha I \subseteq \mathcal{O}_L$ and $\beta J \subseteq \mathcal{O}_L$. Then
\begin{equation*}
\begin{aligned}
(\alpha I)(\beta J) = \alpha\beta IJ
\end{aligned}
\end{equation*}
so ideal multiplication is well-defined on equivalent classes.\\
For any $I \subseteq \mathcal{O}_L$, $\mathcal{O}_L I = I$, so $[\mathcal{O}_L]$ is an identity.\\
We showed that if $I \subseteq \mathcal{O}_L$ is any non-zero ideal, then there exists a non-zero ideal $J \subseteq \mathcal{O}_L$ such that $IJ = (\alpha)$ is principal. Then $[I][J] = [IJ] = [(\alpha)] = [\mathcal{O}_L]$. Hence $[I]^{-1} = [J]$.
\end{proof}
\end{lemma}

\begin{prop} (4.12)\\
The following are equivalent:\\
(i) $\mathcal{O}_L$ is a PID;\\
(ii) $\mathcal{O}_L$ is a UFD;\\
(iii) The ideal class group, $Cl(\mathcal{O}_L)$, is trivial.
\begin{proof}
(i) implies (ii): In IB GRM.\\
(ii) implies (iii): We must show any ideal $I \subseteq \mathcal{O}_L$ is principal. We know that we can write $I=P_1...P_r$ as a product of prime ideals.\\
It's therefore enough to show that every prime ideal of $\mathcal{O}_L$ is principal. Let $P \subseteq \mathcal{O}_L$ be a non-zero prime ideal, let $\alpha \in P$ be non-zero, and let $\alpha=\alpha_1...\alpha_r$ be an expression of $\alpha$ as a product of irreducibles.\\
Recall: if $R$ is a ring, then we say $x \in R$ is prime if $\forall y,z \in R, x|yz \implies x|y$ or $x|z$. Also we learned from GRM that if $R$ is a UFD then irreducible elements of $R$ are prime.\\
We find $P \supset \alpha = (\alpha_1)...(\alpha_r) \implies P | P_1...P_r$ where $P_i = (\alpha_i)$. Since $\alpha_i$ is prime, $P_i$ is a prime ideal. Hence we must have $P=P_i = (\alpha_i)$ for some $i$, and hence $P$ is principal.\\
(iii) implies (i): Let $I \subseteq \mathcal{O}_L$ be a non-zero ideal. Since $Cl(\mathcal{O}_L$ is trivial, we have $[I] = [\mathcal{O}_L]$, so there exists $\alpha \in L^*$ such that $\alpha \mathcal{O}_L = I$. We have $\alpha \cdot 1 = \alpha \in I \subseteq \mathcal{O}_L$, so $\alpha \in \mathcal{O}_L$, hence $I=(\alpha)$ is principal.
\end{proof}
\end{prop}

\begin{lemma} (4.13)\\
If $I,J \subseteq \mathcal{O}_L$ are non-zero ideals, then $N(IJ) = N(I)N(J)$.
\begin{proof}
Example sheet 2.
\end{proof}
\end{lemma}

Example sheet 2 now available!

Last time we learned that, if $L$ is a number field, then we know any non-zero ideal $I \subseteq \mathcal{O}_L$ canbe written uniquely as $I = \prod_{i=1}^r P_i^{e_i}$, wher the $p_i$ are distinct prime ideals, and $e_i \geq 1$. We also defined $Cl(\mathcal{O}_L)$ as the obstruction to $\mathcal{O}_L$ being a UFD.

\newpage
\section{Dedekind's criteion}
If $P\subseteq \mathcal{O}_L$ is a non-zero prime ideal, then there's a unique prime number $p \in \Z_{\geq 0}$ such that $p \in P$. $(p) = \ker(\Z \to \mathcal{O}_L/P)$. Then $P | p \mathcal{O}_L$, and $N(P) = p^f$ for some $f \geq 1$.

\begin{lemma} (5.1)\\
Let $p$ be a prime number, and factor $p\mathcal{O}_L = \prod_{i=1}^r P_i^{e_i}$ where $P_1,...,P_r$ are distinct prime ideals of $\mathcal{O}_L$, $e_i \geq 1$. Define $f_i \geq 1$ by $N(P_i) = p^{f_i}$. Then $\sum_{i=1}^r e_i f_i = [L:\Q]$. In particular, $r \leq [L:\Q]$.
\begin{proof}
Apply norm to get $N(p\mathcal{O}_L) (=p^{[L:\Q]}) = \prod_{i=1}^r N(P_i)^{e_i} (=p^{\prod_{i=1}^r e_if_i})$.
\end{proof}
\end{lemma}

\begin{defi} (5.2)\\
Let $p$ be a prime number, and let $p\mathcal{O}_L = \prod_{i=1}^r P_i^{e_i}$ be the factorization as above.\\
(i) We say $p$ \emph{ramifies} in $L$ if $e_i > 1$ for some $i$. We say $p$ is totally \emph{ramified} if $r=1$ and $e_1 = [L:\Q]$. In other words, $p\mathcal{O}_L = P_i^{[L:\Q]}$.\\
(ii) We say $p$ is \emph{inert} in $L$ if $r=1$ and $e_1 = 1$, i.e. $p\mathcal{O}_L$ is prime.\\
(iii) We say $p$ \emph{splits completely} in $L$ if $r=[L:\Q]$ and $e_i=f_i=1$ for all $i$.

Note that these don't cover all the possible cases.
\end{defi}

\begin{thm} (5.3, Dedekind's criterion)\\
Let $\alpha \in \mathcal{O}_L$ be such that $L=\Q(\alpha)$. Let $f(x) \in \Z[x]$ be its minimal polynomial and let $p$ be a prime such that $p \nmid [\mathcal{O}_L:\Z[\alpha]]$.\\
Let $\bar{f}(x) = f(x) \pmod p$, and factor $\bar{f}(x) = \prod_{i=1}^r \bar{g}_i(x)^{e_i}$ in $F_p[x]$, where $\bar{g}_1(x),...,\bar{g}_r(x) \in F_p[x]$ are distinct monic irreducible polynomials. Let $g_i(x) \in \Z[x]$ be any polynomial with $g_i(x) \pmod p = \bar{g}_i(x)$, and define $Q_i = (p,g_i(\alpha)) \subseteq \mathcal{O}_L$, an ideal of $\mathcal{O}_L$. Let $f_i = \deg \bar{g}_i(x)$.\\
Then $Q_1,...,Q_r$ are distinct prime ideals of $\mathcal{O}_L$, and $p\mathcal{O}_L = \prod_{i=1}^r Q-i^{e_i}$, and $N(Q_i) = p^{f_i}$.
\end{thm}

For example, let's take $L=\Q(\sqrt{-11})$, $p=5$. We see $-11 \equiv 1 \pmod 4$, so $\mathcal{O}_L = \Z [ \frac{1+\sqrt{-11}}{2}]$. Thus $\Z[\sqrt{-11}] \subseteq \mathcal{O}_L$ has index 2 as an additive subgroup. Therefore we can apply Dedekind's criterion to $\alpha = \sqrt{-11}$, with $f(x) = x^2+11$ in order to factorize $5\mathcal{O}_L$. We see $\bar{f}(x) = f(x) \pmod 5 = x^2+1 = (x+2)(x+3)$ in $F_5[x]$. So $t\mathcal{O}_L = PQ$ where $P = (5,\sqrt{-11}+2), Q = (5,\sqrt{-11},3)$, and hence $P,Q$ are the same prime ideals (of $\mathcal{O}_L$). Thus $5\mathcal{O}_L$ splits completely in $\mathcal{Q}\sqrt{-11}$.

\begin{proof} (of 5.3)\\
Recall: if $R$ is a ring and $I \subseteq R$ is an ideal, then there's a bijection between ideals containing $I$ and idealks of $R/I$. 3rd isomorphism theorem gives $R/J \cong (R/I)/(J/I)$. We have $\Z[\alpha] \subseteq \mathcal{O}_L$ of finite index. Let $A = \Z[\alpha]$, $\phi:A \to \mathcal{O}_L$. By reduction mod $p$, we get another ring homomorphism $\bar{\phi}: A/pA \to \mathcal{O}_L / p\mathcal{O}_L$ by $\bar{\phi}(\beta+pA) = \beta + p\mathcal{O}_L$.\\
We claim that this is actually an isomorphism. Both source and targe have cardinality $p^{[L:\Q]}$, so it's enough to show $\bar{\phi}$ is surjective. Let $N=[\mathcal{O}_L:\Z[\alpha]]$. We can find $a,b \in \Z$ such that $aN+bp = 1$. If $\beta \in \mathcal{O}_L$, then $N\beta \in \Z[\alpha]$ (by Lagrance), and $\beta = aN\beta + bp\beta \implies \bar{\phi} (aN\beta + pA) = \beta + p\mathcal{O}_L$. Therefore there is a bijection between ideals in $\mathcal{O}_L$ containing $p$ and ideals of $A/pA$.\\
We have $A=\Z[\alpha] \cong \Z[x] / (f(x))$ by sending $\alpha$ to $x$. Reduction mod $p$ gives an isomorphism $A/pA \cong \Z[x] / (p,f(x)) \cong F_p[x]/ (\bar{f}(x))$. We have $\bar{f}(x) = \prod_{i=1}^r \bar{g}_i(x)^{e_i}$, so there are homomorphisms $F_p[x] / (\bar{f}(x)) \to \F_p[x]/(\bar{g}_i(x))$, given by quotient by the ideal $(\bar{g}_i (x)) \supseteq (\bar{f}(x))$. Define $\Q_i \subseteq \mathcal{O}_L$ to be the ideal containing $p$ such that $\Q_i/(p)$ is the kernel of the ring homomorphism $\mathcal{O}_L/p\mathcal{O}_L \xrightarrow{\bar{\phi}^{-1}} A/pA \xrightarrow{\cong} F_p[x]/(\bar{f}(x)) \to F_p[x]/(\bar{g}_i(x))$. This ring homomorphism is surjective, and its image is a field of cardinality $p^{f_i}$. Hence $\mathcal{O}_L/\Q_i$ is a finite field of cardinality $p^{f_i}$, hence $\Q_i$ is a prime ideal of norm $N(\Q_i) = p^{f_i}$.\\
Also, the $\Q_i$ are distinct, because their images in $\mathcal{O}_L/p\mathcal{O}_L$ are distinct, as if $i \neq j$ then $(\bar{g}_i(x),\bar{g}_j(x))$ is the unit ideal of $F_p[x]$. To show $\Q_i = (p,g_i(\alpha))$, it's enough to show $\Q_i/(p) \subseteq \mathcal{O}_L/p\mathcal{O}_L$ is generated by $\bar{g}_i(\alpha)$. This is equivalent to showing that $\ker(F_p[x] / (\bar{f}(x)) \to F_p[x]/(\bar{g}_i(x)))$ is generated by $\bar{g}_i(x)$. This is true by definition.\\
It remains to show $Q_1^{e_1}...Q_r^{e_r} = p\mathcal{O}_L$. We have
\begin{equation*}
\begin{aligned}
Q_1^{e_1}...Q_r^{e_r} &= (p_1g_1(\alpha))^{e_1}...(p_rg_r(\alpha))^{e_r}\\
&=(p_1g_1(\alpha)^{e_1}) ... (p_1g_r(\alpha)^{e_r})\\
&\leq (p,g_1(\alpha)^{e_1})...(g_r(\alpha)^{e_r}) = (p,f(\alpha))=(p)
\end{aligned}
\end{equation*}
Take norms, $N(LHS) = \prod_{i=1}^r N(Q_i)^{e_i} = p^{\sum_{i=1}^r e_i f_i} =p^{\deg f} = p^{[L:\Q]} = N(p) = N(RHS)$. This forces $Q_1^{e_1}...Q_r^{e_r} = p\mathcal{O}_L$.
\end{proof}

Let $L$ be a number field. Last time we had that if $\alpha \in \mathcal{O}_L$, $\Q(\alpha) = L$, $p \nmid [\mathcal{O}_L:\Z[\alpha]]$. Dedekind's criterion: can factor $p\mathcal{O}_L$ by factoring $f_\alpha(x) \pmod p$.

\begin{prop} (5.4)\\
Let $d$ be a square-free integer, $d \neq 0,1$, $L = \Q(\sqrt{d})$, and let $p$ be a prime number. Then\\
(1) If $p$ is odd, then:\\
$\bullet$ if $p|d$, then $(p) = P^2$, so $p$ ramifies in $L$;\\
$\bullet$ if $p \nmid d$ and $(\frac{d}{p}) = 1$, then $(p) = PQ$, so $p$ splits completely in $L$;\\
$\bullet$ if $p \nmid d$ and $(\frac{d}{p} = -1$, then $(p)$ is prime and $p$ is inert in $L$.\\
(2) If $p=2$, then:\\
$\bullet$ if $d \equiv 2,3 \pmod 4$, then 2 ramifies in $L$;\\
$\bullet$ if $d \equiv 1 \pmod 8$, then 2 splits completely in $L$;\\
$\bullet$ if $d \equiv 5 \pmod 8$, then $2$ is inert in $L$.
\begin{proof}
We just do the case where $p=2$. If $d \equiv 2,3 \pmod 4$, then $\mathcal{O}_L = \Z[\sqrt{d}]$, so by Dedekind's criterion, we must factor $x^2 - d \pmod 2$. But $x^2-d \equiv (x-d)^2 \pmod 2$. If $d \equiv 1 \pmod 4,$ then $\mathcal{O}_L = \Z[\frac{1+\sqrt{d}}{2}]$, so we must factor $x^2+x+\frac{1-d}{4} \pmod 2$. If $d \equiv 1 \pmod 8$, this is $x^2+x = x(x+1) \pmod 2$. If $d \equiv 5 \pmod 8$, this is $x^2+x+1 \pmod 2$ which is irreducible.
\end{proof}
\end{prop}

\newpage
\section{Geometry of numbers}

\begin{defi} (6.1)\\
If $V$ is a finite dimensional $\R$-vector space, then a lattice in $V$ is a subgroup of the form $\Lambda = \oplus_{i=1}^m \Z v_i$, where $v_1,...,v_n$ is a basis of $V$ as $\R$-vector space (for example, $\Z^n \subseteq \R^n$).
\end{defi}

\begin{defi} (6.2)\\
If $V$ is a finite-dimensional inner product space over $\R$, and $\Lambda \subseteq V$ is a lattice, then the covolume of $\Lambda$ is
\begin{equation*}
\begin{aligned}
A(\Lambda) = vol(\{\sum_{i=1}^n t_i v_i | t_i \in [0,1)\})
\end{aligned}
\end{equation*}
where $\Lambda = \oplus_{i=1}^n \Z v_i$.\\
Check: this is independent of the choice of basis $v_1,...,v_n$.
\end{defi}

For today, let's consider only a fixed imaginary quadratic field $L = \Q(\sqrt{d})$ where $d<0$ is a square-free integer. Let's take $\sigma:L \to \Q$ be a complex embedding. Then $\sigma(\mathcal{O}_L)$ is a lattice in $\phi$. If $d \equiv 2,3 \pmod 4$, then $\sigma(\mathcal{O}_L) = \Z \oplus \Z [\sqrt{d}]$; if $d \equiv 1 \pmod 4$ then $\sigma(\mathcal{O}_L) = \Z \oplus \Z (\frac{1+\sqrt{d}}{2})$\\
If $I \leq \mathcal{O}_L$ is a non-zero ideal, then $\sigma(I)$ is a lattice in $\C$.

\begin{lemma} (6.3)\\
If $I \subseteq \mathcal{O}_L$ is a non-zero ideal, then $A(I) = \frac{1}{2} \sqrt{|disc(I)|} = \frac{N(I)}{2} \sqrt{|D_L|}$.
\begin{proof}
Let $\alpha_1,\alpha_2$ be an integral basis for $I$. Then $\sigma(I) = \Z \sigma(\alpha_1) \oplus \Z \sigma (\alpha_2)$. Write $\alpha_1 = x_1+iy_1,\alpha_2=x_2+iy_2$, then $A(\sigma(I)) = |\det{{x_1 \ x_2} \choose {y_1 \ y_2}}|$ (area of a parallelogram).\\
Then
\begin{equation*}
\begin{aligned}
disc(I) = \det
\begin{pmatrix}
x_1+iy_1 & x_2 + iy_2\\
x_1 - iy_1 & x_2 - iy^2
\end{pmatrix}
=
(2i)^2 \det
\begin{pmatrix}
y_1 & y_2\\
x_1 & x_2
\end{pmatrix}
\end{aligned}
\end{equation*}
\end{proof}
\end{lemma}

\begin{thm} (6.4, special case of Minkovski's theorem)\\
Let $\Lambda \subseteq \R^2$ be a lattice, and let $S=D(0,r) \subseteq \R^2$ be the closed disk of radius $r$. Then if $area(S) \geq 4A(\Lambda)$, then $\exists \lambda \in \Lambda - \{0\}$ such that $\lambda \in S$.\\
In particular, there exists $\lambda \in \Lambda - \{0\}$ such that $|\lambda|^2 \leq \frac{4}{\pi} A(\Lambda)$.
\end{thm}

\begin{coro} (6.5)\\
If $I \subseteq \mathcal{O}_L$ is a non-zero ideal, then there exists $\alpha \in I-\{0\}$ s.t. $N(\alpha) \leq c_LN(I)$, where $c_L := \frac{2}{\pi} \sqrt{|D_L|}$.
\begin{proof}
We apply the theorem to $\sigma(I) \subseteq \C$ to get $\lambda \in \sigma(I) - \{0\}$, such that $|\lambda|^2 \leq \frac{4}{\pi} \cdot \frac{N(I)}{2} \sqrt{|D_L|} = c_l N(I)$. If $\alpha \in I$ is such that $\sigma(\alpha) = \lambda$, then $N(\alpha) = \sigma(\alpha) \overline{\sigma(\alpha)} = |\sigma(\alpha)|^2 = |\lambda|^2$.
\end{proof}
\end{coro}

\begin{coro} (6.6)\\
If $[I] \in Cl(\mathcal{O}_L)$, then there exists $J \in [I]$ such that $N(J) \leq c_L$.
\begin{proof}
Choose $k \in [I]^{-1}$ so that $IK$ is principal. Apply the corollary to find $\alpha \in K-\{0\}$, such that $N(\alpha) \leq c_L N(K)$. Then $(\alpha) \subseteq K \implies K | (\alpha) \implies \exists J \subseteq \mathcal{O}_L$ non-zero ideal such that $JK = (\alpha)$. We have $[J] = [K]^{-1} = [I]$, so $J \in [I]$. Also, $N(J) = N(\alpha) / N(K) \leq c_L$.
\end{proof}
\end{coro}

\begin{thm} (6.7)\\
The group $Cl(\mathcal{O}_L)$ is finite. (we'll prove this for any $L$ next time).
\begin{proof}
We've shown every class $[I] \in Cl(\mathcal{O}_L)$ has a representative of norm $\leq c_L$. It therefore suffices to show that $\forall m \in \Z, m \geq 1$, the number of ideals $I \subseteq \mathcal{O}_L$ of norm $N(I) = m$ is finite. If $N(I) = m$, then $[\mathcal{O}_L:I] = m$, so by Lagrance, $m \in I$. Thus $I$ comes from an ideal of the finite ring $\mathcal{O}_L / m\mathcal{O}_L$.
\end{proof}
\end{thm}

Note: we see $CL(\mathcal{O}_L)$ is generated by ideal classes $[P]$, where $P \subseteq \mathcal{O}_L$ is a non-zerp prime ideal of norm $N(P) \leq c_L$. Why? Any class has the form $[I]$, where $N(I) \leq c_L$. If $I = \prod_{i=1}^r p_i^{e_i}$, then $[I] = \pod_{i=1}^r [P_i]^{e_i}$ and $N(I) = \prod_{i=1}^r N(P_i)^{e_i}$, so $N(P_i) \leq N(I) \leq c_L$ for each $i=1,...,r$.

\begin{eg}
Consider $d=-7$. $d \equiv 1\pmod 4$, so $D_L = -d$, $c_l = \frac{2}{\pi} \sqrt{7} < \frac{2}{3} \sqrt{7} < 2$.\\
$Cl(\mathcal{O}_L)$ is generated by ideals of norm $<2$. There are none except $\mathcal{O}_L$, so $Cl(\mathcal{O}_L)$ is the trivial group. Hence $\mathcal{O}_L = \Z[\frac{1+\sqrt{-7}}{2}]$ is a UFD.\\
$d=-5$: $D_L = -4d$, $c_L = \frac{2}{\pi} \sqrt{70} = \frac{4}{\pi} \sqrt{5} < \frac{4}{3}\sqrt{5} < 3$. Hence $Cl(\mathcal{O}_L)$ is generated by prime ideals $P \subseteq \mathcal{O}_L$ of norm $N(P) = 2$. We know by Dedekind's criterion that $2\mathcal{O}_L = P^2$. Hence $Cl(\mathcal{O}_L)$ is generated by $[P]$, and $[P]^2 = [2\mathcal{O}_L]$ is the trivial class.\\
Hence there are two possibilities: if $P$ is principal, then $Cl(\mathcal{O}_L)$ is trivial; if $P$ is not principal, then $Cl(\mathcal{O}_L) \cong \Z/2\Z$. We know $\mathcal{O}_L$ is not a UFD, so we must have $Cl(\mathcal{O}_L) \cong \Z/2\Z$.
\end{eg}

Last time we see that if $L$ is an imaginary quadratic field, then $Cl(\mathcal{O}_L)$ is finite, generated by $[P]$ where $P$ is a prime ideal of norm $N(P) \leq C_L$, where $C_L = \frac{2}{\pi} \sqrt{|D_L|}$.

This time we will show the case of a general number field $L$.

\begin{thm} (6.8, Minkowski's theorem)\\
Let $\Lambda \subseteq \R^n$ be a lattice, and let $E \subseteq \R^n$ be a measurable subset which is conve, and centrally symmetric ($E=-E = \{x \in \R^n | -x \in E\}$). Then:\\
(i) If $vol(E) > 2^n A(\Lambda)$, then $\exists \lambda \in \Lambda \setminus \{0\}$ such that $\lambda \in E$;\\
(i) If $vol(E) \geq 2^n A(\Lambda)$ and $E$ is compact, then $\exists \lambda \in \Lambda \setminus \{0\}$ such that $\lambda \in E$.\\
(we used this last time in the special case $n=2$, $E$=closed disk).
\begin{proof}
Let $\Lambda = \oplus_{i=1}^n \Z v_i$, $P = \{\sum_{i=1}^n t_i v_i | t_i \in [0,1)\}$. Then $vol(P) = A(\Lambda)$, and $\R^n = \sqcup_{\lambda \in \Lambda} (P+\lambda)$.\\
(i) $vol(P) < \frac{1}{2^n} vol(E) = vol(\frac{1}{2} E) = \sum_{\lambda \in \Lambda} vol([\frac{1}{2} E] \cap [\lambda+P]) = \sum_{\lambda \in \Lambda} vol ([\frac{1}{2} E - \lambda] \cap P)$.\\
We claim that there exists $\lambda\neq\mu \in \Lambda$ such that $(\frac{1}{2} E - \lambda) \cap (\frac{1}{2} E - \mu)$ is non-empty. Why? If not, sets $\frac{1}{2} E - \lambda$ are pairwise disjoint, so $vol(P) < \sum_{\lambda \in \Lambda} vol([\frac{1}{2} E-\lambda]\cap P) \leq vol(P)$, contradiction.\\
Hence $\exists z,w \in E$ such that $\frac{z}{2} - \lambda = \frac{w}{2} - \mu$, where $\lambda \neq \mu \in \Lambda$, so $\lambda-\mu = \frac{z}{2} - \frac{w}{2} = \frac{z}{2} + \frac{(-w)}{2}$. Since $E$ is centrally symmetric, $-w \in E$, and $E$ is convex implies that $\frac{z}{2} + \frac{(-w)}{2} \in E$, so $\lambda -\ mu \in (\Lambda \setminus \{0\}) \cap E$.\\
(ii) $E$ compact implies that $E$ is closed and bounded. $vol(E) \geq 2^n A(\Lambda)$ so $\forall m \geq 1$, $vol((1+\frac{1}{m}) E) > 2^n A(\Lambda)$. By (i), $\forall m \in \N \exists s\lambda_m \in (\Lambda \setminus \{0\})\cap((1+\frac{1}{m})E)$, and $(1+\frac{1}{m})E \subseteq 2E$, and $2E \cap \Lambda$ is finite as $2E$ is bounde. By pigeonhole principle we can assume $\exists \lambda \in \Lambda \setminus \{0\}$ such that $\lambda_m = \lambda \forall m \geq 1$. $E$ closed and $\lambda \in (1+\frac{1}{m})E \forall m \geq 1$ $\implies \lambda \in E$. Now let $L$ be a number field. Let $n = [L:\Q]$, let $\tau_1,...,\tau_r:L \to \R$ be the real embeddings of $L$, and let $\sigma_1,\bar{\sigma}_1,...,\sigma_s,\bar{\sigma}_s:L \to \C$ be the remaining distinct complex embeddings of $L$. Then $r+2s = n$.

Define a map $S:l \to \R^r \times \C^s$ by $\alpha \to (\tau_1(\alpha),...,\tau_r(\alpha),\sigma_1(\alpha),...,\sigma_s(\alpha))$. This is a homomorphism of additive groups.
\end{proof}
\end{thm}

\begin{lemma}
If $I \subseteq \mathcal{O}_L$ is a non-zero ideal, then $S(I)$ is a lattice.
\begin{proof}
Let $\alpha_1,...,\alpha_n$ be an integral basis of $I$. Then $S(I) = \oplus_{i=1}^n \Z s(\alpha_i)$ and $\R^r \times \C^3$ has dimension $n$ as $\R$-vector space. So we must show that $S(\alpha_1),...,S(\alpha_n)$ are independent or equivalently that
\begin{equation*}
\begin{aligned}
\det \begin{pmatrix}
\tau_1 (\alpha)1) ... \tau_1(\alpha_n)\\
...\\
\tau_r(\alpha_1) ... \tau_r(\alpha_n)\\
Re \sigma_1 (\alpha_1)...Re \sigma_1(\alpha_n)\\
Im \sigma_1 (\alpha_1)...Im \sigma_1(\alpha_n)\\
...\\
Im \sigma_n (\alpha_1)...Im \sigma_s(\alpha_n)
\end{pmatrix} \neq 0
\end{aligned}
\end{equation*}
Note: for $z \in \C$,
\begin{equation*}
\begin{aligned}
\begin{pmatrix}
z\\
z
\end{pmatrix} =
\begin{pmatrix}
1 & i\\
1 & -i
\end{pmatrix}
\begin{pmatrix}
Re z\\
Im z
\end{pmatrix}
\end{aligned}
\end{equation*}
So this determinant equals
\begin{equation*}
\begin{aligned}
(\frac{1}{-2i})^s  \det \begin{pmatrix}
\tau_1 (\alpha)1) ... \tau_1(\alpha_n)\\
...\\
\tau_r(\alpha_1) ... \tau_r(\alpha_n)\\
\sigma_1 (\alpha_1)...\sigma_1(\alpha_n)\\
...\\
sigma_n (\alpha_1)...\sigma_s(\alpha_n)
\end{pmatrix} \neq 0
\end{aligned}
\end{equation*}
as $disc(I) \neq 0$.
\end{proof}
\end{lemma}

\begin{lemma} (6.10)\\
If $I \subseteq \mathcal{O}_L$ is a non-zero ideal, then
\begin{equation*}
\begin{aligned}
A(S(I)) = \frac{1}{2^s} \sqrt{|disc(I)|} = \frac{N(I)}{2^s} \sqrt{|D_L|}
\end{aligned}
\end{equation*}
\end{lemma}

\begin{prop} (6.11)\\
If $I\subseteq \mathcal{O}_L$ is a non-zero ideal, then there exists $\alpha \in I \setminus \{0\}$ such that $N(\alpha) \leq C_L N(I)$, where $C_L = (\frac{4}{\pi})^s \frac{n!}{n^n} \sqrt{|D_L|}$.\\
Here $C_L$ is called the Minkowski constant of $L$.
\begin{proof}
We apply Minkowski's theorem to the lattice $S(I)$, and region $B_{r,s}(t) = \{(\mathbf{x},\mathbf{z}) \in \R^r \times \C^s | \sum_{i=1}^r |X_i| + 2\sum_{i=1}^s |z_i| \leq t\}$.\\
Note: $B_{r,s} (t)$ is convex, centrally symmetric and compact.\\
If $vol(B_{r,s}(t)) \geq 2^n A(S(I))$, then there exists $\alpha \in I \setminus \{0\}$ such that $S(\alpha) \in B_{r,s}(t)$.\\
We use a tuck with the AM-GM inequality to bound $N(\alpha)$:
\begin{equation*}
\begin{aligned}
N(\alpha)^{1/n} = (\prod_{i=1}^r |\tau_i(\alpha)) \prod_{i=1}^s |\sigma_i(\alpha)|^2)^{1/n} \leq \frac{(\sum_{i=1}^r |\tau_1(\alpha)| + 2\sum_{i=1}^s |\sigma_i(\alpha)|)}{n}
\end{aligned}
\end{equation*}
Hence $N(\alpha) \leq t^n/n^n$. To get optimal bound, choose $t$ so that $vol(B_{r,s}(t)) = 2^n A(S(I))$.\\
Exercise: $vol(B_{r,s}(t)) = 2^r (\frac{\pi}{2})^s t^n/n!$ (Induction on $r$ and $s$).\\
We have
\begin{equation*}
\begin{aligned}
2^r (\pi/2)^s t^n / n! &= 2^n A(S(I)) = 2^{r+s} N(I) \sqrt{|D_L|}\\
\implies t^n &= (4/\pi)^s n! N(I) \sqrt{|D_L|}\\
\implies N(\alpha) &\leq t^n/n^n = C_L N(I)
\end{aligned}
\end{equation*}
\end{proof}
\end{prop}

\begin{coro} (6.12)\\
For any class $[I] \in Cl(\mathcal{O}_L)$, there exists $J \in [I]$ such that $N(J) \leq C_L$.
\end{coro}

\begin{coro} (6.13)\\
The group $Cl(\mathcal{O}_L)$ is finite, generated by $[P]$ where $P$ is a prime ideal of norm $N(P) \leq C_L$.
\end{coro}

These corollaries are deduced from the proposition exactly as in the case $L=\Q(\sqrt{d})$, $d<0$.

\begin{rem}
In practice this bound is very effective. For example consider $f(x) = x^5 -x+1$, this is irreducible mod 5, so over $\Q$. Let $L=\Q(\alpha)$ where $\alpha$ is a root of $f(x)$. In this case $r=1,s=2$, the discriminant $disc f = 2869 = 19 \cdot 151$ is square-free, so $\mathcal{O}_L = \Z[\alpha]$, and $D_L = disc f$, so $c_L =(4/\pi)^2 (5^!/5^5) \sqrt{2869} < 4$. Hence $Cl)\mathcal{O}_L$ is generated by $P$ of norm $N(P) = 2$ or $3$. By Dedekind's criterion, such primes exist iff $f(x)$ has a root in $F_2$ or $F_3$. But there are no such roots. Hence $Cl(\mathcal{O}_L)$ is trivial, hence $\Z[\alpha]$ is a UFD.
\end{rem}

Last time we showed $CL(\mathcal{O}_L)$ is generated by $[P]$ where $[P]$ is a prime ideal of norm $N(P) \leq C_L = (4/\pi)^3 n!/n^n \sqrt{|D_L|}$. For example, if $L=\Q(\sqrt{10})$, $C_L = \frac{1}{2} \sqrt{4 \cdot 10} = \sqrt{10} < 4$. $Cl(\mathcal{O}_L$ is generated by $[P]$ where $N(P) = 2$ or $3$. \\
Dedekind's criterion: $2\mathcal{O}_L = P_2^2$, where $P_2 = (2,\sqrt{10})$. $x^2 -10 \equiv x^2-1 \pmod 3$ so $3\mathcal{O}_L = P_3 P_3'$, where $P_3 = (3,1+\sqrt{10})$. To find relatoins in $Cl(\mathcal{O}_L)$, we can calculate norms, e.g. $N(2+\sqrt{10}) = |4-10| = 6$, so $(2+\sqrt{10}) = P_2 P_3$ or $P_2 P_3'$. In either case we see that $[P_2]$ generates $Cl(\mathcal{O}_L$. So either $Cl(\mathcal{O}_L)$ is trivail, or $Cl(\mathcal{O}_L \cong \Z/2\Z$ with the second case occuring iff So $P_2$ is not principal. $P_2$ is principal $\iff \exists a+b\sqrt{10} \in \mathcal{O}_L$ such that $(a+b\sqrt{10}) = P_2$ $\iff \exists a,b \in \Z$ s.t. $a^2 - 10b^2 = \pm 2$.\\
If $a^2-10b^2 = \pm 2$, then either $2$ or $-2$ is a quadratic residue $\pmod 5$. So in fact $P_2$ is not principal. So $Cl(\mathcal{O}_L) \cong \Z/2\Z$.

Now take $L = \Q(\sqrt{-17})$. $C_l = \frac{4}{\pi}\cdot \frac{1}{2} \sqrt{4\cdot 17} = 4/\pi \sqrt{17} < \frac{4}{3} \sqrt{17} < 6$. So $Cl(\mathcal{O}_L)$ is generated by primes of norm $2,3$ or $5$. Dedekind's criterion: $x^2 + 17 \equiv x^2 + 2 \pmod 5$, so $5 \mathcal{O}_L$ is prime of norm 25. $x^2+17 \equiv x^2-1 \pmod 3$, so $3 \mathcal{O}_L = Q_3 Q'_3$ where $Q_3 = (3,1+\sqrt{-17})$, $Q_3' = (3,1-\sqrt{-17})$. $x^2+17 = (x+1)^2 \pmod 2$, so $2 \mathcal{O}_L = Q_2^2$ where $Q_2 = (2,1+\sqrt{-17})$.\\
Now $N(1+\sqrt{-17}) = 18 = 2 \times 3^2$. Note $1+\sqrt{-17} \in Q_3 \implies Q_3 | (1+\sqrt{-17})$. So we must have either $(1+\sqrt{-17}) = Q_2Q_3Q'_3$, or $(1+\sqrt{-17}) = Q_2 Q_3^2$. To decide between these, we compute
\begin{equation*}
\begin{aligned}
Q_3^2 &= (0,3+3\sqrt{-17},(1+\sqrt{-17})^2)\\
&= (9,3+3\sqrt{-17},-16+2\sqrt{-17})\\
&= (9,3+3\sqrt{-17},2+2\sqrt{-17})\\
&= (9,1+\sqrt{-17})
\end{aligned}
\end{equation*}

We see $1+\sqrt{-17} \in Q_3^2$ so $Q_3^2 | (1+\sqrt{-17})$, hence $(1+\sqrt{-17}) = Q_2Q_3^2$. We see $[Q_3]$ generates $Cl(\mathcal{O}_L)$ and if $Q_2$ is not principal then $Cl(\mathcal{O}_L) \cong \Z/4\Z$. But $Q_2$ is principal iff we can solve $a^2+17b^2 = 2$ with $a,b \in \Z$. This is impossible, so $Cl(\mathcal{O}_L) \cong \Z/4\Z$.

\begin{rem}
Ther are many open questions about ideal class groups even for quadratic fields.\\
Things we know: Number of $Cl(\mathcal{O}_{\Q(\sqrt{d})} \to \infty$ as $d \to -\infty$ through squaree-free integers. There are exactly 9 imaginary quadratic fields with trivial ideal class group (hard).\\
Things we don't know: are there infinitely many real quadratic fields of trivial ideal class group?
\end{rem}

Cohen-Lenstra heuristics: let $p$ be an odd prime, and let $A$ be a finite abelian group of $p$-power order. Then for $d<0$ square-free, $\P(Cl(\mathcal{O}_{\Q(\sqrt{d})}) \cong A) = \frac{\prod_{i=1}^\infty (1-1/p^i)}{\text{Number of }Aut(A)}$.

For $M$ a finite abelian group, $M_p$ is the (unique) $p$-sylow subgroup.

By definition, The above probablity is the ratio between the number of $d<0$ square-free, $Cl(\mathcal{O}_{\Q(\sqrt{d})})_p \cong A$, $|d| < X$ and the number of $d<0$ square-free, $|d|<x$.

\newpage

\section{Dirichlet's unit theorem}
Let $L$ be a number field of degree $n = [L:\Q]$, $\tau_1,...,\tau_r:L \to \R$ are real embeddings, $\sigma_1,...,\sigma_s,\bar{\sigma}_1,...,\bar{\sigma}_s: L \to \C$ are distinct complex embeddings.

\begin{thm} (7.1)\\
There is an isomorphism $\mathcal{O}_L^* \cong \mu_L \times \Z^{r+s-1}$, where $\mu_L \subseteq \mathcal{O}_L^*$ is the finite cyclic group of roots of unity in $\mathcal{O}_L^*$.\\
In fact the proof shows omre: define a map $l:\mathcal{O}_L^* \to \R^{r+s}$: $l(\alpha) = (\log |\tau_1(\alpha)|,...,\log|\tau_r(\alpha)|,2\log |\sigma_1(\alpha)|,...,2\log|\sigma_s(\alpha)|)$, then this is a homomorphism of abelian groups, and $l(\mathcal{O}_L^*)$ is contained in the hyperplane $H =\{\mathbf{x} \in \R^{r+s} | \sum_{i=1}^{r+s} x_i = 0\}\subseteq \R^{r+s}$. This expresses the condition $\alpha \in \mathcal{O}_L^* \implies \log N(\alpha) = \sum_{i=1}^r \log |\tau_i(\alpha)|+2\sum_{i=1}^s |\sigma_i(\alpha)|$.

The proof of the theorem will show $l(\mathcal{O}_L^*)$ is a lattice in $H$.

Example: $\mathcal{O}_L^*$ is finite $\iff r+s = 1$, i.e. $r=1,s=0$ ($L=\Q$), or $r=0,s=1$ ($L=\Q(\sqrt{d})$,$d<0$ square-free). The first case where $\mathcal{O}_L^*$ is infinite is $L=\Q\sqrt{d}), d>0$, square-free. Then $+s-1=1$, so $l(\mathcal{O}_L^*)$ is infinite cyclic. Let's fix $\sigma:\Q(sqrt{d}) \to \R$ to be the real embedding with $\sigma(\sqrt{d}) \geq 0$. $\sigma(\mu_L) \subseteq \R^*$, so $\mu_L = \{\pm 1\}$ in this case. In this case, we can consider the map $l':\mathcal{O}_L^* \to \R$ by $\alpha \to \log |\sigma(\alpha)|$. We know that $l'(\mathcal{O}_L^*) \subseteq \R$ is a lattice, in particular there is a uniquely characterised unit $\alpha \in \mathcal{O}_L^*$ satisfying $\sigma(\alpha)>0$, $\log |\sigma(\alpha)| > 0$ and as small as possible. In other words, $\alpha \in \mathcal{O}_L^*$ is the unit for which $\sigma(\alpha)>1$ and $\sigma(\alpha)$ is minimal with respect to this property. We call $\alpha$ the fundamental unit of $L=\Q(\sqrt{d})$. Then we have $\mathcal{O}_L^* = \{\pm \alpha^n | n \in \Z\}$.
\end{thm}

Example sheet 3 is now online!

Last time we have: if $L$ is a number field, then $\mathcal{O}_L^* \cong \mu_L \times \Z^{r+s-1}$, where $\mu_L$ are roots of unity.

Now suppose $L = \Q(\sqrt{d})$ where $d \in \Z$ is a square free integer, $d>1$. We identify $L$ with a subfield of $\R$, where $\sqrt{d}$ is the positive square root.

We saw that the Dirichlet's unit theorem implies $\exists u \in \mathcal{O}_L^*$ such that $u = \min \{v \in \mathcal{O}_L^* | v>1\}$. $u$ is called the fundamental unit, and $\mathcal{O}_L^* = \{\pm u^n | n \in \Z\}$.

\begin{lemma} (7.2)\\
(1) If $d \equiv 2,3 \pmod 4$ and $v \in \mathcal{O}_L^*$ satisfies $v > 1$, then $v = a+b\sqrt{d}$ where $a \geq b \geq 1$;\\
(2) If $d \equiv 1 \pmod 4$, and $v \in \mathcal{O}_L^*$ satisfies $v>1$, then $v = \frac{1}{2} (a+b\sqrt{d})$ wher $a \geq b \geq 1$.
\begin{proof}
(1) Let $v' = a-b\sqrt{d}$. Then $vv' = a^2 - db^2 = N_{L/\Q}(v) = \pm 1$. So $v>1 \implies |v'| < 1$. Hence $v+v' = 2a > 0$, $v-v' = sb\sqrt{d} > 0$. As $a,b$ are integers, we must have $a \geq 1, b \geq 1$.\\
Also, $(a/b)^2 = d \pm 1/b^2 \geq 1$ as $d \geq 2$.\\
(2) Let $v' = \frac{1}{2} (a-b\sqrt{d}$). Then $vv' = \pm 1$ and $a^2-db^2 = \pm 4$. Then $v+v' = a > 0$, and $v-v' = b\sqrt{d} > 0$. Hence $a \geq 1, b \geq 1$. Also, $(a/b)^2 = d \pm 4/b^2$ as $d \geq 5$ as $d \equiv 1 \pmod 4$.
\end{proof}
\end{lemma}

We can use this to find the fundamental unit $u \in \mathcal{O}_L^*$. First suppose $d \equiv 2,3 \pmod 4$ and let $u = a+b\sqrt{d}$. Let $u^k = a_k + b_k \sqrt{d}$. Then $u^{k+1} = (a_1 + b_1 \sqrt{d})(a_k + b_k \sqrt{d}) = (a_1a_k + db_1b_k) + (b_1a_k + a_1b_k) \sqrt{d}$. Hence $b_{k+1} = b_1a_k + a_1b_k > b_k$.\\
Hence the sequence $b_1,b_2,b_3$ is strictly increasing.

We can therefore characterise $u$ as follows: let $b \in \N$ be the least positive integer such that $db^2+1$ or $db^2-1$ is of the form $a^2$ for some $a \in \N$. Then $u = a+b\sqrt{d}$.\\
Now suppose $d \equiv 1 \pmod 4$, and let $u = \frac{1}{2} (a+b\sqrt{d})$, $a,b \in \Z$. Let $u^k = \frac{1}{2} (a_k + b_k \sqrt{d})$. Then $b_{k+1} = \frac{1}{2} (a_1b_k + b_1 a_k$). Using lemma 7.2, we see $b_{k+1} \geq b_k$. If (??)\\
This is wrong. Let's correct this next time. Sorry!

\begin{eg}
$d=2$.$L = \Q(\sqrt{2})$. $b=1$ works: $2-1=1^2$. So $1+\sqrt{2}$ is a fundamental unit.\\
$d=7$. Try $b=1$: $7 \pm 1$ is not a square; $b=2,$ doesn't work either; $b=3$: $9 \cdot 7 \pm 1 = 8^2$. So $8+3\sqrt{7}$ is a fundamental unit.
\end{eg}

Note: This procedure is not always efficient. For example, the fundamental unit in $\Q(\sqrt{22})$ is $197+42\sqrt{22}$.

There is a more efficient algorithm which uses continued fractions, but it is not discussed in this course (see number theory).

We now prove the unit theorem (this is non-examinable).

We recall the setup: $L$ is a number field, $\tau_1,...,\tau_r: L \to \R$, $\sigma_1,\bar{\sigma}_1,...,\sigma_s,\bar{\sigma}_s:L \to \C$ are real and complex embeddings of $L$ respectively.\\
Last time we defined a map: $l: \mathcal{O}_L^* \to \R^{r+s}$ by $\alpha \to (\log (\tau_1(\alpha)),...,\log(\tau_r (\alpha)),2\log (\sigma_1(\alpha)),...,2\log(\sigma_s(\alpha)))$.\\
The image is contained inside the subspace $H = \{\mathbf{x} \in \R^{r+s}| \sum_{i=1}^{r+s} x_i = 0\}$.

\begin{lemma} (7.3)\\
Let $\alpha \in \mathcal{O}_L \setminus \{0\}$ be such that the above image vector is $(a_1,...,a_{r+s}) \in \R^{r+s}$. Fix an integer $1 \leq k \leq r+s$. Then ther exists $\beta \in \mathcal{O}_L \setminus\{0\}$ such that if $l(\beta) = (b_1,...,b_{r+s}) \in \R^{r+s}$, then $b_i < a_i$ if $i \neq k$. Moreover, $N(\beta) \leq (\frac{2}{\pi})^s \sqrt{|D_L|}$.
\begin{proof}
Let $c_1,...,c_{r+s} \in \R_{>0}$, and let
\begin{equation*}
\begin{aligned}
E=\{(\mathbf{x},\mathbf{z})\in \R^r \times \C^s | |x_1| \leq c_1,...,|x_r| \leq c_r,|z_1|^2 \leq c_{r+1},...,|z_r|^2 \leq c_{r+s}\}
\end{aligned}
\end{equation*}
Then if $vol(E) \geq 2^{r+2s} A(S(\mathcal{O}_L)) = 2^{r+s} \sqrt{|D_L|}$, then $(S:\mathcal{O}_L \to \R^r \times \C^s)$.

There exists $\beta \in \mathcal{O}_L \setminus \{0\}$ such that $S(\beta) \in E$ (by Minkovski's theorem). In particular, $N(\beta) = \prod_{i=1}^r |\tau_1(\beta)| \prod_{i=1}^s |\sigma_i(\beta)|^2 \leq c_1...c_{r+s}$ (by defiintion of $E$).

We choose $c_i$ so that $0 < c_i < e^{a_i}$ if $i \neq k$, and $vol(E) = \pi^s 2^r c_1...c_{r+s} = 2^{r+s} \sqrt{|D_L|}$.

The first property gives $b_i < a_i$ if $i \neq k$, and the second property gives $N(\beta) \geq c_1...c_{r+s} = (\frac{2}{\pi})^s \sqrt{|D_L|}$.
\end{proof}
\end{lemma}

\begin{coro} (7.4)\\
Fix an integer $1 \leq k \leq r+s$. Then there exists $\varepsilon \in \mathcal{O}_L^*$ such that if $l(\varepsilon) = (a_1,...,a_{r+s})$ then $a_i < 0$ if $i \neq k$, and $a_k > 0$.
\begin{proof}
By the lemma, we can find elements $\alpha_1,\alpha_2,...$ of $\mathcal{O}_L\setminus \{0\}$ such that $N(\alpha_1) \leq (\frac{2}{\pi})^s \sqrt{|D_L|}$ $\forall i \in \N$, and if $l(\alpha_i) = (b_{i_1},...,b_{i,r+s})$, then $b_{ij} < b_{i-1,j}$ if $j \neq k$ $\forall i = 2,3,...$. The ideals $(\alpha_i)$ have bounded norm, so are finite in number, so there exist elements $\alpha_N, \alpha_M$ with $(\alpha_N) = (\alpha_M)$. Then the element $\varepsilon = \alpha_N/\alpha_M \in \mathcal{O}_L^*$ has the desired property.
\end{proof}
\end{coro}

We continue with the non-examinable proof of Dirichlet's unit theorem.

We proved propoition: let $\alpha \in \mathcal{O}_L \setminus \{0\}$ be such that $l(\alpha)$ fix $1 \leq k \leq r+s$. Then $\exists \beta \in \mathcal{O}_L \setminus \{0\}$ such that $N(\beta) \leq (\frac{2}{\pi})^s \sqrt{|D_L|}$, and if $l(\beta) = (b_1,...,b_{r+s})$ then $b_i < a_i$ if $i \neq k$.

We deduced Corllary 7.4: fix $1 \leq k \leq r+s$. Then there exists $\varepsilon \in \mathcal{O}_L^*$ such that if $l(\varepsilon) = (a_1,...,a_{r+s})$, then $a_i < 0$ if $i \neq k$.
\begin{proof}
Choose $\alpha \in \mathcal{O}_L \setminus \{0\}$. By the proposition, we can find elements $\alpha_1,...$ such that $N(\alpha_i) \leq (2/\pi)^s \sqrt{|D_L|}$, and if $l(i) = (b_{i1,...,ir+s})$ then $b_{ij} > b_{i+1j}$ if $j \neq k$ for all $i \geq 1$.

We now look at the ideals $(\alpha_1),(\alpha_2),...$. These have norm at most $(2/\pi)\sqrt{|D_L|}$. We know there are only finitely many ideals of $\mathcal{O}_L$ of norm at monst that, so there must exist $N<M$ such that $(\alpha_N) = (\alpha_M)$. Hence $\exists u \in \mathcal{O}_L^*$ such that $\alpha_M = u \alpha_N$. Also, $u = \alpha_M / \alpha_N \implies l(u) = (b_{m1}-b_{N1},...,b_{mr+s}-b_{Nr+s})$. But $N<M$, so $b_{Nj} > b_{Mj}$ if $j \neq k$. So $B_{Mj} - b_{Nj} < 0$ if $j \neq k$.
\end{proof}

\begin{lemma} (7.5)\\
Let $N \geq 1$, and let $A \in M_{N \times N} (\R)$ be such that:\\
$\bullet$ $\sum_{i=1}^N A_{ij} = 0$ for all $j=1,...,N$;\\
$\bullet$ $A_{ij} > 0$ if $i = j$, and $<0$ if $i \neq j$.\\
Then $A$ has rank $N-1$.
\begin{proof}
The rank is at most $N-1$. We show the first $N-1$ rows of $A$ are LI.\\
Suppose there exist $t_i \in \R,i = 1,...,N-1$ not all zero s.t. $\sum_{i=1}^{N-1} t_i A_{ij} = 0$ for each $j = 1,...,N$. WLOG after rescaling ther exists $k$ that $t_k=1$ and $t_i \leq 1$ if $i \neq k$. Then $0 = \sum_{i=1}^{N-1} t_i A_{ik} \geq \sum_{i=1}^{N-1} A_{ik} > \sum_{i=1}^N A_{ik} = 0$, contradiction.
\end{proof}
\end{lemma}

\begin{lemma} (7.6)\\
Fix $B>0$. Let $X_B = \{\alpha \in \mathcal{O}_L | \forall \sigma: L \to \C, |\sigma(\alpha)| \leq B\}$. THen $X_B$ is finite.
\begin{proof}
Recall the map $S:\mathcal{O}_L \to \R^r \times \C^s$. $S(\mathcal{O}_L)$ is a lattice in $\R^r \times \C^s$. $S(X_B)$ is the intersection of the lattice $S(\mathcal{O}_L)$ with a compact subset of $\R^r \times \C^s$. Therefore it must be finite.
\end{proof}
\end{lemma}

\begin{prop} (7.7)\\
$l(\mathcal{O}_L^*)$ is a lattice in $H \leq \R^{r+s}$.
\begin{proof}
We must show there exist units $v_1,...,v_{r+s-1} \in \mathcal{O}_L^*$ such that $l(v_1),...,l(v_{r+s-1})$ span $H$ as an $\R$-vector space and generate $l(\mathcal{O}_L^*)$ as an abelian group.\\
By corollary 7.4, we can find $\varepsilon_1,...,\varepsilon_{r+s} \in \mathcal{O}_L^*$ such htat if $l(\varepsilon_j) = (A_{ij},...,A_{r+sj})$, then $A_{ij} < 0$ if $i \neq j$ and $A_{ij} > 0$ if $i = j$. By lemma 7.5, the matrix $A$ has rank $r+s-1$, so we can find $v_1,...,v_{r+s-1} \in \mathcal{O}_L^*$ such that $l(v_1),...,l(v_{r+s-1})$ span $\mathcal{O}_L^*$ as an $\R$-vector space.\\
Let $\Lambda = \oplus_{i=1}^{r+s-1} \Z l(v_i) \leq H$. This is a lattice in $H$. Then $\Lambda \leq l(\mathcal{O}_L^*)$ and if $u \in \mathcal{O}_L^*$, then $\exists \lambda \in \Lambda$ such that $l(u) - \lambda \in \{\sum_{i=1}^{r+s-1} t_i l(v_i) | t_1,...,t_{r+s-1} \in [0,1]\}=P$. But the set of units $l(P)$ is finite by Lemma 7.6. Hence the quotien $l(\mathcal{O}_L^*) / \Lambda$ is finite. By Lagrange's theorem, $\exists N \in \Z, N > 1$ such that $N l(\mathcal{O}_L^*) \leq \Lambda$. Hence $\Lambda \leq l(\mathcal{O}_L^*) \leq \frac{1}{N}\Lambda$. By the sandwich lemma, $l(\mathcal{O}_L^*)$ is a free abelian group of rank $r+s-1$. In particular, it is a lattice in $H$.
\end{proof}
\end{prop}

Let's now finish the proof of the unit theorem, i.e. show there's an isomorphism $\mathcal{O}_L^* \cong \mu_L \times \Z^{r+s-1}$, where $\mu_L$ is the (finite) group of roots of unity in $\mathcal{O}_L$.

\begin{proof}
We have $\mu_L = \ker l$. If $\xi \in \mu_L$, then $\xi^N = 1$ for some $N\geq 1$, hence $l(\xi^N) = 0 = N l(\xi) \implies l(\xi) = 0$ as $l(\xi \in \R^{r+s}$. If $\alpha \in \mathcal{O}_L^*$ and $l(\alpha) = 0$ then $\forall \sigma: L \to \C$, $|\sigma(\alpha)| = 1$. By lemma 7.6, $\ker l$ is finite. By Lagrange's theorem, it consists of roots of unity.

Choose $v_1,...,v_{r=s-1} \in \mathcal{O}_L^*$ such that $l(v_1),...,l(v_{r+s-1})$ is a $\Z$-basis of $l(\mathcal{O}_L^*)$. Define a map $f:\mu_L \times \Z^{r+s-1} \to \mathcal{O}_L^*$ by $(\xi,n_1,...,n_{r+s-1}) \to \xi v_1^{n_1} ... v_{r+s-1}^{n_{r+s-1}}$.
\end{proof}

Exercise: this is an isomorphism.

Return to the examinable parts:

We now show how to find the fundamental unit in $\Q(\sqrt{d})$, where $\sqrt{d} \in \R_{>0}$ and $d \in \Z$ is a positive square-free integer.

$d>1,d \equiv 1 \pmod 4$:

Recall: the fundamental unit $u \in \mathcal{O}_L^*$ is the least unit $u>1$. We saw last time that if $v=\frac{1}{2}(a+b\sqrt{d}) \in \mathcal{O}_L^*$ is any unit with $v>1$, then $a \geq b \geq 1$.

Let $u^k = \frac{1}{2} (a_k+b_k\sqrt{d})$. Then $b_{k+1} = \frac{1}{2} (a_1 b_k + b_1a_k) \geq \frac{1}{2} (a_1+b_1)b_k \geq b_k$. We see $b_{k+1} \geq b_k$, with equality iff $a_k = b_k$ and $a_1=b_1=1$. Note: if $a_1=b_1 =1$, then $N(u) = |\frac{1-d}{4}| = 1 \implies d=5$. Assume first that $d>5$. Then the sequence $b_1<b_2<b_3<...$ is strictly increasing. The fundamental unit $u$ can therefore be found as following: let $b \in \N$ be the least positive integer such that $db^2 + 4 = a^2$ or $db^2 - 4 = a^2$, where $a \in \N$. Then $\frac{1}{2} (a+b\sqrt{d})$ is the fundamental unit.

Now suppose $d=5$. Then at least $b_1 \leq b_2 \leq ...$ is non-decreasing, and each value $b_i$ can appear at most twice: this is because occurrences correspond to solutions to $b_i^2 d \pm 4 = a_i^2$. We can therefore characterize the fundamental unit $u$ as follows: let $b\ in \N$ be the least positive integer for which $db^2+4 = a^2$ or $db^2-4 = a^2$ for $a,a' \in \N$ (units $\frac{1}{2}(a+b\sqrt{d}) and \frac{1}{2} (a'+b\sqrt{d})$). Recall that the fundamental unit is the least unit with $u>1$. Of these two possibilities, choose the unit with the smaller value of $a$ or $a'$. In this case, $b=1$ gives $d+4=3^2,d-4=1$. So $\frac{1}{2} (1+\sqrt{5})$ is the fundamental unit in this case.

\iffalse
\begin{equation*}
\begin{aligned}

\end{aligned}
\end{equation*}
\fi

\end{document}


\documentclass{beamer}
\usepackage{csquotes}
\usepackage{tikz}
\usetikzlibrary{arrows,positioning,shapes.geometric, calc}
\usepackage{amsmath}
\usepackage{listings, xcolor}
\usepackage{lmodern}
\usepackage{adjustbox}
\usepackage{booktabs}
\usepackage{colortbl}
\usepackage{caption}
\usepackage{icomma}
\usepackage{bigstrut}
\usepackage{geometry}
\usepackage{subfigure}

\DeclareMathOperator*{\argmin}{argmin}

\usetheme{metropolis}           % Use metropolis theme
\title{Penalized Regression for predicting trait from genotypes}
\date{\today}
\author{Robert M. Porsch}
\institute{Center of Genomic Science}
\begin{document}
\maketitle

\begin{frame}[t]{Introduction}
  Our goal is to use raw genotypes to predict traits and compare it to PGS\@.
  \begin{enumerate}[(i)]
    \item Application of penalized regressions (linear models)
      \begin{itemize}
        \item $L_1$, $L_2$, and $L_0$ norm
      \end{itemize}
    \item Application of non-linear frameworks
      \begin{itemize}
        \item Neural Networks, SVM
      \end{itemize}
  \end{enumerate}
  Identify and estimate epistatic effects.
\end{frame}

\section{Simple Simulation}
\label{sec:simulation}

\begin{frame}[t]{Some simple simulation}
  I simulated some toy data with $n = 10,000$ with $p = 10,000$.
  Effect sizes of 1\% of variables were drawn from a $\mathcal{N}(0, 0.01)$, the rest are set to 0.

  \begin{figure}[htpb]
    \centering
    \includegraphics[width=0.99\linewidth]{./performance.png}
  \end{figure}
  \begin{columns}
    \begin{column}{0.35\textwidth}
      \includegraphics[width=0.99\linewidth]{./joyplot_l0.png}
    \end{column}
    \begin{column}{0.35\textwidth}
      \includegraphics[width=0.99\linewidth]{./joyplot_l1.png}
    \end{column}
    \begin{column}{0.35\textwidth}
      \includegraphics[width=0.99\linewidth]{./percentage_0_l0l1.png}
    \end{column}
  \end{columns}
\end{frame}

\begin{frame}[t]{}
  \begin{figure}[htpb]
    \centering
    \includegraphics[width=0.999\linewidth]{./performance_epochs_l1l0.png} \\
  \end{figure}
  \begin{figure}[htpb]
    \centering
    \includegraphics[width=0.999\linewidth]{./loss_l1l0.png} \\
  \end{figure}
\end{frame}

\section{Combing $L_0$ and $L0_1$}
\label{sec:combing_l_0_and_l0_1_}

\begin{frame}[t]{Connection between the $L_2$-norm and Gaussian prior}
  \small
  Let $\mathcal{D}$ the dataset consisting of $N$ input-output pairs $\{(x_1, y_1), \ldots, (x_N, y_N)\}$.

  Lets also assume that the output is linear related via $\theta$ and that the data is corrupted by some noise $\epsilon\sim N(0, \sigma^2)$.
  Then the Gaussian likelihood is:
  \begin{equation}
    \prod^N_{i=1} \mathcal{N}(y_i|\theta x_i, \sigma^2)
  \end{equation}
  We can then impose a Gaussian prior $\mathcal{N}(\theta|0, \lambda^{-1})$, in which $\lambda$ is a positive scalar.
  Then we have for the likelihood:
  \begin{equation}
    \prod^N_{i=1} \mathcal{N}(y_i|\theta x_i, \sigma^2)\mathcal{N}(\theta|0, \lambda^{-1})
  \end{equation}
  Taking the logarithm of the above and removing unecessary constants we get:
  \begin{equation}
    \sum^N_{i=1} - \frac{1}{\sigma^2} (y_i - \theta x_i)^2 - \lambda \theta^2 + const.
  \end{equation}
\end{frame}

\begin{frame}[t]{Combining $L_0$ and $L_2$}
  \small
  Often it is desirable to shrink paramenters, hence on should combine $L_0$ and other norms.
  Using the $L_2$-norm and under a bernulli gating mechanism:
  \begin{equation}
    \mathbb{E}_{q(z|\pi)} [||\theta||^2_2] = \sum^P_{j=1} \mathbb{E}_{q(z_j|\pi_j)} [z_j^2\tilde{\theta}^2_j] = \sum^P_{j=1} \pi_j \tilde{\theta}^2_j
  \end{equation}
  in which $\pi_j$ is the probability of the gate being open.

  Since the $L_2$ norm is proportional to the negative log density of $\mathcal{N}(0, \sigma^2)$ we can assume that the $\sigma$ for each $\theta$ is controlled by $z$.
  That is if $z=0 \rightarrow \sigma=1$, while if $z > 0 \rightarrow \sigma = z$
  Hence the $L_2$ norm is then (where $\hat{\theta} = \frac{\theta}{\sigma}$)
  \begin{equation}
    \begin{split}
      \mathbb{E}_{q(z|\pi)} [||\hat{\theta}||^2_2] =  & \sum^P_{j=1} (1 - Q_{\hat{s}_j}(0 | \phi_j)) \mathbb{E}_{q(z_j|\pi_j, \hat{s}_j > 0)} [\frac{\tilde{\theta}^2_j z^2_j}{z^2_j}] \\
                                                & \sum^P_{j=1} (1 - Q_{\hat{s}_j}(0 | \phi_j)) \tilde{\theta}^2_j
      \end{split}
  \end{equation}
\end{frame}

\begin{frame}[t]{Results of $L_{0,2}$}

\end{frame}

\begin{frame}[t]{Simulation Framework}
  \begin{center}
  \textbf{Completely blind. You need to ask Tim.}
  \end{center}
  \\
  But here is what I know:
  \begin{itemize}
    \item Linear and non-linear effects present
    \item Currently only using chromosome 10
    \item $R^2$ between $0.04$ and $0.01$
    \item Performance of Lassosum is a correlation of $0.05$
  \end{itemize}
\end{frame}

\begin{frame}[t]{Task processing}
  \begin{figure}[htpb]
    \centering
    \includegraphics[width=0.8\linewidth]{Dask_processing.png}
  \end{figure}
\end{frame}

\begin{frame}[t]{Some Results}
  \begin{figure}[htpb]
    \centering
    \includegraphics[width=0.99\linewidth]{performance.png}
    \caption{Performance}
  \end{figure}
\end{frame}

\begin{frame}[t]{Parameter Space}
  \begin{figure}[htpb]
    \centering
    \includegraphics[width=0.99\linewidth]{null_proportion.png}
    \caption{Proportion of parameters equal or close to 0}
  \end{figure}
  \begin{itemize}
    \item $L_0$ comes very quickly to sparse solution (parameters are not accurate, small effects)
    \item $L_1$ and $L_2$ seem to take a bit longer
  \end{itemize}
\end{frame}

\section{Suplementary for $L_0$-norm}
\label{sec:suplementary}

\begin{frame}[t]{Penalized Regression}
  Let $\mathcal{D}$ the dataset consisting of $N$ input-output pairs $\{(x_1, y_1), \ldots, (x_N, y_N)\}$ and consider the following regularized minimization procedure

  \begin{equation}
    \mathcal{R}(\theta) = \frac{1}{N} ( \sum^N_{i=1} \mathcal{L}(h(x_i; \theta), y_i)) + \lambda\mathcal{P}(\theta)
  \end{equation}

  With $\theta^* = \underset{\theta}{\argmin}\{\mathcal{R}(\theta)\}$.

  $\mathcal{P}(\theta)$ is a penalization function for the parameters $\theta$.
\end{frame}

\begin{frame}[t]{The General Recipe}
  The first step is to reformulate the $L_0$ norm under the parameters $\theta$.
  Hence let,
  \begin{equation}
    \begin{matrix}
      \theta_j = \tilde{\theta_j}z_j, & z_j \in \{0, 1\}, & \tilde{\theta}_j \neq 0
    \end{matrix}
  \end{equation}
  Therefore $z_j$ can be considered as binary gates (parameter has an effect).

  Then we can reformulate the minimization from Eq. 1 by letting $q(z_j|\pi_j) = Bern(\pi_j)$
  \begin{equation}
    \mathcal{R}(\tilde{\theta}, \pi) = \mathbb{E}_{q(z|\pi)} [\frac{1}{N} ( \sum^N_{i=1} \mathcal{L}(h(x_i; \tilde{\theta} \otimes z), y_i)] + \lambda \sum^{p}_{j=1} \pi_j
  \end{equation}
  with  $\tilde{\theta}^*, \pi^* = \underset{{\tilde{\theta}, \pi}}{\argmin} \{\mathcal{R}(\tilde{\theta}, \pi)\}$

  However, the discrete nature of $z$ makes it still difficult to minimize $\pi$.
\end{frame}

\begin{frame}[t]{Hard-sigmoid function}
  \small
  Let s be a continuous random variable with a distribution $q(s)$ with parameter $\phi$.
  Then we can give the gates $z$ a hard sigmoid function with:
  \begin{equation}
    \begin{align*}
      s \sim& q(s|\phi) \\
      z =& \min(1, \max(0, s))
    \end{align*}
  \end{equation}
  Then the probability of the gates being non-zero is
  \begin{equation}
    q(z \neq 0 | \delata) =  1 - Q(s\leq 0 | \phi)
  \end{equation}
  in which $Q(\cdot)$ is the cumulative distribution function of s
  \begin{equation}
    \begin{split}
      \mathcal{R}(\tilde{\theta}, \phi) = \mathbb{E}_{q(s|\phi)} [\frac{1}{N} ( \sum^N_{i=1} \mathcal{L}(h(x_i; \tilde{\theta} \otimes g(s)), y_i)] + \\
      \lambda \sum^{|\theta|}_{j=1} (1 - Q(s_j \leq 0 | \phi_j))
    \end{split}
  \end{equation}
  with $\theta^*, \phi^* = \underset{{\tilde{\theta}, \phi}}{\argmin} \{\mathcal{R}(\tilde{\theta}, \phi)\}$ and $g(\cdot) = \min(1, \max(0, \cdot))$
\end{frame}

\begin{frame}[t]{The Hard Concrete Distribution}
  The literature suggests to use a hard concrete distribution as a smoothing function $q(s)$.
  The parameters of the distribution are $\phi = (\log \alpha, \beta)$ and can be stretched to $(\gamma, \zeta)$ intervals.
  \begin{equation}
    \begin{align*}
      u \sim \mathcal{U}(0,1) \\
      s = Sigmoid((\log u - \log(1-u) + \log\alpha)/\beta) \\
      \bar{s} = s(\zeta - \gamma) + \gamma
    \end{align*}
  \end{equation}
  \begin{figure}[htpb]
    \centering
    \includegraphics[width=0.5\linewidth]{hard_concrete.png}
    \caption{Sample from the Hard Concrete Distribution}\label{fig:hard_concrete}
  \end{figure}
\end{frame}

\begin{frame}[t]{Connection between the $L_2$-norm and Gaussian prior}
  \small
  Let $\mathcal{D}$ the dataset consisting of $N$ input-output pairs $\{(x_1, y_1), \ldots, (x_N, y_N)\}$.

  Lets also assume that the output is linear related via $\theta$ and that the data is corrupted by some noise $\epsilon\sim N(0, \sigma^2)$.
  Then the Gaussian likelihood is:
  \begin{equation}
    \prod^N_{i=1} \mathcal{N}(y_i|\theta x_i, \sigma^2)
  \end{equation}
  We can then impose a Gaussian prior $\mathcal{N}(\theta|0, \lambda^{-1})$, in which $\lambda$ is a positive scalar.
  Then we have for the likelihood:
  \begin{equation}
    \prod^N_{i=1} \mathcal{N}(y_i|\theta x_i, \sigma^2)\mathcal{N}(\theta|0, \lambda^{-1})
  \end{equation}
  Taking the logarithm of the above and removing unecessary constants we get:
  \begin{equation}
    \sum^N_{i=1} - \frac{1}{\sigma^2} (y_i - \theta x_i)^2 - \lambda \theta^2 + const.
  \end{equation}
\end{frame}

\begin{frame}[t]{Combining $L_0$ and $L_2$}
  \small
  Often it is desirable to shrink paramenters, hence on should combine $L_0$ and other norms.

  Using the $L_2$-norm and under a bernulli gating mechanism:
  \begin{equation}
    \mathbb{E}_{q(z|\pi)} [||\theta||^2_2] = \sum^P_{j=1} \mathbb{E}_{q(z_j|\pi_j)} [z_j^2\tilde{\theta}^2_j] = \sum^P_{j=1} \pi_j \tilde{\theta}^2_j
  \end{equation}
  in which $\pi_j$ is the probability of the gate being open.

  Since the $L_2$ norm is proportional to the negative log density of $\mathcal{N}(0, \sigma^2)$ we can assume that the $\sigma$ for each $\theta$ is controlled by $z$.
  That is if $z=0 \rightarrow \sigma=1$, while if $z > 0 \rightarrow \sigma = z$
  Hence the $L_2$ norm is then (where $\hat{\theta} = \frac{\theta}{\sigma}$)
  \begin{equation}
    \begin{split}
      \mathbb{E}_{q(z|\pi)} [||\hat{\theta}||^2_2] =  & \sum^P_{j=1} (1 - Q_{\hat{s}_j}(0 | \phi_j)) \mathbb{E}_{q(z_j|\pi_j, \hat{s}_j > 0)} [\frac{\tilde{\theta}^2_j z^2_j}{z^2_j}] \\
                                                & \sum^P_{j=1} (1 - Q_{\hat{s}_j}(0 | \phi_j)) \tilde{\theta}^2_j
      \end{split}
  \end{equation}

\end{frame}

\begin{frame}[t]{Challenges}
  \textbf{Challenge:} \\
  The plumbing (data engineering)
  \\
  \begin{itemize}
    \item Process of the UKB in parallel efficiently
    \item Large Memory requirements for the UKB (scaling)
    \item Currently using Dask on our cluster
  \end{itemize}
  The optimization/implementation:
  \begin{itemize}
    \item Works fine on test data (1k Genome Project)
    \item Issues with larger data
    \item size of mini-batch size
    \item choosing appropriate learning rates
  \end{itemize}
\end{frame}

\end{document}