Before the proofs that are the main results of this thesis we will start with a formal introduction of partizan poset games in general and partizan poset games played on chess-colored Young diagrams in particular.
%\\
\begin{defn}[Partizan Poset Games]
Let $P$ be any colored poset and let $p_L,p_R$ denote arbitrary elements in $P$ of Left and Right respectively. The partizan poset game $G_{\rm PP}(P)$ played on $P$ is a partizan two-player game where the Left player has the option to select any white element $p_L$ in $P$ and then remove $p_L$ together with all elements greater than $p_L$ and equivalently for the Right player but with black elements in $P$. More formally we have:
\begin{align*}
&G_{\rm PP}(P)=\{L|R\}&~\\
&L=\{G_{\rm PP}(P\setminus S_{\rm P}(p_L)):p_L\in P\text{ is white}\}&~\\
&R=\{G_{\rm PP}(P\setminus S_{\rm P}(p_R)):p_R\in P\text{ is black}\}&\\
&S_{\rm P}(p)=\{p':p'\in P,p'\ge p\}&~
\end{align*}
\end{defn}
~\\
More specifically, this thesis deals with partizan poset games played on posets that are chess-colored and in the form of Young diagrams. We will denote such a game, with $k\ge1$ rows in the Young diagram, as $A_\lambda$, where $\lambda=(\lambda_1,\lambda_2,\dots,\lambda_k)$ is as in Definition \ref{def:lambda} and $\lambda_1\ge \lambda_2\ge \dots\ge \lambda_k$ denotes the lengths of the 1st, 2nd,$\dots,k$'th rows respectively. In particular, when $k=3$ or $k=2$, we will use the notation $A_{x,y,z}$ and $A_{x,y}$ respectively.

\subsection{All Poset Games Are Numbers}
As it is, we have that all poset games are numbers. In particular, for a large number of partizan poset games, the value is bounded.% as $0\le G\le 1$.
%According to Section \ref{section:numbers} in general and Theorem \ref{numthm} in particular, it is, using \emph{Conway Induction}, sufficient to show that for a poset game $G$ we have $G^L<G^R$.
%\\
\begin{thm}
\label{thm:posetnum}
All poset games are numbers.
\end{thm}
\begin{proof2}{Proof of Theorem \ref{thm:posetnum}}
Assume that we have an arbitrary poset game $G$. Using \emph{Conway Induction} (Theorem \ref{thm:conind}) it suffices to assume that $G^L,G^R$ are numbers and then deduce that $G$ is a number as well. By Theorem \ref{thm:number} it is then sufficient to show that $G^L<G^R$ for all options of $G$.
\\
If we can show that $G^L<G$ and $G^R>G$ for any Left and Right options of $G$, then it also holds that $G^L<G^R$, and hence $G$ must be a number.
\\\\
Consider the scenario where Left moves to some option $G^{L_1}$, as illustrated in Figure \ref{fig:posetnum1}. We have that $G^{L_1}<G$ since Right always wins in $G^{L_1}-G$.
\\
\begin{figure}[H]
\centering
\begin{subfigure}{0.45\textwidth}
\begin{tikzpicture}
\path[draw,use Hobby shortcut,closed=true]
(0,-0.2) .. (1.2,1) .. (2.5,2) .. (.3,3.3) .. (-1.4,1.3) .. (-1.3,.3);
\node (G) at (0.3,1.5) {$G$};
\end{tikzpicture}
\end{subfigure}
%$\hfill$
\begin{subfigure}{0.45\textwidth}
\begin{tikzpicture}
\path[draw,use Hobby shortcut,closed=true]
(0,0) .. (.5,1) .. (1,2) .. (.3,3) .. (-1,1) .. (-1,.5);
\path[dashed,draw,use Hobby shortcut,closed=true]
(0,-0.2) .. (1.2,1) .. (2.5,2) .. (.3,3.3) .. (-1.4,1.3) .. (-1.3,.3);
\path[draw,use Hobby shortcut,closed=true]
(1.5,2.3) .. (1.8,2) .. (2,2.4) .. (1.7,3);
\node (G) at (0,1.5) {$G^{L_1}$};
\draw (1,2) -- (1.5,2.3);
\node at (1.5,2.3) {\tikz\draw[black,fill=white] (0,0) circle (.5ex);};
\draw [<-,thick] (1.5,1) -- (2,0.5);
\node at (2.2,.3) {G};
\end{tikzpicture}
\end{subfigure}
\captionof{figure}{Arbitrary poset game $G$ and $G$ with an arbitrary Left option $G^{L_1}$.}
\label{fig:posetnum1}
\end{figure}

This is easily understood from the following. In the game $G^{L_1}-G$ in Figure \ref{fig:posetnum2} the Right player wins if it plays first, since then Right can move to $-G^{L_1}$ in $-G$ and then mimic Left's moves until Left has no moves left. If Left starts and plays in the part of $G$ that is not included in $G^{L_1}$, i.e., the small appendage of G in Figure \ref{fig:posetnum1}, then Right can move to $-G^{L_1}$ in that component and copy Left in the same way as before. If Left starts and plays in the $G^{L_1}$-part of either component, then Right can copy Left until either Left has no moves or until Left plays in the appendage part of the $-G$ component, and then Right can just move to the option that removes that appendage, which makes the two components mirrored again, so Right can then copy Left until Left has no moves and loses.
\\
Since Right wins in $G^{L_1}-G$ no matter if Right starts or not, then $G^{L_1}-G<0$.
\begin{figure}[H]
\centering
\begin{tikzpicture}
\path[draw,use Hobby shortcut,closed=true]
(0,0) .. (.5,1) .. (1,2) .. (.3,3) .. (-1,1) .. (-1,.5);
\node (G) at (0,1.5) {$G^{L_1}$};
\end{tikzpicture}
{\scalefont{10}
\begin{tikzpicture}
\node at (0,3){};
\node at (0,1.5){-};
\node at (0,0){};
\end{tikzpicture}
}
\begin{tikzpicture}
\path[draw,use Hobby shortcut,closed=true]
(0,0) .. (.5,1) .. (1,2) .. (.3,3) .. (-1,1) .. (-1,.5);
\path[dashed,draw,use Hobby shortcut,closed=true]
(0,-0.2) .. (1.2,1) .. (2.5,2) .. (.3,3.3) .. (-1.4,1.3) .. (-1.3,.3);
\path[draw,use Hobby shortcut,closed=true]
(1.5,2.3) .. (1.8,2) .. (2,2.4) .. (1.7,3);
\node (G) at (0,1.5) {$G^{L_1}$};
\draw (1,2) -- (1.5,2.3);
\node at (1.5,2.3) {\tikz\draw[black,fill=white] (0,0) circle (.5ex);};
\end{tikzpicture}
\captionof{figure}{The poset game $G^{L_1}-G$.}
\label{fig:posetnum2}
\end{figure}
%\\
In the exact same way, it is possible to show that Left always wins in $G^{R_1}-G$, and hence that $G^{R_1}-G>0$. We therefore have $G^{L_1}<G^{R_1}$. Since $G^{L_1}$ and $G^{R_1}$ were arbitrary, this holds for any Left and Right options $G^{L_1},G^{R_1}$, and therefore $G$ must be a number.
\end{proof2}

This lets us know that all poset games are numbers. But we can also bound the value of some partizan poset games, as will be seen in Theorem \ref{thm:value}.

\begin{minipage}[b]{0.5\textwidth}
\begin{thm}
Any partizan poset game $G$ with a single smallest element colored white, covered only by black elements, has a value $0< G< 1$.
\\
An example game can be seen in Figure \ref{fig:partizanvalue}.
\label{thm:value}
\end{thm}
\end{minipage}
\begin{minipage}{0.05\textwidth}
~
\end{minipage}
\begin{minipage}[b]{0.45\textwidth}

%\begin{figure}[H]
\centering
\begin{tikzpicture}[baseline=-0.65ex,scale=.2]
  \draw[thick] (0,-2) -- (-4,0);
  \draw[thick] (0,-2) -- (4,0);
  \draw[dashed] (-4,0) -- (-6,2);
  \draw[dashed] (-4,0) -- (-4,3);
  \draw[dashed] (-4,0) -- (-2,2);
  \draw[dashed] (4,0) -- (6,2);
  \draw[dashed] (4,0) -- (4,3);
  \draw[dashed] (4,0) -- (2,2);
  \node (zero) at (0,-2) {\tikz\draw[black,fill=white] (0,0) circle (.5ex);};
  \node (1) at (-4,0) {\tikz\draw[black,fill=black] (0,0) circle (.5ex);};
  \node (2) at (4,0) {\tikz\draw[black,fill=black] (0,0) circle (.5ex);};
\end{tikzpicture}
\captionof{figure}{}
\label{fig:partizanvalue}
%\end{figure}
\end{minipage}
\begin{proof2}{Proof of Theorem \ref{thm:value}}
Let $G$ be any partizan poset game with a single smallest element colored white, covered only by black elements. Clearly $G>0$ since Left can remove the smallest element in the poset, removing all elements, resulting in no options for Right, so Left wins.
\\
Moreover, since the game with only the smallest (white) element left is either an option of Right, or an option of an option of Right, or an option of an option of an option of Right,\dots, etc., and all $G^R>G$, then $G<1$.
\end{proof2}
%Obviously, the value of games for which the coloring is reversed that of Theorem \ref{thm:value} is also bounded, but as $0>G>-1$ instead.
%\\
We may note that this theorem holds for all chess-colored partizan poset games with a single smallest elements, e.g., games played on chess-colored Young diagrams.
\\\\
In addition to bounding the value of some games, it is also possible to determine that a player should try to play the option of removing as great elements as possible.
\begin{thm}[Play Strategy]
\label{thm:playstrategy}
A player should only play the options of removing elements not lower than any other element of the same color.
\end{thm}
\begin{proof2}{Proof of Theorem \ref{thm:playstrategy}}
We will prove this theorem by showing that any option of removing an element that is lower than some other element of the same color is also a dominated option.
\\
Let $G$ be any partizan poset game, let $G^{L_{x_1}},G^{L_{x_2}}$ be the Left options when removing the elements $x_1$ and $x_2$ respectively and let $x_1>x_2$.
The option $G^{L_{x_2}}$ must be an option of $G^{L_{x_1}}$. This is because $x_1>x_2$, which yields that the option of removing $x_2$ also removes $x_1$, and therefore the option of removing $x_1$ does not remove any elements that are not removed when playing the option of removing $x_2$.
\\
Since $G^{L_{x_2}}$ is an option of $G^{L_{x_1}}$ and Theorem \ref{thm:posetnum} yields that $G$ is a number, then $G^{L_{x_1}}>G^{L_{x_2}}$ and hence $G^{L_{x_2}}$ is dominated by $G^{L_{x_1}}$, i.e., Left should not play the option $G^{L_{x_2}}$.
\\
Similarly, this holds for Right options as well.
\end{proof2}
\newpage
%
%\subsection{Partizan Tree Poset Games And Blue-Red Hackenbush}
%\begin{thm}
%A Partizan tree poset game where no element is covering more than one element is equivalent to a game of Blue-Red Hackenbush.
%\end{thm}
%\begin{proof2}
%Consider a partizan tree poset game $G$. Then transform every element in the poset of $G$ to a stick in the game of Blue-Red Hackenbush, color them according to the appropriate player, connect every stick with the stick that it covers and connect the least element to the ground. We then have an equivalent game of Blue-Red Hackenbush.
%\begin{figure}[H]
%\centering
%\begin{tikzpicture}[scale=1]
%  \node (zero) at (-6,-1) {\tikz\draw[black,fill=white] (0,0) circle (.5ex);};
%  \node (1) at (-8,.5) {\tikz\draw[black,fill=black] (0,0) circle (.5ex);};
%  \node (2) at (-6,.5) {\tikz\draw[black,fill=white] (0,0) circle (.5ex);};
%  \node (3) at (-4,.5) {\tikz\draw[black,fill=black] (0,0) circle (.5ex);};
%  \node (4) at (-9,2) {\tikz\draw[black,fill=black] (0,0) circle (.5ex);};
%  \node (5) at (-7,2) {\tikz\draw[black,fill=white] (0,0) circle (.5ex);};
%  \node (6) at (-4,2) {\tikz\draw[black,fill=white] (0,0) circle (.5ex);};
%  \draw[thick] (zero) -- (1) -- (4);
%  \draw[thick] (zero) -- (2);
%  \draw[thick] (1) -- (5);
%  \draw[thick] (zero) -- (3) -- (6);
%%\end{tikzpicture}
%%\begin{tikzpicture}[scale=0.5]
%    \draw[densely dashed] (-1,-1) -- (1,-1);
%    \node[hackennode] (down)   at ( 0,  -1) {};
%    \node[hackennode] (middle) at ( 0,   0) {};
%    \node[hackennode] (left)   at (-1.5, 1) {};
%    \node[hackennode] (right)  at ( 1.5, 1) {};
%    \node[hackennode] (top)    at ( 0,   1) {};
%    \node[hackennode] (top2)   at (-2,   2) {};
%    \node[hackennode] (top3)   at (-1,   2) {};
%    \node[hackennode] (top4)   at ( 1.5, 2) {};
%
%    \draw[hackenline,blue]
%		(down) -- (middle);
%    \draw[hackenline,red]
%		(middle) -- (right);
%    \draw[hackenline,red]
%		(middle) -- (left);
%    \draw[hackenline,blue]
%        (middle) -- (top);
%    \draw[hackenline,red]
%        (left) -- (top2);
%    \draw[hackenline,blue]
%        (left) -- (top3);
%    \draw[hackenline,blue]
%        (right) -- (top4);
%
%\end{tikzpicture}
%\end{figure}
%\begin{figure}[H]
%\centering
%\begin{tikzpicture}[scale=1]
%  \node (zero) at (-6,-1) {\tikz\draw[black,fill=white] (0,0) circle (.5ex);};
%  \node (1) at (-8,.5) {\tikz\draw[black,fill=black] (0,0) circle (.5ex);};
%  \node (2) at (-6,.5) {\tikz\draw[black,fill=white] (0,0) circle (.5ex);};
%  \node (3) at (-4,.5) {\tikz\draw[black,fill=black] (0,0) circle (.5ex);};
%  \node (4) at (-9,2) {\tikz\draw[black,fill=black] (0,0) circle (.5ex);};
%  \node (5) at (-7,2) {\tikz\draw[black,fill=white] (0,0) circle (.5ex);};
%  \node (6) at (-4,2) {\tikz\draw[black,fill=white] (0,0) circle (.5ex);};
%  \draw[thick] (zero) -- (1) -- (4);
%  \draw[thick] (zero) -- (2);
%  \draw[thick] (1) -- (5);
%  \draw[thick] (zero) -- (3) -- (6);
%%\end{tikzpicture}
%%\begin{tikzpicture}[scale=0.5]
%    \draw[densely dashed] (-1,-1) -- (1,-1);
%    \node[hackennode] (down)   at ( 0,  -1) {};
%    \node[hackennode] (middle) at ( 0,   0) {};
%    \node[hackennode] (left)   at (-1.5, 1) {};
%    \node[hackennode] (right)  at ( 1.5, 1) {};
%    \node[hackennode] (top)    at ( 0,   1) {};
%    \node[hackennode] (top2)   at (-2,   2) {};
%    \node[hackennode] (top3)   at (-1,   2) {};
%    \node[hackennode] (top4)   at ( 1.5, 2) {};
%
%    \draw[hackenline,blue]
%		(down) -- (middle);
%    \draw[hackenline,red]
%		(middle) -- (right);
%    \draw[hackenline,red]
%		(middle) -- (left);
%    \draw[hackenline,blue]
%        (middle) -- (top);
%    \draw[hackenline,red]
%        (left) -- (top2);
%    \draw[hackenline,blue]
%        (left) -- (top3);
%    \draw[hackenline,blue]
%        (right) -- (top4);
%
%\draw[<->, blue, shorten <= 0.25cm, shorten >= 0.1cm] (-6,-1) to[out=-20,in=-180] (0,-.5);
%\draw[<->, red, shorten <= 0.25cm, shorten >= 0.1cm] (-8,.5) to[out=20,in=-135] (-.625,.25);
%\draw[<->, blue, shorten <= 0.25cm, shorten >= 0.1cm] (-6,.5) to[out=-30,in=-180] (0,.5);
%\draw[<->, red, shorten <= 0.25cm, shorten >= 0.1cm] (-4,.5) to[out=50,in=140] (.875,.75);
%\draw[<->, red, shorten <= 0.25cm, shorten >= 0.1cm] (-9,2) to[out=30,in=-160] (-1.75,1.5);
%\draw[<->, blue, shorten <= 0.25cm, shorten >= 0.1cm] (-7,2) to[out=30,in=120] (-1.1,1.8);
%\draw[<->, blue, shorten <= 0.25cm, shorten >= 0.1cm] (-4,2) to[out=30,in=160] (1.5,1.5);
%
%
%\end{tikzpicture}
%\end{figure}
%\begin{figure}[H]
%\centering
%\begin{tikzpicture}[scale=1]
%    \draw[densely dashed] (-1,-1) -- (1,-1);
%    \node[hackennode] (down)   at ( 0,  -1) {};
%    \node[hackennode] (middle) at ( 0,   0) {};
%    \node[hackennode] (left)   at (-1.5, 1) {};
%    \node[hackennode] (right)  at ( 1.5, 1) {};
%    \node[hackennode] (top)    at ( 0,   1) {};
%    \node[hackennode] (top2)   at (-2,   2) {};
%    \node[hackennode] (top3)   at (-1,   2) {};
%    \node[hackennode] (top4)   at ( 1.5, 2) {};
%
%    \draw[hackenline,blue]
%		(down) -- (middle);
%    \draw[hackenline,red]
%		(middle) -- (right);
%    \draw[hackenline,red]
%		(middle) -- (left);
%    \draw[hackenline,blue]
%        (middle) -- (top);
%    \draw[hackenline,red]
%        (left) -- (top2);
%    \draw[hackenline,blue]
%        (left) -- (top3);
%    \draw[hackenline,blue]
%        (right) -- (top4);
%
%  \node (zero) at (0,-.5) {\tikz\draw[black,fill=white] (0,0) circle (1ex);};
%  \node (1) at (-.75,.5) {\tikz\draw[black,fill=black] (0,0) circle (1ex);};
%  \node (2) at (-0,.5) {\tikz\draw[black,fill=white] (0,0) circle (1ex);};
%  \node (3) at (.75,.5) {\tikz\draw[black,fill=black] (0,0) circle (1ex);};
%  \node (4) at (-1.75,1.5) {\tikz\draw[black,fill=black] (0,0) circle (1ex);};
%  \node (5) at (-1.25,1.5) {\tikz\draw[black,fill=white] (0,0) circle (1ex);};
%  \node (6) at (1.5,1.5) {\tikz\draw[black,fill=white] (0,0) circle (1ex);};
%%  \draw[thick, dashed] (zero) -- (1) -- (4);
%%  \draw[thick, dashed] (zero) -- (2);
%%  \draw[thick, dashed] (1) -- (5);
%%  \draw[thick, dashed] (zero) -- (3) -- (6);
%\end{tikzpicture}
%\end{figure}
%jjjj
%\end{proof2}
%\newpage

\subsection{Chess-Colored Young Diagram Partizan Poset Games}
For chess-colored Young diagrams, we have a very regular structure. This regularity makes it possible to reduce the games significantly, and make even stronger statements about the values of these games. A general result about how we can reduce games played on chess-colored Young diagrams is the following.

\begin{lem}
\label{lem:chessdomopt}
The dominating option of $A_\lambda$, with $\lambda=(\lambda_1,\lambda_2,\dots,\lambda_k)$, is always to remove the greatest element of your color in one of the rows.
\end{lem}
~\\
Lemma \ref{lem:chessdomopt} follows from Theorem \ref{thm:playstrategy}. For a better understanding of what the lemma yields, we will provide some examples of the concept.
\begin{ex}{}
Let $k=4$. With $\lambda_1=9,\lambda_2=7,\lambda_3=7,\lambda_4=2$, Lemma \ref{lem:chessdomopt} gives us that: $$A_{9,7,7,2}=\left\{A_{8,7,7,2},A_{9,5,5,2},A_{9,7,6,2},A_{9,7,7,1}\middle|A_{7,7,7,2},A_{9,6,6,2},A_{9,7,5,2},A_{9,7,7,0}\right\}.$$
\end{ex}
\begin{ex}{}
For $x=y=3,z=1$ Lemma \ref{lem:chessdomopt} gives us $$A_{3,3,1}=\left\{A_{2,2,1},A_{3,1,1},A_{3,3,0}\middle|A_{1,1,1},A_{3,2,1}\right\},$$ as illustrated in Figure \ref{fig:chessdomex}.
\begin{figure}[H]
\centering
$
\begin{tabular}{ | c | c | c |}
\hline
~&\cellcolor[gray]{0}&~\\
\hline
\cellcolor[gray]{0}&~&\cellcolor[gray]{0}\\
\hline
~\\
\cline{1-1}
\end{tabular}
=\left\{
\begin{tabular}{ | c | c |}
\hline
~&\cellcolor[gray]{0}\\
\hline
\cellcolor[gray]{0}&~\\
\hline
~\\
\cline{1-1}
\end{tabular}
,
\begin{tabular}{ | c | c | c |}
\hline
~&\cellcolor[gray]{0}&~\\
\hline
\cellcolor[gray]{0}\\
\cline{1-1}
~\\
\cline{1-1}
\end{tabular}
,
\begin{tabular}{ | c | c | c |}
\hline
~&\cellcolor[gray]{0}&~\\
\hline
\cellcolor[gray]{0}&~&\cellcolor[gray]{0}\\
\hline
\end{tabular}
\;\middle|\;
\begin{tabular}{ | c |}
\hline
~\\
\hline
\cellcolor[gray]{0}\\
\hline
~\\
\hline
\end{tabular}
,
\begin{tabular}{ | c | c | c |}
\hline
~&\cellcolor[gray]{0}&~\\
\hline
\cellcolor[gray]{0}&~\\
\cline{1-2}
~\\
\cline{1-1}
\end{tabular}
\right\}
$
\captionof{figure}{Concept of Lemma \ref{lem:chessdomopt}.}
\label{fig:chessdomex}
\end{figure}
\end{ex}
%~\\
%Lemma \ref{lem:chessdomopt} follows from Theorem \ref{thm:playstrategy}, but we will provide an explicit proof and prove Lemma \ref{lem:chessdomopt} using Theorem \ref{thm:number} by showing that options when removing non-maximal elements are options of a option when a maximal element is removed, and must therefore be dominated by this option.
%\begin{proof2}{Proof of Lemma \ref{lem:chessdomopt}}
%Let $G=A_\lambda$, with $\lambda=(\lambda_1,\lambda_2,\dots,\lambda_k)$, and let $G^{L_i},i\in\{1,2,\dots,k\}$ denote an arbitrary option of Left when playing in the $i$'th row and $G^{R_i},i\in\{1,2,\dots,k\}$ denote an arbitrary option of Right when playing in the $i$'th row. Let $G^{L_i^{max}},G^{R_i^{max}}$ denote the game options of $G$ when removing the greatest white and black element respectively in the $i$'th row for players Left and Right. \\
%We will then have that $G^{L_i^{max}}>G^{L_i}$ for any other option for Left in the $i$'th row. This is because any other Left option when playing in the $i$'th row except removing the greatest Left element is a game option of $G^{L_i^{max}}$ and by Theorem \ref{thm:number} we have $G^{L_i^{max}L}<G^{L_i^{max}}$. The same argument also gives us that $G^{R_i^{max}}<G^{R_i}$ for all other Right options of playing in the $i$'th row. Therefore $G^{L_1^{max}},G^{L_2^{max}},G^{L_3^{max}}, G^{R_1^{max}},G^{R_2^{max}},G^{R_3^{max}}$ must be the dominating game options of $G$, and hence Lemma \ref{lem:chessdomopt} is valid for $G$ itself.
%\end{proof2}

\newpage
\subsubsection{Two-Row Chess-Colored Young Diagrams}
\input{tworow.tex}
\newpage
\subsubsection{Three-Row Chess-Colored Young Diagrams}
\input{threerow.tex}


\documentclass{article}
\title{Chapter 05}
\author{Newton Ni}

\usepackage{bussproofs}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{amsthm}

% Set cardinality: |#1|
\newcommand{\cardinality}[1]{\lvert#1\rvert}

% Set: { #1 }
\newcommand{\set}[1]{\{\ #1\ \}}

% Set comprehension: { #1 | #2 }
\newcommand{\comp}[2]{\set{#1\ \mid\ #2}}

% t₁, t₂, t₃, ...
\newcommand{\term}[1]{\texttt{t\textsubscript{#1}}}

% v₁, v₂, v₃, ...
\newcommand{\val}[1]{\texttt{v\textsubscript{#1}}}

% v₁, v₂, v₃, ...
\newcommand{\var}[1]{\texttt{x\textsubscript{#1}}}

\renewcommand{\ss}[2]{#1 \longrightarrow #2}
\renewcommand{\bs}[2]{#1 \Downarrow #2}

% Monospace
\newcommand{\ms}[1]{\texttt{#1}}

\newcommand{\LabelR}[1]{\RightLabel{\textsc{#1}}}

\theoremstyle{remark}
\newtheorem*{case}{Case}

\begin{document}
\maketitle

\section{5.3.3}

    \textit{Give a careful proof that} $|FV(\term{})| \le size(\term{})$ \textit{for every term} $\term{}$.

    \begin{proof}
        By structural induction on terms \term{}. Our inductive hypothesis is:
        $$H(\term{}): |FV(\term{})| \le size(\term{})$$

        \begin{case}[\textsc{T-Var}]
            Here, $|FV(\var{})| = |\{\var{}\}| = 1 \le size(\var{}) = 1$.
        \end{case}

        \begin{case}[\textsc{T-Abs}]
            Here, $|FV(\lambda \var{}. \term{1})| = |FV(\term{1}) \setminus \{\var{}\}|$.
            \begin{itemize}
                \item If $\var{} \in FV(\term{1})$, then $|FV(\term{1}) \setminus \{\var{}\}| = |FV(\term{1})| - 1$.
                \item Otherwise $|FV(\term{1}) \setminus \{\var{}\}| = |FV(\term{1})|$.
            \end{itemize}
            It follows that $|FV(\term{1}) \setminus \{\var{}\}| \le |FV(\term{1})|$.
            \begin{align*}
                |FV(\lambda \var{}. \term{1})| &= |FV(\term{1}) \setminus \{\var{}\}| \\
                                               &\le |FV(\term{1})| \tag{By above} \\
                                               &\le size(\term{1}) \tag{By inductive hypothesis} \\
                                               &\le size(\term{1}) + 1 \\
                                               &\le size(\lambda \var{}. \term{1}) \tag{By definition of $size$}
            \end{align*}
        \end{case}

        \begin{case}[\textsc{T-App}]
            \begin{align*}
                |FV(\term{1}\ \term{2})| &= |FV(\term{1}) \cup FV(\term{2})| \\
                                         &\le |FV(\term{1})| + |FV(\term{2})| \\
                                         &\le size(\term{1}) + size(\term{2}) \tag{By inductive hypothesis} \\
                                         &\le size(\term{1}\ \term{2}) \tag{By definition of $size$}
            \end{align*}
        \end{case}
    \end{proof}

\pagebreak
\section{5.3.6}

    \textit{Adapt these rules to describe the other three strategies for}
    \textit{evaluation---full beta-reduction, normal-order, and lazy evaluation.}

    \subsection*{Full Beta-Reduction}

        \begin{prooftree}
            \LabelR{E-App1}
            \AxiomC{$\ss{\term{1}}{\term{1}'}$}
            \UnaryInfC{$\ss{\term{1}\ \term{2}}{\term{1}'\ \term{2}}$}
        \end{prooftree}

        \begin{prooftree}
            \LabelR{E-App2}
            \AxiomC{$\ss{\term{2}}{\term{2}'}$}
            \UnaryInfC{$\ss{\term{1}\ \term{2}}{\term{1}\ \term{2}'}$}
        \end{prooftree}

        \begin{prooftree}
            \LabelR{E-Abs}
            \AxiomC{$\ss{\term{1}}{\term{1}'}$}
            \UnaryInfC{$\ss{\lambda \var{}.\ \term{1}}{\lambda \var{}.\ \term{1}'}$}
        \end{prooftree}

        \begin{prooftree}
            \LabelR{E-AppAbs}
            \AxiomC{}
            \UnaryInfC{$\ss{
                (\lambda \var{}.\ \term{1})\ \term{2}
            }{
                [\var{} \mapsto \term{2}] \term{1}
            }$}
        \end{prooftree}

    \subsection*{Normal-Order}

        % TODO

    \subsection*{Lazy}

        \begin{prooftree}
            \LabelR{E-App1}
            \AxiomC{$\ss{\term{1}}{\term{1}'}$}
            \UnaryInfC{$\ss{\term{1}\ \term{2}}{\term{1}'\ \term{2}}$}
        \end{prooftree}

        \begin{prooftree}
            \LabelR{E-AppAbs}
            \AxiomC{}
            \UnaryInfC{$\ss{
                (\lambda \var{}.\ \term{1})\ \term{2}
            }{
                [\var{} \mapsto \term{2}] \term{1}
            }$}
        \end{prooftree}

\section{5.3.8}

    \textit{Exercise 4.2.2 introduced a ``big-step'' style of evaluation for arithmetic expressions,}
    \textit{where the basic evaluation relation is ``term \term{} evaluates to final result \val{}''.}
    \textit{Show how to formulate the evaluation rules for lambda-terms in the big-step style.}

    \begin{prooftree}
        \LabelR{E-Abs}
        \AxiomC{}
        \UnaryInfC{$\bs{\lambda \var{}.\ \term{}}{\lambda \var{}.\ \term{}}$}
    \end{prooftree}

    \begin{prooftree}
        \LabelR{E-App}
        \AxiomC{$\bs{\term{1}}{\lambda \var{}.\ \term{}}$}
        \AxiomC{$\bs{\term{2}}{\val{2}}$}
        \AxiomC{$\bs{[\var{} \mapsto \val{2}]\ \term{}}{\term{}'}$}
        \TrinaryInfC{$\bs{\term{1}\ \term{2}}{\term{}'}$}
    \end{prooftree}

\end{document}


% To be compiled by XeLaTeX, preferably under TeX Live.
% LaTeX source for ``Yanqi Lake Lectures on Algebra'' Part III.
% Copyright 2019  李文威 (Wen-Wei Li).
% Permission is granted to copy, distribute and/or modify this
% document under the terms of the Creative Commons
% Attribution-NonCommercial 4.0 International (CC BY-NC 4.0)
% https://creativecommons.org/licenses/by-nc/4.0/

% To be included
\chapter{Warming up}

The reader might be familiar with most of the materials in this lecture. Our goal is to fix notation and present the basic structural results on Noetherian and Artinian rings or modules, including the celebrated Nakayama's Lemma which will be used repeatedly.

\section{Review on ring theory}
Let $R$ be a ring, supposed to be commutative with unit $1 \neq 0$ as customary. Recall that an ideal $I \subsetneq R$ is called
\begin{compactitem}
	\item \emph{prime}, if $ab \in I \iff (a \in I) \vee (b \in I)$;
	\item \emph{maximal}, if $I$ is maximal among the proper ideals of $R$ with respect to inclusion.
\end{compactitem}
Recall the following standard facts
\begin{itemize}
	\item $I$ is prime if and only if $R/I$ is an integral domain, i.e. has no zero divisors except $0$;
	\item $I$ is maximal if and only if $R/I$ is a field; in particular, maximal ideals are prime;
	\item every proper ideal $I$ is contained in a maximal ideal (an application of Zorn's Lemma).\index{Zorn's Lemma}
\end{itemize}

\begin{definition}[Local rings] \index{local ring}
	The ring $R$ is called \emph{local} if it has a unique maximal ideal, \emph{semi-local} if it has only finitely many maximal ideals.

	Let $\mathfrak{m}$ be the maximal ideal of a local ring $R$. We call $R/\mathfrak{m}$ the \emph{residue field} of $R$. A local homomorphism between local rings $\varphi: R_1 \to R_2$ is a ring homomorphism such that $\varphi(\mathfrak{m}_1) \subset \mathfrak{m}_2$. Consequently, local homomorphisms induce embeddings on the level of residue fields.
\end{definition}
Sometimes we denote a local ring by the pair $(R, \mathfrak{m})$.

\begin{remark}
	Let $R$ be a local ring with maximal ideal $\mathfrak{m}$, then $R^\times = R \smallsetminus \mathfrak{m}$. The is easily seen as follows. An element $x \in R$ is invertible if and only if $Rx = R$. Note that $Rx=R$ is equivalent to that $x$ is not contained in any maximal ideal, and the only maximal ideal is $\mathfrak{m}$.
\end{remark}

Throughout these lectures, we shall write \index{Spec@$\Spec(R)$} \index{MaxSpec@$\MaxSpec(R)$}
\begin{align*}
	\Spec(R) & := \{ \text{prime ideals of } R \}, \\
	\MaxSpec(R) & := \{ \text{maximal ideals of } R \}.
\end{align*}
They are called the \emph{spectrum} and the \emph{maximal spectrum} of $R$, respectively. The upshot is that $\Spec(R)$ comes with a natural topology.

\begin{definition}[Zariski topology] \index{Zariski topology}\index{$V(\mathfrak{a})$}
	For any ideal $\mathfrak{a} \subset R$, set $V(\mathfrak{a}) := \{ \mathfrak{p} \in \Spec(R): \mathfrak{p} \supset \mathfrak{a} \}$. Then there is a topology on $\Spec(R)$, called the \emph{Zariski topology}, whose closed subset are precisely $V(\mathfrak{a})$, for various ideals $\mathfrak{a}$.
\end{definition}
Indeed, we only have to prove the family of subsets $\{ V(\mathfrak{a}) : \mathfrak{a} \subset R \}$ is closed under finite union and arbitrary intersections. It boils down to the easy observation that $V(\mathfrak{a}) \cup V(\mathfrak{b}) = V(\mathfrak{a}\mathfrak{b})$ (check this!) and $\bigcap_{\mathfrak{a} \in \mathcal{A}} V(\mathfrak{a}) = V\left( \sum_{\mathfrak{a} \in \mathcal{A}} \mathfrak{a} \right)$, where $\mathcal{A}$ is any family of ideals.

Given a ring homomorphism $\varphi: R_1 \to R_2$, if $I \subset R_2$ is an ideal, then $\varphi^{-1}(I) \subset R_1$ is also an ideal.
\begin{proposition}
	Given $\varphi$ as above, it induces a continuous map
	\begin{align*}
		\varphi^\sharp: \Spec(R_2) & \longrightarrow \Spec(R_1) \\
		\mathfrak{p} & \longmapsto \varphi^{-1}(\mathfrak{p})
	\end{align*}
	with respect to the Zariski topologies on spectra.
\end{proposition}
\begin{proof}
	Clearly, $ab \in \varphi^{-1}(\mathfrak{p})$ is equivalent to $\varphi(a)\varphi(b) \in \mathfrak{p}$, which is in turn equivalent to $(\varphi(a) \in \mathfrak{p}) \vee (\varphi(b) \in \mathfrak{p})$ when $\mathfrak{p}$ is prime.

	To show the continuity of $\varphi^\sharp$, observe that for any ideal $\mathfrak{a} \subset R_1$ and $\mathfrak{p} \in \Spec(R_2)$, we have $\varphi^{-1}(\mathfrak{p}) \supset \mathfrak{a}$ if and only if $\mathfrak{p} \supset \varphi(\mathfrak{a})$, i.e. $\mathfrak{p} \in V(\varphi(\mathfrak{a}) R_2)$. Hence the preimage of closed subsets are still closed.
\end{proof}

More operations on spectra:
\begin{itemize}
	\item Take $R_1$ to be a subring of $R_2$ and $\varphi$ be the inclusion map, the map above becomes $\mathfrak{p} \mapsto \mathfrak{p} \cap R_1$.
	\item Take $\varphi: R \twoheadrightarrow R/I$ to be a quotient homomorphism, then $\varphi^{-1}$ is the usual bijection from $\Spec(R/I)$ onto $V(I)$.
	\item In general, $\varphi^{-1}$ does not induce $\MaxSpec(R_2) \to \MaxSpec(R_1)$, as illustrated in the case $\varphi: \Z \hookrightarrow \Q$.
\end{itemize}

At this stage, we can prove a handy result concerning prime ideals.
\begin{proposition}[Prime avoidance]\label{prop:prime-avoidance} \index{prime avoidance}
	Let $I$ and $\mathfrak{p}_1, \ldots, \mathfrak{p}_n$ be ideals of $R$ such that $I \subset \bigcup_{i=1}^n \mathfrak{p}_i$. Suppose that
	\begin{compactitem}
		\item either $R$ contains an infinite field, or
		\item at most two of the ideals $\mathfrak{p}_1, \ldots, \mathfrak{p}_n$ are non-prime,
	\end{compactitem}
	then there exists $1 \leq i \leq n$ such that $I \subset \mathfrak{p}_i$.
\end{proposition}
\begin{proof}
	If $R$ contains an infinite field $F$, the ideals are automatically $F$-vector subspaces of $R$. Since $I = \bigcup_{i=1}^r I \cap \mathfrak{p}_i$ whereas an $F$-vector space cannot be covered by finitely many proper subspaces, there must exist some $i$ with $I \cap \mathfrak{p}_i = I$.

	Under the second assumption, let us argue by induction on $n$ that $\forall i \; I \not\subset \mathfrak{p}_i$ implies $I \not\subset \bigcup_{i=1}^n \mathfrak{p}_i$. The case $n=1$ is trivial. When $n \geq 2$, by induction we may choose, for each $i$, an element $x_i \in I \smallsetminus \bigcup_{j \neq i} \mathfrak{p}_j$. Suppose on the contrary that $I \subset \bigcup_{j=1}^n \mathfrak{p}_j$, then we would have $x_i \in \mathfrak{p}_i$, for all $i=1, \ldots, n$.

	When $n=2$ we have $x_1 + x_2 \notin \mathfrak{p}_1 \cup \mathfrak{p}_2$ and $x_1 + x_2 \in I$, a contradiction. When $n > 2$, we may assume $\mathfrak{p}_1$ is prime, therefore
	\[ x_1 + \prod_{j=2}^n x_j \notin \bigcup_{i=1}^n \mathfrak{p}_i, \]
	again a contradiction.
\end{proof}

\begin{exercise}
	The following construction from \cite[Exercise 3.17]{Eis95} shows that the assumptions of Proposition \ref{prop:prime-avoidance} cannot be weakened. Take $R = (\Z/2\Z)[X, Y] / (X,Y)^2$, which has a basis $\{1, X, Y\}$ (modulo $(X,Y)^2$) as a $\Z/2\Z$-vector space. Show that the image $\mathfrak{m}$ of $(X, Y)$ in $R$ is the unique prime ideal, and can be expressed as a union of three ideals properly contained in $\mathfrak{m}$.
\end{exercise}

\section{Localization of rings and modules} \index{localization}\index{$M[S^{-1}]$}
Let $S$ be a \emph{multiplicative subset} of $R$, which means that
\begin{inparaenum}[(a)]\index{multiplicative subset}
	\item $1 \in S$,
	\item $S$ is closed under multiplication, and
	\item $0 \notin S$.
\end{inparaenum}
The \emph{localization} of $R$ with respect to $S$ is the ring $R[S^{-1}]$ formed by classes $[r,s]$ with $r \in R$, $s \in S$, modulo the equivalence relation
\[ [r,s] = [r',s'] \iff \exists t \in S, \; (rs' - r's)t = 0. \]

You should regard $[r,s]$ as a token for $r/s$; the ring structure of $R[S^{-1}]$ is therefore evident. In brief, localization amounts to formally inverting the elements of $S$, whence the notation $R[S^{-1}]$. Note that condition (c) guarantees $R[S^{-1}] \neq \{0\}$.

\begin{exercise}
	Given $R$ and $S$, show that $r \mapsto r/1$ yields a natural homomorphism $R \to R[S^{-1}]$ and show that its kernel equals $\{r: \exists s \in S, \; sr=0 \}$.
\end{exercise}

The universal property of $R \to R[S^{-1}]$ can be stated using commutative diagrams as follows.
\[
	\forall \left\{ \begin{array}{l}
		\varphi: R \to R': \; \text{ring homomorphism} \\
		\text{s.t. } \varphi(S) \subset (R')^\times
	\end{array}\right. ,\quad
	\begin{tikzcd}
		R \arrow[r] \arrow[rd, "\varphi"'] & R[S^{-1}] \arrow[d, dashed, "\exists!"] \\
		& R'
	\end{tikzcd}
\]

Consequently, if $S \subset R^\times$ then $R \simeq R[S^{-1}]$ canonically. Furthermore, the homomorphism $R \to R[S^{-1}]$ induces a bijection
\begin{equation}\label{eqn:localization-Spec} \begin{tikzcd}[row sep=tiny, column sep=small]
	\Spec(R[S^{-1}]) \arrow[leftrightarrow, r, "1:1"] & \left\{ \mathfrak{p} \in \Spec(R): \mathfrak{p} \cap S = \emptyset \right\} \arrow[phantom, r, "\subset" description] & \Spec(R) \\
	\mathfrak{p} R[S^{-1}] = \{ r/s: r \in \mathfrak{p}, \; s \in S \} & \mathfrak{p} \arrow[mapsto, l] & \\
	\mathfrak{q} \arrow[mapsto, r] & \text{its preimage} .
\end{tikzcd}\end{equation}

\begin{exercise}
	Check the properties above.
\end{exercise}

Let us review some important instances of the localization procedure.
\begin{enumerate}
	\item Take $S$ to be the subset of non zero-divisors of $R$. This is easily seen to be a multiplicative subset (check it!) and $K(R) := R[S^{-1}]$ is called the \emph{total fraction ring} of $R$. The reader is invited to check that $R \to K(R)$ is the ``biggest localization'' such that the natural homomorphism $R \to R[S^{-1}]$ is injective. Hint: state this in terms of universal properties.\index{total fraction ring}

	When $R$ is an integral domain, we shall take $S := R \smallsetminus \{0\}$; in this case the total fraction ring $\text{Frac}(R) := K(R)$ is the well-known \emph{field of fractions} of $R$.\index{field of fractions}

	\item Take any $\mathfrak{p} \in \Spec(R)$ and $S := R \smallsetminus \mathfrak{p}$. From the definition of prime ideals, one infers that $S$ is a multiplicative subset of $R$. The corresponding localization is denoted by $R \to R_{\mathfrak{p}} := R[S^{-1}]$. We see from \eqref{eqn:localization-Spec} that
		\[ \MaxSpec(R_{\mathfrak{p}}) = \{ \mathfrak{p} R_{\mathfrak{p}} \}; \]
	in particular, $R_{\mathfrak{p}}$ is a local ring with maximal ideal $\mathfrak{p}R_{\mathfrak{p}}$. This is the standard way to produce local rings; we say that $R_{\mathfrak{p}}$ is the localization of $R$ at the prime $\mathfrak{p}$.

	\item Suppose $f \in R$ is not nilpotent, that is, $f^n \neq 0$ for every $n$. Take $S := \{ f^n : n \geq 0 \}$. The corresponding localization is denoted by the self-explanatory notation $R \to R[f^{-1}]$.
\end{enumerate}

\begin{exercise}
	Describe the following localizations explicitly.
	\begin{enumerate}[(a)]
		\item $R = \Z$, and we localize at the prime ideal $(p)$ where $p$ is a prime number.
		\item $R = \CC[X_1, \ldots, X_n]$ and we localize at the maximal ideal generated by $X_1, \ldots, X_n$.
		\item $R = \CC\llbracket X \rrbracket$ (the ring of formal power series) and $S := \{X^n : n \geq 0 \}$.
	\end{enumerate}
\end{exercise}

\begin{exercise}
	Prove that $R[X]/(fX-1) \rightiso R[f^{-1}]$ by mapping $X \mapsto f^{-1}$. Hint: use the universal property.
\end{exercise}

Always let $S \subset R$ be a multiplicative subset. The localization $M[S^{-1}]$ of an $R$-module $M$ can be defined in the manner above, namely as the set of equivalence classes $[m,s]$ with $m \in M$ and $s \in S$, such that
\[ [m,s] = [m',s'] \iff \exists t \in S, \; t(s'm - sm')=0. \]
As in the case of rings, we shall write $m/s$ instead of $[m,s]$. It is an $R[S^{-1}]$-module, equipped with a natural homomorphism $M \to M[S^{-1}]$ of $R$-modules. This yields a functor: for any homomorphism $f: M \to N$ we have a natural $f[S^{-1}]: M[S^{-1}] \to N[S^{-1}]$, mapping $m/s$ to $f(m)/s$; furthermore $f[S^{-1}] \circ g[S^{-1}] = (f \circ g)[S^{-1}]$ whenever composition makes sense.

A slicker interpretation is to use the natural isomorphism $M[S^{-1}] \rightiso R[S^{-1}] \dotimes{R} M$ which maps $m/s$ to $(1/s) \otimes m$. Hereafter, we shall identify $M[S^{-1}]$ and $R[S^{-1}] \dotimes{R} M$ without further comments.

In the same vein, we may define $M[f^{-1}]$ and $M_{\mathfrak{p}}$, for non-nilpotent $f \in R$ and $\mathfrak{p} \in \Spec(R)$ respectively. Localization ``commutes'' with several standard operation on modules, which we sketch below. The details are left to the reader.
\begin{itemize}
	\item For $R$-modules $M$, $N$, we have a natural isomorphism of $R[S^{-1}]$-modules
		\begin{gather*}
			(M \dotimes{R} N)[S^{-1}] \simeq M[S^{-1}] \dotimes{R[S^{-1}]} N[S^{-1}], \\
			(M \oplus N)[S^{-1}] \simeq M[S^{-1}] \oplus N[S^{-1}].
		\end{gather*}
		Same for arbitrary direct sums. This is easily seen by viewing $M[S^{-1}]$ as $M \otimes_R R[S^{-1}]$.
	\item Note that $\Hom_R(M, N)$ is also an $R$-module: simply set $(rf)(m) = r \cdot f(m)$ for any $f \in \Hom_R(M, N)$. There is a natural homomorphism
		\begin{gather}\label{eqn:localization-Hom}
			\Hom_R(M, N)[S^{-1}] \to \Hom_{R[S^{-1}]} \left( M[S^{-1}], N[S^{-1}] \right)
		\end{gather}
		sending $s^{-1} \otimes \varphi$ to $s^{-1}\varphi: m/t \mapsto \varphi(m)/st$. It is clearly an isomorphism for $M = R$, thus also for $M = R^a$ where $a \in \Z_{\geq 0}$, but this is not the case in general, as there is no uniform bound for the ``denominators'' for any given $\psi: M[S^{-1}] \to N[S^{-1}]$ --- some finiteness condition is needed. Let us assume $M$ to be \emph{finitely presented}\index{finitely presented}, i.e. there is an exact sequence
		\[ R^a \to R^b \to M \to 0, \quad a,b \in \Z_{\geq 0}. \]
		In this case \eqref{eqn:localization-Hom} is an isomorphism, as easily seen from the commutative diagram with exact rows:
		\[ \begin{tikzcd}[column sep=tiny]
			0 \arrow[r] & \Hom(M,N)[S^{-1}] \arrow[r] \arrow[d] & \Hom(R^b, N)[S^{-1}] \arrow[r] \arrow[d, "\simeq"] & \Hom(R^a, N)[S^{-1}] \arrow[d, "\simeq"] \\
			0 \arrow[r] & \Hom(M[S^{-1}], N[S^{-1}]) \arrow[r] & \Hom(R[S^{-1}]^b, N[S^{-1}]) \arrow[r] & \Hom(R[S^{-1}]^a, N[S^{-1}])
		\end{tikzcd}\]
		Here we used the fact that localization preserves exactness: see the Proposition \ref{prop:localization-exactness} below.
	\item Let $\varphi: R \to R'$ be a ring homomorphism and $S \subset R$ be a multiplicative subset, so that $S' := \varphi(S) \subset R'$ is also multiplicative. View $R'$ as an $R$-module, then we have
	\[\begin{tikzcd}[row sep=tiny]
		\underbracket{R'[(S')^{-1}]}_{\text{as ring}} \arrow[r, "\sim"] & \underbracket{R'[S^{-1}]}_{\text{as module}} \arrow[equal, r] & R[S^{-1}] \dotimes{R} R' \\
		r'/\varphi(s) \arrow[mapsto, rr] & & (1/s) \otimes r' \\
		r'\varphi(r)/\varphi(s) & & (r/s) \otimes r' \arrow[mapsto, ll]
	\end{tikzcd}\]
	\item As a special case, take $\varphi$ to be a quotient homomorphism $R \to R/I$, we get a natural isomorphism
		\[ (R/I)[(S')^{-1}] \simeq R[S^{-1}] \dotimes{R} (R/I) = \frac{R[S^{-1}]}{I[S^{-1}]} \]
		from the right exactness of $\otimes$.
\end{itemize}

We prove an easy yet fundamental property of localizations, namely they are exact functors.
\begin{proposition}[Exactness of localization]\label{prop:localization-exactness}
	Let $S$ be any multiplicative subset of $R$. If
	\[ \cdots \to M_i \xrightarrow{f_i} M_{i+1} \to \cdots \]
	is an exact sequence of $R$-modules, then
	\[ \cdots \to M_i[S^{-1}] \xrightarrow{f_i[S^{-1}]} M_{i+1}[S^{-1}] \to \cdots \]
	is also exact.
\end{proposition}
\begin{proof}
	By homological common sense, we are reduced to the exact sequences
	\begin{inparaenum}[(i)]
		\item $0 \to M' \to M \to M''$ (i.e. left exactness),
		\item $M' \to M \to M'' \to 0$ (i.e. right exactness).
	\end{inparaenum}
	The case (ii) is known for tensor products in general.

	As for (i), note that for every homomorphism $g: M \to M''$,
	\begin{align*}
		\Ker\left(g[S^{-1}]\right) & = \left\{ \frac{y}{s} \in M[S^{-1}]: \exists t \in S, \; t g(y)=0 \right\}  \xlongequal{\because y/s = ty/ts} \left\{ \frac{y}{s} : y \in \Ker(g)  \right\} \\
		& = \Image\left[ \Ker(g)[S^{-1}] \to M[S^{-1}] \right].
	\end{align*}
	Thus it remains to show that if $f: M' \hookrightarrow M$, then $f[S^{-1}]: M'[S^{-1}] \to M[S^{-1}]$ is injective as well. If $x/s \mapsto f(x)/s = 0$ under $f[S^{-1}]$, there exists $t \in S$ such that $tf(x) = f(tx) = 0$ in $M$, therefore $tx=0$ in $M'$, but the latter condition implies $x/s = 0$ in $M'[S^{-1}]$.
\end{proof}

\begin{lemma}
	Let $M$ be an $R$-module. The localizations $M \to M_{\mathfrak{m}}$ for various maximal ideals $\mathfrak{m}$ assemble into an injection
	\[ M \hookrightarrow \prod_{\mathfrak{m} \in \MaxSpec(R)} M_{\mathfrak{m}}. \]
\end{lemma}
\begin{proof}
	Let $m \in M$ be such that $m \mapsto 0 \in M_{\mathfrak{m}}$ for all $\mathfrak{m}$. This means that for all $\mathfrak{m}$ there exists $s \in R \smallsetminus \mathfrak{m}$ such that $sm=0$. Hence the annihilator ideal $\text{ann}_R(m) := \{r \in R: rm=0 \}$ is not contained in any maximal ideal, thus $\text{ann}_R(m) = R$.
\end{proof}
There is an analogue for rings. Observe that when $R$ is an integral domain, all the localizations $R[S^{-1}]$ can be regarded as subrings of the field of fractions $\text{Frac}(R)$.
\begin{lemma}
	Let $R$ be an integral domain, then $R = \bigcap_{\mathfrak{m} \in \MaxSpec(R)} R_{\mathfrak{m}}$ as subrings of $\mathrm{Frac}(R)$.
\end{lemma}
\begin{proof}
	Only the inclusion $\supset$ requires proof. Let $x \in \text{Frac}(R)$ and define $D := \{r \in R: rx \in R \}$ (the ideal of denominators). Suppose $x \in R_{\mathfrak{m}}$ for all maximal $\mathfrak{m}$, then $D \not\subset \mathfrak{m}$ for all maximal $\mathfrak{m}$. The same reasoning as above leads to $D=R$.
\end{proof}
It will be important to gain finer control on the ideals $\mathfrak{m}$ in the assertion above, say by using some prime ideals ``lower'' than the maximal ones. We will return to this issue later.

\section{Radicals and Nakayama's lemma}
We begin with two important notions of radicals. The first version is defined as follows. Given an ideal $I$ of $R$, the \emph{nilpotent radical} $\sqrt{I}$ is defined to be
\[ \sqrt{I} := \{ r \in R: \exists n, \; r^n \in I \}. \]
It is readily seen to be an ideal from the binomial identity $(a+b)^{2n} = \sum_{k=0}^{2n} \binom{2n}{k} a^k b^{2n-k}$. It should also be clear that $\sqrt{I} \subset R$ equals the preimage of $\sqrt{0} \subset R/I$. \index{nilpotent radical}

\begin{exercise}
	Show that $\sqrt{\sqrt{I}} = I$ for all ideal $I$.
\end{exercise}

\begin{proposition}
	Let $I$ be a proper ideal of $R$. We have
	\[ \sqrt{I} = \bigcap_{\substack{\mathfrak{p} \in \Spec(R) \\ \mathfrak{p} \supset I }} \mathfrak{p}. \]
\end{proposition}
\begin{proof}
	By replacing $R$ by $R/I$, this is easily reduced to the case $I = \{0\}$. If $r$ is nilpotent and $\mathfrak{p} \in \Spec(R)$, then $r^n = 0 \in \mathfrak{p}$ implies $r \in \mathfrak{p}$. Conversely, suppose that $r$ is not nilpotent. There exists a prime ideal in $R[r^{-1}]$, which comes from some $\mathfrak{p} \in \Spec(R)$ with $r \in R \smallsetminus \mathfrak{p}$ by \eqref{eqn:localization-Spec}. Hence $r \notin \mathfrak{p}$.
\end{proof}
\begin{remark}\index{reduced ring}
	A ring $R$ is called \emph{reduced} if $\sqrt{0} = \{0\}$. In any case, $R_\text{red} := R \big/ \sqrt{0}$ is a reduced ring. Furthermore, any reduced quotient of $R$ factors through $R_\text{red}$.
\end{remark}

The second radical is probably familiar to the readers. The \emph{Jacobson radical} $\text{rad}(R)$ of the ring $R$ is the intersection of all maximal ideals. The previous proposition implies $\text{rad}(R) \supset \sqrt{(0)}$. Note that
\[ a \in \text{rad}(R) \implies (1+a) \in R^\times . \]
Indeed, $1+a$ cannot be contained in any maximal ideal $\mathfrak{m}$, for otherwise $1 = (1+a)-a \in \mathfrak{m}$, which is absurd. \index{Jacobson radical}

To prove the celebrated Nakayama's Lemma, let us recall an easy variant of the Cayley--Hamilton theorem from linear algebra.
\begin{lemma}\label{prop:Cayley-Hamilton}\index{Cayley--Hamilton theorem}
	Suppose that $I \subset R$ is an ideal, $M$ is an $R$-module with generators $x_1, \ldots, x_n$ and $\varphi \in \End_R(M)$ satisfies $\varphi(M) \subset IM$, then there exists a polynomial $P(X) = X^n + a_{n-1} X^{n-1} + \cdots + a_0 \in R[X]$ with $a_i \in I$, such that $P(\varphi) = \varphi^n + a_{n-1} \varphi^{n-1} + \cdots + a_0 = 0$.
\end{lemma}
\begin{proof}
	Write $\varphi(x_i) = \sum_{j=1}^n a_{ij} x_j$ where $a_{ij} \in I$. Set $A := (a_{ij})_{1 \leq i,j \leq n} \in \text{Mat}_n(R)$. Regard $M$ as an $R[X]$-module by letting $X$ act as $\varphi$. Then we have the matrix equation over $R[X]$
	\[ (X \cdot \identity_{n \times n} - A) \begin{pmatrix} x_1 \\ \vdots \\ x_n \end{pmatrix} = \begin{pmatrix} 0 \\ \vdots \\ 0 \end{pmatrix} \]
	Multiplying by the cofactor matrix $(X \cdot \identity_M - A)^\vee$ on the left, we see that $P(X) := \det(X \cdot \identity_{n \times n} - A) \in R[X]$ acts as $0$ on each $x_i$, thus on the whole $M$. This is the required polynomial.
\end{proof}

\begin{theorem}[Nakayama's Lemma]\label{prop:NAK}\index{Nakayama's lemma}
	Suppose that $M$ is a finitely generated $R$-module and $I$ is an ideal of $R$ such that $IM = M$. Then there exists $a \in I$ such that $(1+a)M=0$. If $I \subset \text{rad}(R)$, then we have $M = \{0\}$ under these assumptions.
\end{theorem}
\begin{proof}
	Write $M = Rx_1 + \cdots + Rx_n$. Plug $\varphi = \identity_M$ into Lemma \ref{prop:Cayley-Hamilton} to deduce that $P(\identity_M) = 1 + \underbracket{a_{n-1} + \cdots + a_0}_{=: a \in I}$ acts as $0$ on $M$. This proves the first part. Assume furthermore that $I \subset \text{rad}(R)$, then $1+a \in R^\times$ so that $M = (1+a)M = 0$.
\end{proof}

\begin{figure}[h]
	\centering \includegraphics[height=180pt]{Nakayama.png} \\ \vspace{1em}
	\begin{minipage}{0.7\textwidth}
		\small Nakayama's Lemma is named after Tadashi Nakayama (1912---1964). Picture borrowed from \cite{obi-NAK}.
	\end{minipage}
\end{figure}

\begin{corollary}\label{prop:NAK-generation}
	Let $M$ be a finitely generated $R$-module, and let $I \subset \mathrm{rad}(R)$ be an ideal of $R$. If the images of $x_1, \ldots, x_n \in M$ in $M/IM$ form a set of generators, then $x_1, \ldots, x_n$ generate $M$.
\end{corollary}
\begin{proof}
	Apply Theorem \ref{prop:NAK} to $N := M/(Rx_1 + \cdots + Rx_n)$; our assumption $M = IM + Rx_1 + \cdots + Rx_n$ entails that $IN=N$, thus $N=0$.
\end{proof}

We record another amusing consequence of Theorem \ref{prop:NAK}.
\begin{proposition}
	Let $M$ be a finitely generated $R$-module and $\psi \in \End_R(M)$. If $\psi$ is surjective then $\psi$ is an automorphism.
\end{proposition}
\begin{proof}
	Introduce a variable $Y$. Make $M$ into an $R[Y]$-module by letting $Y$ act as $\psi$. Put $I := (Y)$ so that $IM=M$. Theorem \ref{prop:NAK} yields some $Q(Y) \in R[Y]$ satisfying $(1 - Q(Y)Y) M = 0$, that is, $Q(\psi)\psi = \identity_M$.
\end{proof}

\section{Noetherian and Artinian rings}
An $R$-module $M$ is called \emph{Noetherian} (resp. \emph{Artinian}) if every ascending (resp. descending) chain of submodules eventually stabilizes. Recall that in a short exact sequence $0 \to M' \to M \to M'' \to 0$, we have $M$ is Noetherian (resp. Artinian) if and only if $M'$ and $M''$ are. Being both Noetherian and Artinian is equivalent to being a module of \emph{finite length}\index{length}, that is, a module admitting composition series. \index{Artinian}\index{Noetherian}

If we take $M := R$ on which $R$ acts by multiplication, then the submodules are precisely the ideals of $R$. We say that $R$ is a Noetherian (resp. Artinian) ring if $R$ as an $R$-module is Noetherian (resp. Artinian); this translates into the corresponding chain conditions on the ideals. Both chain conditions are preserved under passing to quotients and localizations. Finitely generated modules over a Noetherian ring are Noetherian. The following result ought to be known to the readers.
\begin{theorem}[Hilbert's Basis Theorem] \index{Hilbert's basis theorem}
	If $R$ is Noetherian, then so is the polynomial algebra $R[X_1, \ldots, X_n]$ for any $n \in \Z_{\geq 1}$.
\end{theorem}
Joint with the foregoing remarks, we infer that finitely generated algebras over Noetherian rings are still Noetherian.

On the other hand, being Artinian is a rather stringent condition on rings.
\begin{theorem}\label{prop:Artinian-length}
	A ring $R$ is Artinian if and only if $R$ is of finite length as an $R$-module. Such rings are semi-local.
\end{theorem}
\begin{proof}
	As noticed before, having finite length implies that $R$ is Noetherian as well as Artinian. Assume conversely that $R$ is an Artinian ring. First we claim that $\MaxSpec(R)$ is finite, i.e. $R$ is semi-local. If there were an infinite sequence of distinct maximal ideals $\mathfrak{m}_1, \mathfrak{m}_2, \ldots$, we would have an infinite chain
	\[ \mathfrak{m}_1 \supset \mathfrak{m}_1 \mathfrak{m}_2 \supset \mathfrak{m}_1 \mathfrak{m}_2 \mathfrak{m}_3 \supset \cdots. \]
	This chain is strictly descending, since $\mathfrak{m}_1 \cdots \mathfrak{m}_i = \mathfrak{m}_1 \cdots \mathfrak{m}_{i+1}$ would imply $\mathfrak{m}_{i+1} \supset \mathfrak{m}_1 \cdots \mathfrak{m}_i$, hence $\mathfrak{m}_{i+1} \supset \mathfrak{m}_j$ for some $1 \leq j \leq i$ because maximal ideals are prime. From the Artinian property we conclude that there are only finitely many maximal ideals $\mathfrak{m}_1, \ldots, \mathfrak{m}_n$ of $R$.

	Set $\mathfrak{a} := \mathfrak{m}_1 \cdots \mathfrak{m}_n$. Since $R$ is Artinian we must have $\mathfrak{a}^k = \mathfrak{a}^{k+1}$ for some $k > 0$. We claim that $\mathfrak{a}^k = 0$.

	Put $\mathfrak{b} := \{r \in R: r\mathfrak{a}^k = 0 \}$, we have to show $\mathfrak{b}=R$. If not, let $\mathfrak{b}'$ be a minimal ideal lying strictly over $\mathfrak{b}$. Thus $\mathfrak{b}' = Rx + \mathfrak{b}$ for any $x \in \mathfrak{b}' \smallsetminus \mathfrak{b}$. We must have $\mathfrak{a}x + \mathfrak{b} \subsetneq \mathfrak{b}'$, for otherwise $M := \mathfrak{b}'/\mathfrak{b}$ is finitely generated (say by $x$) and satisfies $M = \mathfrak{a}M$, then Theorem \ref{prop:NAK} plus $\mathfrak{a} \subset \text{rad}(R)$ would imply $M = \{0\}$, which is absurd. By minimality we have $\mathfrak{b} = \mathfrak{a}x + \mathfrak{b}$. It follows that $\mathfrak{a}x \subset \mathfrak{b}$, i.e. $\mathfrak{a}^{k+1} x = 0$; from $\mathfrak{a}^k = \mathfrak{a}^{k+1}$ we infer $x \in \mathfrak{b}$. Contradiction.

	All in all, we obtain a descending chain of ideals
	\begin{align*}
		R & \supset \mathfrak{m}_1 \supset \mathfrak{m}_1 \mathfrak{m}_2 \supset \cdots \supset \mathfrak{m}_1 \cdots \mathfrak{m}_n = \mathfrak{a} \\
		& \supset \mathfrak{a} \mathfrak{m}_1 \supset \mathfrak{a} \mathfrak{m}_1 \mathfrak{m}_2 \supset \cdots \supset \mathfrak{a} \mathfrak{m}_1 \cdots \mathfrak{m}_n = \mathfrak{a}^2 \\
		& \supset \cdots \supset \mathfrak{a}^k = \{0\}.
	\end{align*}
	Each subquotient thereof, which is \textit{a priori} an $R$-module, is actually an $R/\mathfrak{m}_i$-vector space for some $1 \leq i \leq n$. Such a vector space must also satisfy the descending chain condition on vector subspaces, otherwise pulling-back will contradict the Artinian assumption on $R$. Artinian vector spaces must be finite-dimensional. It follows that all these subquotients are of finite length, hence so is $R$ itself.
\end{proof}

\begin{corollary}\label{prop:Artinian-dim-0}
	A ring $R$ is Artinian if and only if it is Noetherian and every prime ideal of $R$ is maximal.
\end{corollary}
\begin{proof}
	If $R$ is Artinian, then $R$ is of finite length, hence is Noetherian as well. For every prime ideal $\mathfrak{p}$, we have $\mathfrak{p} \supset \{0\} = (\mathfrak{m}_1 \cdots \mathfrak{m}_n)^k$ in the notations of the proof above, therefore $\mathfrak{p} \supset \mathfrak{m}_i$ for some $i$, so $\mathfrak{p} = \mathfrak{m}_i$ is maximal.

	Conversely, if $R$ is Noetherian but of infinite length, then the nonempty set of ideals
	\[ \mathcal{S} := \left\{ \text{ideals } I \subsetneq R: R/I \text{ has infinite length} \right\} \]
	contains a maximal element $\mathfrak{p}$. We contend that $\mathfrak{p}$ is prime. If $xy \in \mathfrak{p}$ with $x,y \notin \mathfrak{p}$, then $R/(\mathfrak{p}+Rx)$ has finite length by the choice of $\mathfrak{p}$; on the other hand, $\mathfrak{a} := \{ r \in R: rx \in \mathfrak{p}\} \supsetneq \mathfrak{p}$ (as $y \in \mathfrak{a}$), hence $R/\mathfrak{a}$ has finite length as well. From the short exact sequence $0 \to R/\mathfrak{a} \xrightarrow{x} R/\mathfrak{p} \to R/(\mathfrak{p}+Rx) \to 0$ we see $R/\mathfrak{p}$ has finite length, contradiction.

	If we assume moreover that every prime ideal is maximal, then for the $\mathfrak{p}$ chosen above, $R/\mathfrak{p}$ will be a field, thus of finite length. This is impossible.
\end{proof}

Rings whose prime ideals are all maximal are said to have \emph{dimension zero}, in the sense of Krull dimensions; we shall return to this point in \S\ref{sec:Krull-dimension}.

\section{What is commutative algebra?}
In broad terms, \emph{commutative algebra} is the study of commutative rings. Despite its intrinsic beauty, we prefer to motivate from an external point of view. See also \cite{Eis95}.

\begin{asparaenum}[(A)]
	\item \textbf{Algebraic geometry}\index{variety}. To simplify matters, we consider affine algebraic varieties over an algebraically closed field $\Bbbk$. Roughly speaking, such a variety is the zero locus $\mathcal{X} = \{ f_1 = \cdots = f_r = 0 \}$ in $\mathbb{A}^n = \Bbbk^n$ of $f_i \in \Bbbk[X_1, \ldots, X_n]$. The choice of equations is of course non-unique: what matters is the ideal $I(\mathcal{X}) := \{ f \in \Bbbk[X_1, \ldots, X_n] : f|_{\mathcal{X}} = 0 \}$. Conversely, every ideal $\mathfrak{a}$ defines a subset $V(\mathfrak{a}) := \{x \in \Bbbk^n : \forall f \in \mathfrak{a}, \; f(x)=0 \}$. As consequences of Hilbert's Nullstellensatz\index{Nullstellensatz}, which we will discuss later, we have
	\[ V \circ I(\mathcal{X}) = \mathcal{X}, \qquad I \circ V(\mathfrak{a})  = \sqrt{\mathfrak{a}}. \]
	One can deduce from this that the (closed) subvarieties of $\mathbb{A}^n$ are in bijection with ideals $\mathfrak{a}$ satisfying $\sqrt{\mathfrak{a}} = \mathfrak{a}$.

	Furthermore, $\Bbbk[\mathcal{X}] := \Bbbk[X_1, \ldots, X_n]/I(\mathcal{X})$ may be regarded as the ring of ``regular functions'' (i.e. functions definable by means of polynomials) on $\mathcal{X}$, and $\MaxSpec(\Bbbk[\mathcal{X}])$ is in bijection with the points of $\mathcal{X}$: to $x = (x_1, \ldots, x_n) \in \mathcal{X}$ we attach
	\[ \mathfrak{m}_x = (X_1 - x_1, \ldots, X_n - x_n) \supset I(\mathcal{X}). \]
	By passing to the ring $\Bbbk[\mathcal{X}]$, we somehow obtain a description of $\mathcal{X}$ that is independent of embeddings into affine spaces. Moreover, $\mathcal{X}$ inherits the Zariski topology from that on $\Spec(\Bbbk[\mathcal{X}])$.

	Naively speaking, the geometric properties of $\mathcal{X}$ transcribe in ring-theoretic terms to the reduced Noetherian $\Bbbk$-algebra $\Bbbk[\mathcal{X}]$. For example, assume that $f \in \Bbbk[\mathcal{X}]$ is not nilpotent, then the formation of $\Bbbk[\mathcal{X}][f^{-1}]$ corresponds to taking the Zariski-open subset $\mathcal{X}_f = \{x \in \mathcal{X}: f(x) \neq 0 \}$ of $\mathcal{X}$. This may be explained as follows:
	\[ \mathcal{X}_f \simeq \left\{ (x_1, \ldots, x_n, y) : f_1(x_1, \ldots, x_n) = \cdots = f_r(x_1, \ldots, x_n) = 0, \; f(x_1, \ldots, x_n)y = 1 \right\} \]
	which is also an affine algebraic variety in $\Bbbk^{n+1}$, and one may verify that $\Bbbk[\mathcal{X}_f] = \Bbbk[\mathcal{X}][f^{-1}]$.

	\item \textbf{Invariant theory}\index{invariant theory}. Let $G$ be a group acting on a finite-dimensional $\Bbbk$-vector space $V$ from the right, and let $\Bbbk[V]$ be the $\Bbbk$-algebra of polynomials on $V$. Thus $\Bbbk[V]$ carries a left $G$-action by $gf(v) = f(vg)$. For ``reasonable'' groups $G$, say finite or $\Bbbk$-algebraic ones, the classical invariant theory seeks to describe the subalgebra $\Bbbk[V]^G$ of invariants\footnote{More generally, we are also interested in the algebra of invariant differential operators with polynomial coefficients.} in terms of \emph{generators} and \emph{relations}.

	In particular, one has to know when is the algebra $\Bbbk[V]^G$ finitely generated. This is actually the source of many results in commutative algebra, such as the Basis Theorem and Nullstellensatz of Hilbert. For example, let the symmetric group $G = \mathfrak{S}_n$ act on $V = \Bbbk^n$ in the standard manner, then our question is completely answered by the following classical result: $\Bbbk[V]^G$ equals the polynomial algebra $\Bbbk[e_1, \ldots, e_n]$, where $e_i$ stands for the $i$-th elementary symmetric function in $n$ variables.

	The same questions may be posed for any affine algebraic variety $V$. From the geometric point of view, if $\Bbbk[V]^G$ is finitely generated, it will consist of regular functions of some kind of quotient variety $V /\!/ G$. The study of quotients in this sense naturally leads to \emph{geometric invariant theory}, for which we refer to \cite{AG4} for details.
\end{asparaenum}


\section{Introduction}

The main focus of the report is to find anomaly in data set from NSL-KDD dataset. Most of these patterns represent normal behaviour, but there are several cases that due to faulty device or attack to the network with abnormal patterns. In this report, spectral clustering method is going to be used.

Most of spectral clustering algorithms here are highly dependent on the eigenvector decomposition of the graph Laplacian and are variants of the normalized cut method. Basic idea of clustering started from \textit{Normalized Cuts and Image Segmentation}. All graph clustering objective function can be written as: \\

\begin{figure}[ht]
\begin{mdframed}
$J = cut(A,B)/assoc(1) + cut(A,B)/assoc(2)$. \\
$assoc(1) = \sum_{i \in C_k} 1$ for \textit{Ratio cut}.  \\
$assoc(1) \sum_{i,j \in C_k} w_{i,j}$ for \textit{Normalized cut}. \\
\end{mdframed}
\caption{Objective function of graph clustering algorithm}
\end{figure}

In \textit{Learning spectral clustering}, a new algorithm for spectral clustering with an objective function that minimize the error measure between a given partition and the minimum normalized cut partition is suggested. In \textit{On Spectral Clustering: Analysis and an algorithm}, a similar approach with previous one is used except the authors normalize the rows of the chosen eigenvectors. In \textit{Kernel K-means, Spectral Clustering and Normalized Cut}, the authors present kernel k-means algorithm and derive the nomi- nalized cut algorithm as a special case of the kernel k-means. In \textit{Linearized Cluster Assignment via Spectral Ordering}, the authors suggest a new way clustering method that is able to partition the data into $K$ clusters. \\


\documentclass{ximera}
\input{../preamble}
\title{Exercises: Centers of Mass and Centroids}
%%%%%\author{Philip T. Gressman}

\begin{document}
\begin{abstract}
Various questions relating to centers of mass and centroids.
\end{abstract}
\maketitle

%\begin{exercise}%%Community Calculus Section 09.06
%A thin plate fills the upper half of the unit circle $x^2 + y^2 = 1$. Find the centroid.
%\[ \overline{x} = \answer{0} \text{ and } \overline{y} = \answer{\frac{4}{3 \pi}}. \]
%\end{exercise}

\begin{exercise}%%Community Calculus 09.06
Find the centroid of the region bounded above by $y = x$ and below by $y = x^2$.
\[ \overline{x} = \answer{\frac{1}{2}} \text{ and } \overline{y} = \answer{\frac{2}{5}}. \]
\end{exercise}

\begin{exercise}%%Community Calculus 09.06
Find the centroid of the region bounded above by $y = 4-x^2$ and below by $y = 0$.
\[ \overline{x} = \answer{0} \text{ and } \overline{y} = \answer{\frac{8}{5}}. \]
\end{exercise}

\begin{exercise}
A thin plate in the plane defined by $x^2 \leq y \leq 1$ and $x \geq 0$ has density $y$ at the point $(x,y)$. Compute the center of mass.
\begin{hint}
Use $y$ as the variable of slicing. The center of mass of a single slice $(\tilde x, \tilde y)$ is then $(\sqrt{y}/2,y)$.
\end{hint}
\[ \overline{x} = \answer{\frac{1}{2}} \text{ and } \overline{y} = \answer{\frac{5}{7}}. \]
\end{exercise}

\begin{exercise}
A thin plate in the plane defined by $x^2 \leq y \leq 2x^2$ and $0 \leq x \leq 1$ has density $x$ at the point $(x,y)$. Compute the center of mass.
\begin{hint}
Use $x$ as the variable of slicing. The center of mass of a single slice $(\tilde x, \tilde y)$ is then $(x,3x^2/2)$.
\end{hint}
\[ \overline{x} = \answer{\frac{4}{5}} \text{ and } \overline{y} = \answer{1}. \]
\end{exercise}

\begin{exercise}
The same thin plate as above ($x^2 \leq y \leq 2x^2$ and $0 \leq x \leq 1$) now has density $x^{-2}$ at the point $(x,y)$.  Because the density of the plate is now higher near the origin than in the previous problem, this suggests that the center of mass will shift \wordChoice{\choice{away from}\choice[correct]{towards}} the origin relative to the previous exercise.

Compute the center of mass.
\[ \overline{x} = \answer{\frac{1}{2}} \text{ and } \overline{y} = \answer{\frac{1}{2}}. \]
\end{exercise}

\begin{exercise}
Compute the centroid of a thin wire along the graph $y = \sqrt{1-x^2}$ between $x = 0$ and $x=1$.
\begin{hint}
Recall that
\[ M = \int ds \]
\[ \overline{x} = \frac{1}{M} \int x ds \]
\[ \overline{y} = \frac{1}{M} \int y ds \]
where $ds$ is the arc length element. We also know that
\[ \int \frac{dx}{\sqrt{1-x^2}} = \arcsin x + C. \]
\end{hint}
\[ \overline{x} = \answer{\frac{2}{\pi}} \text{ and } \overline{y} = \answer{\frac{2}{\pi}}. \]
\end{exercise}

\section*{Sample Quiz Questions}
\begin{question}%%%%%[CentroidQuad01]

Compute the centroid of the region bounded by the inequalities \[-2 \leq x \leq 0 \qquad \text{ and } \qquad {3x^2-\frac{13}{2}} \leq y \leq {3x^2-\frac{11}{2}}.\]
(Hints won't be revealed until after you choose a response.)
\begin{multiplechoice}
\choice{\(\displaystyle \left(-\frac{3}{2},-3 \right)\)}
\choice{\(\displaystyle \left(-1,-3 \right)\)}
\choice{\(\displaystyle \left(-\frac{1}{2},-3 \right)\)}
\choice{\(\displaystyle \left(-\frac{3}{2},-2 \right)\)}
\choice[correct]{\(\displaystyle \left(-1,-2 \right)\)}
\choice{\(\displaystyle \left(-\frac{1}{2},-2 \right)\)}
\end{multiplechoice}
\begin{feedback}
The key calculations are as follows:
\[ \begin{aligned}
M & = \int_{-2}^{0} \left[ \left({3x^2-\frac{11}{2}}\right) - \left({3x^2-\frac{13}{2}}\right) \right] dx , \\
M_y & = \int_{-2}^{0} x \left[ \left({3x^2-\frac{11}{2}}\right) - \left({3x^2-\frac{13}{2}}\right) \right] dx, \\
M_x & = \frac{1}{2} \int_{-2}^{0} \left[ \left({3x^2-\frac{11}{2}}\right)^2 - \left({3x^2-\frac{13}{2}}\right)^2 \right] dx.
\end{aligned}\]
 \begin{hint}
 \[ \begin{aligned}
M & = \int_{-2}^{0} \left[ \left({3x^2-\frac{11}{2}}\right) - \left({3x^2-\frac{13}{2}}\right) \right] dx = \int_{-2}^{0} \left[{1}\right] dx = 2, \\
M_y & = \int_{-2}^{0} x \left[ \left({3x^2-\frac{11}{2}}\right) - \left({3x^2-\frac{13}{2}}\right) \right] dx = \int_{-2}^{0} x \left[{1}\right] dx = -2, \\
M_x & = \frac{1}{2} \int_{-2}^{0} \left[ \left({3x^2-\frac{11}{2}}\right)^2 - \left({3x^2-\frac{13}{2}}\right)^2 \right] dx = \int_{-2}^{0} \left[{3x^2-6}\right] = -4, \\
 \overline{x} &  = \frac{M_y}{M} = -1, \\
 \overline{y} &  = \frac{M_x}{M} = -2.\end{aligned}\]
 \end{hint}
\end{feedback}

\end{question}

\section*{Sample Exam Questions}

\begin{question}%%%%%[2015C.12]

Find the \(y\)-coordinate of the centroid of the region bounded by the \(x\)-axis, the \(y\)-axis, and the graph of \(y = \cos x\) for \(0 \leq x \leq \pi/2\) if the density is constant.
\begin{hint}
Use the identity \[ \cos^2 x  = \frac{1 + \cos 2x}{2} \]
to calculate the integral of $\cos^2 x$.
\end{hint}
\begin{multiplechoice}
\choice{\(\displaystyle \frac{\pi}{18}\)}
\choice{\(\displaystyle \frac{\pi}{12}\)}
\choice[correct]{\(\displaystyle \frac{\pi}{8}\)}
\choice{\(\displaystyle \frac{\pi}{6}\)}
\choice{\(\displaystyle \frac{\pi}{4}\)}
\choice{\(\displaystyle \frac{\pi}{2}\)}
\end{multiplechoice}
\begin{feedback}
The area of the region is given by
\[ M = \int_0^{\frac{\pi}{2}} \cos x~dx = 1 \]
and
\[\begin{aligned}
 M_x & = \int_0^{\frac{\pi}{2}} \frac{0 + \cos x}{2} \cos x~ dx = \frac{1}{2} \int_0^{\frac{\pi}{2}} \cos^2 x ~ dx \\
& \frac{1}{2} \int_0^{\frac{\pi}{2}} \frac{1 + \cos 2x}{2} dx = \frac{\pi}{8}.
\end{aligned}\]
Therefore \(\overline{y} = M_x / M = \pi/8\).
\end{feedback}

\end{question}

\begin{question}%%%%%[2016C.02]

Find the \(y\)-coordinate of the centroid of the region in the upper half-plane (i.e., for \(y > 0\)) bounded by the semicircle \(y = \sqrt{1-x^2}\). (It is easiest to use a geometric formula to find the area of the region.)
\begin{multiplechoice}
\choice{\(\displaystyle \frac{4 \pi}{3}\)}
\choice[correct]{\(\displaystyle \frac{4}{3 \pi}\)}
\choice{\(\displaystyle \frac{7 \pi}{3}\)}
\choice{\(\displaystyle \frac{7}{3 \pi}\)}
\choice{\(\displaystyle \frac{28 \pi}{9}\)}
\choice{\(\displaystyle \frac{28}{9 \pi}\)}
\end{multiplechoice}

\end{question}

\end{document}


\chapter{Forcing}
We are now going to introduce Paul Cohen's technique of \vocab{forcing},
which we then use to break the Continuum Hypothesis.

Here is how it works.
Given a transitive model $M$ and a poset $\Po$ inside it,
we can consider a ``generic'' subset $G \subseteq \Po$, where $G$ is not in $M$.
Then, we are going to construct a bigger universe $M[G]$ which contains both $M$ and $G$.
(This notation is deliberately the same as $\ZZ[\sqrt2]$, for example -- in the algebra case,
we are taking $\ZZ$ and adding in a new element $\sqrt 2$, plus everything that can be generated from it.)
By choosing $\Po$ well, we can cause $M[G]$ to have desirable properties.

Picture:

\begin{center}
	\begin{asy}
		size(14cm);
		pair A = (12,30);
		pair B = -conj(A);
		pair M = midpoint(A--B);
		pair O = origin;
		MP("V", A, dir(10));
		draw(A--O--B);

		fill(A--O--B--cycle, opacity(0.3)+palecyan);

		MP("V_0 = \varnothing", origin, dir(-20));
		MP("V_1 = \{\varnothing\}", 0.05*A, dir(0));
		MP("V_2 = \{\varnothing, \{\varnothing\} \}", 0.10*A, dir(0));

		pair A1 = 0.4*A;
		pair B1 = 0.4*B;
		draw(MP("V_\omega", A1, dir(0))--B1);
		draw(MP("V_{\omega+1} = \mathcal P(V_\omega)", 0.45*A, dir(0))--0.45*B);
		Drawing("\omega", 0.45*M, dir(45));

		filldraw(O--A1--(A1+0.30*M)..(0.85*M)..(B1+0.30*M)--B1--cycle,
			opacity(0.3)+lightgreen, heavygreen+1);
		draw(O--0.85*M, heavygreen+1);
		filldraw(O--(1.3*A1)..(0.85*M)..(1.3*B1)--cycle,
			opacity(0.1)+lightred, heavyred+1);

		Drawing("\aleph_1^V", 0.95*M, dir(0));

		pair F = 0.55*B+0.10*A;
		Drawing("f", F, dir(90));
		draw(F--0.55*M, dotted, EndArrow, Margins);
		draw(F--0.45*M, dotted, EndArrow, Margins);

		Drawing("\aleph_1^M", 0.55*M, dir(45));
		Drawing("\aleph_1^{M[G]}", 0.65*M, dir(45));

		draw(0.85*M--M);
		MP("\mathrm{On}^V", M, dir(90));
		MP("\mathrm{On}^M = \mathrm{On}^{M[G]}", 0.85*M, dir(135));

		MP("M \subseteq M[G]", 0.85*M, 3*dir(0)+dir(45));

		Drawing("\mathbb P", 0.3*M+0.3*A, dir(135));
		Drawing("G", 0.55*A+0.1*B, dir(45));
	\end{asy}
\end{center}

The model $M$ is drawn in green, and its extension $M[G]$ is drawn in red.

The models $M$ and $M[G]$ will share the same ordinals, which is represented here
as $M$ being no taller than $M[G]$.
But one issue with this is that forcing may introduce some new bijections between cardinals of $M$
that were not there originally; this leads to the phenomenon called \vocab{cardinal collapse}:
quite literally, cardinals in $M$ will no longer be cardinals in $M[G]$, and instead just an ordinal.
This is because in the process of adjoining $G$, we may accidentally pick up some bijections which were not in the earlier universe.
In the diagram drawn, this is the function $f$ mapping $\omega$ to $\aleph_1^M$.
Essentially, the difficulty is that ``$\kappa$ is a cardinal'' is a $\Pi_1$ statement.

In the case of the Continuum Hypothesis, we'll introduce a $\Po$ such that
any generic subset $G$ will ``encode'' $\aleph_2^M$ real numbers.
We'll then show cardinal collapse does not occur, meaning $\aleph_2^{M[G]} = \aleph_2^M$.
Thus $M[G]$ will have $\aleph_2^{M[G]}$ real numbers, as desired.

\section{Setting up posets}
\prototype{Infinite Binary Tree}
Let $M$ be a transitive model of $\ZFC$.
Let $\Po = (\Po, \le) \in M$ be a poset with a maximal element $1_\Po$
which lives inside a model $M$.
The elements of $\Po$ are called \vocab{conditions};
because they will force things to be true in $M[G]$.

\begin{definition}
	A subset $D \subseteq \Po$ is \vocab{dense} if for all $p \in \Po$,
	there exists a $q  \in D$ such that $q \le p$.
\end{definition}
Examples of dense subsets include the entire $\Po$ as well
as any downwards ``slice''.

\begin{definition}
	For $p,q \in \Po$ we write $p \parallel q$,
	saying ``$p$ is \vocab{compatible} with $q$'',
	if there exists $r \in \Po$ with $r \le p$ and $r \le q$.
	Otherwise, we say $p$ and $q$ are \vocab{incompatible}
	and write $p \perp q$.
\end{definition}
\begin{example}[Infinite binary tree]
	Let $\Po = 2^{<\omega}$ be the \vocab{infinite binary tree} shown below,
	extended to infinity in the obvious way:
	\begin{center}
		\begin{asy}
			size(8cm);
			pair P = Drawing("\varnothing", (0,4), dir(90));
			pair P0 = Drawing("0", (-5,2), 1.5*dir(90));
			pair P1 = Drawing("1", (5,2),  1.5*dir(90));
			pair P00 = Drawing("00", (-7,0), 1.4*dir(120));
			pair P01 = Drawing("01", (-3,0), 1.4*dir(60));
			pair P10 = Drawing("10", (3,0),  1.4*dir(120));
			pair P11 = Drawing("11", (7,0),  1.4*dir(60));

			pair P000 = Drawing("000", (-8,-3));
			pair P001 = Drawing("001", (-6,-3));
			pair P010 = Drawing("010", (-4,-3));
			pair P011 = Drawing("011", (-2,-3));

			pair P100 = Drawing("100", (2,-3));
			pair P101 = Drawing("101", (4,-3));
			pair P110 = Drawing("110", (6,-3));
			pair P111 = Drawing("111", (8,-3));

			label("$\vdots$", (-7,-3), dir(-90));
			label("$\vdots$", (-3,-3), dir(-90));
			label("$\vdots$", (3,-3), dir(-90));
			label("$\vdots$", (7,-3), dir(-90));

			draw(P01--P0--P00);
			draw(P11--P1--P10);
			draw(P0--P--P1);
			draw(P000--P00--P001);
			draw(P100--P10--P101);
			draw(P010--P01--P011);
			draw(P110--P11--P111);
		\end{asy}
	\end{center}

	\begin{enumerate}[(a)]
		\ii The maximal element $1_\Po$ is the empty string $\varnothing$.
		\ii $D = \{\text{all strings ending in $001$}\}$ is an example of a dense set.
		\ii No two elements of $\Po$ are compatible unless they are comparable.
	\end{enumerate}
\end{example}

Now, I can specify what it means to be ``generic''.
\begin{definition}
	A nonempty set $G \subseteq \Po$ is a \vocab{filter} if
	\begin{enumerate}[(a)]
		\ii The set $G$ is upwards-closed:
		$\forall p \in G (\forall q \ge p) (q \in G)$.
		\ii Any pair of elements in $G$ is compatible.
	\end{enumerate}
	We say $G$ is \vocab{$M$-generic} if for all $D$ which are \emph{in the model $M$},
	if $D$ is dense then $G \cap D \neq \varnothing$.
\end{definition}
\begin{ques}
	Show that if $G$ is a filter then $1_\Po \in G$.
\end{ques}
\begin{example}[Generic filters on the infinite binary tree]
	Let $\Po = 2^{<\omega}$.
	The generic filters on $\Po$ are sets of the form
	\[ \left\{ 0,\; b_1,\; b_1b_2,\; b_1b_2b_3,\; \dots \right\}. \]
	So every generic filter on $\Po$ corresponds
	to a binary number $b = 0.b_1b_2b_3\dots$.

	It is harder to describe which reals correspond to generic filters,
	but they should really ``look random''.
	For example, the set of strings ending in $011$ is dense,
	so one should expect ``$011$'' to appear inside $b$,
	and more generally that $b$ should contain every binary string.
	So one would expect the binary expansion of $\pi-3$ might correspond to a generic,
	but not something like $0.010101\dots$.
	That's why we call them ``generic''.
\end{example}

\begin{center}
	\begin{asy}
		size(8cm);
		pair P = Drawing("\varnothing", (0,4), dir(90), red);
		pair P0 = Drawing("0", (-5,2), 1.5*dir(90), red);
		pair P1 = Drawing("1", (5,2),  1.5*dir(90));
		pair P00 = Drawing("00", (-7,0), 1.4*dir(120));
		pair P01 = Drawing("01", (-3,0), 1.4*dir(60), red);
		pair P10 = Drawing("10", (3,0),  1.4*dir(120));
		pair P11 = Drawing("11", (7,0),  1.4*dir(60));

		pair P000 = Drawing("000", (-8,-3));
		pair P001 = Drawing("001", (-6,-3));
		pair P010 = Drawing("010", (-4,-3), red);
		pair P011 = Drawing("011", (-2,-3));

		pair P100 = Drawing("100", (2,-3));
		pair P101 = Drawing("101", (4,-3));
		pair P110 = Drawing("110", (6,-3));
		pair P111 = Drawing("111", (8,-3));

		draw(P01--P0--P00);
		draw(P11--P1--P10);
		draw(P0--P--P1);
		draw(P000--P00--P001);
		draw(P100--P10--P101);
		draw(P010--P01--P011);
		draw(P110--P11--P111);

		draw(P--P0--P01--P010--(P010+2*dir(-90)), red+1.4);
		MP("G", P010+2*dir(-90), dir(-90), red);
	\end{asy}
\end{center}

\begin{exercise}
	Verify that these are every generic filter $2^{<\omega}$ has the form above.
	Show that conversely, a binary number gives a filter, but it need not be generic.
\end{exercise}

Notice that if $p \ge q$, then the sentence $q \in G$ tells us more information than the sentence $p \in G$.
In that sense $q$ is a \emph{stronger} condition.
In another sense $1_\Po$ is the weakest possible condition,
because it tells us nothing about $G$; we always have $1_\Po \in G$
since $G$ is upwards closed.

\section{More properties of posets}
We had better make sure that generic filters exist.
In fact this is kind of tricky, but for countable models it works:
\begin{lemma}[Rasiowa-Sikorski lemma]
	Suppose $M$ is a \emph{countable} transitive model of $\ZFC$
	and $\Po$ is a partial order.
	Then there exists an $M$-generic filter $G$.
\end{lemma}
\begin{proof}
	Essentially, hit them one by one.
	\Cref{prob:rslemma}.
\end{proof}

Fortunately, for breaking $\CH$ we would want $M$ to be countable anyways.
% This is really just the proof of the Baire category theorem.

The other thing we want to do to make sure we're on the right track is guarantee
that a generic set $G$ is not actually in $M$.
(Analogy: $\ZZ[3]$ is a really stupid extension.)
The condition that guarantees this is:

\begin{definition}
	A partial order $\Po$ is \vocab{splitting} if
	for all $p \in \Po$, there exists $q,r \le p$
	such that $q \perp r$.
\end{definition}
\begin{example}[Infinite binary tree is (very) splitting]
	The infinite binary tree is about as splitting as you can get.
	Given $p \in 2^{<\omega}$, just consider the two elements right under it.
\end{example}

\begin{lemma}[Splitting posets omit generic sets]
	Suppose $\Po$ is splitting.  Then if $F \subseteq \Po$ is a filter
	such that $F \in M$, then $\Po \setminus F$ is dense.
	In particular, if $G \subseteq \Po$ is generic, then $G \notin M$.
\end{lemma}
\begin{proof}
	Consider $p \notin \Po \setminus F \iff p \in F$.
	Then there exists $q, r \le p$ which are not compatible.
	Since $F$ is a filter it cannot contain both;
	we must have one of them outside $F$, say $q$.
	Hence every element of $p \in \Po \setminus (\Po \setminus F)$
	has an element $q \le p$ in $\Po \setminus F$.
	That's enough to prove $\Po \setminus F$ is dense.
	\begin{ques}
		Deduce the last assertion of the lemma about generic $G$. \qedhere
	\end{ques}
\end{proof}

\section{Names, and the generic extension}
We now define the \emph{names} associated to a poset $\Po$.

\begin{definition}
	Suppose $M$ is a transitive model of $\ZFC$, $\Po = (\Po, \le) \in M$ is a partial order.
	We define the hierarchy of \vocab{$\Po$-names} recursively by
	\begin{align*}
		\Name_0 &= \varnothing \\
		\Name_{\alpha+1} &= \PP(\Name_\alpha \times \Po) \\
		\Name_{\lambda} &= \bigcup_{\alpha < \lambda} \Name_\alpha.
	\end{align*}
	Finally, $\Name = \bigcup_\alpha \Name_\alpha$ denote the class of all $\Po$-names.
	% For $\tau \in \Name$, let $\nrank(\tau)$ be the least $\alpha$ such that $\tau \in \Name_\alpha$.
\end{definition}
(These $\Name_\alpha$'s are the analog of the $V_\alpha$'s:
each $\Name_\alpha$ is just the set of all names with rank $\le \alpha$.)

\begin{definition}
	For a filter $G$, we define the \vocab{interpretation} of $\tau$ by $G$,
	denoted $\tau^G$, using the transfinite recursion
	\[ \tau^G
		= \left\{ \sigma^G
		\mid \left<\sigma, p\right> \in \tau
		\text{ and } p \in G\right\}. \]
	We then define the model
	\[ M[G] = \left\{ \tau^G \mid \tau \in \Name^M \right\}. \]
	In words, $M[G]$ is the interpretation of all the possible $\Po$-names
	(as computed by $M$).
\end{definition}

\textbf{You should think of a $\Po$-name as a ``fuzzy set''.}
Here's the idea.
Ordinary sets are collections of ordinary sets,
so fuzzy sets should be collections of fuzzy sets.
These fuzzy sets can be thought of like the Ghosts of Christmases yet to come:
they represent things that might be, rather than things that are certain.
In other words, they represent the possible futures of $M[G]$ for various choices of $G$.

Every fuzzy set has an element $p \in \Po$ pinned to it.
When it comes time to pass judgment,
we pick a generic $G$ and filter through the universe of $\Po$-names.
The fuzzy sets with an element of $G$ attached to it materialize into the real world,
while the fuzzy sets with elements outside of $G$ fade from existence.
The result is $M[G]$.

\begin{example}[First few levels of the name hierarchy]
	Let us compute
	\begin{align*}
		\Name_0 &= \varnothing \\
		\Name_1 &= \PP(\varnothing \times \Po) \\
		&= \{\varnothing\} \\
		\Name_2 &= \PP(\{\varnothing\} \times \Po) \\
		&= \PP\left( \left\{
			\left<\varnothing, p\right>
			\mid p \in \Po
		\right\} \right).
	\end{align*}
\end{example}
Compare the corresponding von Neuman universe.
\[ V_0 = \varnothing, \; V_1 = \{\varnothing\}, \;
V_2 = \left\{ \varnothing, \left\{ \varnothing \right\} \right\}. \]

\begin{example}[Example of an interpretation]
	As we said earlier, $\Name_1 = \{\varnothing\}$.
	Now suppose
	\[ \tau =
		\left\{
			\left<\varnothing, p_1\right>,
			\left<\varnothing, p_2\right>,
			\dots,
			\left<\varnothing, p_n\right>
		\right\}
		\in \Name_2. \]
	Then
	\[
		\tau^G
		= \left\{ \varnothing \mid
		\left<\varnothing, p\right> \in \tau \text{ and } p \in G\right\}
		=
		\begin{cases}
			\{\varnothing\} & \text{if some } p_i \in G \\
			\varnothing & \text{otherwise}.
		\end{cases}
	\]
	In particular, remembering that $G$ is nonempty we see that
	\[ \left\{ \tau^G \mid \tau \in \Name_2 \right\} = V_2. \]
	In fact, this holds for any natural number $n$, not just $2$.
\end{example}
So, $M[G]$ and $M$ agree on finite sets.

Now, we want to make sure $M[G]$ contains the elements of $M$.
To do this, we take advantage of the fact that $1_\Po$ must be in $G$, and define
for every $x \in M$ the set
\[ \check x = \left\{ \left<\check y, 1_\Po\right> \mid y \in x \right\} \]
by transfinite recursion.
Basically, $\check x$ is just a copy of $x$ where we add check marks and tag every element with $1_\Po$.

\begin{example}
	Compute $\check 0 = 0$ and $\check 1 = \left\{ \left<\check 0, 1_\Po\right> \right\}$.
	Thus \[ (\check 0)^G = 0 \quad\text{and}\quad (\check 1)^G = 1. \]
\end{example}
\begin{ques}
	Show that in general, $(\check x)^G = x$.
	(Rank induction.)
\end{ques}

However, we'd also like to cause $G$ to be in $M[G]$.
In fact, we can write down the name exactly: we define
\[ \dot \Po \defeq \left\{ \left<\check p, p\right> \mid p \in \Po \right\}. \]
\begin{ques}
	Show that $(\dot \Po)^G = G$.
\end{ques}
\begin{ques}
	Verify that $M[G]$ is transitive:
	that is, if $\sigma^G \in \tau^G \in M[G]$, show that $\sigma^G \in M[G]$.
	(This is offensively easy.)
\end{ques}

In summary,
\begin{moral}
	$M[G]$ is a transitive model extending $M$ (it contains $G$).
\end{moral}

Moreover, it is reasonably well-behaved even if $G$ is just a filter.
Let's see what we can get off the bat.
\begin{lemma}[Properties obtained from filters]
	Let $M$ be a transitive model of $\ZFC$.
	If $G$ is a filter, then $M[G]$ is transitive
	and satisfies $\Extensionality$, $\Foundation$,
	$\EmptySet$, $\Infinity$, $\Pairing$, and $\Union$.
\end{lemma}

This leaves $\PowerSet$, $\Replacement$, and Choice.
\begin{proof}
	Hence, we get $\Extensionality$ and $\Foundation$ for free.
	Then $\Infinity$ and $\EmptySet$ follows from $M \subseteq M[G]$.

	For $\Pairing$, suppose $\sigma_1^G, \sigma_2^G \in M[G]$.
	Then
	\[ \sigma =
		\left\{ \left<\sigma_1, 1_\Po\right>, \left<\sigma_2, 1_\Po\right> \right\}
	\]
	satisfies $\sigma^G = \{\sigma_1^G, \sigma_2^G\}$.
	(Note that we used $M \vDash \Pairing$.)
	$\Union$ is left as a problem, which you are encouraged to try now.
\end{proof}
Up to here, we don't need to know anything about when a sentence is true in $M[G]$;
all we had to do was contrive some names like $\check x$ or
$\left\{ \left<\sigma_1, 1_\Po\right>, \left<\sigma_2, 1_\Po\right> \right\}$
to get the facts we wanted.
But for the remaining axioms, we \emph{are} going to need this extra power
are true in $M[G]$.
For this, we have to introduce the fundamental theorem of forcing.

\section{Fundamental theorem of forcing}
The model $M$ unfortunately has no idea what $G$ might be,
only that it is some generic filter.\footnote{You might
	say this is a good thing; here's why.
	We're trying to show that $\neg \CH$ is consistent with $\ZFC$,
	and we've started with a model $M$ of the real universe $V$.
	But for all we know $\CH$ might be true in $V$ (what if $V=L$?),
	in which case it would also be true of $M$.

	Nonetheless, we boldly construct $M[G]$ an extension of the model $M$.
	In order for it to behave differently from $M$, it has to be out of reach of $M$.
	Conversely, if $M$ could compute everything about $M[G]$,
	then $M[G]$ would have to conform to $M$'s beliefs.

	That's why we worked so hard to make sure $G \in M[G]$ but $G \notin M$.}
Nonetheless, we are going to define a relation $\Vdash$,
called the \emph{forcing} relation.
Roughly, we are going to write
\[ p \Vdash \varphi(\sigma_1, \dots, \sigma_n) \]
where $p \in \Po$, $\sigma_1, \dots, \sigma_n \in M[G]$, if and only if:
\begin{quote}
	For \emph{any} generic $G$,
	if $p \in G$,
	then $M[G] \vDash \varphi(\sigma_1^G, \dots, \sigma_n^G)$.
\end{quote}
Note that $\Vdash$ is defined without reference to $G$:
it is something that $M$ can see.
We say $p$ \vocab{forces} the sentence $\varphi(\sigma_1, \dots, \sigma_n)$.
And miraculously, we can define this relation in such a way that the converse is true:
\emph{a sentence holds if and only if some $p$ forces it}.

\begin{theorem}
	[Fundamental theorem of forcing]
	Suppose $M$ is a transitive model of ZF.
	Let $\Po \in M$ be a poset, and $G \subseteq \Po$ is an $M$-generic filter.
	Then,
	\begin{enumerate}[(1)]
		\ii Consider $\sigma_1, \dots, \sigma_n \in \Name^M$,
		Then
		\[ M[G] \vDash \varphi[\sigma_1^G, \dots, \sigma_n^G] \]
		if and only if there exists a condition $p \in G$
		such that $p$ \emph{forces} the sentence $\varphi(\sigma_1, \dots, \sigma_n)$.
		We denote this by $p \Vdash \varphi(\sigma_1, \dots, \sigma_n)$.
		\ii This forcing relation is (uniformly) definable in $M$.
	\end{enumerate}
\end{theorem}

I'll tell you how the definition works in the next section.

\section{(Optional) Defining the relation}
Here's how we're going to go.
We'll define the most generous condition possible such that
the forcing works in one direction ($p \Vdash \varphi(\sigma_1, \dots, \sigma_n)$ means
$M[G] \vDash \varphi[\sigma_1^G, \dots, \sigma_n^G]$).
We will then cross our fingers that the converse also works.

We proceed by induction on the formula complexity.
It turns out in this case that the atomic formula (base cases)
are hardest and themselves require induction on ranks.

For some motivation, let's consider how we should define
$p \Vdash \tau_1 \in \tau_2$ given that we've
already defined $p \Vdash \tau_1 = \tau_2$.
We need to ensure this holds iff
\[ \forall \text{$M$-generic $G$ with $p \in G$}:
	\ M[G] \vDash \tau_1^G \in \tau_2^G. \]
So it suffices to ensure that any generic $G \ni p$ hits a condition $q$ which forces $\tau_1^G$ to \emph{equal} a member $\tau^G$ of $\tau_2^G$.
In other words, we want to choose the definition of $p \Vdash \tau_1 \in \tau_2$ to hold if and only if
\[
	\left\{ q \in \Po
		\mid \exists \left<\tau, r\right> \in \tau_2
		\left( q \le r \land q \Vdash(\tau=\tau_1) \right) \right\}
\]
is dense below in $p$.
In other words, if the set is dense, then the generic must hit $q$, so it must hit $r$, meaning that $\left<\tau_r\right> \in \tau_2$ will get interpreted such that $\tau^G \in \tau_2^G$, and moreover the $q \in G$ will force $\tau_1 = \tau$.

Now let's write down the definition\dots
In what follows, the $\Vdash$ omits the $M$ and $\Po$.
\begin{definition}
	Let $M$ be a countable transitive model of ZFC.
	Let $\Po \in M$ be a partial order.
	For $p \in \Po$ and $\varphi(\sigma_1, \dots, \sigma_n)$
	a formula in the language of set theory,
	we write $\tau \Vdash \varphi(\sigma_1, \dots, \sigma_n)$
	to mean the following, defined by induction on formula complexity plus rank.
	\begin{enumerate}[(1)]
		\ii $p \Vdash \tau_1 = \tau_2$ means
		\begin{enumerate}[(i)]
			\ii For all $\left<\sigma_1, q_1\right> \in \tau_1$ the set
			\[ D_{\sigma_1, q_1}
				\defeq
				\left\{ r \mid
				r \le q_1 \lthen \exists \left<\sigma_2, q_2\right> \in \tau_2 \left( r \le q_2 \land r \Vdash (\sigma_1 = \sigma_2) \right)\right\}.
			\]
			is dense in $p$.
			(This encodes ``$\tau_1 \subseteq \tau_2$''.)
			\ii For all $\left<\sigma_2, q_2\right> \in \tau_2$,
			the set $D_{\sigma_2, q_2}$ defined similarly is dense below $p$.
		\end{enumerate}
		\ii $p \Vdash \tau_1 \in \tau_2$ means
		\[
		\left\{ q \in \Po
		\mid \exists \left<\tau, r\right> \in \tau_2
		\left( q \le r \land q \Vdash(\tau=\tau_1) \right)
		\right\} \]
		is dense below $p$.
		\ii $p \Vdash \varphi \land \psi$ means $p \Vdash \varphi$ and $p \Vdash \psi$.
		\ii $p \Vdash \neg \varphi$ means $\forall q \le p$, $q \not\Vdash \varphi$.
		\ii $p \Vdash \exists x \varphi(x, \sigma_1, \dots, \sigma_n)$ means that the set
		\[
			\left\{ q \mid \exists \tau \left( q \Vdash
				\varphi(\tau, \sigma_1, \dots, \sigma_n ) \right)
			\right\}
		\]
		is dense below $p$.
	\end{enumerate}
\end{definition}
This is definable in $M$!
All we've referred to is $\Po$ and names, which are in $M$.
(Note that being dense is definable.)
Actually, in parts (3) through (5) of the definition above,
we use induction on formula complexity.
But in the atomic cases (1) and (2) we are doing induction on the ranks of the names.

So, the construction above gives us one direction (I've omitted tons of details, but\dots).

Now, how do we get the converse: that a sentence is true if and only if something forces it?
Well, by induction, we can actually show:
\begin{lemma}[Consistency and Persistence]
	We have
	\begin{enumerate}[(1)]
		\ii (Consistency) If $p \Vdash \varphi$ and $q \le p$ then $q \Vdash \varphi$.
		\ii (Persistence) If $\left\{ q \mid q \Vdash \varphi \right\}$
		is dense below $p$ then $p \Vdash \varphi$.
	\end{enumerate}
\end{lemma}
You can prove both of these by induction on formula complexity.
From this we get:
\begin{corollary}[Completeness]
	The set $\left\{ p \mid p \Vdash \varphi \text{ or } p \Vdash \neg\varphi \right\}$
	is dense.
\end{corollary}
\begin{proof}
	We claim that whenever $p \not\Vdash \varphi$ then
	for some $\ol p \le p$ we have $\ol p \Vdash \neg\varphi$;
	this will establish the corollary.

	By the contrapositive of the previous lemma,
	$\{q \mid q \Vdash \varphi\}$ is not dense below $p$,
	meaning for some $\ol p \le p$, every $q \le \ol p$ gives $q \not\Vdash \varphi$.
	By the definition of $p \Vdash \neg\varphi$,
	we have $\ol p \Vdash \neg\varphi$.
\end{proof}
And this gives the converse: the $M$-generic $G$ has to hit some condition
that passes judgment, one way or the other.
This completes the proof of the fundamental theorem.

\section{The remaining axioms}
\begin{theorem}[The generic extension satisfies $\ZFC$]
	Suppose $M$ is a transitive model of $\ZFC$.
	Let $\Po \in M$ be a poset, and $G \subseteq \Po$ is an $M$-generic filter.
	Then \[ M[G] \vDash \ZFC. \]
\end{theorem}
\begin{proof}
	We'll just do $\Comprehension$, as the other remaining axioms are similar.

	Suppose $\sigma^G, \sigma_1^G, \dots, \sigma_n^G \in M[G]$
	are a set and parameters, and
	$\varphi(x,x_1, \dots, x_n)$ is a formula
	in the language of set theory.
	We want to show that the set
	\[ A = \left\{
		x \in \sigma^G \mid M[G] \vDash \varphi[x, \sigma_1^G, \dots, \sigma_n^G]
	\right\} \]
	is in $M[G]$; i.e.\ it is the interpretation of some name.

	Note that every element of $\sigma^G$ is of the form $\rho^G$
	for some $\rho \in \dom(\sigma)$ (a bit of abuse of notation here,
	$\sigma$ is a bunch of pairs of names and $p$'s,
	and the domain $\dom(\sigma)$ is just the set of names).
	So by the fundamental theorem of forcing, we may write
	\[ A =
		\left\{ \rho^G \mid \rho \in \dom(\sigma)
			\text{ and }
			\exists p \in G
			\left( p \Vdash \rho \in \sigma
			\land \varphi(\rho, \sigma_1, \dots, \sigma_n)
			\right)
		\right\}.
	\]
	To show $A \in M[G]$ we have to write down a $\tau$
	such that the name $\tau^G$ coincides with $A$.
	We claim that
	\[
		\tau
		=
		\left\{ \left<\rho, p\right>
			\in \dom(\sigma) \times \Po \mid
			p \Vdash \rho \in \sigma
			\land \varphi(\rho, \sigma_1, \dots, \sigma_n)
		\right\}
	\]
	is the correct choice.
	It's actually clear that $\tau^G = A$ by construction;
	the ``content'' is showing that $\tau$ is in actually a name of $M$,
	which follows from $M \vDash \Comprehension$.

	So really, the point of the fundamental theorem of forcing
	is just to let us write down this $\tau$;
	it lets us show that $\tau$ is in $\Name^M$
	without actually referencing $G$.
\end{proof}

\section\problemhead
\begin{problem}
	For a filter $G$ and $M$ a transitive model of $\ZFC$,
	show that $M[G] \vDash \Union$.
\end{problem}

\begin{problem}[Rasiowa-Sikorski lemma]
	\label{prob:rslemma}
	Show that in a countable transitive model $M$ of $\ZFC$,
	one can find an $M$-generic filter on any partial order.
	\begin{hint}
		Let $D_1$, $D_2$, \dots be the dense sets (there are countably many of them).
	\end{hint}
	\begin{sol}
	Since $M$ is countable, there are only countably many dense sets (they live in $M$!),
	say \[ D_1, D_2, \ldots, D_n, \ldots \in M. \]
	Using Choice,
	let $p_1 \in D_1$, and then let $p_2 \le p_1$ such that $p_2 \in D_2$
	(this is possible since $D_2$ is dense), and so on.
	In this way we can inductively exhibit a chain
	\[ p_1 \ge p_2 \ge p_3 \ge \dots \]
	with $p_i \in D_i$ for every $i$.

	Hence, we want to generate a filter from the $\{p_i\}$.
	Just take the upwards closure -- let $G$ be the set of $q \in \Po$ such that $q \ge p_n$ for some $n$.
	By construction, $G$ is a filter (this is actually trivial).
	Moreover, $G$ intersects all the dense sets by construction.
	\end{sol}
\end{problem}

%\begin{exercise}
%	Show that $\rank \sigma^G \le \nrank(\sigma)$ for any $\sigma \in \Name^M$.
%\end{exercise}

%\begin{exercise}
%	Check that
%	\begin{enumerate}[(1)]
%		\ii $(\check x)^G = x$.
%		\ii $(\dot G)^G = G$.
%	\end{enumerate}
%\end{exercise}


\chapter{Context methods I}

Context methods are a group of methods of compression which exploits the different probablities of symbols based on the preceeding characters - the context. Each of these methods usually works in a completely different manner, but the basis idea about context is common to all of them.

\section{Entrophy of higher order}

Entrophy of higher order is closely related to context methods. Order is length of the context preceeding the character. When is order $0$ it means that the context is empty and it is just and ordinary entrophy.

\begin{dt}{Entrophy of $0$ order, $T = \Sigma^+$.}
  The entrophy of $0$ order is defined $$H_{0}(T) = - \sum_{a \in \Sigma} \frac{|T_a|}{n} \log_2 \frac{|T_a|}{n}.$$
\end{dt}

\begin{dt}{Entrophy of $k$ order, $k > 0$.}
  The entrophy of $k$ order is defined $$H_{k}(T) = \frac{1}{n} \sum_{w \in \Sigma^k} |w_T| H_0(w_T).$$
\end{dt}

\begin{figure}
    $$H_{0}(\text{aabaabaaabaaabaa}) = - (\frac{12}{16} \log_2 \frac{12}{16} + \frac{4}{16} \log_2 \frac{4}{16})$$
  \caption{$H_{0}(\text{aabaabaaabaaabaa})$}
\end{figure}

\begin{figure}
  \begin{center}
  \begin{tabular}{c|c|c}
    $w$ & $w_T$ & $|w_T|$ \\
    \hline
    a & ababaabaaba & 11 \\
    b & aaaa & 4 \\
  \end{tabular}
  \end{center}
    $$H_{1}(\text{aabaabaaabaaabaa}) = \frac{1}{16} (11 H_{0}(\text{ababaabaaba}) + 4 H_{0}(\text{aaaa}))$$
  \caption{$H_{1}(\text{aabaabaaabaaabaa})$}
\end{figure}

\begin{figure}
  \begin{center}
  \begin{tabular}{c|c|c}
    $w$ & $w_T$ & $|w_T|$ \\
    \hline
    aa & bbabab & 5 \\
    ab & aaaa & 4 \\
    ba & aaaa & 4 \\
    bb & $\varepsilon$ & 0 \\
  \end{tabular}
  \end{center}
    $$H_{2}(\text{aabaabaaabaaabaa}) = \frac{1}{16} (5 H_{0}(\text{bbabab}) + 4 H_{0}(\text{aaaa}) + 4 H_{0}(\text{aaaa}))$$
  \caption{$H_{2}(\text{aabaabaaabaaabaa})$}
\end{figure}

\begin{figure}
  \begin{center}
  \begin{tabular}{c|c|c}
    $w$ & $w_T$ & $|w_T|$ \\
    \hline
    aaa & bb & 2 \\
    aab & aaaa & 4 \\
    aba & aaaa & 4 \\
    abb & $\varepsilon$ & 0 \\
    baa & baa & 3 \\
    bab & $\varepsilon$ & 0 \\
    bba & $\varepsilon$ & 0 \\
    bbb & $\varepsilon$ & 0 \\
  \end{tabular}
  \end{center}
    $$H_{3}(\text{aabaabaaabaaabaa}) = \frac{1}{16} (2 H_{0}(\text{bb}) + 4 H_{0}(\text{aaaa}) + 4 H_{0}(\text{aaaa}) + 3 H_{0}(\text{baa}))$$
  \caption{$H_{3}(\text{aabaabaaabaaabaa})$}
\end{figure}

\begin{figure}
  \begin{center}
  \begin{tabular}{c|c|c}
    $w$ & $w_T$ & $|w_T|$ \\
    \hline
    aaaa & $\varepsilon$ & 0 \\
    aaab & aa & 2 \\
    aaba & aaaa & 4 \\
    aabb & $\varepsilon$ & 0 \\
    abaa & baa & 3 \\
    abab & $\varepsilon$ & 0 \\
    abba & $\varepsilon$ & 0 \\
    abbb & $\varepsilon$ & 0 \\
    baaa & bb & 2 \\
    baab & a & 1 \\
    baba & $\varepsilon$ & 0 \\
    babb & $\varepsilon$ & 0 \\
    bbaa & $\varepsilon$ & 0 \\
    bbab & $\varepsilon$ & 0 \\
    bbba & $\varepsilon$ & 0 \\
    bbbb & $\varepsilon$ & 0 \\
  \end{tabular}
  \end{center}
    $$H_{4}(\text{aabaabaaabaaabaa}) = \frac{1}{16} (2 H_{0}(\text{aa}) + 4 H_{0}(\text{aaaa}) + 3 H_{0}(\text{baa}) + 2 H_{0}(\text{bb}) + 1 H_{0}(\text{a}))$$
  \caption{$H_{4}(\text{aabaabaaabaaabaa})$}
\end{figure}

\section{PPM}


\hypertarget{delaunay}{%
\section{Delaunay}\label{delaunay}}

The \texttt{delaunay} module creates Delaunay triangulations from point
clouds. It is dimensionally independent, so generates tetrahedra in 3D
and higher order simplices beyond.

To use the module, first import it:

\begin{lstlisting}
import delaunay
\end{lstlisting}

To create a Delaunary triangulation from a list of points:

\begin{lstlisting}
var pts = []
for (i in 0...100) pts.append(Matrix([random(), random()]))
var del=Delaunay(pts)
print del.triangulate()
\end{lstlisting}

The module also provides \texttt{DelaunayMesh} to directly create meshes
from Delaunay triangulations.

\hypertarget{triangulate}{%
\section{Triangulate}\label{triangulate}}

The \texttt{triangulate} method performs the delaunay triangulation. To
use it, first construct a \texttt{Delaunay} object with the point cloud
of interest:

\begin{lstlisting}
var del=Delaunay(pts)
\end{lstlisting}

Then call \texttt{triangulate}:

\begin{lstlisting}
var tri = del.triangulate()
\end{lstlisting}

This returns a list of triangles
\texttt{{[}\ {[}i,\ j,\ k{]},\ ...\ {]}}.

\hypertarget{delaunaymesh}{%
\section{DelaunayMesh}\label{delaunaymesh}}

The \texttt{DelaunayMesh} constructor function creates a \texttt{Mesh}
object directly from a point cloud using the Delaunay triangulator.

\begin{lstlisting}
var pts = []
for (i in 0...100) pts.append(Matrix([random(), random()]))
var m=DelaunayMesh(pts)
Show(plotmesh(m))
\end{lstlisting}

You can control the output dimension of the mesh (e.g.~to create a 2D
mesh embedded in 3D space) using the optional \texttt{outputdim}
property.

\begin{lstlisting}
var m = DelaunayMesh(pts, outputdim=3)
\end{lstlisting}

\hypertarget{circumsphere}{%
\section{Circumsphere}\label{circumsphere}}

The \texttt{Circumsphere} class calculates the circumsphere of a set of
points, i.e.~a sphere such that all the points are on the surface of the
sphere. It is used internally by the \texttt{delaunay} module.

Create a \texttt{Circumsphere} from a list of points and a triangle
specified by indices into that list:

\begin{lstlisting}
var sph = Circumsphere(pts, [i,j,k])
\end{lstlisting}

Test if an arbitrary point is inside the \texttt{Circumsphere} or not:

\begin{lstlisting}
print sph.pointinsphere(pt)
\end{lstlisting}