\documentclass{article}
\title{Topology 2 Notes}
\author{Lucas Simon}
\date{\copyright\ 2015 Judith Packer, All Rights Reserved}

\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{amsthm}
\usepackage{tikz}
\usepackage{tikz-cd}
\usepackage{mathrsfs}
\usepackage{mathpazo}
\usepackage[all]{xy}

\begin{document}

\maketitle

\section{March 6, 2015}

\textbf{NOTICE:} Reminder, there is an open book exam on the 11th, next week on Wednesday. There will be four multipart questions during the 55 minute exam.

Back to the two-torus, we identify the sides of $I \times I$
%% DRAW A PICTURE HERE
Let $Y = S^1 \times S^1$ and $Y^1 = A \cup B$. We showed last time that $H_q(Y, Y^1) \cong H_1(E^2, \dot{E}^2) = \mathbb{Z}$ for $q = 2$ and $0$ otherwise.
Recall from the long exact sequence in homology, we have

\[
\begin{tikzcd}
H_2(Y^1) \cong 0 \arrow[r, "i_*"] & H_2(Y) \arrow[r, "j_*"] & H_2(Y, Y^1) \arrow[r, "\partial_2"] & H_1(Y^1) \cong \mathbb{Z} \oplus \mathbb{Z} \arrow[r, "i_*"] & H_1(Y) \arrow[r, "j_*"] & H_1(Y, Y^1) = 0
\end{tikzcd}
\]
then we get the sequence
\[
0 \to H_2(Y) \xrightarrow{j_*} H_2(Y, Y^1) \cong \mathbb{Z} \xrightarrow{\partial_2} \mathbb{Z} \oplus \mathbb{Z} \xrightarrow{i_*} H_1(Y) \xrightarrow{j_*} 0
\]
Then we have $\text{im}(j_*) \cong H_2(Y) \cong \text{ker}(\partial_*) ? = H_2(Y, Y^1) \cong \mathbb{Z}$.

We make a guess before diving into the mess, $H_2(Y) \cong \mathbb{Z}$. So $j_*(n) = dn$ for $|d| > 1$? If $\text{im}(j_*) \cong \text{ker}{i_*}$. But then $\mathbb{Z}/ |d|\mathbb{Z}$ would be a subgroup of $H_1(Y^1)$, which is a contradition since every free abelian group is torsion free.

So if $H_2(Y, Y^1) \neq 0$, then $j_*$ is onto $H_2(Y, Y^1) \cong \mathbb{Z}$. We want to show $\partial_*$ is the zero map for $H_2(Y, Y^1) \cong \mathbb{Z} \to H_1(Y^1) \cong \mathbb{Z} \oplus \mathbb{Z}$.

Notice that a mpa $\mathbb{Z} \xrightarrow{M} \mathbb{Z} \oplus \mathbb{Z}$ for $\text{ker}(M) = |d|\mathbb{Z}$. Then by algebra
\[
\begin{tikzcd}
\mathbb{Z} \arrow[d, "\pi"] \arrow[r, "M"] & \mathbb{Z} \oplus \mathbb{Z} \\
\mathbb{Z}/ \text{ker}(M) \arrow[ur, dotted, "\tilde{M}"]
\end{tikzcd}
\]

Recall part of diagram from page 202

\[
\begin{tikzcd}
H_2(E^2, \dot{E}^2) \arrow[r, "\cong \tilde{\partial_*}"] \arrow[d, "\cong f_*"] &  H_1(\dot{E}^2) \arrow[d, "\cong f_*"] \\
H_2(Y, Y^1) \arrow[r, "\cong \partial_*"] & H_1(Y^1)
\end{tikzcd}
\]

Looking at the graph of the boundary, the generator for $H_1(\dot{E}^2)$ is $T_{e_1} + T_{e_2} + T_{e_3} + T_{e_4}$ where $T_{e_1}(x) = (x,0)$, $T_{e_2}(x) = (1,x)$, $T_{e_3}(x) = (1-x,1)$, $T_{e_4}(x) = (0, 1-x)$,

LOOK AT IMAGE AND FILL IN DETAILS

therefore $f_*$ of the generators of $H_1(\dot{E}^2)$ is $f_*(T_{e_1} + T_{e_2} + T_{e_3} + T_{e_4}) = f_*(T_{e_1}) + f_*(T_{e_2}) + f_*(T_{e_3}) + f_*(T_{e_4}) = 0$.

Therefore $\partial_* = (f_*) \circ \tilde{\partial_*} f_*^{-1} = 0$. Then we have the exact sequence
\[
0 \xrightarrow{\partial_*} H_1(Y^1) \cong \mathbb{Z} \oplus \mathbb{Z} \xrightarrow{i_*} H_1(Y) \to 0
\]
hence $i_*$ is an isomorphism. Therefore we have the following computation for $Y$, the torus
\[
H_q(Y) = 0 q \geq 2 \mathbb{Z} q = 2 \mathbb{Z} \oplus \mathbb{Z} q=1 \mathbb{Z} q = 0
\]

Now we condsider the homology of the real projective plane $\mathbb{RP}^2$. Let $g: E^2 \to E^2/\sim$ relation on the boundary. Let $X = g(E^2)$ and $X^1 = g(\dot{E}^2) = S^1$. Remark, we can go through the same proof from the torus involving deformation retracts, excision, and the 5-lemma: to prove $H_1(E^2, \dot{E}^2) \xrightarrow{f_* \cong} H_q(X, X^1)$ go through as before to show
\[
H_q(E^2, \dot{E}^2) \xrightarrow{g_* \cong} H_q(X, X^1) = \mathbb{Z} q = 2 0 \text{otherwise}
\]
Now look back at the long exact sequence
\[
\begin{tikzcd}
H_3(X, X^1) \arrow[r] & H_2(X^1) \arrow[r] & H_2(X) \arrow[r] & H_2(X, X^1)\cong \mathbb{Z} \arrow[r, "\partial_*"] H_1(X^1) \arrow[r, "i_*"] & H_1(X) \arrow[r, "j_*"] & H_1(X, X^1) \cong 0
\end{tikzcd}
\]
Then we look at the generators

FINISH with IMAGE....

the $\partial_*$ is multiplication by 2!

\section{March 9, 2015 (Monday)}
We have an exam on Wednesday. This covers chapter II sections 1-6 and chapter III sections 1-3.
Overview of material

(1) Definition of singular n-cubes: $C_n(X) = Q_n(X)/ D_n(X)$ where $T: I^n \to X$ is degenerate if for one of the coordinates, T is invariant.

(2) Boundary map $\partial_n(T) = \sum_{j=1}^n [A_jT - B_jT]$. Note that $\partial_{n-1} \circ \partial{n} = 0$. We have n-cycles $Z_n(X) = \text{ker}(\partial_n)$ and n-boundaries $B_n(X) = \text{im}(\partial_{n+1})$.

(3) We get the homology groups $H_n(X) = Z_n(X) / B_n(X)$ and we have the augmentation map $\varepsilon: C_n(X) \to \mathbb{Z}$ where $\tilde{Z}_0 = \text{ker}(\varepsilon_*)$. We have $B_0(X) \subset Z_n(X)$ so we get the reduced homology $\tilde{H}_0(X) = \tilde{Z}_0(X) / B_0(X) \subset H_0(X)$.

(4) We get homomophisms in homoloy from continuous maps $f: X \to Y$. We obtain $f_*:H_n(X) \to H_n(Y)$ for $n \geq 0$ and $f_*: \tilde{H}_0(X) \to \tilde{H}_0(Y)$. If $f,g:X \to Y$ are homotopic then there is a $F: X \times I \to I$ such that $F(x,0) = f(x)$ and $F(x,1) = g(x)$. Then $f_* = g_*$ on $H_n(X) \to H_n(Y)$ and $\tilde{H}_0(X) \to \tilde{H}_0(Y)$.

(5) We say spaces $X$ and $Y$ are homotopic if there exists continuous functions $f: X \to Y$ and $f: Y \to X$ such that $f \circ g \simeq id_X$ and $f \circ g \simeq id_Y$. If $X$ and $Y$ are homotopy equivalent then $f_*: H_n(X) \xrightarrow{\cong} H_n(Y)$ for each $n \geq 0$.

(6) Let $A \subseteq X$ then $A$ is said to be a deformation retraction of $X$ if there exists $r: X \to A$ such that $r$ is homotopic to the identity map on $X$, $id_X$. If $A$ is a deformation retract of $X$ then $i_*: H_n(A) \xrightarrow{\cong} H_n(X)$ and $r_*: H_n(X) \xrightarrow{\cong} H_n(A)$.

(7) Homology of a pair $(X,A)$. We have $C_n(X,A) = C_n(X) / C_n(A)$ and we have $\partial_n: C_n(X,A) \to C_{n-1}(X,A)$ where $\partial_{n-1} \circ \partial_n = 0$ for all $n \geq 1$. We have the relative n-boundaries $B_n(X,A) = \text{im}\partial_{n+1} \subset Z_n(X,A)$. We have the relative homology group $H_n(X,A) = Z_n(X,A) / B_n(X,A)$.

(8) Using the short exact sequence of chain complexes
\[
\begin{tikzcd}
0 \arrow[r] & C_\bullet(A) \arrow[r, "i"] & C_\bullet(X) \arrow[r, "j"] & C_\bullet(X,A) \arrow[r] & 0
\end{tikzcd}
\]
We get the long exact sequence:

ADD SNAKING LONG EXACT SEQUENCE

(9) Let $f: (X,A) \to (Y,B)$; that is, $f:X \to Y$ where $f(A) \subseteq B$. We can apply the five lemma to get
\[
\begin{tikzcd}
H_n(A) \arrow[r] \arrow[d, "f_*"] & H_n(X) \arrow[r] \arrow[d, "f_*"] & H_n(X,A) \arrow[r] \arrow[d, "f_*"] & H_{n-1}(A) \arrow[d, "f_*"]\\
H_n(B) \arrow[r] & H_n(Y) \arrow[r] & H_n(Y, B) \arrow[r] & H_{n-1}(B)
\end{tikzcd}
\]

(10) We then got the excision theorem: Let $(X,A)$ be a pair of topological spaces and suppose $W \subseteq A$ such that $\bar{W} \subset \text{Int}(A)$. Then $i_*: H_n(X \sim W, A \sim W) \to H_n(X,A)$ for $n \geq 0$  is an isomorphism.

(11) Once we got this theorem, we were able to deduce the homology groups of the n-sphere. Then $S^n \subseteq E^{n+1}$, with $S^n = \{(x_1, \ldots, x_{n+1}: \sum_{j=1}^{n+1} (x_i)^2 = 1 \}$. For $n \geq 1$ this gives
\[
H_1(S^n) =
  \begin{cases}
   \mathbb{Z} & \text{if } q \in \{0, n \} \\
   0       & \text{otherwise}
  \end{cases}
\]

(12) From proposition 2.4, we get that $H_q(E_n, S^{n-1}) = \mathbb{Z}$ for $q=n$ and 0 otherwise.

(13) If $f: S^n \to S^n$ is a continuous map, define $deg(f)$ as the integer $k$ such that $f_*([1]_{\tilde{H}_n(S^n))}) = k \cdot [1]_{\tilde{H}_n(S^n)}$

(14) Suspension: If $f: S^n \to S^n$ is continuous, then we get the suspension $\Sigma f: S^{n+1} \to S^{n+1}$, we have $def(f) = deg(\Sigma f)$.

