\chapter{The ring of integers}
\section{Norms and traces}
\prototype{$a+b\sqrt2$ as an element of $\QQ(\sqrt2)$ has norm $a^2-2b^2$ and trace $2a$.}
Remember when you did olympiads and we had like $a^2+b^2$ was the ``norm'' of $a+bi$?
Cool, let me tell you what's actually happening.

First, let me make precise the notion of a conjugate.
\begin{definition}
	Let $\alpha$ be an algebraic number, and let $P(x)$ be its minimal polynomial,
	of degree $m$.
	Then the $m$ roots of $P$ are the (Galois) \vocab{conjugates} of $\alpha$.
\end{definition}
It's worth showing at the moment that there are no repeated conjugates.
\begin{lemma}[Irreducible polynomials have distinct roots]
	An irreducible polynomial in $\QQ[x]$ cannot have a complex double root.
	\label{lem:irred_complex}
\end{lemma}
\begin{proof}
	Let $f(x) \in \QQ[x]$ be the irreducible polynomial and assume it has a double root $\alpha$.
	\textbf{Take the derivative $f'(x)$.}
	This derivative has three interesting properties.
	\begin{itemize}
		\ii The degree of $f'$ is one less than the degree of $f$.
		\ii The polynomials $f$ and $f'$ are not relatively prime
		because they share a factor $x-\alpha$.
		\ii The coefficients of $f'$ are also in $\QQ$.
	\end{itemize}
	Consider $g = \gcd(f, f')$. We must have $g \in \QQ[x]$ by Euclidean algorithm.
	But the first two facts about $f'$ ensure that $g$ is nonconstant
	and $\deg g < \deg f$.
	Yet $g$ divides $f$,
	contradiction to the fact that $f$ should be a minimal polynomial.
\end{proof}
Hence $\alpha$ has exactly as many conjugates as the degree of $\alpha$.

Now, we would \emph{like} to define the \emph{norm} of an element $\Norm(\alpha)$
as the product of its conjugates.
For example, we want $2+i$ to have norm $(2+i)(2-i) = 5$,
and in general for $a+bi$ to have norm $a^2+b^2$.
It would be \emph{really cool} if the norm was multiplicative;
we already know this is true for complex numbers!

Unfortunately, this doesn't quite work: consider
\[ \Norm(2+i) = 5 \text{ and } \Norm(2-i) = 5. \]
But $(2+i)(2-i) = 5$, which doesn't have norm $25$ like we want,
since $5$ is degree $1$ and has no conjugates at all.
The reason this ``bad'' thing is happening is that we're
trying to define the norm of an \emph{element},
when we really ought to be defining the norm of an element
\emph{with respect to a particular $K$}.

What I'm driving at is that the norm should have
different meanings depending on which field you're in.
If we think of $5$ as an element of $\QQ$, then its norm is $5$.
But thought of as an element of $\QQ(i)$, its norm really ought to be $25$.
Let's make this happen: for $K$ a number field, we will now define $\Norm_{K/\QQ}(\alpha)$
to be the norm of $\alpha$ \emph{with respect to $K$} as follows.
\begin{definition}
	Let $\alpha \in K$ have degree $n$, so $\QQ(\alpha) \subseteq K$, and set $k = (\deg K) / n$.
	The \vocab{norm} of $\alpha$ is defined as
	\[ \Norm_{K/\QQ}(\alpha) \defeq \left( \prod \text{Galois conj of $\alpha$} \right)^k. \]
	The \vocab{trace} is defined as
	\[ \Tr_{K/\QQ}(\alpha) \defeq k \cdot \left( \sum \text{Galois conj of $\alpha$} \right). \]
\end{definition}
The exponent of $k$ is a ``correction factor'' that makes the norm of $5$ into $5^2=25$
when we view $5$ as an element of $\QQ(i)$ rather than an element of $\QQ$.
For a ``generic'' element of $K$, we expect $k = 1$.
\begin{exercise}
	Use what you know about nested vector spaces to convince
	yourself that $k$ is actually an integer.
\end{exercise}
\begin{example}[Norm of $a+b\sqrt2$]
	Let $\alpha = a+b\sqrt2 \in \QQ(\sqrt2)$.
	If $b \neq 0$, then $\alpha$ and $K$ have the degree $2$.
	Thus the only conjugates of $\alpha$ are $a \pm b\sqrt2$, which gives
	the norm \[ (a+b\sqrt2)(a-b\sqrt2) = a^2-2b^2, \]
	The trace is $(a-b\sqrt2) + (a+b\sqrt2) = 2a$.

	Nicely, the formula $a^2-2b^2$ and $2a$ also works when $b=0$.
\end{example}
Of importance is:
\begin{proposition}[Norms and traces are rational integers]
	If $\alpha$ is an algebraic integer, its norm and trace
	are rational integers.
\end{proposition}
\begin{ques}
	Prove it. (Vieta formula.)
\end{ques}

That's great, but it leaves a question unanswered:
why is the norm multiplicative?
To do this, I have to give a new definition of norm and trace.

\begin{theorem}[Morally correct definition of norm and trace]
	Let $K$ be a number field of degree $n$, and let $\alpha \in K$.
	Let $\mu_\alpha \colon K \to K$ denote the map \[ x \mapsto \alpha x \]
	viewed as a linear map of $\QQ$-vector spaces.
	Then,
	\begin{itemize}
		\ii the norm of $\alpha$ equals the determinant $\det \mu_\alpha$, and
		\ii the trace of $\alpha$ equals the trace $\Tr \mu_\alpha$.
	\end{itemize}
\end{theorem}
Since the trace and determinant don't depend on the choice of basis,
you can pick whatever basis you want
and use whatever definition you got in high school.
Fantastic, right?

\begin{example}[Explicit computation of matrices for $a+b\sqrt2$]
	Let $K = \QQ(\sqrt2)$, and let $1$, $\sqrt 2$ be the basis of $K$.
	Let \[ \alpha = a + b \sqrt 2 \] (possibly even $b = 0$), and notice that
	\[ \left( a+b\sqrt2 \right) \left(x+y\sqrt2 \right)
		= (ax+2yb) + (bx+ay)\sqrt2. \]
	We can rewrite this in matrix form as
	\[
		\begin{bmatrix}
			a & 2b \\
			b & a
		\end{bmatrix}
		\begin{bmatrix}
			x \\ y
		\end{bmatrix}
		=
		\begin{bmatrix}
			ax+2yb \\ bx+ay
		\end{bmatrix}.
	\]
	Consequently, we can interpret $\mu_\alpha$ as the matrix
	\[ \mu_\alpha =
		\begin{bmatrix}
			a & 2b \\ b & a
		\end{bmatrix}. \]
	Of course, the matrix will change if we pick a different basis,
	but the determinant and trace do not: they are always given by
	\[ \det \mu_\alpha = a^2-2b^2 \text{ and }
		\Tr \mu_\alpha = 2a. \]
\end{example}
This interpretation explains why the same formula should work for $a+b\sqrt 2$
even in the case $b = 0$.

\begin{proof}
I'll prove the result for just the norm; the trace falls out similarly.
Set
\[ n = \deg \alpha, \qquad kn = \deg K. \]
The proof is split into two parts, depending on whether or not $k=1$.
\begin{subproof}[Proof if $k=1$]
	Set $n = \deg \alpha = \deg K$.
	Thus the norm actually \emph{is} the product of the Galois conjugates.
	Also, \[ \{1, \alpha, \dots, \alpha^{n-1}\} \]
	is linearly independent in $K$, and hence a basis (as $\dim K = n$).
	Let's use this as the basis for $\mu_\alpha$.

	Let \[ x^n+c_{n-1}x^{n-1} + \dots + c_0  \]be the minimal polynomial of $\alpha$.
	Thus $\mu_\alpha(1) = \alpha$, $\mu_\alpha(\alpha) = \alpha^2$, and so on,
	but $\mu_\alpha(\alpha^{n-1}) = -c_{n-1}\alpha^{n-1} - \dots - c_0$.
	Therefore, $\mu_\alpha$ is given by the matrix
	\[
		M =
		\begin{bmatrix}
			0 & 0 & 0 & \dots & 0 & -c_0 \\
			1 & 0 & 0 & \dots & 0 & -c_1 \\
			0 & 1 & 0 & \dots & 0 & -c_2 \\
			\vdots & \vdots & \vdots & \ddots & 0 & -c_{n-2} \\
			0 & 0 & 0 & \dots & 1 & -c_{n-1}
		\end{bmatrix}.
	\]
	Thus \[ \det M = (-1)^n c_0 \] and we're done by Vieta's formulas.
\end{subproof}
\begin{subproof}[Proof if $k > 1$]
	We have nested vector spaces
	\[ \QQ \subseteq \QQ(\alpha) \subseteq K. \]
	Let $e_1$, \dots, $e_k$ be a $\QQ(\alpha)$-basis for $K$
	(meaning: interpret $K$ as a vector space over $\QQ(\alpha)$, and pick that basis).
	Since $\{1, \alpha, \dots, \alpha^{n-1}\}$ is a $\QQ$ basis for $\QQ(\alpha)$,
	the elements
	\[
			\begin{array}{cccc}
			e_1, & e_1\alpha, & \dots, & e_1\alpha^{n-1} \\
			e_2, & e_2\alpha, & \dots, & e_2\alpha^{n-1} \\
			\vdots & \vdots & \ddots & \vdots \\
			e_k, & e_k\alpha, & \dots, & e_k\alpha^{n-1}
			\end{array}
	\]
	constitute a $\QQ$-basis of $K$.
	Using \emph{this} basis, the map $\mu_\alpha$ looks like
	\[
			\underbrace{
			\begin{bmatrix}
					M & & & \\
					& M & & \\
					& & \ddots & \\
					& & & M
			\end{bmatrix}
			}_{\text{$k$ times}}
	\]
	where $M$ is the same matrix as above:
	we just end up with one copy of our old matrix for each $e_i$.
	Thus $\det \mu_\alpha = (\det M)^k$, as needed. \qedhere
\end{subproof}
\begin{ques}
	Verify the result for traces as well. \qedhere
\end{ques}
\end{proof}

From this it follows immediately that
\[ \Norm_{K/\QQ}(\alpha\beta) = \Norm_{K/\QQ}(\alpha)\Norm_{K/\QQ}(\beta) \]
because by definition we have
\[ \mu_{\alpha\beta} = \mu_\alpha \circ \mu_\beta, \]
and that the determinant is multiplicative.
In the same way, the trace is additive.

\section{The ring of integers}
\prototype{If $K = \QQ(\sqrt 2)$, then $\OO_K = \ZZ[\sqrt 2]$.
	But if $K = \QQ(\sqrt 5)$, then $\OO_K = \ZZ[\frac{1+\sqrt5}{2}]$.}

$\ZZ$ makes for better number theory than $\QQ$.
In the same way, focusing on the \emph{algebraic integers} of $K$
gives us some really nice structure, and we'll do that here.

\begin{definition}
	Given a number field $K$, we define
	\[ \OO_K \defeq K \cap \ol\ZZ \]
	to be the \vocab{ring of integers} of $K$;
	in other words $\OO_K$ consists of the algebraic integers of $K$.
\end{definition}

We do the classical example of a quadratic field now.
Before proceeding, I need to write a silly number theory fact.
\begin{exercise}
	[Annoying but straightforward]
	Let $a$ and $b$ be rational numbers, and $d$ a squarefree positive integer.
	\begin{itemize}
		\ii If $d \equiv 2, 3 \pmod 4$, prove that
		$2a, a^2-db^2 \in \ZZ$ if and only if $a,b \in \ZZ$.
		\ii For $d \equiv 1 \pmod 4$, prove that
		$2a, a^2-db^2 \in \ZZ$ if and only if $a,b \in \ZZ$
		OR if $a -\half, b-\half \in \ZZ$.
	\end{itemize}
	You'll need to take mod $4$.
\end{exercise}

\begin{example}
	[Ring of integers of $K = \QQ(\sqrt3)$]
	Let $K$ be as above.
	We claim that \[ \OO_K = \ZZ[\sqrt 3] = \left\{ m + n\sqrt 3 \mid m,n \in \ZZ  \right\}. \]
	We set $\alpha = a + b \sqrt 3$.
	Then $\alpha \in \OO_K$ when the minimal polynomial has integer coefficients.

	If $b = 0$, then the minimal polynomial is $x-\alpha=x-a$,
	and thus $\alpha$ works if and only if it's an integer.
	If $b \neq 0$, then the minimal polynomial is
	\[ (x-a)^2 - 3b^2 = x^2 - 2a \cdot x + (a^2-3b^2). \]
	From the exercise, this occurs exactly for $a,b \in \ZZ$.
\end{example}
\begin{example}
	[Ring of integers of $K = \QQ(\sqrt 5)$]
	We claim that in this case
	\[ \OO_K = \ZZ\left[ \frac{1+\sqrt5}{2} \right]
	= \left\{ m + n \cdot \frac{1+\sqrt5}{2} \mid m,n \in \ZZ \right\}. \]
	The proof is exactly the same, except the exercise tells us instead
	that for $b \neq 0$, we have both the possibility that $a,b \in \ZZ$
	or that $a,b \in \ZZ - \half$.
	This reflects the fact that $\frac{1+\sqrt5}{2}$ is the root of $x^2-x-1 = 0$;
	no such thing is possible with $\sqrt 3$.
\end{example}
In general, the ring of integers of $K = \QQ(\sqrt d)$ is
\[ \OO_K
	=
	\begin{cases}
		\ZZ[\sqrt d] & d\equiv 2,3 \pmod 4 \\[1em]
		\ZZ\left[ \frac{1+\sqrt d}{2} \right] & d \equiv 1 \pmod 4.
	\end{cases}
\]
What we're going to show is that $\OO_K$ behaves in $K$
a lot like the integers do in $\QQ$.
First we show $K$ consists of quotients of numbers in $\OO_K$.
In fact, we can do better:
\begin{example}[Rationalizing the denominator]
	For example, consider $K = \QQ(\sqrt3)$.
	The number $x = \frac{1}{4+\sqrt3}$ is an element of $K$, but by
	``rationalizing the denominator'' we can write
	\[ \frac{1}{4+\sqrt3} = \frac{4-\sqrt3}{13}. \]
	So we see that in fact, $x$ is $\frac{1}{13}$ of an integer in $\OO_K$.
\end{example}

The theorem holds true more generally.
\begin{theorem}[$K = \QQ \cdot \OO_K$]
	Let $K$ be a number field, and let $x \in K$ be any element.
	Then there exists an integer $n$ such that $nx \in \OO_K$;
	in other words, \[ x = \frac 1n \alpha \] for some $\alpha \in \OO_K$.
\end{theorem}
\begin{exercise}
	Prove this yourself.
	(Start by using the fact that $x$ has a minimal
	polynomial with rational coefficients.
	Alternatively, take the norm.)
\end{exercise}

Now we are going to show $\OO_K$ is a ring;
we'll check it is closed under addition and multiplication.
To do so, the easiest route is:
\begin{lemma}[$\alpha \in \ol\ZZ$ $\iff$ {$\ZZ[\alpha]$} finitely generated]
	Let $\alpha \in \ol\QQ$.
	Then $\alpha$ is an algebraic integer if and only if
	the abelian group $\ZZ[\alpha]$ is finitely generated.
\end{lemma}
\begin{proof}
	Note that $\alpha$ is an algebraic integer if and only if it's the root
	of some nonzero, monic polynomial with integer coefficients.
	Suppose first that
	\[ \alpha^N = c_{N-1} \alpha^{N-1} + c_{N-2} \alpha^{N-2} + \dots + c_0. \]
	Then the set $1, \alpha, \dots, \alpha^{N-1}$ generates $\ZZ[\alpha]$,
	since we can repeatedly replace $\alpha^N$ until all powers of $\alpha$
	are less than $N$.

	Conversely, suppose that $\ZZ[\alpha]$ is finitely generated
	by some $b_1, \dots, b_m$.
	Viewing the $b_i$ as polynomials in $\alpha$, we can select a large integer
	$N$ (say $N = \deg b_1 + \dots + \deg b_m + 2015$)
	and express $\alpha^N$ in the $b_i$'s to get
	\[ \alpha^N = c_1b_1(\alpha) + \dots + c_mb_m(\alpha). \]
	The above gives us a monic polynomial in $\alpha$,
	and the choice of $N$ guarantees it is not zero.
	So $\alpha$ is an algebraic integer.
\end{proof}
\begin{example}[$\half$ isn't an algebraic integer]
	We already know $\half$ isn't an algebraic integer.
	So we expect
	\[ \ZZ \left[ \half \right] = \left\{ \frac{a}{2^m}
		\mid a, m \in \ZZ \text{ and } m \ge 0 \right\} \]
	to not be finitely generated, and this is the case.
\end{example}
\begin{ques}
	To make the last example concrete:
	name all the elements of $\ZZ[\half]$
	that cannot be written as an integer combination of
	\[ \left\{ \frac12, \frac{7}{8}, \frac{13}{64},
		\frac{2015}{4096}, \frac{1}{1048576} \right\} \]
\end{ques}

Now we can state the theorem.
\begin{theorem}[Algebraic integers are closed under $+$ and $\times$]
	The set $\ol\ZZ$ is closed under addition and multiplication;
	i.e.\ it is a ring.
	In particular, $\OO_K$ is also a ring for any number field $K$.
\end{theorem}
\begin{proof}
	Let $\alpha, \beta \in \ol\ZZ$.
	Then $\ZZ[\alpha]$ and $\ZZ[\beta]$ are finitely generated.
	Hence so is $\ZZ[\alpha, \beta]$.
	(Details: if $\ZZ[\alpha]$ has $\ZZ$-basis $a_1, \dots, a_m$ and
	$\ZZ[\beta]$ has $\ZZ$-basis $b_1, \dots, b_n$,
	then take the $mn$ elements $a_ib_j$.)

	Now $\ZZ[\alpha \pm \beta]$ and $\ZZ[\alpha \beta]$ are subsets of $\ZZ[\alpha,\beta]$ and so they are also finitely generated.
	Hence $\alpha \pm \beta$ and $\alpha\beta$ are algebraic integers.
\end{proof}

In fact, something even better is true.
As you saw, for $\QQ(\sqrt 3)$ we had $\OO_K = \ZZ[\sqrt 3]$;
in other words, $\OO_K$ was generated by $1$ and $\sqrt 3$.
Something similar was true for $\QQ(\sqrt 5)$.
We claim that in fact, the general picture looks exactly like this.

\begin{theorem}[$\OO_K$ is a free $\ZZ$-module of rank $n$]
	Let $K$ be a number field of degree $n$.
	Then $\OO_K$ is a free $\ZZ$-module of rank $n$,
	i.e.\ $\OO_K \cong \ZZ^{\oplus n}$ as an abelian group.
	In other words, $\OO_K$ has a $\ZZ$-basis of $n$ elements as
	\[ \OO_K = \left\{ c_1\alpha_1 + \dots
			+ c_{n-1}\alpha_{n-1} + c_n\alpha_n \mid c_i \in \ZZ \right\} \]
	where $\alpha_i$ are algebraic integers in $\OO_K$.
	\label{thm:OK_free_Z_module}
\end{theorem}

\begin{proof}
	TODO: add this in.
	(Originally, there was an incorrect proof;
	the mistake was pointed out 2020-02-12 on
	\url{https://math.stackexchange.com/q/3543641/229197}
	and I hope to supply a correct one soon.)
%	This is a kind of fun proof, so it may be worth
%	trying to work out yourself before reading it.
%
%	Pick a $\QQ$-basis of $\alpha_1$, \dots, $\alpha_n$ of $K$ and WLOG
%	the $\alpha_i$ are in $\OO_K$ by scaling.
%
%	Consider $\alpha \in \OO_K$,
%	and write $\alpha = c_1\alpha_1 + \dots + c_n\alpha_n$.
%	We will try to bound the denominators of $c_i$.
%	Look at $\Norm(\alpha) = \Norm(c_1\alpha_1 + \dots + c_n\alpha_n)$.
%
%	If we do a giant norm computation, we find that $\Norm(\alpha)$
%	is a polynomial in the $c_i$ with fixed coefficients.
%	(For example, $\Norm(c_1 + c_2\sqrt 2) = c_1^2 - 2c_2^2$, say.)
%	But $\Norm(\alpha)$ is an \emph{integer}, so the denominators of the $c_i$
%	have to be bounded by some very large integer $N$.
%	Thus
%	\[ \bigoplus_i \ZZ \cdot \alpha_i \subseteq \OO_K
%		\subseteq \frac 1N \bigoplus_i \ZZ \cdot \alpha_i.  \]
%	The latter inclusion shows that $\OO_K$ is a subgroup
%	of a free group, and hence it is itself free.
%	On the other hand, the first inclusion shows it's rank $n$.
\end{proof}

This last theorem shows that in many ways $\OO_K$ is a ``lattice'' in $K$.
That is, for a number field $K$ we can find $\alpha_1$, \dots, $\alpha_n$
in $\OO_K$ such that
\begin{align*}
	\OO_K &\cong \alpha_1\ZZ \oplus \alpha_2\ZZ \oplus \dots \oplus \alpha_n\ZZ \\
	K &\cong \alpha_1\QQ \oplus \alpha_2\QQ \oplus \dots \oplus \alpha_n\QQ
\end{align*}
as abelian groups.

\section{On monogenic extensions}
Recall that it turned out number fields $K$ could all be
expressed as $\QQ(\alpha)$ for some $\alpha$.
We might hope that something similar is true of the ring of integers:
that we can write \[ \OO_K = \ZZ[\theta] \]
in which case $\{1, \theta, \dots, \theta^{n-1}\}$
serves both as a basis of $K$ and as the $\ZZ$-basis for $\OO_K$ (here $n = [K:\QQ]$).
In other words, we hope that the basis of $\OO_K$ is actually a ``power basis''.

This is true for the most common examples we use:
\begin{itemize}
	\ii the quadratic field, and
	\ii the cyclotomic field in \Cref{prob:ring_int_cyclotomic}.
\end{itemize}
Unfortunately, it is not true in general:
the first counterexample is $\QQ(\alpha)$ for $\alpha$ a root of $X^3-X^2-2X-8$.

We call an extension with this nice property \vocab{monogenic}.
As we'll later see, monogenic extensions have a really nice factoring algorithm,
\Cref{thm:factor_alg}.

\section{\problemhead}

\begin{sproblem} % trivial
	\label{prob:OK_unit_norm}
	Show that $\alpha$ is a unit of $\OO_K$ (meaning $\alpha\inv \in \OO_K$)
	if and only if $\Norm_{K/\QQ}(\alpha) = \pm 1$.
	\begin{hint}
		The norm is multiplicative and equal to product of Galois conjugates.
	\end{hint}
\end{sproblem}

\begin{sproblem}
	Let $K$ be a number field.
	What is the field of fractions of $\OO_K$?
	\begin{hint}
		It's isomorphic to $K$.
	\end{hint}
\end{sproblem}

\begin{problem}
	[Russian olympiad 1984]
	Find all integers $m$ and $n$ such that
	\[ \left( 5+3\sqrt2 \right)^m = \left( 3+5\sqrt2 \right)^n. \]
	\begin{hint}
		Taking the standard norm on $\QQ(\sqrt2)$ will destroy it.
	\end{hint}
\end{problem}

\begin{problem}
	[USA TST 2012]
	Decide whether there exist $a,b,c > 2010$ satisfying
	\[ a^3+2b^3+4c^3=6abc+1. \]
	\begin{hint}
		Norm in $\QQ(\sqrt[3]2)$.
	\end{hint}
\end{problem}

\begin{dproblem}[Cyclotomic Field]
	\yod
	\label{prob:ring_int_cyclotomic}
	Let $p$ be an odd rational prime and $\zeta_p$ a primitive $p$th root of unity.
	Let $K = \QQ(\zeta_p)$.
	Prove that $\OO_K = \ZZ[\zeta_p]$.
	(In fact, the result is true even if $p$ is not a prime.)
	\begin{hint}
		Obviously $\ZZ[\zeta_p] \subseteq \OO_K$, so our goal is to show the reverse inclusion.
		Show that for any $\alpha \in \OO_K$, the trace of $\alpha(1-\zeta_p)$ is divisible by $p$.
		Given $x = a_0 + a_1\zeta_p + \dots + a_{p-2}\zeta^{p-2} \in \OO_K$ (where $a_i \in \QQ$),
		consider $(1-\zeta_p)x$.
	\end{hint}
\end{dproblem}


\input{settings}

\begin{document}

\lhead{Shallow Neural Networks}
\rhead{ Deep Learning specialization \\ Neural Networks and Deep Learning}
\cfoot{\thepage \ of \pageref{LastPage}}

\subsection*{Neural Network Representation}

    The following diagram represents a two layer Neural Network:

    \begin{tikzpicture}[
        % define styles
        clear/.style={
            draw=none,
            fill=none
        },
        net/.style={
            matrix of nodes,
            nodes={ draw, circle, inner sep=10pt },
            nodes in empty cells,
            column sep=2cm,
            row sep=-9pt
        },
        >=latex
    ]
    % define matrix mat to hold nodes
    % using net as default style for cells
    \matrix[net] (mat)
    {
    % Define layer headings
    |[clear]| \parbox{1.3cm}{\centering Input\\layer}
    & |[clear]| \parbox{1.3cm}{\centering Hidden\\layer}
    & |[clear]| \parbox{1.3cm}{\centering Output\\layer} \\
    |[clear]|  &  $a_1^{[1]}$  & |[clear]| \\
    $x_1$  & |[clear]|  & |[clear]|\\
    |[clear]|  &  $a_2^{[1]}$ & |[clear]|\\
    $x_2$  & |[clear]|  &  $a^{[2]}$\\
    |[clear]|  &  $a_3^{[1]}$ & |[clear]| \\
    $x_3$  & |[clear]|  & |[clear]| \\
    |[clear]|  &  $a_4^{[1]}$ & |[clear]| \\
    };

    %left most lines into input layers
    \foreach \ai in {3,5,7}
    \draw[<-] (mat-\ai-1) -- +(-2cm,0);

    %lines from a_{i}^{0} to each a_{j}^{1}
    \foreach \ai in {3,5,7} {
    \foreach \aii in {2,4,6,8}
        \draw[->] (mat-\ai-1) -- (mat-\aii-2);
        }

    %lines from a_{i}^{1} to a_{0}^{2}
    \foreach \ai in {2,4,6,8}
    \draw[->] (mat-\ai-2) -- (mat-5-3);

    % right most line with Output label
    \draw[->] (mat-5-3) -- node[above] {$\hat{y}$} +(2cm,0);
    \end{tikzpicture}

    In this case, two parameters are associated with the hidden layer:
    \begin{align*}
        W^{[1]} \in \R^{4\times3} \\
        b^{[1]} \in \R^{4\times1}
    \end{align*}
    Similarly two parameters are associated with the output layer:
    \begin{align*}
        W^{[2]} \in \R^{1\times4} \\
        b^{[2]} \in \R
    \end{align*}

\subsection*{Computing a Neural Network's Output (one input)}

    Remember that for logistic regresion we did the following computation

    \begin{tikzpicture}[
        % define styles
        clear/.style={
            draw=none,
            fill=none
        },
        net/.style={
            matrix of nodes,
            nodes={ draw, circle, inner sep=10pt },
            nodes in empty cells,
            column sep=2cm,
            row sep=-9pt
        },
        >=latex
    ]
    % define matrix mat to hold nodes
    % using net as default style for cells
    \matrix[net] (mat)
    {
    % Define layer headings
    |[clear]| \parbox{1.3cm}{\centering Input\\layer}
    & |[clear]| \parbox{1.3cm}{\centering Hidden\\layer}
    & |[clear]| \parbox{1.3cm}{\centering Output\\layer} \\

    $x_1$  & |[clear]|  & |[clear]| \\
    |[clear]|  & |[clear]|  & |[clear]| \\
    $x_2$  & $\sigma(w^tx + b)$  & $\Hat{y}$ \\
    |[clear]|  & |[clear]|  & |[clear]| \\
    $x_3$  & |[clear]|  & |[clear]| \\
    };

    %lines from a_{i}^{0} to each a_{j}^{1}
    \foreach \ai in {2,4,6} {
    \foreach \aii in {4}
        \draw[->] (mat-\ai-1) -- (mat-\aii-2);
        }

    %lines from a_{i}^{1} to a_{0}^{2}
    \foreach \ai in {4}
    \draw[->] (mat-\ai-2) -- (mat-4-3);

    \end{tikzpicture}

    Another way to think about a neural network is that that each hidden layer is
    performing a logistic regression. Each of the logistic regresion units has it's own
    $w$ and $b$ parameters. So, in a neural network, each neuron does the
    following computation:
    \begin{align*}
        z_i^{[1]} &= w_i^{[1]}x + b_i^{[1]} \\
        a_i^{[1]} &= \sigma(z_i^{[1]}) \\
        z_i^{[2]} &= w_i^{[2]}a_i^{[1]} + b_i^{[2]} \\
        a_i^{[2]} &= \sigma(z_i^{[2]})
    \end{align*}
    Or in matrix notation
    \begin{align*}
        z^{[1]} &= W^{[1]}x + b^{[1]} \\
        a^{[1]} &= \sigma(z^{[1]}) \\
        z^{[2]} &= W^{[1]}a^{[1]} + b^{[2]}  \\
        a^{[2]} &= \sigma(z^{[2]})
    \end{align*}

\subsection*{Computing a Neural Network's Output (multiple inputs)}

    We define the following matrices:
    \begin{align*}
        X &= \begin{bmatrix} x^{(1)} | \cdots | x^{(m)} \end{bmatrix} \\
        Z^{[i]} &= \begin{bmatrix} z^{[i](1)} | \cdots | z^{[i](m)} \end{bmatrix} \\
        A^{[i]} &= \begin{bmatrix} a^{[i](1)} | \cdots | a^{[i](m)} \end{bmatrix}
    \end{align*}
    And then, the vectorized form for the forward propagation calculations are:
    \begin{align*}
        Z^{[1]} &= W^{[1]}X + b^{[1]} \\
        A^{[1]} &= \sigma(Z^{[1]}) \\
        Z^{[2]} &= W^{[2]}A^{[1]} + b^{[2]}  \\
        A^{[2]} &= \sigma(Z^{[2]})
    \end{align*}

\subsection*{Activation functions}

    We replace the sigmoid function $\sigma$ with a more general function $g$
    \begin{align*}
        A^{[i]} = \cancel{\sigma(Z^{[i]})} \ g(Z^{[i]})
    \end{align*}

    Common activation functions are:
    \begin{figure}[H]
        \begin{center}
                \includegraphics[width=0.75\textwidth]{img/activations.jpg}
                \caption{Common activation functions}
            \end{center}
    \end{figure}
    If your output is binary the sigmoid is ideal for the output layer. In any other case the
    hyperbolic tangent activation function is superior than the sigmoid.

    The most common activation function is the ReLU and it usually performs better because
    for a lot of the space of $Z$, the derivative of the activation function if far from 0.
    So, using the ReLU activation function, the neural network will often learn much faster
    than when using the tanh or the sigmoid activation functions.

    One disadvantage of ReLU is that for negative $x$ the derivative is zero, it works fine
    in practice but that can be fixed using the leaky ReLU.

    Finally, to implement back propagation for a neural network, it's necessary to
    compute the derivative of the activation functions, the following table summarises the
    derivatives of the former activation functions.

    \begin{figure}[H]
        \begin{center}
                \includegraphics[width=0.9\textwidth]{img/derivatives.jpg}
                \caption{Derivatives of activation functions}
            \end{center}
    \end{figure}

\subsection*{Importance of non-linear activation functions}

    Since the composition of linear functions is linear, using linear activation functions outputs
    a linear function of the input and you might as well not have any hidden layers.
    The whole purpose of the neural networksis to capture non-linear relationships in the
    input data and that's why it's important to use non-linear activation functions.

    The one place in which you can use a linear activation function is in the output layer of
    regression problems when your output is a real number.

\subsection*{Gradient descent for Neural Networks}

    Using te following cost function:
    \begin{align*}
        J(W^{[1]},b^{[1]},W^{[2]},b^{[2]}) = \frac{1}{n} \sum_{i=1}^n L(\Hat{y},y)
    \end{align*}

    We can compute the derivatives using the computation graph as we did with the logistic
    function. The derivatives are:
    \begin{align*}
        dZ^{[2]} &= A^{[2]} - Y \\
        dW^{[2]} &= \frac{1}{m} dZ^{[2]} A^{[1]\top} \\
        db^{[2]} &= \frac{1}{n} sum(dZ^{2}) \\ \\
        dZ^{[1]} &= W^{[2]\top} dZ^{[2]} * g^{[1]'}(Z^[1]) \\
        dW^{[1]} &= \frac{1}{m} dZ^{[1]} X\top \\
        db^{[1]} &= \frac{1}{n} sum(dZ^{1})
    \end{align*}
\subsection*{Weight initialization}
    If the weights are initialized to zero (as we did with the logistic regresion) every
    hidden unit will be completely identical and, in fact, they will be exactly the same
    after every iteration, then there's really no point in having several hidden units.

    As you want the different hidden units to compute different functions, we usually
    initialize every weight matrix with small observations of random gaussian variables.
    The bias terms can be initialized with zeros.

\end{document}


%
% CMPT 473: Software Quality Assurance - A Course Overview
% Section: Logic-Based Coverage
%
% Author: Jeffrey Leung
%

\section{Logic-Based Coverage}
	\label{sec:logic-based-coverage}
\begin{easylist}

& \textbf{Predicate coverage:} Each boolean expression must be tested as true and false in at least one test each
& \textbf{Clause coverage:} Each clause must be tested as true and false in at least one test
& \textbf{Combinatorial/Multiple Condition coverage:} Each possible combination of clauses must be tested

& Clause determines the outcome of a predicate if changing only the value of that clause changes the outcome of the predicate

& \textbf{Modified Condition/Decision Coverage (MCDC):} Coverage demonstrating that each entry/exit is used, each decision can take every possible outcome, each clause can take every possible outcome, and each clause independently can impact the outcome
	&& Based on the behaviour how one clause affects the entire expression
	&& Ensures that each clause has an impact
	&& Not effective to generate a test suite as the drive to create minimal tests interferes with MC/DC
	&& Used to check test suites generated using other strategies

& Determining the impact of a predicate
	&& Process for a given predicate $a$:
		&&& Create two clauses, one which replaces $a$ with $\#T$ (true) and the other which replaces $a$ with $\#F$ (false)
		&&& Set these two clauses as not equal to each other
		&&& Solve the equation
		&&& If the equation is not equal, then the predicate has impact

	&& Example: Given $(a \land b) \lor (a \land \neg b)$, prove whether $a$ has impact or not.
		&&& Let $a = T$ for one version of the clause, and $a = F$ for another version of the clause.

		\end{easylist}
		\begin{align*}
		(T \land b) \lor (T \land \neg b)
		& \stackrel{?}{=} (F \land b) \lor (F \land \neg b) \\
		b \lor \neg b
		& \stackrel{?}{=} F \lor F \\
		T
		& \stackrel{?}{=} F
		\end{align*}
		\begin{easylist}

		&&& The expression evalutes to $T \neq F$. Therefore $a$ has impact.

& Process of creating a minimal test suite using MC/DC:
	&& Change all compared expressions into clauses, each represented by one predicate
	&& Create a minimal set of logical assignments where, for each predicate, there are at least two assignments where:
		&&& The values of the predicate and result both differ, and
		&&& The values of all other predicates match
	&& Create a test suite with the original inputs set to specific values to satisfy the predicate values

	&& Example: Given $a \lor (b \land c)$, generate a minimal set of tests to demonstrate MCDC coverage.
		&&& See figure~\ref{fig:mcdc-example-1}.
		&&& Test entries 1 and 2 show the impact of $a$.
		&&& Test entries 2 and 3 show the impact of $b$.
		&&& Test entries 3 and 4 show the impact of $c$.

		\end{easylist}
		\begin{figure}[!htb]
			\centering
			\begin{tabular}{ c c c | c }
				a & b & c & Result \\
				\hline
				T & F & T & T \\
				F & F & T & F \\
				F & T & T & T \\
				F & T & F & F
			\end{tabular}
			\caption{MCDC Example Test Suite}
			\label{fig:mcdc-example-1}
		\end{figure}
		\begin{easylist}

	&& Example: Given $(a \land b \land c) \lor (d \land a)$, generate a minimal set of tests to demonstrate MCDC coverage.
		&&& See figure~\ref{fig:mcdc-example-2}.
		&&& Test entries 1 and 2 show the impact of $a$.
		&&& Test entries 2 and 3 show the impact of $d$.
		&&& Test entries 3 and 4 show the impact of $c$.
		&&& Test entries 4 and 5 show the impact of $b$.

		\end{easylist}
		\begin{figure}[!htb]
			\centering
			\begin{tabular}{ c c c c | c }
				a & b & c & d & Result \\
				\hline
				F & T & F & T & F \\
				T & T & F & T & T \\
				T & T & F & F & F \\
				T & T & T & F & T \\
				T & F & T & F & F
			\end{tabular}
			\caption{MCDC Example Test Suite}
			\label{fig:mcdc-example-2}
		\end{figure}
		\begin{easylist}

\end{easylist}
\clearpage


First, we proceed to motivate and derive a new \emph{expected} F1-Score we use to optimize for cluster extraction.  % in this work.
Following this, we describe two efficient greedy algorithms to (approximately) optimize it.  %To this end, we describe in this section  two scalable and efficient  algorithms to optimize EF1.
%used to build filters setting for querying large data graphs in order to retrieve relevant UI elements that are of interest to the users.
%Following this, we describe an optimization-based approach based on Mixed Integer Linear Programming (MILP) to benchmark the performance of the proposed greedy algorithms on moderate-sized problems.

\subsection{Deriving Expected F1-Score (EF1)}

We adopt the Boolean relevance framework in information retrieval~\cite{Baeza-Yates2010} and thus assume that any information element $j$ has a ground truth relevance assessment $B(j)$ available at evaluation time.
%%However, unlike previous document-based methods for estimating relevance at retrieval-time, we do not rely on text associated with information elements and instead rely on a third-party to supply an estimated probability (score) of relevance $S(j)$.
%Traditionally, Boolean labels indicate the relevance of documents is used to evaluate retrieval sets (e.g., precision).
%In practice, IR models are based on probabilistic scores to measure relevance of the elements, such as TF-IDF and cosine similarity.
%In practice, we are able to employ third-party technique to provide probabilistic scores to measure relevance of the document in IR system, such as TF-IDF and cosine similarity. Consequently,
Because clustering implies a Boolean retrieval model (clusters either contain or do not contain elements) and we have a probabilistic estimate of relevance $S(j)$, we propose to evaluate
\emph{expected} variants of standard precision, recall, and F1-score of these clusters.
%Boolean retrieval evaluation metrics based on the relaxation of Boolean labels to probabilistic scores resulting in expected metrics, i.e., \emph{expected precision} (EP), \emph{expected recall} (ER) and \emph{expected F1-Score} (EF1).

However, as standard for both precision and recall, we note that precision and recall alone can be trivially optimized through pathological solutions.  That is, the cluster that selects all information elements (i.e., all time, all space, no excluded keywords) would trivially maximize (expected) recall.  Similarly, the cluster that selects the highest probability singleton information element would maximize expected precision.  \emph{This leaves expected F1-score as the only of these three objectives commonly used in Boolean information retrieval that does not have a pathological solution.}
%to balance expected precision and recall. % in a Boolean retrieval framework.

To formally define expected F1-Score, we first begin with definitions of expected precision and recall.  Recalling our previous definitions, given a set of information elements  $E$  that match a user query and a relevant set $RS$, %the global information element collection $GC$ with size $m$,
the precision of $E$ is defined as follows:
\begin{equation}
   P(E) = \dfrac{\sum_{j \in E} B(j)}{|E|} = \dfrac{\sum_{j=1}^m B(j)I(j)}{\sum_{j=1}^m I(j)}
\end{equation}
Given that $B(j)$ is a Boolean random variable, we can take the expectation of $P(E)$ leading to the following definition of
%Replacing the ground-truth Boolean relevance label $B(j)$ with the Boolean random variable $S(j)$ gives the following definition of
\emph{expected precision}:
\begin{equation}
EP(E)=\mathbb{E_{S}}\left[\dfrac{{ \sum_{j=1}^{m}}B(j)I(j)}{{ \sum_{j=1}^{m}}I(j)}\right]=\dfrac{{ \sum_{j=1}^{m}}\mathbb{E_{S}}[B(j)]I(j)}{{ \sum_{j=1}^{m}}I(j)}=\dfrac{{ \sum_{j=1}^{m}}S(j)I(j)}{{ \sum_{j=1}^{m}}I(j)}
\end{equation}
Similarly the recall of a retrieved set $R(E)$ is defined as:
\begin{equation}
   R(E) = \dfrac{\sum_{j \in RS} B(j)}{|RS|} = \dfrac{\sum_{j=1}^m B(j)I(j)}{ \sum_{j=1}^m B(j)}
\end{equation}
Taking a 1st order Taylor expansion, we have the following expectation approximation %$\mathbb{E}(X/Y)\approx\dfrac{\mathbb{E}(X)}{\mathbb{E}(Y)}$
$\mathbb{E}(X/Y)\approx \mathbb{E}(X)/ \mathbb{E}(Y)$ for two dependent random variables $X$ and $Y$~\cite{Kempen2000}. Hence,
we can now define an \emph{approximated expected recall} as follows:
%Given a retrieved element set $E$  and a relevant element set $RS$ among a global element collection $GC$ with size $m$, we propose the following definition of \emph{expected precision} (EP), \emph{expected recall} (ER) and \emph{expected F1-Score} (EF1):
\begin{equation}
   \emph{ER(E)}=\mathbb{E_{S}}\left[\dfrac{{ \sum_{j=1}^{m}}B(j)I(j)}{|RS|}\right]\approx\dfrac{{ \sum_{j=1}^{m}}\mathbb{E_{S}}[B(j)]I(j)}{{ \sum_{j=1}^{m}}\mathbb{E_{S}}[B(j)]}=\dfrac{{ \sum_{j=1}^{m}}S(j)I(j)}{{ \sum_{j=1}^{m}}S(j)}
\end{equation}
Finally, we define the \emph{approximated expected F1-Score} (EF1) using the \emph{expected precision} and the \emph{approximated expected recall} as follows:
\begin{align}
    \emph{EF1(E)}  \approx \dfrac{2\times EP\times ER}{EP+ER} = \dfrac{2\times\sum_{j=1}^m S(j)I(j)}{\sum_{j=1}^m I(j) + \sum_{j=1}^m S(j)}
    \label{eq:EF1}
\end{align}
%Due to space limitations, we focus on F1-score in this paper, however expected F$_\beta$ scores follow directly from the above definitions.

%Conventional metrics are based on Boolean relevance label $B(j)$ instead of probabilistic score $S(j)$. To link standard precision with our expected precision,  The definition of standard precision $P(RS)$ is as follows:

%Now, we  derive expectation of precision $P(RS)$ as follows:
%\begin{align}
%	\mathbb{E_S}[P(E)] &= \mathbb{E_S}[\dfrac{\sum_{j=1}^m B(j)I(j)}{\sum_{j=1}^m I(j)}] = \dfrac{\sum_{j=1}^m %\mathbb{E_S}[B(j)]I(j)}{\sum_{j=1}^m I(j)} \notag \\
%    &= \dfrac{\sum_{j=1}^m S(j)I(j)}{\sum_{j=1}^m I(j)} = EP(E)
   	%\mathbb{E_S}[R(RS)] &= \dfrac{\sum_{j=1}^m \mathbb{E_S}[B(j)] I(j)}{\sum_{j=1}^m \mathbb{E_S}[B(j)]} = \dfrac{\sum_{j=1}^m S(j)I(j)}{\sum_{j=1}^m S(j)} = ER(RS)  \\
    %\mathbb{E_S}[F1(RS)] &= \dfrac{2*\sum_{j=1}^m \mathbb{E_S}[B(j)]I(j)}{\sum_{j=1}^m I(j) + \sum_{j=1}^m \mathbb{E_S}[B(j)]} \notag \\
    %&= \dfrac{2*\sum_{j=1}^m S(j)I(j)}{\sum_{j=1}^m I(j) + \sum_{j=1}^m S(j)} = EF1(RS)
%\end{align}

%\begin{equation}
%\emph{\ensuremath{EP(RS)}}=\dfrac{{\displaystyle \sum_{j\in RS}S(j)}}{|RS|} =  \dfrac{\sum_{j=1}^m S(j)I(j)}{\sum_{j=1}^m I(j)}
%\end{equation}

%Analogously, we define the  \emph{expected recall} (ER) as follows:
%\begin{equation}
%\emph{\ensuremath{ER(RS)}}=\dfrac{{\displaystyle \sum_{j\in RS}S(j)}}{|RE|} = \dfrac{\sum_{i=1}^m S(i)I(i)}{\sum_{i=1}^m S(i)} = \dfrac{\sum_{i=1}^m S(i)I(i)}{C}
%\end{equation}

%\noindent where $|RE|$ is the size of the entire relevant element set. Finally, we define the  \emph{expected F1-Score} (EF1) as follows:

%\begin{equation}
%\emph{\ensuremath{EF1(RS)}}=\dfrac{2\times EP\times ER}{EP+ER} = \dfrac{2*\sum_{i=1}^m S(i)I(i)}{\sum_{i=1}^m I(i) + C}
%\end{equation}

%In Figure \ref{fig:F1_vs_EF1}, we experimentally show that while EF1 is only an approximation of the true expectation, EF1 serves as an excellent surrogate for F1, which is our main concern when considering filter optimization.  That is, maximizing EF1 score with respect to a noisy classifier (noise decreases to 0 as $\lambda \to 1$) is strongly correlated with maximizing F1 score evaluated on the ground truth; we will further study the effect of a noisy classifier in Section~\ref{sec:Evaluation}.   Specifically, while the EF1 and F1 scores are not perfectly calibrated along the diagonal, there is a linear correlation in that as the EF1 score increases for a scenario, the F1-score proportionally increases on average (as shown by the best fit linear regression in the plots).

%\begin{figure}[H]
%\begin{centering}
%\par\end{centering}
%\begin{centering}
%\includegraphics[width=8.5cm]{imgs/Enron_results/scatter_plot_EF1\lyxdot vs\lyxdot F1}
%\par\end{centering}
%\caption{Scatter plot showing EF1-Score vs. F1-Score.}
%\label{fig:F1_vs_EF1}
%\end{figure}

\subsection{Greedy relevance-driven clustering}

% Should discuss greedy algorithm generically as having a metric and at each step
% a choice of k restrictions, which are each scored against the metric with the
% highest score chosen at each step.  Then each individual filter only has to
% specify what the choices are and how the choice restricts the set of emails
% selected.  What is a good succinct notation for this?

A single cluster $E^*$ is specified as all information elements $\{j \in E^* | I(j)=1, j \in E \}$ in the intersection of spatial bounding box, time interval, and keyword inclusion or exclusion constraints.  Given an estimated probability of relevance of each information element in the cluster $S(j)$, we can then compute the EF1 of the cluster given in~\eqref{eq:EF1}.  Through a series of transformations, this EF1 optimization problem can be reduced to a Mixed Integer Linear Program (MILP), which is NP-Hard and only practical for small element sets.  Hence, in the following, we describe how to \emph{greedily} optimize the parameters of each constraint to approximately optimize EF1.

In greedy optimization, we would have the option to start with a singleton element cluster and expand, or start with a cluster including all elements and prune.  While the former has a non-deterministic choice of which singleton to start with, the latter has an unambiguous initial starting condition.  Thus we choose the latter pruning approach starting with initial spatial bounding box, time interval, and keyword constraints set to include \emph{all} of $E$.
% Each cluster has an associated EF1 score
% We assume that three types of clustering attributes are used to optimize clusters of relevant information according to spatial, temporal, and keyword content constraints.  A cluster is generated by \emph{conjoining} (i.e., intersecting) these three attribute constraints.  While it is possible to convert the problem of selecting joint settings of spatial, temporal, and keyword constraints to optimize EF1 to a mixed-integer linear programming (MILP) problem, optimizing MILPs is NP-Hard

\subsubsection{Greedy Keyword Selection algorithm}

% TODO: there is some confusion here between elements matching a query and displayed information elements.  To be resolved later.
Given a set of candidate information elements matching a query, this algorithm greedily selects a set of keywords to exclude (i.e., prune) to maximize EF1.

Formally, the algorithm aims to select an
optimal subset of $k$ terms $T_{k}^{*}\subset V$ (where $V$ is a vocabulary of keywords for the document corpus) to exclude elements containing these keywords to optimize EF1.  This is achieved by
building $T_{k}^{*}$ in a greedy manner by choosing the next optimal
term $t_{k}^{*}$ given the previous set of optimal term selections
$T_{k-1}^{*}=\{t_{1}^{*},\ldots,t_{k-1}^{*}\}$ (assuming $T_{0}^{*}=\emptyset$)
using the following selection criterion
\begin{equation}
t_{k}^{*}=\argmax_{t_{k}\notin T_{k-1}^{*}} [EF1(E^{*} \textrm{ that don't contain } \{t_{1}^{*},\dots t_{k}^{*}\})]
\end{equation}
that terminates at $k$ when no $T_{k+1}^{*}$ can improve the EF1 of $E^*$.
%In order to reduce the keyword search space, we propose to use the top 100 terms ranked using Mutual Information to identify the keywords that are predictive of the ``supervised'' relevance measure.  We remark that other metrics like frequency would be more appropriate for unsupervised tasks.
%We further remark that we have chosen to use term exclusion as a means to effectively prune the content as more terms are selected.
%mainly for technical reasons as a negation query generates queries with much fewer terms.
%The best indexing strategy to support this greedy search is the inverted index data structure~\cite{Zobel2006}.

\subsubsection{Greedy Time Selection algorithm}

The idea behind the time-based greedy selection algorithm is to start with the maximal time range and greedily contract it to a sub-window of time $[t_{\tstart},t_{\tend}]$ such that $\{ j \in E^* | t_{\tstart} < t_j < t_{\tend}, j \in E \}$.  In this case, we propose two different greedy approaches to iteratively contract (i.e., prune) the time window in order to maximize EF1:

\subfour{(a) Naive Greedy algorithm:} Let $t_{\min}$ and $t_{\max}$ respectively correspond to the current minimum and maximum timestamps in $E^*$.  If setting $t_{\tstart} = t_{\min}$ improves the EF1 of $E^*$ then this lower bound contraction is accepted.  Similarly if setting $t_{\tend} = t_{\max}$ improves the EF1 of $E^*$ then this upper bound contraction is accepted.  This repeats until no lower or upper bound contraction improves EF1.

\subfour{(b) Binary Partition Search (BPS) algorithm:} Large datasets will cause the previous Greedy algorithm to take a large number of iterations to terminate.  A more efficient way to address this problem is to use binary partitioning search (BPS).  Hence, instead of removing a single element $j$ at each iteration, BPS operates by selecting between the lower or upper half of the time interval.

%\begin{algorithm}[t]
%%\scriptsize
%\caption{Binary Partition Search (BPS) Algorithm}
%\SetAlgoLined
%\SetKwData{Left}{left}\SetKwData{This}{this}\SetKw%Data{Up}{up}
%\SetKwFunction{Union}{Union}\SetKwFunction{FindCom%press}{FindCompress}
%\SetKwInOut{Input}{input}\SetKwInOut{Output}{outpu%t}
%\Input{A set of ordered elements $E=\{j_{v_1} %\dots j_{v_n}\}$ }
%\Output{A timestamp $t$;}
%\BlankLine
%\label{alg:Dichotomy}

%$v_{min}=v_1$; $v_{max}=v_n$;  %$v_{mid}=\tfrac{v_1+v_n}{2}$;

%\While {$v_{min}!=v_{mid}!=v_{max}$}{

%\eIf{$[EF1(\{j_{v_{min}} \dots  j_{v_n}\}) \geq %EF1(\{j_{v_{mid}} \dots  j_{v_n}\})]$}{
%$v_{max}=v_{mid}$;
%$v_{mid}=\tfrac{v_{min}+v_{mid}}{2}$;
%}{
%$v_{min}=v_{mid}$;
%$v_{mid}=\tfrac{v_{min}+v_{max}}{2}$;
%}
%}
%\Return  $v_{mid}$;

%\label{alg:return}
%\end{algorithm}

%Therefore, the algorithm first sets the values $t_{min}=t_1$, $t_{max}=t_n$,  and $t_{mid}=\tfrac{t_1+t_n}{2}$. Then, for each iteration, if $[EF1(\{d_{t_{min}}\leq \dots \leq d_{t_n}\}) \geq EF1(\{d_{t_{mid}}\leq \dots \leq d_{t_n}\})]$, the algorithm sets $t_{max}=t_{mid}$, $t_{mid}=\tfrac{t_{min}+t_{mid}}{2}$ and makes a new iteration, else, the algorithm sets $t_{min}=t_{mid}$,  $t_{mid}=\tfrac{t_{min}+t_{max}}{2}$  and makes a new iteration. The algorithm keeps iterating until $t_{min}=t_{mid}=t_{max}$, where it assigns $t_{mid}$ to the lower time bound of the time query, i.e., $t_{start}=t_{mid}$.

As an example of the BPS approach for time selection, the algorithm first sorts $E^*$ for the current $[t_{\tstart},t_{\tend}]$ according to time stamps.  From this, it is possible to extract $t_{\min}$, $t_{\tmedian}$, and $t_{\max}$, respectively the minimum, median, and maximum time stamps in $E^*$.
BPS then selects the interval  $[t_{\tstart},t_{\tmedian}]$, $[t_{\tmedian},t_{\tend}]$, $[t_{\tstart},t_{\tend}]$ that minimizes EF1.  If either of the first two intervals are chosen, the process is repeated with the new $t_{\tstart}$ or $t_{\tend}$.  Once the third interval is chosen, no BPS contraction will improve EF1.

% in increasing order of time stamp. Then, it applies the BPS algorithm. This procedure will return  the lower time bound of the time window, i.e., $t_{start}=t_{mid}$. Next, the algorithm sorts $E$ in decreasing order of time stamp, and then, it applies again a Binary Partitioning Search to get the upper time bound of the time window, i.e., $t_{end}=t_i$. Lastly, the algorithm returns the  time window $[t_{\tstart},t_{\tend}]$, such that $EF1(E^{*} \in [t_{start},t_{end}]) \geq EF1(E)$. %Note that this algorithm proceeds in a total of $log(n)$ iterations in the best case, and $2\times log(n)$ iterations in the worst case.

%For both the naive and time-based greedy algorithms, we use the red-black tree as the indexing data structure \cite{Guibas1978}.

\subsubsection{Greedy Spatial Selection algorithm}

The aim of this algorithm is to return coordinates $[(x_{min},y_{min}),(x_{max},y_{max})]$ representing the EF1 maximizing spatial bounding box represented by the lower and upper bound coordinates -- respectively $(x_{min},y_{min})$ and $(x_{max},y_{max})$. This 2D problem is similar to the previous 1D problem of finding the best time window. Therefore, the two algorithms described above (Greedy and BPS) can be adapted for this problem by first applying each algorithm on the x-axis to determine $(x_{min},x_{max})$, then on the y-axis to determine $(y_{min},y_{max})$.
% We need to ditch some citations and this removes the complaint that we did not provide all details -- we claim it is obvious.  -Scott
%We omit the description of these two algorithms for lack of space, but a detailed description can be found in the technical report~\cite{Bouadjenek2018}.
%We use the R-tree as a data structure for indexing multi-dimensional continuous data~\cite{Guttman1984}.

\subsubsection{Relevance-driven clustering algorithm}
\label{sec:relclustering}

To obtain a cluster $E^*$ combining the above (i) keyword, (ii) time, and (iii) spatial constraints, we propose a greedy round-robin algorithm, which at each iteration applies the selection pruning algorithms for (i), (ii), and (iii) in order.  Iterations terminate when no selection algorithm can unilaterally improve EF1 and the final cluster is returned.
%to, theselects the best sub-filter to apply (according to its reduction in EF1-Score), then checks if that filter improves the EF1-Score. If so, the algorithm continues with the updated filter settings, otherwise, it terminates.
% Don't get the following -- seems non-essential, at least for submission.  -Scott
%Note that here, we use  $k=1$ for the keywords greedy algorithm.
%The algorithm will then determine a sequence of filters to apply on the initial set, and the final query is then built by combining these filters by types.

 %such as: $\{Keyword \to Time -> Position \to Time \to Keyword\} $

% I don't follow this example, but I think the algorithm is intuitive enough and we need space.  -Scott
% For example, let's suppose the algorithm determines the following filter sequence: $\{Q_{k_1}=\{ \neg natural\} \to Q_{t_1}=[50,2030] \to Q_{p_1}=[(10,60), (50,100)] \to Q_{t_2}=[60,1230] \to Q_{k_2}=\{ \neg fictive\}  \to  Q_{p_2}=[(10,60), (30,85)] \to  Q_{t_3}=[60,800] \}$.
% The final query is built by combining these filters by types as follows: $Q_k=Q_{k_1} \cup Q_{k_2}=\{\neg natural,\neg fictive\}$, $Q_t =Q_{t_1} \cap Q_{t_2} \cap Q_{t_3}=[60,800]$, and  $ Q_p=Q_{p_1}  \cap Q_{p_2}=[(10,60),$ $(30,85)]$, which gives $Q=[Q_k=\{\neg natural,\neg fictive\}\wedge Q_t=[60,800]\wedge Q_p = [(10,60),$ $(30,85)]]$.

Finally, we note that our relevance-driven clustering algorithm can use the Greedy keyword selection algorithm with either the naive Greedy time and spatial selection algorithms, which we refer to experimentally as {\bf Greedy}, or the BPS time and BPS spatial variants, which we refer to experimentally as {\bf BPS}.
%time and position naive greedy algorithms to which we refer as Greedy Algorithm, or the keywords greedy algorithm with the time and position Binary Partition Search algorithms to which we refer as BPS Algorithm.

%\subsection{Optimal MILP Solutions for Benchmarking}

%Next, we propose an exact Mixed Integer Linear Progamming (MILP) optimization-based formulation to maximize EF1 and provide a benchmark for evaluating our two relevance-driven clustering algorithms (Greedy and BPS).  %Given the trivial solution of optimizing the expected precision (singleton) and expected recall (the whole collection), we consider in the following only the optimization of EF1.

%\subsubsection{Fractional MILP Formulation} \hfill \\
%We begin by reformulating the EF1 objective to prepare for further optimization steps by replacing the global sum of scores of all information elements with a constant $C = \sum_{j=1}^m S(j)$:
%\begin{equation}
%\begin{aligned}
%    \emph{$EF1$} &= \dfrac{2\times \sum_{j=1}^m S(j)I(j)}{\sum_{j=1}^m I(j) + \sum_{j=1}^m S(j)} = \dfrac{2 \times \sum_{j=1}^m S(j)I(j)}{\sum_{j=1}^m I(j) + C}
%\end{aligned}
%\end{equation}

%In order to obtain the EF1-optimal cluster, we let binary variables $\emph{I\textsubscript{filter}}($j$) \in \{0, 1\}$ to indicate whether an information element $j$ is selected by each parameter of the cluster and constrain that to be selected in the cluster (i.e., $I(j)=1$), $j$ must be selected in all selection constrains (i.e., a conjunction).  This leads to the following fractional MILP formulation with selection constraints to be defined later:
%intend to directly optimize the EF1 metric in terms of decision indication variables  for filter setting as follows:
% Don't use I(i)... confusing!
%\begin{align}
%\max_{\textit{filter vars}} \;\;
%& \dfrac{\sum_{j=1}^m S(i)I(j)}{\sum_{j=1}^m I(j) + C} \nonumber \\
%& \textrm{subject to constraints between {\it filter vars} and $I(j)$}
%\end{align}
%\begin{equation}
%\begin{aligned}
%& \underset{I_{\mathit{filter}}(j)}{\text{maximize}}
%& & \dfrac{\sum_{j=1}^m S(j)I(j)}{\sum_{j=1}^m I(j) + C} \\
%& s.t
%& & I(j) = \bigwedge I_{\mathit{filter}}(j) \\
%\end{aligned} \label{eq:frac_milp}
%\end{equation}

% Not necessary.  -Scott
%Note that our goal is to optimize the element set in terms of \emph{filters settings}. This means elements in the interface sharing the same property needs to be simultaneously added to the selected set. This is a unique property of our filter-based UI problem, which is different from the independent retrieval of each document in standard IR system.

%\subsubsection{Transformation to a MILP} \hfill \\
%While there are no direct solvers for fractional MILPs, we can transform~\eqref{eq:frac_milp} into a pure MILP form for which we have efficient and optimal solvers.  To do this, we use the Charnes-Cooper method \cite{Charnes1962} and Glover linearization method \cite{Glover1975} with big-M constraints, where auxiliary variables \emph{w(j)} and \emph{u} are  introduced\footnote{https://optimization.mccormick.northwestern.edu/index.php/Mixed-integer\_linear\_fractional\_programming\_(MILFP)}. Here, $w(j)$ is defined as $w(j)=I(j)\times u$ with $u$ defined as follows:
%\begin{equation}
%u = \dfrac{1}{\sum_{j=1}^m I(j) + C}
%\end{equation}

%Then, the EF1 optimization problem is able to be transformed into the following MILP problem:
%\begin{equation}
%\begin{aligned}
%& \underset{w,u}{\text{maximize}}
%& & \sum_{j=1}^m S(j)w(j) \\
%& s.t
%& & \sum_{j=1}^m w(j) + uC = 1 \\
%& & & w(j) \leqslant u, \quad w(j) \leqslant M\times I(j)  \\
%& & & w(j) \geqslant u - M\times [1-I(j)] \\
%& & & u > 0,  \quad I(j) \in \{0, 1\}, \quad w(j) \geqslant 0 \label{eq:milp}
%\end{aligned}
%\end{equation}

%\subsubsection{Constraints} \hfill \\
%As our goal is to select elements through three clustering parameters, we add three constraints to the above optimization.
%\begin{enumerate}
%\item {\bf Time Parameter Constraint:} a two-element tuple ($t_{start}$, $t_{end}$) indicating respectively the start and the end of the time window.
%\begin{equation}
%\begin{aligned}
%  I_{\mathit{time}}(j) &=
%   \begin{cases}
%     1, & \text{if $(t_{start} \leqslant t(j)) \land (t(j) \leqslant t_{end})$}  \\
%     0, & \text{otherwise}
%  \end{cases} \label{eq:cons1}
%\end{aligned}
%\end{equation}

%\item {\bf Spatial Parameter Constraint:} a four-element tuple ($x_{min}$, $y_{min}$, $x_{max}$, $y_{max}$) to create a bounding box selection in visualization interface.
%\begin{equation}
%\begin{aligned}
%I_{\mathit{pos}}(j) & =\begin{cases}
%1, & \text{if \ensuremath{(x_{min}\leqslant x(j))\land(x(j)\leqslant x_{max})\land}}\\
% & (y_{min}\leqslant y(j))\land(y(j)\leqslant %y_{max})\\
%0, & \text{otherwise}
%\end{cases} \label{eq:cons2}
%\end{aligned}
%\end{equation}

%\item {\bf Keyword Parameter Constraint:} a boolean vector of terms $t^*_k$ with size $m$ - the size of the dictionary of $GC$.
%\begin{equation}
%  I_{\mathit{term}}(j) = \bigwedge_{t^*_k \in j} t^*_k \qquad \textnormal{for s = 1, 2, $\cdots$, m} \label{eq:cons3}
%\end{equation}
%All terms with $I_{\mathit{term}}=0$ are included in the negation query.

%\item {\bf Clustering Selection Constraints:} for information element $j$ to be selected globally, it must be simultaneously selected by the three selection constrains.
%, all filter constraints have to be satisfied in this element. In others words, an AND operator is required between all the sub-filter constraints.
%{\bf TODO: mention how to apply to all filters... need to say an email j is selected if \emph{all} filters say it is selected, so an AND constraint.  \textcolor{red}{[PLEASE COMPLETE YIHAO]}.
%}
%\begin{equation}
%  I(j) = I_{\mathit{time}}(j) \land I_{\mathit{pos}}(j) \land I_{\mathit{keyword}}(j) \label{eq:cons4}
%\end{equation}

%\end{enumerate}
%We refer to the above MILP formulation in~\eqref{eq:milp} with all selection parameter constraints~\eqref{eq:cons1}--\eqref{eq:cons4} as the {\bf Optimal} cluster.

\subsection{Multiple Cluster Selection Wrapper}

%The Global Filter selects a single best filter setting.  However, what if we want to display multiple possible Global Filters.
In practice, a single cluster of information elements $E^*$ chosen by the previously described algorithms will provide the user with one temporal, spatial, and content coherent cluster covering one information perspective.  However, there will likely be additional coherent clusters covering other perspectives.
Consider Figure~\ref{Fig:BPS_FilteredDisplay} which shows three different spatial bounding boxes corresponding to three topically coherent clusters.
Here, we provide a greedy approach for providing a ranked list of such clusters that works with any of the previously defined algorithms -- Greedy or BPS.%); we leave it to future work to develop improved filtering and ranking methods for multiple filters.

The algorithm itself is quite simple and simply wraps the algorithm of Section~\ref{sec:relclustering}.
After the first cluster is produced, all selected elements in that cluster have their scores $S(j)$ zeroed out.  The relevance-driven clustering algorithm is then run again, where it will inherently focus on a different content set.  As each cluster is added, coverage of high relevance content monotonically improves.
%This procedure is repeated until the desired number of filters is reached, or a metric / coverage score for high scoring content is reached.
%The user should then be able to choose among the multiple filters in the VID.


\documentclass[letterpaper]{article}

\usepackage{fullpage}
\usepackage{nopageno}
\usepackage{amsmath}
\usepackage{amssymb}
\allowdisplaybreaks

\newcommand{\abs}[1]{\left\lvert #1 \right\rvert}

\begin{document}
\title{Notes}
\date{November 14, 2014}
\maketitle
\section*{\#10}
$\mathbb{Q}[x]/\langle x^2+2\rangle\cong \mathbb{Q}[x]/\langle x^2+1\rangle$

no, can't find $\beta\in\mathbb{Q}[x]/\langle x^2+2\rangle$ where $\beta=-[2]$

note that if we replace $\mathbb{Q}$ with $\mathbb{R}$ then we get an isomorphism.

\subsubsection*{is $\mathbb{Z}_2[x]/\langle x^2+x+1\rangle$ a field?} is $x^2+x+1\in \mathbb{Z}_2[x]$ irreducible?

$[0],[1]$ are not roots and degree is $\le3$ and so it is a field.
\subsection*{question}
if $f(x)\in \mathbb{Z}_p[x]$ where $p$ is prime and $f(x)$ is irreducible. how many elements does $\mathbb{Z}_p/f(x)$ have? $\{a_0+a_1x+\dots+a_{n-1}x^{n-1}:a_i\in\mathbb{Z}_p\}$  and so $p^n$ elements.

\section*{\#24}
you can always find such an $f(x)$ (of any degree).

\section*{thm}
assume $f(x)=g(x)h(x)$ where $f(x)\in \mathbb{Z}[x]$ and $h(x),g(x)\in\mathbb{Q}[x]$. then we can factor $f(x)$ into poly with integer coefficients of the same degree.
\subsubsection*{proof}
$g(x)\in\mathbb{Q}[x]$ with $g(x)=\frac{1}{b}g_1(x)$ where $g_1(x)\in\mathbb{Z}[x]$ and $b\in\mathbb{Z}$ and $g(x)=\frac{c}{b}g_2(x)$ where $g_2(x)\in\mathbb{Z}[x]$ and $b,c\in\mathbb{Z}$ and $g_2(x)$ is a primitive polynomial

say $\gcd(m,n)=1$

$f(x)=\frac{m}{n}\cdot\frac{s}{t}g_2(x)h_2(x)$.

multiplying two primitive polynomials gives a primitive polynomial

\section*{thm}
eisenstein's irreducibility criterion)

\section*{corollary 4.4.7}
\end{document}


%
%   window
%
\section{Window Function}\label{app:windowfunction}
The observed density field of targets does not cover the full sky, due to the galactic plane obscuration. This means that the pseudo-power spectrum $\hat{C}_{\ell}$ obtained by the direct Spherical Harmonic Transforms of a partial sky map (eq. \ref{eq:pusedocell}), differs from the full-sky angular spectrum $C_{\ell}$. However, their ensemble average is related by \citep{hivonmaster2002ApJ...567....2H, poker2011A&A...535A..90P}

\begin{equation}
    <\hat{C}_{\ell}> = \sum_{\ell^{\prime}} M_{\ell \ell^{\prime}}<C_{\ell^{\prime}}>,
\end{equation}
where $M_{\ell \ell^{\prime}}$ represents the mode-mode coupling from the partial sky coverage. This is known as the Window Function effect and a proper assessment of this effect is crucial for a robust measurement of the large-scale clustering of galaxies. We follow a similar approach to that of \citep{szapudi2001ApJ...548L.115S, chon2004MNRAS.350..914C} to model the window function effect on the theoretical power spectrum $C_{\ell}$ rather than correcting the measured pseudo-power spectrum from data. First, we compute the two-point correlation function of the window,

\begin{equation}
    RR(\theta) = \sum_{i,j>1} f_{\rm pix, i} f_{\rm pix, j} \Theta_{ij}(\theta),
\end{equation}
where $\Theta_{ij}(\theta)$ is one when the pixels i and j are separated by an angle between $\theta$ and $\theta + \Delta\theta$, and zero otherwise. Next, we normalize the RR by $\sin(\theta)\Delta\theta$ to account for the area and total number of pairs such that $RR(\theta=0)=1$. We fit a polynomial on RR to smooth out the wiggles raised by noise. Then, we multiply the theoretical correlation function $\omega(\theta)$ by the window paircount,
\begin{align}
    \omega^{WC}(\theta) &= \omega(\theta)~RR(\theta),
\end{align}
and finally use the Gaussian-Quadrature algorithm to transform the window convolved theory correlation function $\omega^{WC}$ to $C^{WC}_{\ell}$,
\begin{equation}
    C^{WC}_{\ell} = 2\pi \int \omega^{WC}(\theta)P_{\ell}(\theta)d\theta.
\end{equation}

\begin{figure}
    \centering
    \includegraphics[width=0.45\textwidth]{figures/fig25-cltheory.pdf}
    \caption{Window corrected theory C$_{\ell}$ for two different models with and without Redshift Space Distortions respectively in orange and blue. The dashed curves show the theoretical models before window convolution. The effect of the window is around 5\% in redshift and 20\% in real space. The theory with redshift space distortions uses $galaxy\;bias = 2$ and the surface density $n(z)$ of NGC eBOSS ELG ~\citep[Tab. 4 of][]{Raichoor2017MNRAS.471.3955R} and assuming the fiducial cosmology of \citet{ashley2012MNRAS,2012ApJ...761...14H}.}
    \label{fig:Cellwindowratio}
\end{figure}

Fig. \ref{fig:Cellwindowratio} shows the DECaLS window effect on two theoretical models of $C_{\ell}$ with and without redshift space distortions. The window effect for the model without Redshift Space Distortions (RSD) is around 20\% but that for the model with RSD is less than 5\% due to the flat power spectrum at the low ell limit. We find a consistent pattern in the mocks; the window effect on the clustering of the mocks is between 5-15\%.


\section*{Introduction}

Learning $C^0$-continuous functions is a key problem in machine learning, as many problems
are framed as finding good interpolations between a few data points, where we define continuity as $\lim\limits_{x\to c}f(x) = f(c)$.
The continuity of the learned model is not guaranteed, and is enforced through regularization of the output,
usually using something temporal consistency~\cite{tretschk2021nonrigid}. Since consistency is imposed as some loss, it cannot be guaranteed. This leads to difficulties in interpolating between time-steps which is necessary to get higher resolution movement. In addition, there is also the possibility for sudden changes in motion, such as suddenly jumping from one frame to the next.
To enforce a continuity, we are interested in constructing functions with $C^0$ continuity. $C^0$ continuity is necessary for many things, such as reconstructing movement, to ensure, for example, that an object cannot warp between two points instantaneously. We are also interested in $C^1$ continuity, or that the derivative of a function is continuous on some domain. This is because in reality, it is not possible for an object to instantly change its velocity, and thus any reconstruction must have $C^1$ continuity for plausible movement.

To demonstrate our architecture, we tackle the problem of dynamic scene reconstruction using NeRF, which is a method for representing scenes. Following previous work, we define a static scene, which is referred to as the canonical scene, and a model which can produce deformations to the canonical scene. The deformation model is what we are interested for demonstrating continuity. To represent the canonical scene, we use a NeRF~\cite{mildenhall2020nerf}, and the deformation model is our proposed Bezier network. This general approach with deformation networks has been shown to be effective at reconstructing Lambertian scenes with continuous movement as in D-NeRF~\cite{pumarola2020dnerf} and NR(non-rigid)-NeRF~\cite{tretschk2021nonrigid}. These works show convincing
reconstructions of moving scenes, predicting accurate reconstructions on both real
and synthetic scenes. These methods do not have an analytic form, relying purely on learned components but we
are also interested in analyzing and modifying the movement itself, such as
exaggerating movement, or clustering regions based on similar movement. These methods are capable of each of these tasks, but must be extended in order to handle each case. In contrast, classical animation tools are designed to handle all of these problems.

In animation, there are existing tools for creating realistic movement with a high-degree of
control for artists and animators. For example, there are tools such as keyframing, splines,
and other techniques. These tools allow artists and animators to breathe life into animation,
with a high degree of control. Mathematical constructs such as splines have also been thoroughly
studied to understand their behaviour and how they can be manipulated.

We take the interpretable animation techniques of Bezier splines as a method to enforce continuous interpolation in Dynamic NeRF, finding that we are able to get comparable performance without additional cost in memory.
%We also design a new architecture for long duration $C^0$-continuous signal reconstruction.
In summary, our contributions are as follows:

\begin{enumerate}
    \item A general architecture for $C^0, C^1$ continuity over a continuous domain.
    \item An application of this architecture combined with D-NeRF to enforce continuity of movement, a canonical NeRF, and an analytic form at no additional cost, while slightly outperforming the original.
    \item An evaluation of our architecture against an implementation of D-NeRF which performs comparably to the original.
\end{enumerate}


\documentclass[letterpaper]{article}

\usepackage{fullpage}
\usepackage{nopageno}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage[utf8]{inputenc}
\allowdisplaybreaks

\newcommand{\abs}[1]{\left\lvert #1 \right\rvert}

\begin{document}
\title{Notes}
\date{October 3, 2014}
\maketitle
if $\liminf x_n=L$ then there exists $\{x_{n_k}\}$ such that $\lim x_{n_k}=L$

$l=\liminf x_n=\lim(inf\{\underbrace{x_{n_1},x_{n_2},x_{n_3},\dots}_{c_n}\}$

why not just let $c_n$ be the subseuence? because $c_n$ may not be equal to any of the $x_k$ in the sequence

$c_n=\inf\{x_{n_1},x_{n_2},\dots\}$ give $\varepsilon=2^{-n}$ there exists $x_{n_k}\in\{x_{n_1},x_{n+1},x_{n+2},\dots\}$ such that $\left\lvert c_n-x_{n_k}\right\rvert<2^{-n}$ by def of infinum

we has a sequence $\{c_n\}$ given $\varepsilon>0$ there exists $N$ such that $\left\lvert c_n-L\right\rvert<\varepsilon$ if $n\ge N$. we approximate each $c_n$ by some $x_{n_k}$ from the oricinal sequence sutch that ....

\section*{convergence test for series}
first we talk about series with positive terms $\sum\limits_{k=1}^\infty{a_k}$, $s_n=\sum\limits_{k=1}^n{a_k}$. So if $s_n$ is bounded about then the series is convergent. and if not, it is divergent.

geometric series $\sum\limits_{n=0}^\infty{r^n}$ is convergent if $\left\lvert r\right\rvert<1$. $s_n=\sum\limits_{k=0}n{r^k}=1+r+r^2+\dots+r^n, rs_n=r+r^2+r^3+\dots, sn-rSn=1-r^{n+1}$

$s_n=\frac{1-r^{n+1}}{1-r}\to\frac{1}{1-r}$

\section*{comparison test}
if $\forall n, |a_n|\le b_n$
\begin{itemize}
\item
  if $\sum\limits_{n=1}^\infty{b_n}$ is convergent then $\sum\limits_{n=1}^\infty{a_n}$ is convergent,
  \item
  if $\sum\limits{a_n}$ is divergent, so is $\sum\limits{b_n}$.
\end{itemize}
\section*{3.2.b}
show that if $\left(|a_n|\right)_{n=1}^\infty$ is summable then so is $\left(a_n\right)_{n=1}^\infty$.
\begin{align*}
  \sum\limits_{k=n+1}^m{|a_k|}&<\varepsilon\text{ for all }N\le n\le m \text{ because is is summable}\\
  \left\lvert\sum\limits_{k=n+1}^m{a_k}\right\rvert&\le\sum\limits_{k=n+1}^m{|a_k|}<\varepsilon
\end{align*}
so then $\sum\limits{a_k}$ is also cauchy and summable

\section*{cauchy-schwartz inequality}
$\sum\limits_{k=1}^n{a_kb_k}\le \left(\sum\limits_{k=1}^n{a_k^2}\right)^{1/2}\left(\sum\limits_{k=1}^n{b_k^2}\right)^{1/2}$

\section*{3.2.f}

\section*{leibniz test for alternating series}
if $\{a_n\}$ is a monotone decreasing sequence of positive terms with the $\lim a_n=0$ then $\sum\limits_{n=1}^\infty{(-1)^na_n}$ is convergent

\section*{note!} a sequence my have the property $\lim |a_n-a_{n+!}|=0$ but not be cauchy
\section*{3.2.h}
Show that if $\sum\limits_{n=1}^\infty{a_n}$ and $\sum\limits_{n=1}^\infty{b_n}$ are series with $b_n\ge 0$ such that $\limsup\limits_{n\to\infty}<\infty$ and $\sum\limits_{n=1}^\infty{b_n}<\infty$, then the series $\sum\limits_{n=1}^\infty{a_n}$ converges.

\begin{align*}
  \left\lvert\left(\sup\limits_{k\ge n}\frac{|a_k|}{b_k}\right)-L\right\rvert<\varepsilon\\
  \left(\sup\limits_{k\ge n}\frac{|a_k|}{b_k}\right)<L+\varepsilon\\
  \frac{|a_k|}{b_k}<L\varepsilon\\
  |a_k|<(L+\varepsilon) b_k\\
\end{align*}
\section*{3.2.j}
$\liminf\frac{a_n+1}{a_n}\le\liminf{a_n^{\frac{1}{n}}}\le\limsup a_n^{\frac{1}{n}}\le \limsup\frac{a_n+1}{a_n}$.
\subsection*{step 1}
if $x\ge r$ for all $r>b$ then $x$ is a lower bound for the set $\{r\in \mathbb{R}:r>b\}$, $x\le\inf\{r\in\mathbb{R}:r>b\}=b$

we will show that if $\limsup \frac{a_n}{b_n}<r$ then $\limsup a_n^{\frac{1}{n}}\le r$ and then apply step one.

let $r>\limsup \frac{a_{n+1}}{a_n}$ then $\exists N$ such that $r>\frac{a_{n+!}}{a_n}\forall n\ge N$
\begin{align*}
  a_{N+1}<ra_N\\
  a_{N+2}<ra_{N+1}\le r^2a_{N}\\
  a_{N+K}<r^{k}a_N\\
  a_{N+k}^{\frac{1}{N+k}}<(r^ka_N)^{\frac{1}{N+k}}
\end{align*}
\section*{quiz from 10/1/2014}
$L_k\to L$ then $\{x_n\}$ such that $\forall k, \exists$ a subsequence of $\{x_n\}$ converging to $L_k$. prove that $\{x_n\}$ has a subsequence converging to $L$.

given $\varepsilon>0\exists N_0$ such that $\left\lvert L_k-L\right\rvert<\varepsilon$ if $k\ge N_0$

$\left\lvert x_{N_k}-L\right\rvert\le\left\lvert x_{N_k}-L_k\right\rvert+\left\lvert L_k-L\right\rvert<2\varepsilon$

\section*{example}
let $A,B\subseteq \mathbb{R}$, prove that $\sup A\le\inf B$, if $\forall a\in A, b\in B, a\le b$

\section*{3.3.5}
any rearrangement of an absolutely convergent series converges tothe same limit
\subsubsection*{proof}
let $\sum\limits{a_n}=L<\infty$. We know $\sum\limits{|a_n|}$ is convergent (not necessarily to $L$). by th cauchy riterion for series $\forall\varepsilon>0\exists N$ such that $\left(\sum\limits_{n=N+1}^\infty{|a_n|}\right)<\varepsilon$

$\pi:\mathbb{N}\to\mathbb{N}$ is bijective, the rearranged series is $\sum\limits_{n=1}^{\infty}{a_{\pi(n)}}$ and $\{a_1\dots a_N\}\subseteq\{a_{\pi(1)1}\dots a_{\pi(M)}\}$

\section*{3.3.7 rearrangement theorem}
let $\sum\limits{a_n}=L<\infty$ and define $b_n=(a_n\ge 0)?a_n:0$ and $c_n=(a_n<0)?a_n:0$

consider the series $\sum\limits{b_n}$ and $\sum\limits{|c_n|}$
\subsection*{case 1}
both convergent

$\sum\limits{|a_n|}=\sum\limits{b_n}+\sum\limits{|c_n|}$ which is convergent, which contradicts the fact that $a_n$ is conditionally convergent
\subsection*{case 2}
one convergent, one divergent

assume $\sum\limits{|c_n|}=A<\infty$ and $\sum\limits{b_n}$ is divergent to $+\infty$

given any $R\in\mathbb{N}$ big, $\exists N$ such that $\sum\limits_{n=1}^N{b_n}>R+A$, then we pick $M$ big enough so that $\{b_1,\dots,b_N\}\subseteq\{a_1,a_2,\dots,a_M\}$ and $\sum\limits_{n=1}^M{a_n}\ge\sum\limits_{n=1}^N{b_n}-\sum\limits{|c_n|}>R$ so $\sum\limits{a_n}$ is divergent, which  is a contradiction.
\subsection*{case 3}
both divergent

\section*{chapter 4}
$\mathbb{R}^n=\{(x_1,x_2,\dots,x_n),x_i\in\mathbb{R}\}$, vector space (or point in $n$-space).

with the coordinate wise sum and the product by real numbers (scalars).
\begin{align*}
  (x_1,\dots x_n)+(y_1,\dots,y_n)&=(x_1+y_1,\dots,x_n+y_n)\\
  \lambda(x_1,\dots,x_n)&=(\lambda x_1,\dots,\lambda x_n)\\
  x^{\to}&=(x_1,\dots,x_n)=x
  \intertext{euclidean norm}
  ||x||=\sqrt{x_1^2+\dots+ x_n^2}\\
  \intertext{distance from x to y}
  ||x-y||
\end{align*}
\subsection*{cauchy-schwarz}
$\left\lvert\sum\limits_{i=1}^n{a_jb_j}\right\rvert\le\left(\sum\limits_{i=1}^n{a_j^2}\right)^{1/2}\left(\sum\limits_{i=1}^n{b_j^2}\right)^{1/2}$

$|a\cdot b|\le||a||||b||$
\subsubsection*{dot product}
$a\cdot b=\sum\limits{a_ib_i}$
\subsection*{triangle inequality}
\begin{align*}
  ||x+y||\le||x|||+||y||
\end{align*}
\subsubsection*{proof}
\begin{align*}
  ||x+y||^2&=\sum\limits{(x_i+y_i)^2}\\
  &=(x+y)\cdot(x+y)\\
  &=x\cdot x+2x\cdot y+y\cdot y\\
  &=||x||^2+2x\cdot y+||y||^2\\
  &\le ||x||^2+2||x||||y||+||y||^2\\
  =(||x||+||y||)^2
\end{align*}

\subsection*{standard orthogonal base of $\mathbb{R}^n$}
\begin{align*}
  e_1&=<1,0,\dots,0>\\
  e_2&=<0,1,\dots,0>\\
  &\vdots\\
  e_n&=<0.0,\dots,1>
\end{align*}

\section*{4.2 convergence in $\mathbb{R}^n$}
definition:
a sequence $\{x^i\}$ of parts in $\mathbb{R}^n$ converge to $c\in \mathbb{R}^n$ if $\forall\varepsilon>0 \exists N=N(\varepsilon)\in\mathbb{N}$, such that $||x^i-c||<\epsilon$ if $i\ge N$ we say $\lim x^i=c$.

\subsection*{4.2.2 lemma}
$\lim  x^i=a$ if and only if $\lim ||x^i-a||=0$.

\subsection*{4.2.3 lemma}
$\lim x^i=a$ if and only if $\forall j=1,\dots,n, \lim x_j^i=a_j$
\end{document}


\chapter{Affine varieties as ringed spaces}
As in the previous chapter, we are working only over affine varieties in $\CC$ for simplicity.

\section{Synopsis}
Group theory was a strange creature in the early 19th century.
During the 19th century, a group was literally defined
as a subset of $\GL(n)$ or of $S_n$.
Indeed, the word ``group'' hadn't been invented yet.
This may sound ludicrous, but it was true -- Sylow developed his theorems without this notion.
Only much later was the abstract definition of a group given,
an abstract set $G$ which was \emph{independent} of any embedding into $S_n$,
and an object in its own right.

We are about to make the same type of change for our affine varieties.
Rather than thinking of them as an object locked into an ambient space $\Aff^n$
we are instead going to try to make them into an object in their own right.
Specifically, for us an affine variety will become a \emph{topological space}
equipped with a \emph{ring of functions} for each of its open sets:
this is why we call it a \textbf{ringed space}.

The bit about the topological space is not too drastic.
The key insight is the addition of the ring of functions.
For example, consider the double point from last chapter.

\begin{center}
	\begin{asy}
		import graph;
		size(5cm);

		real f(real x) { return x*x; }
		graph.xaxis("$x$", red);
		graph.yaxis("$y$");
		draw(graph(f,-2,2,operator ..), blue, Arrows);
		label("$\mathcal V(y-x^2)$", (0.8, f(0.8)), dir(-45), blue);
		label("$\mathbb A^2$", (2,3), dir(45));
		dotfactor *= 1.5;
		dot(origin, heavygreen);
	\end{asy}
\end{center}

As a set, it is a single point,
and thus it can have only one possible topology.
But the addition of the function ring will let us tell it apart
from just a single point.

This construction is quite involved, so we'll proceed as follows:
we'll define the structure bit by bit onto our existing affine varieties in $\Aff^n$,
until we have all the data of a ringed space.
In later chapters, these ideas will grow up to
become the core of modern algebraic geometry: the \emph{scheme}.

\section{The Zariski topology on $\Aff^n$}
\prototype{In $\Aff^1$, closed sets are finite collections of points.
In $\Aff^2$, a nonempty open set is the whole space minus some finite collection of curves/points.}

We begin by endowing a topological structure on every variety $V$.
Since our affine varieties (for now) all live in $\Aff^n$, all we have to do
is put a suitable topology on $\Aff^n$, and then just view $V$ as a subspace.

However, rather than putting the standard Euclidean topology on $\Aff^n$,
we put a much more bizarre topology.
\begin{definition}
	In the \vocab{Zariski topology} on $\Aff^n$,
	the \emph{closed sets} are those of the form
	\[ \VV(I) \qquad\text{where}\quad I \subseteq \CC[x_1, \dots, x_n]. \]
	Of course, the open sets are complements of such sets.
\end{definition}

\begin{example}
	[Zariski topology on $\Aff^1$]
	Let us determine the open sets of $\Aff^1$,
	which as usual we picture as a straight line
	(ignoring the fact that $\CC$ is two-dimensional).

	Since $\CC[x]$ is a principal ideal domain, rather than looking at $\VV(I)$
	for every $I \subseteq \CC[x]$, we just have to look at $\VV(f)$ for a single $f$.
	There are a few flavors of polynomials $f$:
	\begin{itemize}
		\ii The zero polynomial $0$ which vanishes everywhere:
		this implies that the entire space $\Aff^1$ is a closed set.
		\ii The constant polynomial $1$ which vanishes nowhere.
		This implies that $\varnothing$ is a closed set.
		\ii A polynomial $c(x-t_1)(x-t_2)\dots(x-t_n)$ of degree $n$.
		It has $n$ roots, and so $\{t_1, \dots, t_n\}$ is a closed set.
	\end{itemize}
	Hence the closed sets of $\Aff^1$ are exactly all of $\Aff^1$
	and finite sets of points (including $\varnothing$).
	Consequently, the \emph{open} sets of $\Aff^1$ are
	\begin{itemize}
		\ii $\varnothing$, and
		\ii $\Aff^1$ minus a finite collection (possibly empty) of points.
	\end{itemize}
\end{example}

Thus, the picture of a ``typical'' open set $\Aff^1$ might be
\begin{center}
	\begin{asy}
		size(6cm);
		pair A = (-9,0); pair B = (9,0);
		pen bloo = blue+1.5;
		draw(A--B, blue, Arrows);
		draw(A--B, bloo);
		// label("$\mathbb V()$", (0,0), 2*dir(-90));
		opendot((-3,0), bloo);
		opendot((-1,0), bloo);
		opendot((4,0), bloo);
		label("$\mathbb A^1$", B-(2,0), dir(90));
	\end{asy}
\end{center}
It's everything except a few marked points!

\begin{example}[Zariski topology on $\Aff^2$]
	Similarly, in $\Aff^2$,
	the interesting closed sets are going to consist
	of finite unions (possibly empty) of
	\begin{itemize}
		\ii Closed curves,
		like $\VV(y-x^2)$ (which is a parabola), and
		\ii Single points, like $\VV(x-3,y-4)$
		(which is the point $(3,4)$).
	\end{itemize}
	Of course, the entire space $\Aff^2 = \VV(0)$ and the empty set $\varnothing = \VV(1)$
	are closed sets.

	Thus the nonempty open sets in $\Aff^2$ consist of the \emph{entire} plane,
	minus a finite collection of points and one-dimensional curves.
\end{example}
\begin{ques}
	Draw a picture (to the best of your artistic ability)
	of a ``typical'' open set in $\Aff^2$.
\end{ques}

All this is to say
\begin{moral}
	The nonempty Zariski open sets are \emph{huge}.
\end{moral}
This is an important difference than what you're used to in topology.
To be very clear:
\begin{itemize}
	\ii In the past, if I said something like
	``has so-and-so property in an open neighborhood of point $p$'',
	one thought of this as saying
	``is true in a small region around $p$''.
	\ii In the Zariski topology,
	``has so-and-so property in an open neighborhood of point $p$''
	should be thought of as saying ``is true for virtually all points,
	other than those on certain curves''.
\end{itemize}
Indeed, ``open neighborhood'' is no longer really a accurate description.
Nonetheless, in many pictures to follow,
it will still be helpful to draw open neighborhoods as circles.

It remains to verify that as I've stated it, the closed sets actually form a topology.
That is, I need to verify briefly that
\begin{itemize}
	\ii $\varnothing$ and $\Aff^n$ are both closed.
	\ii Intersections of closed sets (even infinite) are still closed.
	\ii Finite unions of closed sets are still closed.
\end{itemize}
Well, closed sets are the same as affine varieties,
so we already know this!

\section{The Zariski topology on affine varieties}
\prototype{If $V = \VV(y-x^2)$ is a parabola,
	then $V$ minus $(1,1)$ is open in $V$.
	Also, the plane minus the origin is $D(x) \cup D(y)$.}

As we said before, by considering a variety $V$ as a subspace of $\Aff^n$
it inherits the Zariski topology.
One should think of an open subset of $V$ as
``$V$ minus a few Zariski-closed sets''.
For example:
\begin{example}[Open set of a variety]
	Let $V = \VV(y-x^2) \subseteq \Aff^2$ be a parabola,
	and let $U = V \setminus \{(1,1)\}$. We claim $U$ is open in $V$.
	\begin{center}
		\begin{asy}
		import graph;
		size(5cm);

		real f(real x) { return x*x; }
		graph.xaxis("$x$");
		graph.yaxis("$y$");
		draw(graph(f,-2,2,operator ..), blue, Arrows);
		label("$\mathcal V(y-x^2)$", (0.8, f(0.8)), dir(-45));

		opendot( (1,1), blue+1);
		\end{asy}
	\end{center}
	Indeed, $\tilde U = \Aff^2 \setminus \{(1,1)\}$ is open in $\Aff^2$
	(since it is the complement of the closed set $\VV(x-1,y-1)$),
	so $U = \tilde U \cap V$ is open in $V$.
	Note that on the other hand the set $U$ is \emph{not} open in $\Aff^2$.
\end{example}

We will go ahead and introduce now a definition
that will be very useful later.
\begin{definition}
	Given $V \subseteq \Aff^n$ an affine variety and $f \in \CC[x_1, \dots, x_n]$,
	we define the \vocab{distinguished open set}
	$D(f)$ to be the open set in $V$
	of points not vanishing on $f$:
	\[ D(f) = \left\{ p \in V \mid f(p) \neq 0 \right\} = V \setminus \VV(f). \]
\end{definition}
In \cite{ref:vakil}, Vakil suggests remembering the
notation $D(f)$ as ``doesn't-vanish set''.
\begin{example}
	[Examples of (unions of) distinguished open sets]
	\listhack
	\begin{enumerate}[(a)]
		\ii If $V = \Aff^1$ then $D(x)$ corresponds to a line minus a point.
		\ii If $V = \VV(y-x^2) \subseteq \Aff^2$,
		then $D(x-1)$ corresponds to the parabola minus $(1,1)$.
		\ii If $V = \Aff^2$, then
		$D(x) \cup D(y) = \Aff^2 \setminus \{ (0,0) \}$
		is the punctured plane.
		You can show that this set is \emph{not} distinguished open.
	\end{enumerate}
\end{example}

% There used to be an exercise here about D(f)
% being a distinguished base

%\begin{ques}
%	Give an example of an open set of $\Aff^2$
%	which is not a distinguished open set.
%	(There was one above already.)
%\end{ques}

\section{Coordinate rings}
\prototype{If $V = \VV(y-x^2)$ then $\CC[V] = \CC[x,y]/(y-x^2)$.}

The next thing we do is consider the functions from $V$ to the base field $\CC$.
We restrict our attention to algebraic (polynomial) functions on a variety $V$:
they should take every point $(a_1, \dots, a_n)$ on $V$ to some complex number $P(a_1, \dots, a_n) \in \CC$.
For example, a valid function on a three-dimensional affine variety might be $(a,b,c) \mapsto a$;
we just call this projection ``$x$''.
Similarly we have a canonical projection $y$ and $z$,
and we can create polynomials by combining them,
say $x^2y + 2xyz$.

\begin{definition}
	The \vocab{coordinate ring} $\CC[V]$ of a variety $V$
	is the ring of polynomial functions on $V$.
	(Notation explained next section.)
\end{definition}

At first glance, we might think this is just $\CC[x_1, \dots, x_n]$.
But on closer inspection we realize that \emph{on a given variety},
some of these functions are the same.
For example, consider in $\Aff^2$ the parabola $V = \VV(y-x^2)$.
Then the two functions
\begin{align*}
	V & \to \CC \\
	(x,y) & \mapsto x^2 \\
	(x,y) & \mapsto y
\end{align*}
are actually the same function!
We have to ``mod out'' by the ideal $I$ which generates $V$.
This leads us naturally to:
\begin{theorem}[Coordinate rings correspond to ideal]
	Let $I$ be a radical ideal, and $V = \VV(I) \subseteq \Aff^n$.
	Then \[ \CC[V] \cong \CC[x_1, \dots, x_n] / I.  \]
\end{theorem}
\begin{proof}
	There's a natural surjection as above
	\[ \CC[x_1, \dots, x_n] \surjto \CC[V] \]
	and the kernel is $I$.
\end{proof}
Thus properties of a variety $V$ correspond to properties of the ring $\CC[V]$.

\section{The sheaf of regular functions}
\prototype{Let $V = \Aff^1$, $U = V \setminus \{0\}$. Then $1/x \in \OO_V(U)$ is regular on $U$.}

Let $V$ be an affine variety and let $\CC[V]$ be its coordinate ring.
We want to define a notion of $\OO_V(U)$ for any open set $U$:
the ``nice'' functions on any open subset.
Obviously, any function in $\CC[V]$ will work as a function on $\OO_V(U)$.
However, to capture more of the structure we want to
loosen our definition of ``nice'' function slightly
by allowing \emph{rational} functions.

The chief example is that $1/x$ should be a regular function
on $\Aff^1 \setminus \{0\}$.
The first natural guess is:
\begin{definition}
	Let $U \subseteq V$ be an open set of the variety $V$.
	A \vocab{rational function} on $U$
	is a quotient $f(x) / g(x)$ of two elements $f$ and $g$ in $\CC[V]$,
	where we require that $g(x) \neq 0$ for $x \in U$.
\end{definition}
However, the definition is slightly too restrictive;
we have to allow for multiple representations:
\begin{definition}
	Let $U \subseteq V$ be open.
	We say a function $\phi : U \to \CC$ is a \vocab{regular function} if for
	every point $p \in U$, we can find an open set $U_p \subseteq U$ containing $p$
	and a rational function $f_p/g_p$ on $U_p$ such that
	\[ \phi(x) = \frac{f_p(x)}{g_p(x)} \qquad \forall x \in U_p. \]
	In particular, we require $g_p(x) \neq 0$ on the set $U_p$.
	We denote the set of all regular functions on $U$ by $\OO_V(U)$.
\end{definition}

Thus,
\begin{moral}
	$\phi$ is regular on $U$ if it is locally a rational function.
\end{moral}

This definition is misleadingly complicated,
and the examples should illuminate it significantly.
Firstly, in practice, most of the time we will be able to find
a ``global'' representation of a regular function as a quotient,
and we will not need to fuss with the $p$'s.
For example:
\begin{example}
	[Regular functions]
	\listhack
	\begin{enumerate}[(a)]
		\ii Any function in $f \in \CC[V]$ is clearly regular,
		since we can take $g_p = 1$, $f_p = f$ for every $p$.
		So $\CC[V] \subseteq \OO_V(U)$ for any open set $U$.
		\ii Let $V = \Aff^1$, $U_0 = V \setminus \{0\}$.
		Then $1/x \in \OO_V(U_0)$ is regular on $U$.
		\ii Let $V = \Aff^1$, $U_{12} = V \setminus \{1,2\}$. Then
		\[ \frac{1}{(x-1)(x-2)} \in \OO_V(U_{12}) \]
		is regular on $U$.
	\end{enumerate}
\end{example}
The ``local'' clause with $p$'s is still necessary, though.
\begin{example}
	[Requiring local representations]
	\label{ex:local_rep}
	Consider the variety
	\[ V = \VV(ab-cd) \subseteq \Aff^4 \]
	and the open set $U = V \setminus \VV(b,d)$.
	There is a regular function on $U$ given by
	\[
		(a,b,c,d)
		\mapsto
		\begin{cases}
			a/d & d \neq 0 \\
			c/b & b \neq 0.
		\end{cases}
	\]
	Clearly these are the ``same function'' (since $ab=cd$),
	but we cannot write ``$a/d$'' or ``$c/b$''
	to express it because we run into divide-by-zero issues.
	That's why in the definition of a regular function,
	we have to allow multiple representations.
\end{example}

In fact, we will see later on that the definition
of a regular function is a special case of a more
general construction called \emph{sheafification},
in which ``sheaves of functions which are $P$'' are transformed
into ``sheaves of functions which are \emph{locally} $P$''.

\section{Regular functions on distinguished open sets}
\prototype{Regular functions on $\Aff^1 \setminus \{0\}$ are $P(x) / x^n$.}
The division-by-zero, as one would expect,
essentially prohibits regular functions on the entire space $V$;
i.e.\ there are no regular functions in $\OO_V(V)$
that were not already in $\CC[V]$.
Actually, we have a more general result which computes the
regular functions on distinguished open sets:
\begin{theorem}
	[Regular functions on distinguished open sets]
	\label{thm:reg_func_distinguish_open}
	Let $V \subseteq \Aff^n$ be an affine variety
	and $D(g)$ a distinguished open subset of it.
	Then
	\[ \OO_V( D(g) ) = \left\{ \frac{f}{g^n}
		\mid f \in \CC[V] \text{ and } n \in \ZZ \right\}.  \]
	In particular, $\OO_V(V) = \OO_V(D(1)) \cong \CC[V]$.
\end{theorem}
The proof of this theorem requires the Nullstellensatz,
so it relies on $\CC$ being algebraically closed.
In fact, a counter-example is easy to find if we replace $\CC$ by $\RR$:
consider $\frac{1}{x^2+1}$.
\begin{proof}
	Obviously, every function of the form $f/g^n$ works,
	so we want the reverse direction.
	This is long, and perhaps should be omitted on a first reading.

	Here's the situation.
	Let $U = D(g)$.
	We're given a regular function $\phi$, meaning at every point $p \in D(g)$,
	there is an open neighborhood $U_p$ on which $\phi$ can be expressed
	as $f_p / g_p$ (where $f_p, g_p \in \CC[V]$).
	Then, we want to construct an $f \in \CC[V]$ and an integer $n$
	such that $\phi = f/g^n$.

	First, look at a particular $U_p$ and $f_p / g_p$.
	Shrink $U_p$ to a distinguished open set $D(h_p)$.
	Then, let $\wt f_p = f_p h_p$ and $\wt g_p = g_p h_p$.
	Thus we have that
	\[ \frac{\wt f_p}{\wt g_p} \text{ is correct on }
		D(h_p) \subseteq U \subseteq X. \]
	The upshot of using the modified $f_p$ and $g_p$ is that:
	\[ \wt f_p \wt g_q = \wt f_q \wt g_p \qquad \forall p,q \in U. \]
	Indeed, it is correct on $D(h_p) \cap D(h_q)$ by definition,
	and outside this set both the left-hand side and right-hand side are zero.

	Now, we know that $D(g) = \bigcup_{p \in U} D(\wt g_p)$, i.e.\
	\[ \VV(g) = \bigcap_{p \in U} \VV(\wt g_p). \]
	So by the Nullstellensatz we know that
	\[ g \in \sqrt{(\wt g_p : p \in U)}
		\implies \exists n : g^n \in (\wt g_p : p \in U). \]
	In other words, for some $n$ and $k_p \in \CC[V]$ we have
	\[ g^n = \sum_p k_p \wt g_p \]
	where only finitely many $k_p$ are not zero.
	Now, we claim that
	\[ f \defeq \sum_p k_p \wt f_p \]
	works.
	This just observes by noting that for any $q \in U$, we have
	\[
		f \wt g_q - g^n \wt f_q
		= \sum_p k_p(\wt f_p \wt g_q - \wt g_p \wt f_q)
		= 0. \qedhere
	\]
\end{proof}
This means that the \emph{global} regular functions
are just the same as those in the coordinate ring:
you don't gain anything new by allowing it to be locally a quotient.
(The same goes for distinguished open sets.)

\begin{example}[Regular functions on distinguished open sets]
	\listhack
	\begin{enumerate}[(a)]
		\ii As said already,
		taking $g=1$ we recover $\OO_V(V) \cong \CC[V]$
		for any affine variety $V$.
		\ii Let $V = \Aff^1$, $U_0 = V \setminus \{0\}$. Then
		\[ \OO_V(U_0)
			= \left\{ \frac{P(x)}{x^n} \mid P \in \CC[x],
			\quad n \in \ZZ \right\}. \]
		So more examples are $1/x$ and $(x+1)/x^3$.
	\end{enumerate}
\end{example}

\begin{ques}
	Why doesn't our theorem on regular functions apply to \Cref{ex:local_rep}?
\end{ques}

The regular functions will become of crucial importance
once we define a scheme in the next chapter.

\section{Baby ringed spaces}
In summary, given an affine variety $V$ we have:
\begin{itemize}
	\ii A structure of a set of points,
	\ii A structure of a topological space $V$ on these points, and
	\ii For every open set $U \subseteq V$, a ring $\OO_V(U)$.
	Elements of the rings are functions $U \to \CC$.
\end{itemize}
Let us agree that:
\begin{definition}
	A \vocab{baby ringed space} is a topological space $X$
	equipped with a ring $\OO_X(U)$ for every open set $U$.
	It is required that elements of the ring $\OO_X(U)$
	are functions $f : U \to \CC$;
	we call these the \emph{regular functions} of $X$ on $U$.
\end{definition}
Therefore, affine varieties are baby ringed spaces.
\begin{remark}
	This is not a standard definition. Hehe.
\end{remark}

The reason this is called a ``baby ringed space''
is that in a \emph{ringed space},
the rings $\OO_V(U)$ can actually be \emph{any rings},
but they have to satisfy a set of fairly technical conditions.
When this happens, it's the $\OO_V$ that does all the work;
we think of $\OO_V$ as a type of functor called a \emph{sheaf}.

Since we are only studying affine/projective/quasi-projective varieties
for the next chapters, we will just refer to these as baby ringed spaces
so that we don't have to deal with the entire definition.
The key concept is that we want to think of these varieties
as \emph{intrinsic objects}, free of any embedding.
A baby ringed space is philosophically the correct thing to do.

Anyways, affine varieties are baby ringed spaces $(V, \OO_V)$.
In the next chapter we'll meet projective and quasi-projective
varieties, which give more such examples of (baby) ringed spaces.
With these examples in mind, we will finally lay down
the complete definition of a ringed space,
and use this to define a scheme.

\section\problemhead

\begin{dproblem}
	Show that for any $n \ge 1$ the Zariski topology of $\Aff^n$
	is \emph{not} Hausdorff.
\end{dproblem}

\begin{dproblem}
	Let $V$ be an affine variety,
	and consider its Zariski topology.
	\begin{enumerate}[(a)]
		\ii Show that the Zariski topology is \vocab{Noetherian},
		meaning there is no infinite descending chain
		$Z_1 \supsetneq Z_2 \supsetneq Z_3 \supsetneq \dots$ of closed subsets.
		\ii Prove that a Noetherian topological space is compact.
		Hence varieties are topologically compact.
	\end{enumerate}
\end{dproblem}

\begin{sproblem}
	[Punctured Plane]
	\label{prob:punctured_plane}
	Let $V = \Aff^2$ and let $X = \Aff^2 \setminus \{(0,0)\}$ be the punctured plane
	(which is an open set of $V$).
	Compute $\OO_V(X)$.
\end{sproblem}


\section{Set theory}\label{sec:set_theory}

Sets are ubiquitous in mathematics yet set theory itself is quite complicated. Attention needs to be put to define a \hyperref[def:first_order_theory]{logical theory} of sets that is both useful and \hyperref[def:first_order_theory_consistency]{consistent}.

We first use the simplicity of \hyperref[def:naive_set_theory]{na\"ive set theory} to introduce some fundamental definitions. This theory turns out to be inconsistent due to \fullref{thm:russels_paradox}.

We later introduce the more, sophisticated \hyperref[def:zfc]{Zermelo-Fraenkel set theory} (\logic{ZFC}). It is unclear whether the latter theory is consistent, however no contradictions have yet been discovered. Furthermore, the restrictions of \logic{ZFC} (mostly the \hyperref[def:zfc/foundation]{axiom of foundation}) actually make it possible to define a model of \hyperref[def:peano_arithmetic]{Peano arithmetic} and extend the concept of a number to \hyperref[def:ordinal]{ordinals} and \hyperref[def:cardinal]{cardinals}. We then discuss \hyperref[def:cumulative_hierarchy]{von Neumann's cumulative hierarchy}, which can be used to build models of set theory.

We also extend \logic{ZFC} with \hyperref[def:grothendieck_universe]{Grothendieck universes} to obtain the theory \hyperref[def:axiom_of_universes]{\logic{ZFC+U}}, upon which we construct the concept of a \hyperref[def:category]{category}.

By \enquote{set theory} we mean na\"ive set theory, \logic{ZF}, \logic{ZFC}, \logic{ZFC+U} or further variations.

\begin{remark}\label{rem:set_definition_recursion}
  The relation between \hyperref[subsec:first_order_logic]{first-order logic} and set theory is remarkably circular.

  \begin{itemize}
    \item Set theory is defined as a \hyperref[def:first_order_theory]{theory} of first-order logic.

    \item First-order logic itself is defined via sets, for example via the \hyperref[def:first_order_language]{language of first-order logic} or the definitions of a \hyperref[def:first_order_structure]{first-order structure} or of a \hyperref[def:deductive_system]{deductive system}.
  \end{itemize}

  We utilize the concept of \hyperref[rem:metalogic]{metalogic} to resolve this circularity:
  \begin{itemize}
    \item Using the metatheory where we assume the availability of first-order logic, we build in the object logic certain special sets within set theory that can be used as models of \logic{ZFC} --- see \fullref{thm:cumulative_hierarchy_model_of_zfc}. In particular, the theorem implies that the existence of a \hyperref[rem:strongly_inaccessible_cardinal]{regular strong limit cardinal} in the metatheory can prove that \logic{ZFC} is consistent.

    \item We declare such a set as \enquote{the} model of \logic{ZFC} we are interested in. At this point, this set that we have built in the object logic becomes the ambient universe in the metatheory.

    \item Now we can, within the metatheory, define \hyperref[subsec:first_order_logic]{first-order logic}.
  \end{itemize}

  An important point is that we should restrict ourselves to \hyperref[rem:standard_model_of_set_theory]{standard} \hyperref[rem:transitive_model_of_set_theory]{transitive} models in order to avoid very counterintuitive results.

  Another important point is that it is possible that the set theory which we use within the metatheory in order to provide models of \logic{ZFC} is itself inconsistent. In that case, due to \eqref{eq:thm:minimal_propositional_negation_laws/efq}, every theorem can be derived and a proof of consistency of \logic{ZFC} is insubstantial.

  Note that we do need additional assumptions for the \hyperref[def:axiom_of_universes]{axiom of universes} separately because we cannot build a model using the cumulative hierarchy.
\end{remark}

\begin{remark}\label{rem:first_order_theories_in_zfc}
  Instead of discussing first-order theories like the \hyperref[def:group/theory]{theory of groups}, we can instead reformulate the definition within set theory and add a \hyperref[rem:predicate_formula]{predicate formula} \( \op{IsGroup}[\xi] \) with which is valid only for groups. That is, \( \op{IsGroup}[\xi] \) is a tautology if and only if the variable \( \xi \) satisfies the set-based definition of a group given in \fullref{def:group}.

  This is a natural approach, and we usually assume it implicitly. Furthermore, it makes no sense to speak about concepts like the \hyperref[thm:substructures_form_complete_lattice]{lattice of subgroups} or the \hyperref[def:cardinal]{cardinality} of a group otherwise.

  This is also a natural framework for defining \hyperref[def:topological_space]{topological spaces} and \hyperref[def:category]{categories} via \hyperref[def:quiver]{quivers}. Some theories like the \hyperref[def:partially_ordered_set]{partially ordered sets} are first-order theories, however \hyperref[def:well_ordered_set]{well-ordered sets} is an extension that requires an ambient set theory.

  Thus, roughly, set theory allows us to use \hyperref[rem:higher_order_logic]{higher-order relations and types} in first-order logic.
\end{remark}