(15) Finite regular graphs $(X, X^0)$ where $X^0 = \{ v_i \}_{i=1}^n$ and $X^1 = \{ e_i \}^k_{j=1}$ we have $f_i: [0,1] \to \bar{e}_i \subset X^1$ where $ \bar{e}_i = \{ v \} \cup e_i \cup \{ v' \}$ where $v \neq v'$. Then
\[
H_q(X, X^0) =
\begin{cases}
\mathbb{Z}^k & \text{for } q = 1\\
0 & \text{otherwise}
\end{cases}
\]

(16) Theorem 3.4: If $(X, X^0)$ be a finite regular graph with $P$ path components, $n$ vertices, and $k$ edges.

\[
H_q(X) =
\begin{cases}
\mathbb{Z}^{p - (n - k)} = \mathbb{Z}^{p - \chi(X,X^0)} & \text{if } q = 1 \\
\mathbb{Z}^p & \text{if } q = 0 \\
0 & \text{otherwise}
\end{cases}
\]
Note this implies $\tilde{H}_0(X) = \mathbb{Z}^{p-1}$. We write $S^1$ as a graph.

\section{Meyer-Vietoris Exact Sequence}
Imagine a torus, look at pieces $A$ and $B$ which have nonempty intersection that looks like a disjoint union of cylinders, and each subset looks like a cylinder. All pieces deformation retract to circles.

Therefore, we know the homology of $A, B$, and $A \cap B$. The inclusion maps
\begin{align*}
i: A \cap B \hookrightarrow A & &
j: A \cap B \hookrightarrow B \\
k: A \hookrightarrow A \cup B & &
l: B \hookrightarrow A \cup B
\end{align*}
We have the induced morphisms in homology
\begin{align*}
i_*: H_n(A \cap B) \hookrightarrow H_n(A) & &
j_*: H_n(A \cap B) \hookrightarrow H_n(B) \\
k_*: H_n(A) \hookrightarrow H_n(A \cup B) & &
l_*: H_n(B) \hookrightarrow H_n(A \cup B)
\end{align*}
So consider maps
\begin{align*}
\phi_* := (i_*, j_*): H_n(A \cap B) \to H_n(A) \oplus H_n(B) \text{ for all } n \geq 0 \\
\psi_* := k_* - l_*: H_n(A) \oplus H_n(B) \to H_n(A \cup B)
\end{align*}
where $\psi_*([S],[T]) = k_*([S]) - l_*([T])$

\textbf{Theorem:} Let $A$ and $B$ be subspaces of a topological space $X$ such that $X = \text{Int}(A) \cup \text{Int}(B)$. Then there exists a natural homomorphism $\Delta_*:H_n(X) \to H_{n-1}(A \cap B)$ for all $n \geq 1$ giving the following long exact sequence in homology:

\[
\begin{tikzcd}
\cdots \arrow[r] & H_n(A \cap B)
\end{tikzcd}
\]

%%% \cdots \arrow[r] & H_n(A \cap B) & H_n(A) \oplus H_n(B) \arrow[r] & H_n(A \cap B)
%
%        {   & \mbox{} & \mbox{} & \cdots \\
%            & H_n(A \cap B) & H_n(A) \oplus H_n(B) & H_n(A \cap B) \\
%            & H_{n-1}(A \cap B) & H_{n-1}(A) \oplus H_{n-1}(B) & H_{n-1}(A \cap B) \\
%            & \cdots & \mbox{} & \cdots \\
%            & H_1(A \cap B) & H_1(A) \oplus H_1(B) & H_1(A \cap B) \\
%            & \tilde{H}_0(A \cap B) & \tilde{H}_0(A) \oplus \tilde{H}_0(B) & \tilde{H}_0(A \cap B) & 0
Note that in degree 0 the sequence works in reduced homology.

\textbf{Question:} What do we mean by $\Delta_*$ being natural?\\
Given $(X,A,B)$ and $(X', A', B')$ and a continuous map $f: X \to X'$ such that $f(A) \subseteq A'$ and $f(B) \subset B'$. Then the following diagram commutes:
\[
\begin{tikzcd}
H_n(A \cap B) \arrow[r, "\phi_*"] \arrow[d, "f_*"] & H_n(A) \oplus H_n(B) \arrow[d, "f_*\times f_*"] \arrow[r, "\psi_*"] & H_n(X) \arrow[r, "\Delta_*"]  & H_{n-1}(A \cap B) \arrow[d] \\
H_n(A' \cap B') \arrow[r, "\phi_*'"] & H_n(A') \oplus H_n(B') \arrow[r, "\Delta_*'"] & H_n(X') \arrow[r]& H_{n-1}(A' \cap B')
\end{tikzcd}
\]
\begin{proof}
Let $\mathcal{U} = \{ A, B \}$ be a "special" open cover.
From the book, we have an isomorphism
$\sigma_*:H_n(X, \mathcal{U}) \xrightarrow{\cong} H_n(X)$, the restricted chain $C_n(X, \mathcal{U})$ can be written as $C_n(X, \mathcal{U}) = C_n(A) + C_n(B) \subset C_n(X)$. Recall that we have maps on chains
\begin{align*}
i_\sharp: C_n(A \cap B) \to C_n(A) & & j_\sharp: C_n(A \cap B) \to C_n(A)\\
k'_\sharp: C_n(A) \to C_n(X, \mathcal{U}) \hookrightarrow C_n(X) & & k'_\sharp: C_n(B) \to C_n(X, \mathcal{U}) \hookrightarrow C_n(X)
\end{align*}
Then there exists a homomorphism
\begin{align*}
\Phi: C_n(A \cap B) \xrightarrow{i_\sharp \times j_\sharp} C_n(A) \oplus C_n(B) \\
\Psi: C_n(A) \oplus C_n(B) \xrightarrow{k_*' - l_*'}
\end{align*}
 Now consider the following complexes
\begin{align*}
\mathcal{C} = (C_\bullet = C_\bullet(A \cap B), \partial_\bullet) \\
\mathcal{D} = (D_\bullet = C_\bullet(A) \oplus C_\bullet(B), \partial_\bullet' = (\partial_\bullet, \partial_\bullet)) \\
\mathcal{E} = (E_\bullet = C_n(X,\mathcal{U}), \partial_\bullet)
\end{align*}
You can check that the following diagram has exact rows and commutes
\[
\begin{tikzcd}
0 \arrow[r]
& C_n(A \cap B) \arrow[d, "\partial_n"] \arrow[r, "\Phi_n"]
& C_n(A) \oplus C_n(B) \arrow[r, "\Psi_n"] \arrow[d, "\partial_n'"]
& C_n(X, \mathcal{U}) \arrow[d, "\partial_n"] \arrow[r]
& 0 \\
0 \arrow[r]
& C_n(A \cap B) \arrow[r, "\Phi_{n-1}"]
& C_n(A) \oplus C_n(B) \arrow[r, "\Psi_{n-1}"]
& C_n(X, \mathcal{U}) \arrow[r]
& 0
\end{tikzcd}
\]
We have $\text{Im}(\Phi_n) = \text{ker}\Psi_n$. Therefor we have the short exact sequence of chain complexes
\[
0 \to \mathcal{C} \xrightarrow{\Phi} \mathcal{D} \xrightarrow{\Psi} \mathcal{E} \to 0
\]
giving us a long exact sequence with boundary maps $\Delta_n: H_n(\mathcal{E}) \to H_{n-1}(\mathcal{C})$. Because $\sigma_*$ is an isomorphism, we have the natural map.
\end{proof}

\section{March 16, 2015 (Monday)} Suppose $A$ and $B$ are subsets of $X$ such that $\text{int}(A) \cup \text{int}(B) = X$. Let $\phi_*:(i_*, j_*): H_n(A\cap B) \to H_n(A) \oplus H_n(B)$ and $\psi_* = k_* - k_*:H_n(A) \oplus H_n(B) \to H_n(X)$. The for all $n \geq 1$ there is a natural isomorphism $\Delta_*:H_n(X) \to H_{n-1}(A \cap B)$ giving us the short exact sequence
\[
0 \to C_n(A \cap B) \to C_n(A) \oplus C_n(B) \to C_n(X) \to 0
\]
Giving us a long exact sequence
\[
\textbf{OMITTED... Add later}
\]

Moreover, if $A \cap B \neq \varnothing$ we can use reduced homology in dimension $0$.

\textbf{Examples:}

(1) Homology of the torus $X = S^1 \times S^1$. We take two sleeves $A$ and $B$ which each deformation retract to a cirlce, and their intersection deformation retracts of a disjoint union of two circles. Drawing out the long exact sequence, we get the part
\[
0 \xrightarrow{\psi_*} H_2(X) \xrightarrow{\Delta_*} \mathbb{Z} \oplus \mathbb{Z} \xrightarrow{\phi_*} \mathbb{Z} \oplus \mathbb{Z} \xrightarrow{\psi_*} H_1(X) \xrightarrow{\Delta_*} \tilde{H}_0(A \cap B) \cong \mathbb{Z} \to 0
\]

Recall that $\Delta_*$ is one to one, so its image is the kernel of $\phi_*$. Likewise, the image of $\phi_* = \text{ker}(\psi_*)$, and $\Delta_*:H_1(X) \to \tilde{H}_0(A \cap B)$ is onto. We must choose generators on our topological space, so $H_1(A \cap B) = \mathbb{Z}(\text{gen1})\oplus\mathbb{Z}(\text{gen2})$. Then $\phi_*(m,n) = (m-n, m-n) \in H_1(A) \oplus H_1(B)$. Hence the kernel of $\phi_*$ is the image of $\Delta_*$, so it's isomorphic to $\mathbb{Z}$. Then, the image of $\phi_*$ is the diagonal, which is the kernel of $\psi_*$. Now, we look at the short exact sequence
\[
0 \to H_1(A) \oplus H_1(B) / \text{im}\phi_* = \text{ker}\psi_* \xrightarrow{\psi_*} H_1(X) \xrightarrow{\Delta_*} \mathbb{Z} \to 0
\]
Notice $\{ (m,n) : m,n \in \mathbb{Z} \}/\{ (l,l): l \in \mathbb{Z} \}$, which is $\mathbb{Z}$. (observe this quotient is just $\mathbb{Z}^2/\mathbb{Z}$). Now we can look at
\[
0 \to \mathbb{Z} \to H_1(X) to \mathbb{Z} \to 0
\]
Because the term on the right is free, the sequence splits.

(2) We can use induction to find the homology groups of the spheres using overlapping overhemispheres.

\textbf{Jordan-Brauer Separation Theory:} (Related to the Jordan curve theorem)
Let $\gamma: [0,1] \to \mathbb{R}^2$
be a simple closed curve so that
$\gamma(0) = \gamma(1)$. Let
$\mathcal{C} = \{ \gamma(t) : 0 \leq t \leq 1 \}$. Then
$\mathbb{R}^2 \sim \mathcal{C}$. In homological terms, we only need to show
$H_0(\mathbb{R}^2 \sim \mathcal{C}) \cong \mathbb{Z}^2$ or
$\tilde{H}_0(\mathbb{R}^2 \sim \mathcal{C}) \cong \mathbb{Z}$. Consider
$\mathbb{R}^2 \sim \mathcal{C}$ on $S^2$. Let $(0,0)$ be the inside of the curve. Put $S62$ on "top of" $(0,0)$. Using the inverse of stereographic projection, we may take the curve onto
$S^2$. Call it $\tilde{\mathcal{C}}$. We can show that
$\tilde{H}_0(S^2 \sim \tilde{\mathcal{C}}) \cong \mathbb{Z}$.

\textbf{Theorem}(Jordan-Brauer Separation Theorem) Let $A \subset S^n$ with $n \geq 1$. and suppose $A$ is homeomorphic to $S^k$ for $0 \leq k \leq n-1$, then
\[
\tilde{H}_q(S^n - A) = \begin{cases}
\mathbb{Z} & q = n - k - 1 \\
0 & q \neq n - k - 1
\end{cases}
\]
For $n=2, k=1$, we have the original theorem.

\textbf{Lemma 6.1} Let $Y$ be a subset of $S^n$ that is homeomorphic to intervals $I^k$ for $0 \leq k \leq n$. Then the reduced homology of $\tilde{H}_q (S^n \sim Y) = 0$ for $q \in \mathbb{N} \cup \{ 0 \}$.

\section{March 18, 2015}

\textbf{Jordan Brauer Separation Theorem -- Continued}

\textbf{Lemma 6.1}
Let $Y \subset S^n$ that is homeomorphic to a $k$-cube $I^k$ for $0 \leq k \leq n$. Then $\tilde{H}_i(S^n \sim Y) = 0$ for each $i \in \mathbb{N} \cup \{ 0 \}$. True for $Y = h(I^0)=$ single point. We have $\tilde{H}_i(S^n \sim \{ pt \}) \cong \tilde{H}_i(\mathbb{R}^n) \cong 0$ for each $n \geq 0$. Assume now that if $f_j: I^j \to S^n$ are homeomorphisms onto their image $0 \leq j \leq k-1 < n$, then $\tilde{H}_i(S^n\sim f_j(I^j)) = 0$ for each $i \in \mathbb{N} \cup \{ 0 \}$. Now let $h: I^k \to S^n$ be a homeomorphism onto its image. We have to show $\tilde{H}_i(S^n \sim h(I^k))$ for each $i \in \mathbb{N} \cup \{ 0 \}$. Let $Y_0 = h([0, \frac{1}{2}]\times I^{k=1})$, $Y_1 = h([\frac{1}{2}, 1]\times I^{k-1})$, so $Y = Y_0 \cup Y_1 = h(I_k)$. Note $Y_0 \cap Y_1 = h(\{ \frac{1}{2} \} \times I^{k-1})$ which is in the homeomorphic image of $I^k-1$. Not $\tilde{H}_i(S^n \sim Y_0 \cap Y_1) = 0$ for each $i \geq 0$, by induction hypothesis. We have $Y_0, Y_1, Y, Y_0 \cap Y_1$ all closed and let $A = S^n \sim Y_0$ and $B = S^n \sim Y_1$, which are open. Note $A \cup B = S^n \sim (Y_0 \cap Y_1)$ and $A \cap B = S^n \sim (Y_0 \cup Y_1) = S^n \sim Y$. We use the Meyer-Vietoris sequence

\[
\begin{tikzcd}
\tilde{H}_k(A \cup B) \arrow[r, "\Delta_*"] & \tilde{H}_i(A \cap B) \arrow[r, "\phi_*"] & \tilde{H}_i(A) \oplus \tilde{H}_i(B) \arrow[r, "\psi_*"] & \tilde{H}_i(A \cup B)
\end{tikzcd}
\]
We have $\tilde{H}_{i+1}(A \cup B) = 0$ an $\tilde{H}_i(A \cup B) = 0$,
therefore $\phi_*$ is an isomorphism. Suppose by way of contradiction that $\exists [s] \in \tilde{H}_i(A \cap B)$ such that $[s] \neq 0$. Then $\phi_*([s]) = ((i_0)_*([s]), (i_1)_*([s])) \neq 0$ in $\tilde{H}_i(A)\oplus \tilde{H}_i(B)$.

Now fix $n$, by induction on k. Then $\tilde{H}_i(A)$

$Y_{0,0} \cup Y_{0,1} = Y_0 \sim \text{k-cube}$ so $S^n \sim Y_{0,0}$ and $S^n \sim Y_{0,1}$ are open an ... Look at page 63-65 for the proof.

Applications?:

\section{March 20, 2015 (Friday)}
\textbf{Proposition:} Let $A \subset S^n$ with $A$ homeomorphic to $S^{n-1}$. Then write $S^n \sim A \cong X_1 \coprod X_2$ where $X_1$ and $X_2$ are two path-components of $S^n \sim A$. Then $\partial X_1 = \partial X_2$.

We are interested in finding the relationship between the fundamental group of $X$ and it's first homology group.

\textbf{Definition:} Let $G$ be a discrete group. The commutator subgroup $[G,G]$ is the smallest subgroup of $G$ that contains $\{ aba^{-1}b^{-1} : a,b \in G \}$.

\textbf{Theorem (group theory):} Let $G$ be a discrete group then $[G,G]$ is a normal subgroup and $G/[G,G]$ is abelian. Also, if $\phi: G \to A$ is a group homomorphism into an abelian group $A$, then $[G,G] \subset \text{ker}\phi$.
\begin{proof}
Let $aba^{-1}b^{-1}$ and consider $g(aba^{-1}b^{-1})g^{-1}$ for some $g \in G$. This equals $gag^{-1}gbg^{-1}ga^{-1}g^{-1}b^{-1}g^{-1}$. This simplifies to $a'b'(a')^{-1}(b')^{-1}$ for $a' = gag^{-1}$ and $b' = gbg^{-1}$. Therefore $g[G,G]g^{-1} \subset [G,G]$, hence is normal. We know $G/[G,G]$ is abelian since $aba^{-1}b^{-1} \mapsto 1$ under the quotient map.

Similarly, if $\phi:G \to A$ is a homomorphism with $A$ abelian, we have $\phi(aba^{-1}b^{-1}) = A$, hence $[G,G] \subset \text{ker}\phi$.
\end{proof}

Let $X$ be a path connected space and fix some $\{ x_0 \} \subset X$. We want to show there is a homomorphism $h_X: \pi_1(X,x_0) \to H_1(X)$ and moreover $\pi_1(X,x_0)/[\pi_1(X,x_0),\pi_1(X,x_0)]$.

We now define $h_X: \pi_1(X, x_0) \to H_1(X)$. Let $\alpha \in \pi_1(X,x_0)$. Suppose $f:I \to X$ is a loop based at $x_0$ with $[f] = \alpha$. Since $\partial f = -(A_1f -B_1f) = f(1) - f(0) = 0$, $f \in Z_1(X)$. Define $h_X(\alpha) = [f]$ where $f$ is a loop representing $\alpha$. Suppose $f$ and $g$ are homotopic maps, hence both representing $\alpha \in \pi_1(X,x_0)$, we want $h_X(f) = h_X(g)$. $F:I \times I \to X$ such that $F(x,0) = f(x)$ and $F(x,1) = g(x)$. We have $F \in C_2(X)$ since $F: I^2 \to X$. We check that $g = f + \partial F$. Then $[g] = [f + \partial F] = [f]$ in $H_1(X)$. Then $h_X$ is well-define. Next we show that this map is infact a homomorphism. $h_X(f_1\cdot f_2) = h_X(f_1) + h_X(f_2)$. Recall that
\[
f_1 \cdot f_2 = \begin{cases}
f_1(2t) & 0 \leq t \leq \frac{1}{2} \\
f_2(2t - 1) & \frac{1}{2} \leq t \leq 1
\end{cases}
\]
After break, we'll show $[f_1 \cdot f_2]_{H_1(X)} = [f_1]_{H_1(X)} + [f_2]_{H_1(X)}$

\section{March 30, 2015 (Monday)}
Today we study the relationship between $H_1(X)$ and $\pi_1(X,x_0)$ for a path connected space $X$.

\textbf{Theorem:} Fix $x_0 \in X$ in a path connected space $X$. Then, there is agroup homomorphism
\[
h_x: \pi_1(X, x_0) \to H_1(X)
\]
Moreover, $h_X$ is surjective and its kernel is
\[
[\pi_1(X, x_0), \pi_1(X, x_0)]
\]
\begin{proof}
Recall for $\alpha \in \pi_1(X, x_0)$ is represented by $f_\alpha:[0,1] \to X$ with $f_\alpha(0) = f_\alpha(1) = x_0$. Then $h_X(\alpha) = [f_\alpha]$ where $f_\alpha \in Z_1(X)$ and $\partial f_\alpha = 0$. Suppose $f,g : [0,1] \to X$ with $f(0) = f(1) = g(0) = g(1) = x_0$ that both represent $\alpha \in \pi_1(X,x_0)$. Then $f,g$ are homotopic as loops in $X$. So there exists $F:[0,1]\times[0,1] \to X$ with $F(x,0) = f(x)$ and $F(x,1) = g(x)$ for each $x \in X$. Also, $F(0,y) = x_0 = F(1,y)$ for each $y \in [0,1]$. We view $F \in Q_2(X)/D_2(X) = C_2(X)$. Then $\partial F: [0,1] \to X$ is given by $\partial F(x) = -[F(1,x) - F(0,x)] + [F(x,1) - F(x,0)] = -[T_{x_0} - T_{x_0}] + g(x) - f(x)$. Therefore $\partial F(x) + f(x) = g(x)$. Notice that the homology classes are equal; that is, $[f] = [g] \in H_1(X)$. We now show $h_X$ preserves group multiplication. Let $\alpha, \beta \in \pi_1(X, x_0)$ with $\alpha = [f]$ and $\beta = [g]$. We have $f:[0,1] \to X$ and $g:[0,1] \to X$ with $f(0) = f(1) = x_0 = g(0) = g(1)$. Then $\alpha \cdot \beta = [g \star f]$. We set
\[
g \star f(x) = \begin{cases}
f(2x) & 0 \leq x \leq \frac{1}{2} \\
g(2x - 1) & \frac{1}{2} \leq x \leq 1
\end{cases}
\]
We want to show $h_X([g \star f ]) = h_X([g]) + h_X([f])$. We define $T:[0,1] \times [0,1] \to X$ with $T \in Q_2(X)$ by
\[
T(x_1, x_2) = \begin{cases}
f(x_1 + 2x_2) & x_1 + 2x_2 \leq 1 \\
g(\frac{x_1 + 2x_2 - 1}{x_1 + 1}) & 1 \leq x_1 + 2x_2
\end{cases}
\]
Then we have
\begin{align*}
\partial T(x) & = -(T(1,x) - T(0,x)) + T(x,1) - T(x,0) \\
& = -g(\frac{1 + 2x - 1}{1+1}) + \begin{cases}
f(2x) &  0 \leq x \leq \frac{1}{2} \\
g(2x - 1) & \frac{1}{2} \leq x \leq 1
\end{cases} \\
& + g(\frac{x+2-1}{x+1}) - g(x) \\
\partial T(x) & = -g(x) + g \star f(x) + g(1) - f(x)
\end{align*}
Notice $g(1) \in D_1(X)$ hence $f + g + \partial T = g \star f$ in $H_1(X)$, so $[f] + [g] = [g \star f]$ therefore $h_X([g] \star [f]) = h_X([g]) + h_X([f])$. Fill in the gaps that $h_X$ is a homomorphism is surjective into $H_1(X)$ and $\text{ker}(h_X) = [\pi_1(X,x_0), \pi_1(X,x_0)]$. You can also check that $h_X: \pi_1(X, x_0) \to H_1(X)$ is natural in the following sense: Let
$(X, x_0)$ and $(Y,y_0)$ be path connected spaces with base points $x_0$ and $y_0$ respectively. Let $\phi: X \to Y$ be a basepoint preserving map; that is $\phi(x_0) = y_0$. Then there exists a homomorphism $\phi_*:\pi_1(X, x_0) \to \pi_1(Y, y_0)$ given by $\phi_*(f_\alpha) = \phi \circ f_\alpha$ such that the following diagram commutes:
\[
\begin{tikzcd}
\pi_1(X, x_0) \arrow[r, "\phi_*"] \arrow[d, "h_X"] & \pi_1(Y, y_0) \arrow[d, "h_Y"] \\
H_1(X) \arrow[r, "\phi_*"] & H_1(Y)
\end{tikzcd}
\]
\end{proof}

\textbf{Adjoining cells to spaces:} Let $X,Y$ be topological spaces and $A \subset Y$ a subspace. Let $f: A \to X$ by a continuous map. Define an equivalence relation on $Y \coprod X$ by $x \sim f(x)$ for any $x \in A$. We call this space $X^*$. This is also notated $Y \cup_f X$ in other books.

The process we described is called attaching $Y$ to $X$.

Observe that $Y$ may not always be embedded into $Y \cup_f X$. Consider $Y = [0,1]$, $A \subset Y$ by $A = \{ 0, 1 \}$, and $X = S^2 \subset \mathbb{R}^3$. Define $f: A \to S^2$ given by $f(0) = f(1) = (0,0,1)$. Now suppose $X$ is fixed and let $Y = \coprod_{i = 1}^k E_i^n$ for $n,k \in \mathbb{N}^+$ with $E_i^n = \{ (x_i) \in \mathbb{R}^n : \sum x_i^2 \leq 1 \}$. Let $A = \coprod_{i = 1}^n S_i^{n-1}$ where each $S_i^{n-1} \subset E_i^n$ where each $S_{i}^{n-1} \subset E_i^n$ with the boundary $\dot{E}_i^n = S^{n-1}_i$. The question is, how do we compute the (relative) homology groups of $Y \cup_f X$?

\section{April 1, 2015 (Wednesday)}
Recall $X = \coprod_{i = 1}^k E_i^n$ and $Y = \coprod_{i = 1}^n S_i^{n-1}$. We have $S^{n-1} \subseteq E^n$. Let $X$ be a compact Hausdorff space. The map $f:A \to X$ defined as the restriction of a continuous function $f:S^{n-1} \to X$. We let $X^* = Y \cup_f X$ and $\pi: Y \coprod X \to X^* = X \coprod Y / \sim$. Note that $\pi$ is one to one on $X$ into $X^*$ therefore $X$ is a subspace $X^*$, but $\pi$ may not be one to one on $Y$.

\textbf{Lemma: (EXERCISE)} Let $(X,A)$ and $(Y,B)$ be pairs of spaces where $B \subseteq A \subseteq X$ and $Y \subseteq X$. Suppose that $B$ is a deformation retract of $A$, and $Y$ is a deformation retract of $X$. Then the inclusion map $i: (Y,B) \hookrightarrow (X,A)$ induces an isomorphism $i_*: H_q(Y,B) \to H_q(X, A)$ in relative homology.
\begin{proof}
Trivial. This proof comes from two long exact sequences in homology and the five-lemma.
\end{proof}

\textbf{Theorem:} Let $X^*$ and $X$ be as described from above. Then
\[
H_q(X^*, X) = \begin{cases}
0 & q \neq n \\
\mathbb{Z}^k & q = n
\end{cases}
\]
\begin{proof}

For each $i$ we have a map $\pi_i = \pi|_{E_n^{(i)}}: (E^n_i, S^{n-1}_i) \to (X^*, X)$, thus we obtain $(\pi|_{E_n^{(i)}})_*: H_q(E^n_i, S^{n-1}_i) \to H_q(X^*, X)$. We thus obtain $H_q(X^*, X) = \bigoplus_{i=1}^k(\pi_i)_*(H_q(E^n_i, S^{n-1}_i))$.

Let $D_i^n = \{ x \in \mathbb{R}^n: \| x \| \leq \frac{1}{2} \} \subseteq E^n_i$. Note $S^{n-1}_i \subseteq E^n_i - D^n_i$. Let $\mathcal{D}_i = \prod_i(D_i^n) \subset X^*$. Let $a_i \in \mathcal{D}_i = \pi_i(0)$ with $0 \in D_i^n \subseteq E^n_i$ with $a_i \in \mathcal{D}_i$
Let $\mathcal{D} = \cup_{i=1}^k \mathcal{D}_i \subset X^*$. Let $A^0 = \cup^{k}_{i=1} \subset \mathcal{D} \subseteq X^*$. For each $i$ with $1 \leq i \leq k$. We have $(\mathcal{D}_i, \mathcal{D}_i - \{ a_i \}) \subseteq (X^*, X' = X^* - A^0)$, then $(\mathcal{D}, \mathcal{D} - A^0) \subset (X^*, X' = X^* - A^0)$. So by the second problem in the last problem, we have
\begin{align*}
H_q(\mathcal{D}, \mathcal{D} - A^0) & = \bigoplus_{i=1}^k H_q(\mathcal{D}_i, (\mathcal{D} - A^0) \cap \mathcal{D}_i) \\
& = \bigoplus_{i=1}^k H_q(\mathcal{D}_i, \mathcal{D}_i - \{ a_i \})
\end{align*}
We now note that $X = \pi(X)$ is a deformation retract of $X^* - A^0$. Since
\begin{align*}
X^* - A^0 &= X^* - \bigcup_{i=1}^k\{ a_i \} \\
& = \pi(\coprod_{i=1}^k E_i^n \coprod X) - \pi(\coprod \{ 0 \}_i \coprod \varnothing)\\
& = \pi(\coprod_{i=1}^k (E_i^n - \{ 0 \}) \coprod X)
\end{align*}
which deforms to
\[
\pi(\coprod_{i=1}^k S^{n-1}_i \coprod X) = X
\]
So by the next lemma, the inclusion $i:(X^*, \pi(X)) \to (X^*, X^* - A^0)$ induces an isomorphism $(i)_*: H_q(X^*, X) \xrightarrow{\cong} H_q(X^*, X^* - A^0)$. Consider the inclusion $\Phi: (\mathcal{D}, \mathcal{D}-A^0) \to (X^*, X^* - A^0)$. We claim $\Phi_*: H_q(\mathcal{D}, \mathcal{D}-A^0) \xrightarrow{\cong} H_q(X^*, X^* - A^0)$.

Let $W = X^* - \mathcal{D}$ which is open since $\mathcal{D}$ is closed. Then
\begin{align*}
\bar{W} &= X^* - \text{Int}(\mathcal{D}) \\
&= X^* - \pi(\bigcup_{i=1}^k\text{Int}(D^n_i)) \\
&= X^* - \pi(\bigcup_{i=1}^k \{ x \in \mathbb{R}^n : \| x \| < \frac{1}{2} \})
& \subseteq \text{Int}(X^* - A^0)
& = X^* - A^0
\end{align*}
By the excision theorem $\Phi_*: H_q(X^* - W, (X^* - A^0) - W) \to H_q(X^*, X^* - A^0)$ is an isomorphism for each $q \in \mathbb{N}$. That is $\Phi_*: H_q(\mathcal{D}, \mathcal{D} - A^0) \to H_q(X^*, X^* - A^0)$ is an isomorphism for each $q \in \mathbb{N}$.

Using these facts, $(i_*)^{-1} \circ \Phi_*: H_q(\mathcal{D}, \mathcal{D} - A^0) \to H_q(X^*, X)$ is an isomorphism for each $q \in \mathbb{N}$. To finish the theorem, note
\begin{align*}
H_q(\mathcal{D}, \mathcal{D} - A^0) & = \bigoplus_{i = 1}^kH_q(D_i, D_i - \{ 0 \}) \\
& = \bigoplus_{i=1}^k H_q(E^n_i, S^{n-1}_i) \\
& = \begin{cases}
0 & q \neq n \\
\mathbb{Z}^k & q = n
\end{cases}
\end{align*}
\end{proof}

\textbf{Corollary:} Let $X \to X^*$ where $X^* = U \bigcup_f X$ as in the previous theorem. Then $i_*: H_q(X) \to H_q(X^*)$ is an isomorphism except for possibly $q \in \{ n, n-1 \}$. For those values of $q$ we have the long exact sequence
\[
0 \to H_n(X) \to H_n(X^*) \to H_n(X^*, X) \to H_{n-1}(X) \to H_{n-1}(X^*) \to 0
\]
\begin{proof}
For $q > n$ we have $H_{q+1}(X^*, X) = 0$. Look at the photo for the rest of the details.
\end{proof}

\section{3 March, 2015 (Friday)}
We give $\mathbb{RP}^n$ the quotient topology from $S^n$.

\textbf{Theorem:} $\mathbb{RP}^n$ is homeomorphic to $E_1^n \bigcup_f \mathbb{RP}^{n-1}$ for
\[
f: \dot{E}^n_1=S^{n-1} \to \to \to \to \to \to \to \mathbb{RP}^{n-1}=S^{n-1}/\sim
\]
\begin{proof}
Recall $S^n \subseteq \mathbb{R}^{n+1}$ is the set $E_+^N \bigcup E_-^n \bigcup S^{n-1}$. When attaching cells, we view $E^n = \{(x_1, \ldots, x_n) : \sum_{i=1}^n x_i^2 = \leq 1 \}$ and $S^{n-1}$ is the boundary of $E_n$. Observe that $E_{+}^n$ is homeomorphic to $E^n$ by
\[
(x_1, \ldots, x_n, x_{n+1}) \mapsto \left(\frac{x_1}{\sqrt{1 - x_{n+1}^2}}, \ldots, \frac{x_1}{\sqrt{1 - x_{n+1}^2}}\right)
\]
This map takes the image of $S^{n-1}$ in $E_+^n$ to $S^{n-1}$. Then, consider the diagram
\[
\begin{tikzcd}
&S^{n-1} \arrow[r, "\pi_{n-1}"] \arrow[d] \arrow[ld]& \mathbb{RP}^{n-1} \arrow[d, "\iota"] \\
E^n_+ \arrow[r, hookrightarrow] & S^n \arrow[r,"\pi_n"] & \mathbb{RP}^n
\end{tikzcd}
\]
We have a map $E_+^n \coprod \mathbb{RP}^{n-1} \to \mathbb{RP}^n$ by the diagram: if $x \in E_+^n$, $\pi_n(x) \in \mathbb{RP}^n$ and if $l \in \mathbb{RP}^{n-1}$ with $\iota(l) \in \mathbb{RP}^n$. Now we chack that is $y \in S^{n-1}$, $\iota \circ \pi_{n-1}(y) = \pi_n(y) \in \mathbb{RP}^n$. Observer this map is surjective and if it's continuous, and only not 1-1 on $S^{n-1}$ from the diagram. Since $\mathbb{RP}^n$ is compact Hausdorff, $\mathbb{RP}^n \cong E^n_+ \bigcup_f \mathbb{RP}^{n-1}$.
\end{proof}

\textbf{Definition:} A \textbf{finite CW-complex} (or a \textbf{cell-complex}) is a topological space $X$ with a filtration
\[
\varnothing = X^{(-1)} \subseteq X^{(0)} \subseteq X^{(1)} \subseteq \cdots \subseteq X^{(n)} = X
\]
where you get from the \textbf{$(j-1)$-skeleton} $X^{j-1}$ to the $j$-skeleton $X^{j}$ by attaching a finite number of $j$-cells
\[
\coprod_{i=1}^{k_j} E_i^j
\]
along the boundaries
\[
\coprod_{i=1}^{k_j} S_i^{j-1}
\]
via continuous maps $f_i: S_i^{j-1} \to X^{(j-1)}$ such that
\[
X^{(j)} = \left[\coprod_{i=1}^{k_j}E_i^j \right] \bigcup_f X^{(j-1)}
\]
\textbf{Examples:}

(1) We get $S^n$ from $S^{n-1}$ by attaching the lower and upper hemispheres of $S^n$ along $S^{n-1}$.

(2) $\mathbb{RP}^n$ is obtained from the last theorem.

(3)

\section{April 6, 2015 (Monday)}
Before talking about homology with coefficients, we need tensor products.

\textbf{Tensor Products:} Observe that the category of abelian groups is equivalent to the category of $\mathbb{Z}$-modules. For $\mathbb{Z}$-modules $A,B$, we have $A \times B = \{ (a,b) | a \in A \text{ and } b \in B \}$. Let $F(A \times B)$ be the free abelian group generated by the pairs $(a,b)$. This is the collection of finite sums of the generators, or more generally
\[
\{ \sum m_i (a_i,b_i) | m_i \in \mathbb{Z} \text{ and all but finitely many } m_i = 0 \}
\]
Let $R(A \times B)$ be the subgroup of $F(A \times B)$ generated by elements of the form
\begin{align*}
(a_1 + a_2, b) + (-1)(a_1, b) + (-1)(a_2, b) & & (a, b_1 + b_2) + (-1)(a,b_1) + (-1)(a,b_2) \\
(ma,b) + (-1)m(a,b)& & (a,mb) + (-1)m(a,b)
\end{align*}
for $a, a_1, a_2 \in A$, $b, b_1, b_2 \in B$, and $m \in \mathbb{Z}$. We define
\[
A \otimes B = A \otimes_\mathbb{Z} B = F(A \times B) / R(A \times B)
\]
We omit $\mathbb{Z}$ from $\otimes$ since we only look at $\mathbb{Z}$-modules, but in general, it's a wise idea to specify the ring your modules are over. The \textbf{simple tensors} are the elements under the image of this quotient map. They are of the form
\begin{align*}
\pi(1\cdot (a,b)) = a \otimes b
\end{align*}
They have the following nice properties:
\begin{align*}
(a_1 + a_2)\otimes b = a_1 \otimes b + a_2 \otimes b \\
a\otimes (b_1 + b_2) = a \otimes b_1 + a \otimes b_2 \\
m(a \otimes b) = (ma)\otimes b = a \otimes (mb)
\end{align*}
\textbf{Proposition:} Tensor products satisfy the following universal mapping property:
\[
\begin{tikzcd}
A \times B \arrow[r, "\phi"] \arrow[d, "\otimes"'] & \mathbb{Z} \\
A \otimes B \arrow[ru, "\hat{\phi}"']
\end{tikzcd}
\]
That is; for any bilinear map $\phi: A \times B \to \mathbb{Z}$ factors uniquely through $A \otimes B$. This means that there exists a unique map $\hat{\phi}: A \otimes B \to \mathbb{Z}$ such that $\phi = \hat{\phi} \circ \otimes$.

\textbf{Definition:} Given a chain complex $\mathcal{C} = (C_\bullet, \partial_\bullet)$, we define the \textbf{chain complex with coefficients} as
\[
\mathcal{C} \otimes G = (C_\bullet \otimes G, \partial_\bullet' = \partial_\bullet \otimes \mathbb{1}_G)
\]
Clearly, we need to check that this is in fact a chain complex, but we also need to understand what the tensor product of morphisms actually means! We have the map $\partial_n \times \mathbb{1}_G : F(C_n \times G) \to F(C_{n-1} \times G)$ is defined by
\[
(\partial_n \times \mathbb{1}_G) \left( m \sum_{i=1}^N(a_i,g_i) \right) = \sum_{i=1}^N (\partial_n(a_i), g_i)
\]
Now, we must quotient by the induced relations $R(C_n \times G)$. I'll give one of them, but leave the rest as an exercise!
\begin{align*}
(\partial_n \times \mathbb{1}_G)[(c_1 + c_2, g) - (c_1,g) - (c_2,g)] \\ = (\partial_n(c_1 + c_2), g) + (-1)(\partial_n(c_1), g) + (-1)(\partial_n(c_2), g) \\
=  (\partial_n(c_1) + \partial_n(c_2), g) + (-1)(\partial_n(c_1), g) + (-1)(\partial_n(c_2), g)
\end{align*}

Consider the diagram
\[
\{C_n \otimes G \xrightarrow{\partial_n'} C_{n-1}\otimes G\} = \{ C_n \otimes G \xrightarrow{\partial_n \otimes \mathbb{1}_G} C_{n-1}\otimes G \}
\]
We have the maps $\partial_n'(c \otimes g) = \partial_n(c) \otimes g$. Since
\[
0 \otimes g = 0 (1 \otimes g) = 1 \otimes 0 = 0
\]
and
\[
(\partial_{n-1}'\circ \partial_{n}')(c \otimes g) = (\partial_{n-1}\circ \partial_{n})(c) \otimes g = 0 \otimes g
\]
for each $c \otimes g \in C_n \otimes G$, the "complex" with coefficients in $G$ is indeed a complex! Now we can define the homology by
\[
H_n(C_\bullet \otimes G) = \frac{Z_n(C_\bullet \otimes G)}{B_n(C_\bullet \otimes G)}
\]
The exact and boundary elements are given the obvious definition; that is, the abstract definition.

\textbf{Question:} When does $H_n(C_\bullet \otimes G) = H_n(C_\bullet) \otimes G$. For $\mathbb{Z}$, this is trivial since for any $\mathbb{Z}$-module $M$, $M \otimes \mathbb{Z} = M$ (note this holds true over any ring as well). We answer this question using the universal coefficient theorem.

\section{April 8, 2015 (Wednesday)}
Let $(X, A)$ be a pair of topological spaces, $G$ and abelian group, and
\[
0 \to C_\bullet \to D_\bullet \to E_\bullet \to 0
\]
a short exact sequence of chain complexes. We form the complexes of local coefficients. Observe that in general $-\otimes_\mathbb{Z}G$ is only right exact; that is,
\[
C_\bullet \otimes G \to D_\bullet \otimes G \to E_\bullet \otimes G \to 0
\]
is exact. We can form $H_n(C_\bullet \otimes G) = H_n(A; G)$, $H_n(D_\bullet \otimes G) = H_n(X; G)$, and $H_n(E_\bullet \otimes G) = H_n(X,A;G)$, but it's not clear if a long exact sequence exists.

\textbf{Claim:} However, if the original short exact sequence is split, then the complex with local coefficients is exact. It becomes clear since the complex is isomorphic to
\[
0 \to C_\bullet \to C_\bullet \oplus E_\bullet \to E_\bullet \to 0
\]
and because $(C_\bullet \oplus E_\bullet)\otimes G = (C_\bullet \otimes G) \oplus (E_\bullet \otimes G)$, the claim becomes obvious. In this case, we can get a long exact sequence! Since $C_n(X,A)$ is still a free abelian group, we can get the desired long exact sequence
\[
\cdots \xrightarrow{\delta_{k+1}} H_k(A; G) \to H_k(X; G) \to H_k(X,A;G) \xrightarrow{\delta_k} H_{k-1}(A;G) \to \cdots
\]
from homological methods.

\textbf{Definition} Let $A$ be an abelian group. a free resolution for $A$ is a short exact sequence
\[
0 \to R \xrightarrow{i} F \xrightarrow{\pi} A \to 0
\]
where $R \subset F$ and $F$ is a free abelian group.

\textbf{Factoid:} Any abelian group $A$ has a free resolution. Notice that for the free abelian group generated from A, $F(A)$, has elements of the form
\[
\sum_{i=1}^N m_i [a_i] \text{ for } m_i \in \mathbb{Z} \text{ and } a_i \in A
\]
Consider the homomorphism $\pi: F(a) \to A$ given by
\[
\pi(\sum_{i=1}^N m_i [a_i]) = \sum_{i=1}^N m_i a_i
\]
The kernel of this map is a subgroup of $F(A)$. Then, we have the free resolution
\[
0 \to R = \text{ker}(\pi) \xrightarrow{\iota} F(A) \xrightarrow{\pi} A \to 0
\]
In general, given any free resolution, $0 \to R \to F \to A \to 0$, and for $G$ an abelian group, $- \otimes_\mathbb{Z} G$ is still right-exact on this sequence, but we have a tool which measures the failure for left exactness. This is called the $Tor$ functor. We define it as
\[
Tor_\mathbb{Z}^1(A;G) := \text{ker}(R \xrightarrow{\iota \otimes \mathbb{1}_G} F)
\]

\textbf{Remark:} $Tor(A;G)$ is independent of the free resolution.

\textbf{Theorem:}(Universal Coefficient Theorem for Homology) For a chain complex $C_\bullet$, there is a short exact sequence
\[
0 \to H_n(X) \otimes G \to H_n(X;G) \to Tor(H_{n-1}(X); G) \to 0
\]

\section{April 10, 2015}
\textbf{Theorem:} (6.2/ Universal Coefficient Theorem) Let $(C_\bullet, \partial_\bullet)$ be a chain complex of free abelian groups with corresponding homology groups $\{H_k(C_\bullet)\}_{k \in \mathbb{N}_+}$. Then, there exists a collection of short exact sequences
\[
0 \to H_n(X) \otimes G \to H_n(X;G) \to Tor(H_{n-1}(X); G) \to 0
\]

\textbf{Corollary:} Let $G$ be an abelian group, and $(X,A)$ a pair of topological spaces, then we have the long exact sequence with coefficients in $G$:
\[
\cdots \to H_{k+1}(X,A;G) \xrightarrow{\delta_{k+1}} H_k(A;G) \to H_k(X; G) \to H_k(X,A;G) \xrightarrow{\delta_k} H_{k-1}(A;G) \to \cdots
\]
These groups are given by
\begin{align*}
H_n(X;G) \cong H_n(X) \otimes G \oplus Tor(H_n(X), G)\\
H_n(X,A;G) \cong H_n(X,A;G) \oplus Tor(H_n(X,A), G)
\end{align*}
Observe that the splitting is noncanonical:

\textbf{Proposition:} Let $f:(X,A) \to (Y,B)$ be a map of pairs, with corresponding homology maps $f_*: H_n(X) \to H_n(Y)$ and $f_*: H_n(X) \to H_n(Y)$. The splitting just mentioned in noncanonical.
\begin{proof}
Consider a free resolution of $G$
\[
0 \to G_1 \xrightarrow{j} G_0 \xrightarrow{\tau} G \to 0
\]
Dedekind? proved that this implies $G_0$ is a free abelian group and $G_1$ a subgroup of a free abelian group which is also free. Since the groups in $C_\bullet$ are free, tensoring our chain complex with the short exact sequence in the hypothesis gives
\[
\begin{tikzcd}
0 \to C_n \otimes G_1 \arrow[r, "Id_{C_\bullet} \otimes j"] \arrow[d, "\partial_n \otimes Id_{G_1}"] & C_n \otimes G_0 \arrow[r, "Id_{C_\bullet} \otimes \tau"] \arrow[d, "\partial_n \otimes Id_{G_0}"] & C_n \otimes G \arrow[r] \arrow[d, "\partial_n \otimes Id_{G}"] & 0 \\
0 \to C_{n-1} \otimes G_1 \arrow[r, "Id_{C_\bullet} \otimes j"] & C_{n-1} \otimes G_0 \arrow[r, "Id_{C_\bullet} \otimes \tau"]& C_{n-1} \otimes G \arrow[r] & 0
\end{tikzcd}
\]
This commuting diagram gives a short exact sequence of chain complexes giving us a long exact sequence of homology groups for the chain complexes $\{ C_\bullet \otimes G_1, \partial_n \}$, $\{ C_\bullet \otimes G_0, \partial_n' \}$, $\{ C_\bullet \otimes G_1 \partial_n \}$, we have the corresponding long exact sequence
\[
\cdots \xrightarrow{\delta_{q+1}} H_q(C_\bullet \otimes G_1) \xrightarrow{J_*} H_q(C_\bullet \otimes G_0) \xrightarrow{T_*} H_q(C_\bullet \otimes G) \xrightarrow{\delta_q} \cdots
\]
\end{proof}

\textbf{Remark:} If $F$ is a free abelian gruop, and $\{C_\bullet, \partial_\bullet \}$ is a chain complex, then tensoring this chain complex yields a complex $\{ C_\bullet \otimes F, \partial_\bullet' \}$ with the property $H_n(C_\bullet \otimes G) = H_n(C_\bullet) \otimes G$. Notice that this implies that our long exact sequence found in the previous proposition is a long exact sequence of free abelian groups isomorphic to
\[
\cdots \xrightarrow{\delta_{q+1}} H_q(C_\bullet)\otimes G_1 \xrightarrow{J_*} H_q(C_\bullet)\otimes G_0 \xrightarrow{T_*} H_q(C_\bullet)\otimes G \xrightarrow{\delta_q} \cdots
\]
We construct this map
\[
H_q(C_\bullet) \otimes G \xrightarrow{\iota_*} H_q(C_\bullet \otimes G)
\]
by sending $[f] \otimes g \mapsto [f \otimes g]$ for $f$ a homology class and $g$ an element of the group.
%Aside on smith normal form: Given a matrix $M \subset M_n(\mathbb{Z})$ there exist, $S,T \in GL_n(\mathbb{Z})$ such that $SMT = $ a special matrix...

\section{April 13, 2015 (Monday)}
More universal coefficient theorem.

\textbf{Example} We have already seen
\[
H_n(\mathbb{RP}^2) = \begin{cases}
0 & n \geq 2 \\
\mathbb{Z}_2 & n = 1 \\
\mathbb{Z} & n = 0
\end{cases}
\]
Given $G = \mathbb{Z}/2 = \mathbb{Z}/2\mathbb{Z}$,
\[
H_n(\mathbb{RP}^2; \mathbb{Z}/2) = (H_n(\mathbb{RP}^2) \otimes \mathbb{Z}/2) \oplus Tor(H_{n-1}(\mathbb{RP}^2), \mathbb{Z}/2)
\]
Then
\[
H_n(\mathbb{RP}^2; \mathbb{Z}/2) = \begin{cases}
(0 \otimes \mathbb{Z}/2) \oplus Tor(\mathbb{Z}/2, \mathbb{Z}/2) & n = 2 \\
(\mathbb{Z}/2 \otimes \mathbb{Z}/2) \oplus Tor(\mathbb{Z}, \mathbb{Z}/2)  & n = 1 \\
\mathbb{Z} \otimes \mathbb{Z}/2 \oplus Tor(\{ 0 \}, \mathbb{Z}/2) & n = 0 \\
\end{cases}
\]
so
\[
H_n(\mathbb{RP}^2; \mathbb{Z}/2) = \begin{cases}
\mathbb{Z}/2 & n \in \{ 0,1,2 \} \\
0 & n \geq 3
\end{cases}
\]

\textbf{Exercise:} Show $Tor(G,A) = 0$ for any free abelian group $A$.

Let $G$ be an abelian group and $G_0, G_1$ abelian free groups, and
\[
0 \to G_1 \to G_0 \to G \to 0
\]
a free resolution. $A$ is a free abelian group, so we write $A = \bigoplus_{\alpha \in \Sigma} [\mathbb{Z}]_\alpha$, so for $i \in \{ 0 , 1 \}$
\[
G_i \otimes A = G_i \otimes \left( \bigoplus_{\alpha \in \Sigma} [\mathbb{Z}]_\alpha \right) = \bigoplus_{\alpha \in \Sigma} [G_i]_\alpha
\]
Since $(-\otimes A)$ is a right exact functor,
\[
\bigoplus_{\alpha \in \Sigma} G_1 \to \bigoplus_{\alpha \in \Sigma} G_0 \to \bigoplus_{\alpha \in \Sigma} G \to 0
\]
is an exact sequence. Then,
\[
Tor_1(G,A) = \text{ker}\left\{ \bigoplus_{\alpha \in \Sigma} G_1 \to \bigoplus_{\alpha \in \Sigma} G_0 \right\}
\]
Hence $Tor_1(G,A) = 0$.

For the trivial topological space $X = \{ * \}$ and $G$ an abelian group,
\begin{align*}
H_n(X, G) & = \begin{cases}
(H_n(X) \otimes G) \oplus Tor(H_{n-1}(*), G) & n \geq 1 \\
(\mathbb{Z} \otimes G) \oplus Tor(0, G) & n = 0
\end{cases} \\
& = \begin{cases}
0 & n \geq 1 \\
G & n = 0
\end{cases}
\end{align*}

\textbf{Cohomology!} Given a chain complex $(C_\bullet, \partial_\bullet)$ and an abelian group $G$, we form a cochain complex $(C^\bullet, \delta^\bullet)$ as follows: Given a fixed $n$, let $f_1, f_2 \in Hom(C_n, G)$. Define $f_1 + f_2$ as
\[
(f_1 + f_2)(l) = f_1(l) + f_2(l)
\]
for $l \in C_n$. It is a quick exercise to show that the additive structure gives an abelian group structure on $Hom(C_n, G)$; denote it by $C^n$. Consider the following diagram:
\[
\begin{tikzcd}
\cdots \arrow[r, "\partial_{n+2}"] & C_{n+1} \arrow[r, "\partial_{n+1}"] \arrow[dr] & C_n \arrow[r, "\partial_{n}"] \arrow[d] & C_{n-1} \arrow[ld, "\psi"] \arrow[r, "\partial_{n-1}"] & \cdots \\
&& G &&
\end{tikzcd}
\]
Observe that composition of $\psi$ with $\partial_n$ gives a map $C_n \to G$. It's a quick exercise to show this defines a group homomorphism $\delta^{n-1}: C^{n-1} \to C^n$. Because $(\delta^n \circ \delta^{n-1})(\psi) = \psi \circ (\partial_{n} \circ \partial_{n+1}) = 0$, the induced maps are differentials. Therefore, we can rightly give $(C^\bullet, \delta^\bullet)$ the name of a \textbf{cochain complex}. Notice that the indices go up in index; ie, we have the diagram
\[
\cdots \xrightarrow{\delta^{n-2}} C^{n-1} \xrightarrow{\delta^{n-1}} C^{n} \xrightarrow{\delta^{n}} C^{n+1} \xrightarrow{\delta^{n+1}} \cdots
\]

\textbf{Definition:} Given a cochain complex $(C^\bullet, \delta^\bullet)$, we define the \textbf{cohomology} of it as
\[
H^n(C^\bullet) = \frac{\text{ker}\{\delta^n: C^n \to C^{n+1} \}}{\text{im}\{\delta^{n-1}: C^{n-1} \to C^n\}} = \frac{Z^n}{B^n}
\]
We call $Z^n$ and $B^n$ the \textbf{n-cocycles} and \textbf{n-coboundaries}, respecitvely.
\section{April 15, Wednesday}

Given a topological space $X$ with a subspace $A$, and $G$ an abelian group, we have the singular chain complexes $(C_\bullet(X), \partial_\bullet)$, $(C_\bullet(A), \partial_\bullet)$, and $(C_\bullet(X,A), \partial_\bullet)$. Dualizing these complexes with $\text{Hom}_{\mathbb{Z}}(-,G)$ gives the cochain complexes $(C^\bullet(A;G), \delta^\bullet)$, $(C^\bullet(X;G), \delta^\bullet)$, and $(C^\bullet(X, A;G), \delta^\bullet)$ where
\begin{align*}
C^n(A;G) &= \text{Hom}(C_n(A), G)\\
C^n(X;G) &= \text{Hom}(C_n(X), G)\\
C^n(X,A;G) &= \text{Hom}(C_n(X,A),G)
\end{align*}
We have the corresponding cohomology groups
\begin{align*}
H^n(C^\bullet(A;G)) &= \frac{Z^n(A;G)}{B^n(A;G)} \\
H^n(C^\bullet(X;G)) &= \frac{Z^n(X;G)}{B^n(X;G)} \\
H^n(C^\bullet(X,A; G)) &= \frac{Z^n(X,A;G)}{B^n(X,A;G)}
\end{align*}
Given three cochain complexes $(C^\bullet, \delta^\bullet)$, $(D^\bullet, \delta^\bullet)$, and $(E^\bullet, \delta^\bullet)$, and morphisms $f^\bullet: C^\bullet \to D^\bullet$ and $g^\bullet: D^\bullet \to E^\bullet$ such that the following diagram of exact sequences commutes
\[
\begin{tikzcd}
& \vdots & \vdots & \vdots & \\
0 \arrow[r] & C^{k+1} \arrow[r, "f^{k+1}"] \arrow[u, "\delta^{k+1}"] & D^{k+1} \arrow[r, "g^{k+1}"] \arrow[u, "\delta^{k+1}"] & E^{k+1} \arrow[u, "\delta^{k+1}"] \arrow[r] & 0 \\
0 \arrow[r] & C^{k} \arrow[r, "f^{k}"] \arrow[u, "\delta^{k}"] & D^{k} \arrow[r, "g^{k}"] \arrow[u, "\delta^{k}"] & E^{k} \arrow[u, "\delta^{k}"] \arrow[r] & 0 \\
0 \arrow[r] & C^{k-1} \arrow[r, "f^{k-1}"] \arrow[u, "\delta^{k-1}"] & D^{k-1} \arrow[r, "g^{k-1}"] \arrow[u, "\delta^{k-1}"] & E^{k-1} \arrow[u, "\delta^{k-1}"] \arrow[r] & 0 \\
& \vdots \arrow[u, "\delta^{k-2}"] & \vdots \arrow[u, "\delta^{k-2}"] & \vdots \arrow[u, "\delta^{k-2}"] &
\end{tikzcd}
\]
we can apply the same methodology as before to get the long exact sequence
\[
\begin{tikzpicture}[descr/.style={fill=white,inner sep=1.5pt}]
        \matrix (m) [
            matrix of math nodes,
            row sep=1em,
            column sep=2.5em,
            text height=1.5ex, text depth=0.25ex
        ]
        { 0 & H^0(E^\bullet) & H^0(D^\bullet) & H^0(C^\bullet) \\
            & H^1(E^\bullet) & H^1(D^\bullet) & H^1(C^\bullet) \\
            & H^2(E^\bullet) & H^2(D^\bullet) & H^2(C^\bullet) \\
            & \cdots & \mbox{} & \mbox{} \\
        };

        \path[overlay,->, font=\scriptsize,>=latex]
        (m-1-1) edge (m-1-2)
        (m-1-2) edge (m-1-3)
        (m-1-3) edge (m-1-4)
        (m-1-4) edge[out=355,in=175] node[descr,yshift=0.3ex] {$\Delta^0$} (m-2-2)
        (m-2-2) edge (m-2-3)
        (m-2-3) edge (m-2-4)
        (m-2-4) edge[out=355,in=175] node[descr,yshift=0.3ex] {$\Delta^1$} (m-3-2)
        (m-3-2) edge (m-3-3)
        (m-3-3) edge (m-3-4)
        (m-3-4) edge[out=355,in=175] node[descr,yshift=0.3ex] {$\Delta^2$} (m-4-2);
\end{tikzpicture}
\]
of cohomology groups. Hence we have the long exact sequence
\[
\begin{tikzpicture}[descr/.style={fill=white,inner sep=1.5pt}]
        \matrix (m) [
            matrix of math nodes,
            row sep=1em,
            column sep=2.5em,
            text height=1.5ex, text depth=0.25ex
        ]
        { 0 & H^0(C^\bullet(X,A;G)) & H^0(C^\bullet(X;G)) & H^0(C^\bullet(A;G)) \\
            & H^1(C^\bullet(X,A;G)) & H^1(C^\bullet(X;G)) & H^1(C^\bullet(A;G)) \\
            & H^2(C^\bullet(X,A;G)) & H^2(C^\bullet(X;G)) & H^2(C^\bullet(A;G)) \\
            & \cdots & \mbox{} & \mbox{} \\
        };

        \path[overlay,->, font=\scriptsize,>=latex]
        (m-1-1) edge (m-1-2)
        (m-1-2) edge (m-1-3)
        (m-1-3) edge (m-1-4)
        (m-1-4) edge[out=355,in=175] node[descr,yshift=0.3ex] {$\Delta^0$} (m-2-2)
        (m-2-2) edge (m-2-3)
        (m-2-3) edge (m-2-4)
        (m-2-4) edge[out=355,in=175] node[descr,yshift=0.3ex] {$\Delta^1$} (m-3-2)
        (m-3-2) edge (m-3-3)
        (m-3-3) edge (m-3-4)
        (m-3-4) edge[out=355,in=175] node[descr,yshift=0.3ex] {$\Delta^2$} (m-4-2);
\end{tikzpicture}
\]
on relative pairs. These details are left for the reader!
\section{April 17, Friday}
\textbf{Proposition:} For a fixed abelian group $G$, and a split short exact sequence
\[
0 \to F \xrightarrow{i} H \xrightarrow{\pi} K \to 0
\]
applying the functor $\text{Hom}(-,G)$ preserves split exactness; that is, the following sequence is exact
\[
0 \to \text{Hom}(K,G) \to \text{Hom}(H,G) \to \text{Hom}(F,G) \to 0
\]

\textbf{Corollary:} For each $n \geq 0$, and for any abelian group $G$, and any pair of topological spaces $(X,A)$, the following sequence is exact:
\[
0 \to \text{Hom}(C_n(X,A),G) \to \text{Hom}(C_n(X),G) \to \text{Hom}(C_n(A),G) \to 0
\]
This implies we have a split exact sequence of cochain complexes
\[
0 \to C^\bullet(X,A;G) \to C^\bullet(X;G) \to C^\bullet(A;G) \to 0
\]
\textbf{Proposition:}
Note if $f: (X,A) \to (Y,B)$ is a map of pairs, we obtain cochain maps
\begin{align*}
C^\bullet(A;G) &\to C^\bullet(B;G) \\
C^\bullet(X;G) &\to C^\bullet(Y;G) \\
C^\bullet(X,A;G) &\to C^\bullet(Y,A;G)
\end{align*}
for a fixed abelian group $G$. Then we have the following diagram useful for the five lemma
\[
\begin{tikzcd}
H^{k-1}(C^\bullet(B;G)) \arrow[r, "\Delta^{k-1}"] \arrow[d] & H^k(C^\bullet(Y,B;G) \arrow[r] \arrow[d] & H^k(C^\bullet(Y;G)) \arrow[r, "\Delta^{k}"] \arrow[d] & \cdots \\
H^{k-1}(C^\bullet(A;G)) \arrow[r, "\Delta^{k-1}"] & H^k(C^\bullet(X,A;G) \arrow[r] & H^k(C^\bullet(X;G)) \arrow[r, "\Delta^{k}"] & \cdots
\end{tikzcd}
\]
\[
\begin{tikzcd}
\cdots \arrow[r, "\Delta^{k}"] & H^k(C^\bullet(B;G)) \arrow[r] \arrow[d] & H^{k-1}(C^\bullet(Y,B;G)) \arrow[d] \\
\cdots \arrow[r, "\Delta^{k}"] & H^k(C^\bullet(A;G)) \arrow[r] & H^{k-1}(C^\bullet(X,A;G))
\end{tikzcd}
\]

\textbf{Definition:} Now we want to capture homotopic spaces under cochain morphisms. Given a map of cochain complexes $f^\bullet: C^\bullet \to D^\bullet$, we define a \textbf{cochain homotopy} of cochain complexes by the following commutative diagram
\[
\begin{tikzcd}[column sep= large, row sep= large]
\cdots \arrow[r, "\delta^{k-2}"] & C^{k-1} \arrow[dl, "s^{k-1}"'] \arrow[r, "\delta^{k-1}"] \arrow[d, "f^{k-1}"'] & C^k \arrow[r, "\delta^k"] \arrow[d, "f^k"'] \arrow[dl, "s^{k-1}"'] & C^{k+1} \arrow[r, "\delta^{k}"] \arrow[d, "f^{k+1}"'] \arrow[dl, "s^{k+1}"'] & \cdots \arrow[dl, "s^{k+1}"'] \\
\cdots \arrow[r, "\delta^{k-2}"] & D^{k-1} \arrow[r, "\delta^{k-1}"] & D^k \arrow[r, "\delta^k"] & D^{k+1} \arrow[r, "\delta^{k+1}"] & \cdots
\end{tikzcd}
\]
with the condition
\[
f^k = \delta^{k-1}\circ s^{k-1} + s^{k+1}\circ\delta^k
\]

\textbf{Definition:} We say cochain maps $f^\bullet, g^\bullet: C^\bullet \to D^\bullet$ are homotopic if for each $k$
\[
f^k - g^k = \delta^{k-1}\circ s^{k-1} + s^{k+1}\circ\delta^k
\]
\end{document}


\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{multicol}

\usepackage{listings}
\usepackage{geometry}
\usepackage{color}
\usepackage{pdflscape}
\usepackage{float}
\usepackage{amsmath}
\usepackage{hyperref}
\setlength{\belowcaptionskip}{-10pt}
\setlength{\abovecaptionskip}{-30pt}
\floatstyle{boxed}
\restylefloat{figure}
\usepackage{graphicx}
\definecolor{codegreen}{rgb}{0,0.6,0}
\definecolor{codegray}{rgb}{0.5,0.5,0.5}
\definecolor{codepurple}{rgb}{0.58,0,0.82}
\definecolor{backcolour}{rgb}{0.95,0.95,0.92}

\lstdefinestyle{mystyle}{
	backgroundcolor=\color{backcolour},
	commentstyle=\color{codegreen},
	keywordstyle=\color{blue},
	numberstyle=\tiny\color{codegray},
	stringstyle=\color{codepurple},
	basicstyle=\footnotesize,
	breakatwhitespace=false,
	breaklines=true,
	captionpos=b,
	keepspaces=true,
	numbers=left,
	numbersep=5pt,
	showspaces=false,
	showstringspaces=false,
	showtabs=false,
	tabsize=2
}
\renewcommand{\theenumi}{\Alph{enumi}}
\lstset{style=mystyle}
\title{Data Mining\\
		Home work 02\\ Descriptive Statistics}
\author{\textbf{Student:}Aqeel Labash\\ \textbf{Teacher:} Jaak Vilo}
\date{18 February 2016}
\geometry{
	a4paper,
	total={170mm,257mm},
	left=1mm,
	right=1mm,
	top=5mm,
	bottom=5mm,
}
\usepackage{enumitem}
\begin{document}
	\maketitle

\begin{multicols*}{2}
{	\centering	\section*{First Question}}
	\begin{enumerate}[label=\Alph*)]
		\item \textbf{Columns Names:}Gender , Length, Diameter,Height, Weight, Rings.
		\item \textbf{Number of Rows:}1000.
		\item \textbf{Print First 3 Lines ,and Rings Values:} The code for this task is
		\begin{lstlisting}[language=R]
rm(list = ls())
setwd('/home/aqeel/Study/DM/HW02')
mydata = read.csv('abalone.csv')
colnames(mydata)
length(mydata)
nrow(mydata)
mydata[(1:3),]
		\end{lstlisting}
		The result was this table :

		\begin{tabular}{|c|c|c|c|c|c|c|}
			\hline
			&Gender&Length&Diameter&Height&Weight&Rings\\
			\hline
			1&F&0.505&0.385&0.135&0.6185&12\\
			\hline
			2&F&0.650&0.475&0.165&1.3875&9\\
			\hline
			3&I&0.520&0.380&0.135&0.5395&8\\
			\hline
		\end{tabular}
			The Rings values :12,9,8
		\item \textbf{Last two data rows \& there Weight}:
		The code for this question:
		\begin{lstlisting}[language=R]
#print last two rows
mydata[c(nrow(mydata),nrow(mydata)-1),]
#print last two rows weight
mydata[c(nrow(mydata),nrow(mydata)-1),]$Weight
		\end{lstlisting}
		And here is the result table :\\
		\resizebox{\columnwidth}{!}{%
		\begin{tabular}{|c|c|c|c|c|c|c|}
			\hline
			&Gender&Length&Diameter&Height&Weight&Rings\\
			\hline
			1000&M&0.515&0.395&0.135&1.0070&8\\
			\hline
			999&I&0.525&0.400&0.130&0.6455&8\\
			\hline
		\end{tabular} %
	}
		The weight for the last two : 1.0070 and 0.6455
		\item \textbf{Diameter value of row 755}:0.385 achieved by this code:
		\begin{lstlisting}[language=R]
#print diameter of row 755
mydata[755,]$Diameter
		\end{lstlisting}
		\item \textbf{The number of missing values in height column:} 4, the code for this request:
		\begin{lstlisting}[language=R]
		#number of rows that don't have height value
		length(mydata[is.na(mydata)])
		\end{lstlisting}
		\item \textbf{The mean of Height value excluding NA's:} The value is :0.1398092 achieved by this code:
		\begin{lstlisting}[language=R]
		#the mean for height column (two ways)
		mean(mydata[complete.cases(mydata),]$Height)
		mean(mydata[!is.na(mydata$Height),]$Height)
		\end{lstlisting}

		\item \textbf{Extract Subset and it's Diameter mean:} The code for this task is below :
		\begin{lstlisting}[language=R]
#Extract subset with Gender M and weight less than 0.75
newsubset = subset(mydata,mydata$Gender=="M" & mydata$Weight<0.75)
		\end{lstlisting}
		There was 119 object satisfy the previous condition.The mean value for the diameter :0.3426471
		\item \textbf{Most frequent rings value:} 9 Discovered through this code:
		\begin{lstlisting}[language=R]
			#Most frequent rings value
			table(mydata$Rings)
		\end{lstlisting}
			\item \textbf{Minimum length when Rings equal 18:}0.465.Following the code I used for this request
			\begin{lstlisting}[language=R]
			#minimum length when rings equal to 18
			min(subset(mydata,Rings==18)$Length)
			\end{lstlisting}
	\end{enumerate}

{\centering\section*{Second Question}}

	\begin{flushleft}
\begin{enumerate}

 \item \textbf{The data is about:} The data about Abalone or sea ears which belong to the family of Haliotidae (one genus).\cite{1} The data describe the animal sex,length,diameter,height,weight.
 \item \textbf{Discrete and continuous features:}The \textbf{discrete features} are gender and rings.The \textbf{continuous features} are length,weight,diameter,height.
 \item \textbf{Number of rows:}1000 (if you calculate the header as a row it's 1001 :) )
 \item \textbf{More info about features:}\\
 To calculate those information for (gender) I'll replace the values (M,F,I) to (1,2,3), \textbf{Note:} I feel that discrete features shouldn't be measured as continuous feature but I'll do it since it's requested:)).
 \begin{tabular}{|c|c|c|c|c|c|}
\hline
feature&mean&median&min&max&SD\\
\hline
Length&0.52276&0.5450&0.075&0.815&0.12006\\
\hline
Diameter&0.405955&0.42&0.055&0.650&0.09883\\
\hline
Height&0.1398092&0.1425&0.0&1.130&0.04942\\
\hline
Weight&0.8255405&0.801&0.002&2.555&0.49037\\
\hline
Rings&11.318&9.0&1.0&1500.0&47.22769665\\
\hline
Gender&2.016&2&1&3&0.78636020\\
\hline
 \end{tabular}
The code for the previous table  :
\begin{lstlisting}[language=R]
gender<-mydata$Gender
gender<- as.numeric(factor(mydata$Gender,c('F','M','I'),c(1:3)))
#Extract All Required Information
values <-rbind(
#Length
c(mean(mydata$Length),median(mydata$Length),min(mydata$Length),max(mydata$Length),sd(mydata$Length)),
#Diameter
c(mean(mydata$Diameter),median(mydata$Diameter),min(mydata$Diameter),max(mydata$Diameter),sd(mydata$Diameter)),
#Height
c(mean(mydata$Height,na.rm = TRUE),median(mydata$Height,na.rm = TRUE),min(mydata$Height,na.rm = TRUE),max(mydata$Height,na.rm = TRUE),sd(mydata$Height,na.rm = TRUE)),
#Weight
c(mean(mydata$Weight),median(mydata$Weight),min(mydata$Weight),max(mydata$Weight),sd(mydata$Weight)),
#Rings
c(mean(mydata$Rings),median(mydata$Rings),min(mydata$Rings),max(mydata$Rings),sd(mydata$Rings)),
#Gender
c(mean(Gender),median(Gender),min(Gender),max(Gender),sd(Gender)))
values
\end{lstlisting}

\end{enumerate}
\end{flushleft}

The distribution for the features is as following :
\begin{figure}[H]
	\label{fig:ggplotLength}
	\begin{center}
	\includegraphics[scale=0.3]{ggplotLength.png}
	\end{center}
	\caption{Abalone Length Distribution }
\end{figure}
As shown in figure 1 we can see that Length values are very small. The distribution is clearly skewed to the left.\cite{2}
\begin{figure}[H]
	\begin{center}
		\includegraphics[scale=0.3]{ggplotweight.png}
	\end{center}
	\caption{Abalone weight distribution}
\end{figure}
The weight values are well distributed but most of it to the left side.
\begin{figure}[H]
\begin{center}
	\includegraphics[scale=0.3]{ggplotHeight.png}
\end{center}
\caption{Abalone Height Distribution}
\end{figure}
Abalone height somehow not very skewed (slightly skewed to left).Abalone height value is very small with some exception excluded from the previous figure for better view.
\begin{figure}[H]
	\begin{center}
		\includegraphics[scale=0.3]{ggplotdiameter.png}
	\end{center}
	\caption{Abalone diameter distribution}
\end{figure}
Most of the values are small.The values skewed to the left.
\begin{figure}[H]
	\begin{center}
		\includegraphics[scale=0.3]{ggplotRings.png}
	\end{center}
	\caption{Abalone rings distribution}
\end{figure}
Most values between 1 and 30. The distribution almost perfect (it's skewed a little bit to the right)
\begin{figure}[H]
	\begin{center}
		\includegraphics[scale=0.3]{ggplotGender.png}
	\end{center}
	\caption{Abalone gender distribution}
	Nothing much to say about figure 6
\end{figure}

figures from 1 to 5 were generated by the following code:
\begin{lstlisting}[language=R]
#Rings
ggplot(mydata, aes(x=Rings))+stat_count(width=0.5)+xlim(0,30)
#Length
ggplot(mydata, aes(x=Length))+geom_bar(width=0.01)+xlim(0,0.815)
#Diameter
ggplot(mydata,aes(x=Diameter))+geom_bar(width = 0.004)
#Weight
ggplot(mydata,aes(x=Weight))+geom_bar(width = 0.004)+ylim(0,4.1)
#Height
ggplot(mydata,aes(x=Height))+geom_bar(width = 0.004)+xlim(0,0.3)
#Gender
ggplot(mydata,aes(x=Gender))+stat_count(width = 0.9)
\end{lstlisting}
\end{multicols*}
\begin{landscape}
{\centering\section*{Third Question}}
\begin{figure}[H]
	\begin{center}
		\includegraphics[scale=0.5]{scatterplotall.png}
	\end{center}
\end{figure}
\end{landscape}

\begin{multicols*}{2}
{\centering \section*{Continuing  Third Question}}
The previous plot was generated by this code:
\begin{lstlisting}[language=R]
#Save plot with high resultion
png("scatterplotall.png",width = 1600,height = 900)
#draw plot
plot(mydata[,2:6])
#write plot
dev.off()
\end{lstlisting}
To calculate the correlation between all variables I used this code:
\begin{lstlisting}[language=R]
#Print correlation
cor(mydata[complete.cases(mydata),][,2:6])
\end{lstlisting}
The result was the following table.\\
	\resizebox{\columnwidth}{!}{%
\begin{tabular}{|c|c|c|c|c|c|c|}
\hline
		&Length&Diameter&Height&Weight&Rings\\
		\hline
		Length&1.00000000&0.98747396&0.68725941&0.92071393&0.04407577\\
		\hline
		Diameter&0.98747396&1.00000000&0.69249343&0.92348680&0.03787742\\
		\hline
		Height&0.68725941&0.69249343&1.00000000&0.67393746&0.03112661\\
		\hline
		Weight&0.92071393&0.92348680&0.67393746&1.00000000&0.03385043\\
		\hline
		Rings&0.04407577&0.03787742&0.03112661&0.03385043&1.00000000\\
		\hline
		%
\end{tabular}
		}
From the table we can see that Length is the most correlated feature with Rings.
\begin{figure}[H]
	\begin{center}
		\includegraphics[scale=0.28]{scatterplotLengthRings.png}
	\end{center}
	\caption{Scatterplot showing correlation between length and rings}
\end{figure}
\textbf{Note:}in figure 7 I specified X domain to (0,27) to make the figure viewable. Here is the code:
\begin{lstlisting}[language=R]
#scatterplot
plot(mydata$Rings,mydata$Length,xlim = c(0,27),xlab = "Rings",ylab = "Length")
\end{lstlisting}
To get the most correlated two features we can check correlation table we created earlier. Diameter and length are the most correlated features and here is the scatter plot for them:
\begin{figure}[H]
	\begin{center}
		\includegraphics[scale=0.22]{scatterplotDiameterLength.png}
	\end{center}
	\caption{Scatter plot for diameter and length}
\end{figure}
What I notice is it's almost for each unique value for diameter there is only few correspondent value on length.Which mean they are linked to each other. Mathematically make sense since it's a relation between length and diameter.
{\centering \section*{Fourth Question}}
The IQR (Inter-Quartile Ranges) for values shown in this table:\\
\begin{tabular}{|c|c|c|c|c|}
	\hline
Length&Diameter&Height&Weight&Rings\\
\hline
0.165000&0.135000&0.050000&0.707375&3.000000\\
\hline
\end{tabular}\\
The values extracted by this code :
\begin{lstlisting}[language=R]
IQRFunction<-function(x)
{
return (quantile(x,0.75) - quantile(x,0.25) )
}
height<- mydata[complete.cases(mydata),]
IQRALL= c(IQRFunction(mydata$Length),IQRFunction(mydata$Diameter),IQRFunction(height$Height),IQRFunction(mydata$Weight),IQRFunction(mydata$Rings))
names(IQRALL)<- names(mydata)[2:6]
IQRALL
\end{lstlisting}
The total number of values (over,under) the quartiles in the following table:\\
\begin{tabular}{|c|c|c|c|c|c|}
	\hline
	&Length&Diameter&Height&Weight&Rings\\
	\hline
	Over&0&0&2&9&56\\
	\hline
	Under&8&7&6&0&3\\
	\hline
\end{tabular}
\\The previous values where achieved by the following code :
\begin{lstlisting}[language=R]
#Calculate Over outlier
outliercounttop<-function(x,iqr)
{
return (length(which(x>(quantile(x,0.75)+1.5*iqr))))
}
#Calculate Under outlier
outliercountfloor<-function(x,iqr)
{
return (length(which(x<(quantile(x,0.25)-1.5*iqr))))
}
names(IQRALL)
matr <-rbind(c(outliercounttop(mydata$Length,IQRALL[1]),outliercounttop(mydata$Diameter,IQRALL[2]),
outliercounttop(height$Height,IQRALL[3]),outliercounttop(mydata$Weight,IQRALL[4]),
outliercounttop(mydata$Rings,IQRALL[5])),
c(outliercountfloor(mydata$Length,IQRALL[1]),outliercountfloor(mydata$Diameter,IQRALL[2]),
outliercountfloor(height$Height,IQRALL[3]),outliercountfloor(mydata$Weight,IQRALL[4]),
outliercountfloor(mydata$Rings,IQRALL[5])))
colnames(matr)<-names(mydata)[2:6]
rownames(matr)<-(c("Over","Under"))
matr
\end{lstlisting}
For multidimensional outliers I believe they do exist in the data but I think if we removed them depending on one side that will remove them.\\
In the other hand an observation might be over or under outliers for one variable but not for the another.

{\centering \section*{Fifth Question}}
I do believe we should remove them and I think so because :
\begin{enumerate}
	\item They are away from the mean or median.
	\item Usually they are minority and will act as noise more than rule.
\end{enumerate}
The ones that should be deleted : height,length I will exclude rings, because I think the top 56 element in rings are correlated with other features.But maybe we can remove the highest one (1500 ring).\\
Firstly, I cleaned the data by this code:
The result in the following table:\\
\begin{tabular}{|c|c|c|c|c|c|c|}
	\hline
feature&mean&median&min&max&SD\\
\hline
Length&0.5258215&0.5450&0.21&0.815&0.11577628\\
\hline
Diameter&0.4084229&0.4225&0.15&0.650&0.09566371\\
\hline
Height&0.1396907&0.1450&0.00&0.250&0.03706943\\
\hline
Weight&0.8323337&0.8085&0.04&2.555&0.48757002\\
\hline
Rings&9.8894523&9.0000&3.00&27.000&3.09985267\\
\hline
Gender&2.0081136&2.0000&1.00&3.000&0.78432298\\
\hline
\end{tabular}
And here is the same previous value for better comparison:\\
 \begin{tabular}{|c|c|c|c|c|c|}
 	\hline
 	feature&mean&median&min&max&SD\\
 	\hline
 	Length&0.52276&0.5450&0.075&0.815&0.12006\\
 	\hline
 	Diameter&0.405955&0.42&0.055&0.650&0.09883\\
 	\hline
 	Height&0.1398092&0.1425&0.0&1.130&0.04942\\
 	\hline
 	Weight&0.8255405&0.801&0.002&2.555&0.49037\\
 	\hline
 	Rings&11.318&9.0&1.0&1500.0&47.22769665\\
 	\hline
 	Gender&2.016&2&1&3&0.78636020\\
 	\hline
 \end{tabular}
 The first thing to notice is the min,max values which is clearly because we removed the highest \&lowest values.Secondly we see that standard deviation is better now specially Rings.SD for rings shifted from 47.22~ to 3.09 which make more sense.The code to clear the data:
\begin{lstlisting}[language=R]
#Clean Length
mydata<-mydata[(mydata$Length<(quantile(mydata$Length,0.75)+1.5*IQRALL[1])) &
(mydata$Length>(quantile(mydata$Length,0.25)-1.5*IQRALL[1])),]
#clean Height
mydata<-mydata[!is.na(mydata$Height),]
mydata<-mydata[(mydata$Height<(quantile(mydata$Height,0.75)+1.5*IQRALL[1])) &
(mydata$Height>(quantile(mydata$Height,0.25)-1.5*IQRALL[1])),]
#clean Rings
mydata<-mydata[mydata$Rings<1500,]
nrow(mydata)
\end{lstlisting}
\textbf{Note:}Used the same code to get the values.
{\centering \section*{Sixth Question}}
For this question I used lm function in R to get the answer
\begin{lstlisting}[language=R]
#######################################
#           Sixth Question            #
#######################################
#USED MACHINE LEARNING EXERCISE SESSION CODE TO HELP WITH THIS TASK
rm(list=ls())
setwd("/home/aqeel/Study/DM/HW02/")
mydata = read.csv('abalone.csv',header = TRUE)
# Lets observe the data
plot(mydata[,c(3,5)])

# Lets observe the linear model
linear.model = lm(Weight ~ Diameter,mydata)
# Lets extract coeficiens of the linear model
variables <- coef(linear.model)
plot(mydata[,c(3,5)])
abline(a = variables[1],b = variables[2],col="red",lwd=5)
\end{lstlisting}
In figure 9 we can see the line that have the minimum MSE.
\begin{figure}[H]
\begin{center}
\includegraphics[scale=0.5]{plotprediction.png}
\end{center}
\caption{Weights and diameter with line used to minimize MSE}
\end{figure}
\textbf{Please Note:} attached with the report 3 *.R files contain all the R code for this home work.\\

\begin{thebibliography}{9}
	\bibitem{1}
	\href{https://en.wikipedia.org/wiki/Abalone}{Wikipedia - Abalone}
	\bibitem{2}
	\href{http://study.com/academy/lesson/skewed-distribution-examples-definition-quiz.html}{Skewed Distribution}
\end{thebibliography}
\end{multicols*}

\end{document}


\subsection{Instance graphs}
\label{subsec:formalisations:groove_formalisation:instance_graphs}
Before giving a formal definition of instance graphs, the set $Node$ for a grammar needs to be defined. $Node$ is the set of possible nodes that can be part of an instance graph.

\begin{defin}[Node]
\label{defin:formalisations:groove_formalisation:instance_graphs:node}
We define a set $Node$ containing all possible instance nodes. $Node$ can be subdivided into two disjoint and covering sets
\begin{itemize}
    \item $Node_t$ is the set of typed nodes for every label in $Lab_t$
    \item $Node_v$ is the set of typed nodes for every label in $Lab_{prim}$
\end{itemize}

By definition, there exists a mapping for each element in $Node_t$ to an element in $Lab_t$ and a mapping for each element in $Node_v$ to $Lab_{prim}$. We call the mapping $\mathrm{nodeType}$:
\begin{equation*}
    \mathrm{nodeType}: (Node_t \Rightarrow Lab_t) \cup (Node_v \Rightarrow Lab_{prim})
\end{equation*}

Furthermore, the set $Node_v$ can also be mapped to actual data values in GROOVE by the function $value$.
\begin{equation*}
    \mathrm{value}: Node_v \bij \mathbb{B} \cup \mathbb{Z} \cup \mathbb{R} \cup \mathbb{S}
\end{equation*}

\isabellelref{Node}{GROOVE.Instance_Graph}
\end{defin}

Besides the set of nodes, GROOVE also has a set $Id$, which is a set of identifiers that can be used to assign each node a unique identifier.

\begin{defin}[Identifiers]
\label{defin:formalisations:groove_formalisation:instance_graphs:identifiers}
Define a global set $Id$ which consists of unique identifiers.
\end{defin}

With these definitions, it is possible to define an instance graph in GROOVE.

\begin{defin}[Instance graph]
\label{defin:formalisations:groove_formalisation:instance_graphs:instance_graph}
An instance graph corresponding to a type graph $TG$ is modeled as tuple $IG$:
\begin{equation}
    IG = \langle N, E, ident \rangle
\end{equation}
where
\begin{itemize}
    \item $N \subseteq Node_t \cup Node_v$ is the set of nodes in the instance graph.

    \item $E \subseteq N \times ET_{TG} \times N$ is the set of edges in the instance graph. They consist of a source and target node from $N$ and are typed by an edge from the corresponding type graph.

    \item $ident: Id \Rightarrow (N \cap Node_t)$ is a partial injective function which maps selected identifiers from the set $Id$ to a node from $N$ typed by a label in $Lab_t$.
\end{itemize}

\isabellelref{instance_graph}{GROOVE.Instance_Graph}
\end{defin}

\begin{figure}[p]
    \centering
    \begin{subfigure}{\textwidth}
        \centering
        \input{images/03_formalisations/03_groove_formalisation/instance_graph_example.tikz}
        \caption{Instance graph in GROOVEs visual notation}
    \end{subfigure}

    \begin{subfigure}{\textwidth}
        \centering
        \begin{align*}
            N_{IG} =\ & \{
                house,
                payintervalmonth,
                renter1,
                renter2,
                room1,
                room2,
                room3,\\&
                1,
                2,
                3,
                23,
                24,
                \text{``J.A.''},
                \text{``M.S.''},
                \text{``Small House''}
            \}\\
            type_n =\ & \big\{
                ( house, \type{House} ),
                ( payintervalmonth, \type{PaymentInterval\$MONTH} ),\\&
                ( renter1, \type{Renter} ),
                ( renter2, \type{Renter} ),
                ( room1, \type{Room} ),
                ( room2, \type{Room} ),
                ( room3, \type{Room} ),\\&
                ( 1, \type{int} ),
                ( 2, \type{int} ),
                ( 3, \type{int} ),
                ( 23, \type{int} ),
                ( 24, \type{int} ),
                ( \text{``J.A.''}, \type{string} ),
                ( \text{``M.S.''}, \type{string} ),
                ( \text{``Small House''}, \type{string} )
            \big\}\\
            E_{IG} =\ & \big\{
                \big( house, ( \type{House}, \type{name}, \type{string} ), \text{``Small House''} \big),
                \big( house, ( \type{House}, \type{rooms}, \type{Room} ), room1 \big),\\&
                \big( house, ( \type{House}, \type{rooms}, \type{Room} ), room2 \big),
                \big( house, ( \type{House}, \type{rooms}, \type{Room} ), room3 \big),\\&
                \big( renter1, ( \type{Person}, \type{age}, \type{int} ), 24 \big),
                \big( renter2, ( \type{Person}, \type{age}, \type{int} ), 23 \big),\\&
                \big( renter1, ( \type{Person}, \type{name}, \type{string} ), \text{``J.A.''} \big),
                \big( renter2, ( \type{Person}, \type{name}, \type{string} ), \text{``M.S.''} \big),\\&
                \big( renter1, ( \type{Renter}, \type{payment\_interval}, \type{PaymentInterval} ), payintervalmonth \big),\\&
                \big( renter2, ( \type{Renter}, \type{payment\_interval}, \type{PaymentInterval} ), payintervalmonth \big),\\&
                \big( renter1, ( \type{Renter}, \type{rents}, \type{Room} ), room1 \big),
                \big( renter1, ( \type{Renter}, \type{rents}, \type{Room} ), room2 \big),\\&
                \big( renter2, ( \type{Renter}, \type{rents}, \type{Room} ), room3 \big),
                \big( room1, ( \type{Room}, \type{number}, \type{int} ), 1 \big),\\&
                \big( room2, ( \type{Room}, \type{number}, \type{int} ), 2 \big),
                \big( room3, ( \type{Room}, \type{number}, \type{int} ), 3 \big),\\&
                \big( room1, ( \type{Room}, \type{renter}, \type{Renter} ), renter1 \big),
                \big( room2, ( \type{Room}, \type{renter}, \type{Renter} ), renter1 \big),\\&
                \big( room3, ( \type{Room}, \type{renter}, \type{Renter} ), renter2 \big)
            \big\}\\
            ident_{IG} =\ & \{
                ( \text{TwoRem}, house ),
                ( \text{Renter1}, renter1 ),
                ( \text{Renter2}, renter2 ),\\&
                ( \text{Longhorn}, room1 ),
                ( \text{Shorthorn}, room2 ),
                ( \text{onghornLay}, room3 )
            \}
        \end{align*}
        \caption{Formal definition of the instance graph}
    \end{subfigure}
    \caption{Example of an instance graph corresponding with \cref{defin:formalisations:groove_formalisation:instance_graphs:instance_graph}}
    \label{fig:formalisations:groove_formalisation:instance_graphs:instance_graph_example}
\end{figure}

An example of an instance graph is given in \cref{fig:formalisations:groove_formalisation:instance_graphs:instance_graph_example}. This instance graph is typed by the type graph in the example in \cref{fig:formalisations:groove_formalisation:type_graphs:type_graph_example}. As we can see, there is one node typed $\type{House}$, three nodes typed $\type{Room}$ and two nodes typed $\type{Renter}$. The node typed $\type{House}$ is identified by identifier `TwoRem' and is named ``Small House'' and contains all the three room nodes. The first two nodes that are typed room $\type{Room}$ have identifiers `Longhorn' and `Shorthorn' and are rented by the first $\type{Renter}$ identified as `Renter1', as is visible from the $\type{rents}$ and $\type{renter}$ edges. The last node typed $\type{Room}$ has identifier `onghornLay' and is rented by the second $\type{Renter}$ identified as `Renter2'. Please note how the instance graph only has one instance of $\type{PaymentInterval\$MONTH}$ which is reused by both $\type{Renter}$ nodes. Also, notice how there is no instance of $\type{PaymentInterval\$QUARTER}$ since there is no $\type{Renter}$ referencing it. Also notice how the $\type{Renter}$ typed objects now have an $\type{age}$ and $\type{name}$ edge, which are inherited from the $\type{Person}$ node type.

As we have seen in the example, all nodes and edges in the instance graph are typed based on the types defined in its type graph. We define two functions for mapping nodes and edges to their type in the type graph. The nodes in the instance graph can be mapped to their type in the type graph using the function $\mathrm{type}_n$, while edges in the instance graph can be mapped to their type in the type graph using the function $\mathrm{type}_e$.

\begin{defin}[Types]
\label{defin:formalisations:groove_formalisation:instance_graphs:types}
The type of a node in the instance graph can be determined using $\mathrm{type}_n$
\begin{equation*}
    \mathrm{type}_n: N_{IG} \Rightarrow Lab_t \cup Lab_{prim}
\end{equation*}
for which holds that $\forall n \in N_{IG}: \mathrm{type}_n(n) = nodeType(n)$.

The type of an edge in the instance graph can be determined using $\mathrm{type}_e$
\begin{equation*}
    \mathrm{type}_e: E_{IG} \Rightarrow ET_{TG}
\end{equation*}
for which holds that $\forall e = (src, etype, tgt) \in E_{IG}: \mathrm{type}_e(e) = etype$
\end{defin}

Since instance graphs are typed by a corresponding type graph, the type graph imposes some constraints on the instance graph to ensure that the instance graph is valid. If any of these constraints are violated, the instance graph is considered invalid.

\begin{defin}[Instance graph validity]
\label{defin:formalisations:groove_formalisation:instance_graphs:instance_graph_validity}
An instance graph is valid if the following constraints hold:
\begin{enumerate}
    \item The nodes must be properly typed: $\forall n \in N_{IG}\!: \mathrm{type}_n(n) \in NT_{TG}$.
    \item The source of each edge must be properly typed: $\forall e \in E_{IG}\!: \mathrm{type}_n \big(\mathrm{src}(e)\big) \sqsubseteq_{TG} \mathrm{src} \big(\mathrm{type}_e(e)\big)$.
    \item The target of each edge must be properly typed: $\forall e \in E_{IG}\!: \mathrm{type}_n \big(\mathrm{tgt}(e)\big) \sqsubseteq_{TG} \mathrm{tgt} \big(\mathrm{type}_e(e)\big)$.
    \item Abstract types cannot have instances: $\forall n \in N_{IG}\!: \mathrm{type}_n(n) \not\in abs_{TG}$.
    \item The outgoing multiplicity of each edge type must be adhered to: $\forall et \in ET_{TG}\!: \forall n \in N_{IG}\!: \mathrm{type}_n(n) \sqsubseteq_{TG} \mathrm{src}(et) \Longrightarrow |\{e \in E_{IG} \mid \mathrm{src}(e) = n \land \mathrm{type}_e(e) = et\}| \in \mathrm{out}(\mathrm{mult}_{TG}(et))$.
    \item The incoming multiplicity of each edge type must be adhered to: $\forall et \in ET_{TG}\!: \forall n \in N_{IG}\!: \mathrm{type}_n(n) \sqsubseteq_{TG} \mathrm{tgt}(et) \Longrightarrow |\{e \in E_{IG} \mid \mathrm{tgt}(e) = n \land \mathrm{type}_e(e) = et\}| \in \mathrm{in}(\mathrm{mult}_{TG}(et))$.
    \item Nodes must be contained by at most one other node: $\forall n \in N_{IG}\!: |\{e \in E_{IG} \mid \mathrm{tgt}(e) = n\,\land\,\mathrm{type}_e(e) \in contains_{TG}\}| \leq 1$.
    \item There may be no cycle between the containment edges in $E_{IG}$.
\end{enumerate}

\isabellelref{instance_graph}{GROOVE.Instance_Graph}
\end{defin}

\begin{figure}[p]
    \centering
    \input{images/03_formalisations/03_groove_formalisation/instance_graph_prop1_violated.tikz}
    \caption{Invalid instance graph with improper node types}
    \label{fig:formalisations:groove_formalisation:instance_graphs:property_1_violated}
\end{figure}

The first property just ensures that all nodes in an instance graph are typed by the corresponding type graph. \cref{fig:formalisations:groove_formalisation:instance_graphs:property_1_violated} shows an example of an invalid instance graph typed by the type graph of \cref{fig:formalisations:groove_formalisation:type_graphs:type_graph_example}. The instance graph is invalid, since the type $\type{Kitchen}$ is not defined within the type graph. Changing the type of this node to $\type{Room}$ would make the instance graph valid.

\begin{figure}[p]
    \centering
    \input{images/03_formalisations/03_groove_formalisation/instance_graph_prop3_violated.tikz}
    \caption{Invalid instance graph with improper type for the target of edge $number$}
    \label{fig:formalisations:groove_formalisation:instance_graphs:property_3_violated}
\end{figure}

The second and third property ensure that the source and target nodes of edges are correctly typed. \cref{fig:formalisations:groove_formalisation:instance_graphs:property_3_violated} shows an example of an invalid instance graph typed by the type graph of \cref{fig:formalisations:groove_formalisation:type_graphs:type_graph_example}. In this example, the $\type{Room}$-typed node has a $\type{number}$ edge connected to a boolean value. Since the target type of the $( \type{Room}, \type{number}, \type{int} )$ is an integer, the third property is violated. Therefore, the instance graph is invalid. Changing the boolean node to any integer node would make the example valid.

\begin{figure}[p]
    \centering
    \input{images/03_formalisations/03_groove_formalisation/instance_graph_prop4_violated.tikz}
    \caption{Invalid instance graph with node of type $\type{Person}$}
    \label{fig:formalisations:groove_formalisation:instance_graphs:property_4_violated}
\end{figure}

The fourth property ensures that an instance graph cannot instantiate abstract node types. \cref{fig:formalisations:groove_formalisation:instance_graphs:property_4_violated} shows an example of an invalid instance graph typed by the type graph of \cref{fig:formalisations:groove_formalisation:type_graphs:type_graph_example}. In the example, the only node in the graph is typed by the $\type{Person}$ type. However, the $\type{Person}$ type is abstract within the type graph. Therefore, the fourth property is violated, and the instance graph is invalid. Changing the type of the node to $\type{Renter}$ would make the instance graph valid.

\begin{figure}[p]
    \centering
    \begin{subfigure}{0.45\textwidth}
        \centering
        \input{images/03_formalisations/03_groove_formalisation/instance_graph_prop5_violated.tikz}
        \caption{Outgoing multiplicity violated}
        \label{fig:formalisations:groove_formalisation:instance_graphs:property_5_violated}
    \end{subfigure}
    \begin{subfigure}{0.45\textwidth}
        \centering
        \input{images/03_formalisations/03_groove_formalisation/instance_graph_prop6_violated.tikz}
        \caption{Incoming multiplicity violated}
        \label{fig:formalisations:groove_formalisation:instance_graphs:property_6_violated}
    \end{subfigure}
    \caption{Invalid instance graphs with their multiplicity constraints violated}
    \label{fig:formalisations:groove_formalisation:instance_graphs:properties_56_violated}
\end{figure}

The fifth and sixth property ensure the correctness of multiplicities within an instance graph. The fifth property ensures that the outgoing multiplicity is not violated. The sixth property ensures that the incoming multiplicity is not violated. \cref{fig:formalisations:groove_formalisation:instance_graphs:properties_56_violated} shows two instance graphs that are once more typed by type graph \cref{fig:formalisations:groove_formalisation:type_graphs:type_graph_example} but are both invalid. \cref{fig:formalisations:groove_formalisation:instance_graphs:property_5_violated} violates the fifth property, since the node typed by type $\type{House}$ needs to have at least one outgoing edge labelled $\type{rooms}$ to a node of type $\type{Room}$. \cref{fig:formalisations:groove_formalisation:instance_graphs:property_6_violated} violates the sixth property, since the node typed by type $\type{Room}$ needs to have at least one incoming edge labelled $\type{rooms}$ from a node of type $\type{House}$. Merging these two instance graphs and adding an edge labelled $\type{rooms}$ from the $\type{House}$-typed node to the $\type{Room}$-typed node would result in a valid instance graph.

\begin{figure}[p]
    \centering
    \input{images/03_formalisations/03_groove_formalisation/instance_graph_prop7_violated.tikz}
    \caption{Invalid instance graph with multiple containments for the $\type{Room}$-typed node}
    \label{fig:formalisations:groove_formalisation:instance_graphs:property_7_violated}
\end{figure}

The seventh property ensures that nodes can only be contained by one other node. \cref{fig:formalisations:groove_formalisation:instance_graphs:property_7_violated} shows an example of an instance graph that is typed by type graph \cref{fig:formalisations:groove_formalisation:type_graphs:type_graph_example}, but for this example we assume that $\type{Hotel}$ is a defined type similar to $\type{House}$, with the same outgoing edge types and properties. In this case, the incoming multiplicity property (the sixth property) will not be violated, as $( \type{House}, \type{rooms}, \type{Room} )$ and $( \type{Hotel}, \type{rooms}, \type{Room} )$ are different edge types with their own incoming multiplicity. However, the example is still invalid. $( \type{House}, \type{rooms}, \type{Room} )$ and $( \type{Hotel}, \type{rooms}, \type{Room} )$ are both containment edges, which means that the $\type{Room}$-typed node now has 2 incoming containment edges. The seventh property prohibits this, and therefore the example is invalid.

\begin{figure}[p]
    \centering
    \begin{subfigure}{0.3\textwidth}
        \centering
        \input{images/03_formalisations/03_groove_formalisation/instance_graph_prop8_violated_type_graph.tikz}
        \caption{Type graph}
        \label{fig:formalisations:groove_formalisation:instance_graphs:property_8_violated:type_graph}
    \end{subfigure}
    \begin{subfigure}{0.3\textwidth}
        \centering
        \input{images/03_formalisations/03_groove_formalisation/instance_graph_prop8_violated_instance_correct.tikz}
        \caption{Correct use: No cycles}
        \label{fig:formalisations:groove_formalisation:instance_graphs:property_8_violated:correct_instance_graph}
    \end{subfigure}
    \begin{subfigure}{0.3\textwidth}
        \centering
        \input{images/03_formalisations/03_groove_formalisation/instance_graph_prop8_violated_instance_incorrect.tikz}
        \caption{Incorrect use: Cycle present}
        \label{fig:formalisations:groove_formalisation:instance_graphs:property_8_violated:invalid_instance_graph}
    \end{subfigure}
    \caption{Example of correct and incorrect use of containment edges}
    \label{fig:formalisations:groove_formalisation:instance_graphs:property_8_violated}
\end{figure}

The eighth and final property ensures that there are no cycles in the containment edges of an instance graph. Consider the instance graph shown in \cref{fig:formalisations:groove_formalisation:instance_graphs:property_8_violated:correct_instance_graph} with is typed by type graph \cref{fig:formalisations:groove_formalisation:instance_graphs:property_8_violated:type_graph}. This instance graph is valid, as there is no cycle in the containment edges. However, the instance graph shown in \cref{fig:formalisations:groove_formalisation:instance_graphs:property_8_violated:invalid_instance_graph} is invalid, because it has a cycle in the containment edges. This violates the eighth property and is therefore invalid.


% 9.5.07
% This is a sample documentation for Compass in the tex format.
% We restrict the use of tex to the following subset of commands:
%
% \section, \subsection, \subsubsection, \paragraph
% \begin{enumerate} (no-nesting), \begin{quote}, \item
% {\tt ... }, {\bf ...}, {\it ... }
% \htmladdnormallink{}{}
% \begin{verbatim}...\end{verbatim} is reserved for code segments
% ...''
%

\section{Float For Loop Counter}
\label{FloatForLoopCounter::overview}
``CERT Secure Coding'' states
\begin{quote}
Floating point arithmetic is inexact and is subject to rounding errors. Hence, floating point variables should not be used as loop counters.
\end{quote}

\subsection{Parameter Requirements}
This checker takes no parameters and inputs source file.

\subsection{Implementation}
This pattern is checked using a simple AST traversal that visits all for loop init statement nodes and checks the type of its counter variable declaration. If that type is {\tt float} or {\tt double} then flag a violation.

\subsection{Non-Compliant Code Example}

\begin{verbatim}
for (float count = 0.1f; count <= 1; count += 0.1f)
{
}
\end{verbatim}

\subsection{Compliant Solution}
The compliant solution uses an {\tt int} type loop counter.

\begin{verbatim}
for (int count = 1; count <= 10; count += 1)
{
}
\end{verbatim}

\subsection{Mitigation Strategies}
\subsubsection{Static Analysis}

Compliance with this rule can be checked using structural static analysis checkers using the following algorithm:

\begin{enumerate}
\item Perform simple AST traversal visiting all for loop initialization statement nodes.
\item For each node check the type of its variable declaration. If type is {\tt float} or {\tt double} then flag violation.
\item Report any violations.
\end{enumerate}

\subsection{References}

\htmladdnormallink{FLP31-C. Do not use floating point variables as loop counters}{https://www.securecoding.cert.org/confluence/display/cplusplus/FLP31-C.+Do+not+use+floating+point+variables+as+loop+counters}


\documentclass{article}
\usepackage{fullpage}
\usepackage{nopageno}
\usepackage{amsmath}
\allowdisplaybreaks

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

\begin{document}
\title{Notes}
\date{December 13, 2013}
\maketitle
\section*{final exam}
thursday dec 19. see blackboard for details

unit step function is zero before a and 1 after. denoted U(t-a)
\begin{align*}
  \mathcal{L}\{U(t-a)\}&=\frac{e^{-as}}{s}\\
  \mathcal{L}\{f(t-a)U(t-a)\}&=e^{-as}F(s)
\end{align*}
for the exam you should be able to write a problem in terms of the unit step function. for example function that starts as 10 and switches to 0 at 2 is
\begin{align*}
  f(t)&=10-10U(t-a)
  \mathcal{L}\{f(t)\}&=\frac{10}{s}-\frac{10}{s}e^{-2s}
\end{align*}
that is one possibility for exam, another is suppose you are given function. compute inverse laplace
\begin{align*}
  \frac{e^{-\frac{\pi s}{r6s}}}{s^3}\\
  \mathcal{L}^{-1}\{\frac{e^{-\frac{\pi s}{r6s}}}{s^3}\}\\
  \mathcal{L}^{-1}\{e^{-as}F(s)\}&=f(t-a)U(t-a)\\
  a&=\frac{\pi}{6}\\
  F(s)&-\frac{2}{2}\frac{1}{s^3}\\
  f(t)&=\frac{1}{2}t^2\\
  \mathcal{L}^{-1}\{\frac{e^{-\frac{\pi s}{r6s}}}{s^3}\}&=\frac{1}{2}(t-\frac{\pi}{6})U(t-\frac{\pi}{6})
\end{align*}
\subsection*{announcement}
he'll be in office from 1-3 on mw and in mathin tomorrow from 11-1
\subsection*{example}
\begin{align*}
  x\frac{\mathrm{d}y}{\mathrm{d}x}+y&=e^{-x}\\
  \frac{\mathrm{d}y}{\mathrm{d}x}+\frac{1}{x}y&=\frac{e^{-x}}{x}\\
  \intertext{it is linear, so compute integration factor}
  e^{int{\frac{1}{x}\,\mathrm{d}x}}=e^{\ln x}&=x\\
  \intertext{multiply out by integration factor, it's already in exact form}
  x\frac{\mathrm{d}y}{\mathrm{d}x}+y&=e^{-x}\\
  \frac{\mathrm{d}}{\mathrm{d}x}\left(y*IF\right)&=e^{-x}\\
  \frac{\mathrm{d}}{\mathrm{d}x}\left(yx\right)&=e^{-x}\\
  \int{d(yx)}&=int{e^{-x}\,\mathrm{d}x}
\end{align*}
in the exam there is an integral differentiation problem like this
\begin{align*}
  \frac{\mathrm{d}y}{\mathrm{d}x}-4y+4\int_0^t{y(u)\,\mathrm{d}u}&=t^4e^{2t}\\
  y(0)&=0\\
  \mathcal{L}\{y(t)\}&=Y(s)\\
  \mathcal{L}\{\frac{\mathrm{d}y}{\mathrm{d}t}\}&=sY(s)-y(0)\\
  \mathcal{L}\{-4y\}&=-4Y(s)\\
  \mathcal{L}\{4\int_0^t{y(u)\,\mathrm{d}u}\}&=\frac{4}{s}Y(s)\\
  \mathcal{L}\{t^4\}&=\frac{4!}{s^5}=\frac{24}{s^5}\\
  \mathcal{L}\{t^4e^{2t}\}&=\frac{24}{(s-2)^5}\\
  (s-4+\frac{4}{s})Y(s)&=\frac{24}{(s-2)^5}\\
  (s^2-4s+4)Y(s)&=\frac{24s}{(s-2)^5}\\
  (s-2)^2Y(s)&=\frac{24s}{(s-2)^5}\\
  Y(s)&=\frac{24s}{(s-2)^7}\\
  &=\frac{24(s-2)+48}{(s-2)^7}\\
  &=\frac{24}{(s-2)^6}+\frac{48}{(s-2)^7}\\
  y(t)&=\frac{1}{5}t^5e^{2t}+\frac{1}{15}t^6e^{2t}
\end{align*}
\begin{align*}
  y^2\mathrm{d}t+2ty\mathrm{d}y&=0 \intertext{check for exactness}\\
  \frac{\partial M}{\partial y}&=\frac{\partial N}{\partial t}=2y\\
  \frac{\partial f}{\partial t}&=y^2\\
  \frac{\partial f}{\partial y}&=2ty\\
  \int{\mathrm{d}f}&=\int{y^2\mathrm{d}t}=y^2t+\phi(y)\\
  \frac{\partial f}{\partial y}&=2yt+\phi'(y)\\
  2ty&=2yt+\phi'(y)\\
  \phi'(y)&=0\\
  \phi'(y)&=C\\
  y^2t+C&=\text{constant}\\
\end{align*}
\end{document}


\documentclass{article}

\usepackage{nomencl}
\makenomenclature

\begin{document}

\section{Wibble}

\nomenclature{$G$}{Universal gravitational constant}
\nomenclature{$\hbar$}{Dirac constant (reduced Planck constant)}

\printnomenclature
\end{document}


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\chapter{A Type-Inference Algorithm for Higher-Ranked Polymorphism}
\label{chap:ICFP}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

This chapter presents the first fully mechanized formalization of the
metatheory for higher-ranked polymorphic type inference.
Following the woirklist subtyping algorithm in the previous chapter,
we address several drawbacks and extend the technique to
DK's bidirectional type system~\citep{dunfield2013complete}.
We chose DK's type system because it is
quite elegant, well-documented and it comes with detailed manually
written proofs. Furthermore, the system is adopted in practice by a few
real implementations of functional languages, including PureScript and
Unison. The DK type system has two variants: a declarative
and an algorithmic one. The two variants have been
\emph{manually} proved to be \emph{sound}, \emph{complete} and
\emph{decidable}.
We present a mechanical formalization in the Abella theorem prover~\citep{AbellaDesc} for
DK's declarative type system using a different algorithm.

\paragraph{Challenges}
While our initial goal was to formalize both DK's declarative and algorithmic
versions, we faced technical challenges with the latter, prompting us to find
an alternative formulation.

The first challenge that we faced were missing details as well as
a few incorrect proofs and lemmas in DK's formalization. While DK's
original formalization comes with very well-written manual proofs,
there are still several details missing. These complicate the task of
writing a mechanically verified proof. Moreover, some proofs and
lemmas are wrong and, in some cases, it is not clear to us how to fix them.

Despite the problems in DK's manual formalization,
we believe that these problems do not
invalidate their work and that their results are still true.
In fact we have nothing but praise for their detailed
and clearly written metatheory and proofs, which provided invaluable
help to our own work.
We expect that for most non-trivial manual
proofs similar problems exist, so this should not be understood as a sign of sloppiness
on their part. Instead, it should be an indicator that reinforces the arguments
for mechanical formalizations: manual formalizations are error-prone due to the multiple
tedious details involved in them.
There are several other examples of manual formalizations that were found to have
similar problems. For example, \citet{KleinRunYourResearch}
mechanized formalizations
in Redex for nine ICFP 2009 papers and all were found to have mistakes.

Another challenge was variable binding. Type inference algorithms
typically do not rely simply on local environments but instead
propagate information across judgments. While local environments are
well-studied in mechanical formalizations, there is little work on how
to deal with the complex forms of binding employed by type inference algorithms
in theorem provers. To
keep track of variable scoping, DK's algorithmic version employs input
and output contexts to track information that is discovered through
type inference. However, modeling output contexts in a theorem prover
is non-trivial.

Due to those two challenges, our work takes a different approach by refining and
extending the idea of \emph{worklist judgments}
in Chapter~\ref{chap:ITP},
where we mechanically formalized an algorithm for
\emph{polymorphic subtyping}~\citep{odersky1996putting}.
The algorithm eliminates output contexts compared to DK's algorithm,
and therefore the problem of variable binding is solved.
Unfortunately, the subtyping algorithm cannot be naively extended
to support the bidirectional type system.
A key innovation in the new algorithm to be introduced in this chapter is how
to adapt the idea of worklist judgments to
\emph{inference judgments}, which are not needed for polymorphic
subtyping, but are necessary for type inference.
The idea is to use a \emph{continuation
passing style} to enable the transfer of inferred information across
judgments. A further refinement to the idea of worklist judgments is
the \emph{unification between ordered
  contexts~\citep{gundry2010type,dunfield2013complete} and worklists}.
This enables precise scope tracking of free variables in
judgments. Furthermore it avoids the duplication of context
information across judgments in worklists that occurs in other
techniques~\citep{Reed2009,Abel2011higher}.
Despite the use of a different algorithm, we prove the
same results as DK, although with significantly different proofs and
proof techniques. The calculus and its metatheory
have been fully formalized in the Abella theorem prover~\citep{AbellaDesc}.

\input{Sources/ICFP/Overview.tex}
%\input{Sources/ICFP/Declarative.tex}
\input{Sources/ICFP/algorithm.tex}
\input{Sources/ICFP/Metatheory.tex}
\input{Sources/ICFP/Discussion.tex}
\input{Sources/ICFP/Appendix.tex}