\documentclass[a4paper]{article}

\input{temp}

\setcounter{section}{-1}

\begin{document}

\title{Category Theory}

\maketitle

\newpage

\tableofcontents

\newpage

\section{Introduction}
I didn't go to the first 3 lectures, so no intro -- sorry. I have no idea on what this course is about, let's see

\newpage

\section{Definitions and examples}
\begin{defi} (1.1)\\
    A category $\mathcal{C}$ consists of:\\
    (a) a collection $\ob\mathcal{C}$ of \emph{objects} $A,B,C$;\\
    (b) a collection $\mor\mathcal{C}$ of \emph{morphisms} $f,g,h$;\\
    (c) two operations domain, codomain assigining to each $f \in \mor\mathcal{C}$ a pair of objects, its \emph{domain} and \emph{codomain}; we write $A \xrightarrow{f} B$ to mean \emph{$f$ is a morphism and $\dom f = A, \cod f = B$};\\
    (d) an operation assigning to each $A \in \ob\mathcal{C}$ a morphism $A \xrightarrow{1_A} A$;\\
    (e) a partial binary operation $(f,g) \to fg$ on morphisms, such that $fg$ is defined iff $\dom f = \cod g$, and $\dom(fg) = \dom g$, $\cod(fg) = \cod(f)$ if $fg$ is defined, satisfying:\\
    (f) $f 1_A = f = 1_B f$ for any $A \xrightarrow{f} B$;\\
    (g) $(fg) h = f(gh)$ whenever $fg$ and $gh$ are defined.
\end{defi}

\begin{rem} (1.2)\\
    (a) This definition is independent of any model of set theory. If we're given a particular model of set theory, we call $\mathcal{C}$ \emph{small} if $\ob \mathcal{C}$ and $\mor\mathcal{C}$ are sets.\\
    (b) Some texts say $fg$ means $f$ followed by $g$, i.e. $fg$ is defined iff $\cod f = \dom g$.\\
    (c) Note that a morphism $f$ is an identity iff $fg = g$ and $hf = h$ whenever the composites are defined. So we could formulate the definition entirely in terms of morphisms.
\end{rem}

\begin{eg} (1.3)\\
    (a) The category $\mathbf{Set}$ has all sets as objects, and all functions between sets as morphisms.\\
    Strictly speaking, morphisms $A \to B$ are pairs $(f,B)$ where $f$ is a set-theoretic function. (See part II logic and sets)\\
    (b) The category $\mathbf{Gp}$ has all groups as objects, group homomorphisms as morphisms.\\
    Similarly, $\mathbf{Ring}$ is the category of rings, $\mathbf{Mod_R}$ is the category of $R$-modules.\\
    (c) The category $\mathbf{Top}$ has all topological spaces as objects, and continuous functions as morphisms.\\
    Similarly, $\mathbf{Unif}$ has all uniform spaces and uniformly continuous functions as morphisms, $\mathbf{Mf}$ has all manifolds and smooth maps correspondingly.\\
    (d) The category $\mathbf{Htpy}$ has the same objects as $\mathbf{Top}$, but morphisms are homotopy classess of continuous functions. More generally, given $\mathcal{C}$, we call an equivalence relation $\simeq$ on $\mor \mathcal{C}$ a \emph{congruence} if $f \simeq g \implies \dom f = \dom g$ and $\cod f = \cod g$, and $f \simeq g \implies fh \simeq gh$ and $kf \simeq kg$ whenever the composites are defined. Then we have a category $\mathcal{C} / \simeq$ with the same objects as $\mathcal{C}$, but congruence classes as morphisms instead.\\
    (e) Given $\mathcal{C}$, the \emph{opposite category} $C^{op}$ has the same objects and morphisms as $\mathcal{C}$, but $\dom$ and $\cod$ are interchanged, and $fg$ in $\mathcal{C}^{op}$ is $gf$ in $\mathcal{C}$.\\
    This leads to the \emph{duality principle}: if $P$ is a true statement about categories, so is the statement $P^*$ obtained from $P$ by reversing all arrows.\\
    (f) A small category with one object is a \emph{monoid}, i.e. a semigroup with $1$. In particular, a group is a small cat ($\Cat$) with one object in which every morphism is an isomorphism (i.e. for all $f, \exists g$ s.t. $fg$ and $gf$ are identities).\\
    (g) A \emph{groupoid} is a category in which every morphism is an isomorphism. For example, for a topological space $X$, the \emph{fundamental groupoid} $\pi(x)$ has all points of $X$ as objects, and morphisms $x \to y$ are homotopy classes $rel\{0,1\}$ of paths $u:[0,1] \to X$ with $u(0) = x$, $u(1) = y$ (if you know how to prove that the fundamental group is a group, you can prove that $\pi(x)$ is a groupoid).\\
    (h) A \emph{discrete} cat is one whose only morphism are identities.\\
    A \emph{preorder} is a cat $\mathcal{C}$ in which, for any pair $(A,B)$, $\exists$ at most 1 morphism $A \to B$.\\
    A small preorder is a set equipped with a binary relation which is reflexive and transitive.\\
    In particular, a partially ordered set is a small preorder in which the only isomorphisms are identities.\\
    (i) The category $\mathbf{Rel}$ has the same objects as \emph{set}, but morphisms $A \to B$ are arbitrary relations $R \subseteq A \times B$. Given $R$ and $S \subseteq B\times C$, we define $S \cdot R = \{(a,c) \in A \times C | (\exists b \in B) ((a,b) \in R, (b,c) \in S)\}$.\\
    The identity $1_A:A \to A$ is $\{(a,a) | a \in A\}$.\\
    Similarly, the category $\mathbf{Part}$ are for sets and partial functions (i.e. relations s.t. $(a,b) \in R$ and $(a,b') \in R \implies b = b'$).\\
    (j) Let $K$ be a field. The cateogry $\mathbf{Mat_K}$ has natural numbers as objects, and morphism $n \to p$ are $(p \times n)$ matrices with entries from $K$. Composition is matrix multiplication.\\
    (k) We write $\mathbf{Cat}$ for the category whose objects are all small categories, and whose morphisms are functors between them. (see below for definition of functors)
\end{eg}

\begin{defi} (1.4)\\
    Let $\mathcal{C}$ and $\mathcal{D}$ be categories. A \emph{functor} $F:\mathcal{C} \to \mathcal{D}$ consists of:\\
    (a) a mapping $A \to FA$ from $\ob \mathcal{C}$ to $\ob \mathcal{D}$;\\
    (b) a mapping $f \to Ff$ from $\mor \mathcal{C}$ to $\mor \mathcal{D}$,\\
    such that $\dom(Ff) = F(\dom f)$, $\cod(Ff) = F(\cod f)$, $1_{FA} = F(1_A)$, and $(Ff)(Fg) = F(fg)$ whenever $fg$ is defined.
\end{defi}

\begin{eg} (1.5)\\
    (a) We have \emph{forgetful functors} $U$: $\mathbf{Gp} \to \mathbf{Set}$, $\mathbf{Ring}\to \mathbf{Set}$, $\mathbf{Top} \to \mathbf{Set}$, $\mathbf{Ring} \to \mathbf{AbGp}$ (forget $\times$), $\mathbf{Ring} \to \mathbf{Mon}$ (Category of all monoids) (forget $+$).\\
    (b) Given a set $A$, the free group $FA$ has the property:\\
    Given any group $G$ and any function $A \xrightarrow{f} UG$ (?), there's a unique homomorphism $FA \xrightarrow{\bar{f}} G$ extending $f$. Here $F$ is a functor $\mathbf{Set}\to \mathbf{Gp}$: given $A \xrightarrow{f} B$, we define $Ff$ to be the unique homomorphism extending $A \xrightarrow{f} B \leftrightarrow UFB$. \href{https://math.stackexchange.com/questions/1922113/what-exactly-is-functoriality}{Functoriality} follows from uniqueness given $B \xrightarrow{f} C$. $F(gf)$ and $(Fg)(Ff)$ are both homomorphisms extending $A \xrightarrow{f} B \xrightarrow{g} C \rightarrow UFC$.\\
    (c) Given a set $A$, we write $PA$ for the set of all subsets of $A$.\\
    We can make $P$ into a functor $\mathbf{Set} \to \mathbf{Set}$, given $A \xrightarrow{f} B$, we defined $Pf(A') = \{f(a) | a \in A'\}$ for $A' \subseteq A$.\\
    But we also have a functor $P^* : \mathbf{Set} \to \mathbf{Set}^{op}$ defined on objects by $P$, but $P^* f(B') = \{a \in A | f(a) \in B'\}$ for $B' \subseteq B$.\\
    By a \emph{contravariant} functor $\mathcal{C} \to \mathcal{D}$, we mean a functor $\mathcal{C} \to \mathcal{D}^{op}$ (or $\mathcal{C}^{op} \to \mathcal{D}$). A \emph{covariant} functor is one that doesn't reverse arrows (in $op$ I guess?).\\
    (d) Let $K$ be a field. We have a functor $*:\mathbf{Mod_K} \to \mathbf{Mod_K}^{op}$ defined by $V^* = \{ \text{ linear maps }  V \to K\}$, and if $V \xrightarrow{f} W$, $f^*(\theta:W \to K) = \theta f$.\\
    (e) We have a functor $op: \mathbf{Cat} \to \mathbf{Cat}$, which is the identity on morphisms (note that this is a covariant).\\
    (f) A functor between monoids is a monoid homomorphism.\\
    (g) A functor between posets is an order-preserving map.\\
    (h) Let $G$ be a group. A functor $F \circ G \to \mathbf{Set}$ consists of a set $A=F*$ together with an action of $G$ on $A$, i.e. a \emph{permutation representation} of $G$.\\
    Similarly, a functor $G \to \mathbf{Mod_K}$ is a $K$-linear representation of $G$.\\
    (i) The construction of the fundamental group $\pi(X,X)$ of a space $X$ with basepoint $X$ is a functor $\mathbf{Top}* \to \mathbf{Gp}$ where $\mathbf{Top}*$ is the category of spaces with a chosen basepoint.\\
    Similarly, the fundamental groupoid is a functor $\mathbf{Top} \to \mathbf{Gpd}$, where $\mathbf{Gpd}$ is the category of groupoids and functors between them.
\end{eg}

\begin{defi} (1.6)\\
    Let $\mathcal{C}$ and $\mathcal{D}$ be categories and $F, G: \mathcal{C}\rightrightarrows \mathcal{D}$ (why two arrows?) two functors.\\
    A \emph{natural transformation} $\alpha:F \to G$ consists of an assignment $A \to \alpha_A$ from $\ob \mathcal{C}$ to $\mor \mathcal{D}$ (think about this), such that $\dom_{\alpha_A} = FA$ and $\cod_{\alpha A} = G A$ for all $A$, and for all $A \xrightarrow{f} B$ in $\mathcal{C}$, the square
    \begin{equation*}
        \begin{aligned}
            &FA &\xrightarrow{Ff} &FB\\
            &\downarrow \alpha_A & &\downarrow \alpha_B\\
            &GA &\xrightarrow{Gf} & GB
        \end{aligned}
    \end{equation*}
    commutes (i.e. $\alpha_B(Ff) = (Gf)_{\alpha A}$).
\end{defi}

(1.3) (l) Given categories $\mathcal{C}$ and $\mathcal{D}$, we write $[\mathcal{C},\mathcal{D}]$ for the category whose objects are functors $\mathcal{C} \to \mathcal{D}$ and whose morphisms are natural transformations.

\begin{eg} (1.7)\\
    (a) Let $K$ be a field, $V$ a vector space over $K$. There is a linear map $\alpha_V : V \to V^{**}$ given by $\alpha_V (v) \theta = \theta(v)$ for $\theta \in V^*$.\\
    This is the $V$-component of a natural transformation $1_{\mathbf{Mod_K}} \to **: \mathbf{Mod_K} \to \mathbf{Mod_K}$.\\
    (b) For any set $A$, we have a mapping $\sigma_A:A \to PA$ sending $a$ to $\{a\}$. If $f:A \to B$, then $Pf\{a\} = \{f(a)\}$. So $\sigma$ is a natural transformation $1_{\mathbf{Set}} \to P$.\\
    (c) Let $F$:$\mathbf{Set} \to \mathbf{Gp}$ be the free group functor (1.5(b)), and $U: \mathbf{Gp} \to \mathbf{Set}$ the forgetful functor. The inclusions $A \to UFA$ form a natural transformation $1_{\mathbf{Set}} \to UF$.\\
    (d) Let $G,H$ be groups and $f,g: G \rightrightarrows H$ be two homomorphisms. A natural transformation $\alpha: f \to g$ corresponds to an element $h=\alpha_*$ of $H$, s.t. $h f(x) \to g(x) h$ for all $x \in G$ or equivalently $f(x) = h^{-1} g(x) h$, i.e. $f$ and $g$ are conjugate group homomorphisms.\\
    (e) Let $A$ and $B$ be two $G$-sets, regarded as functors: $G \rightrightarrows \mathbf{Set}$. A natural transformation $A \to B$ is a function $f$ satisfying $f(g\cdot a) = g \cdot f(a)$ for all $a \in A$, i.e. a $G$-equivariant map.
\end{eg}

\begin{lemma} (1.8)\\
    Let $F,G: \mathcal{C} \rightrightarrows \mathcal{D}$ be two functors, and $\alpha: F \to G$ a natural transformation. Then $\alpha$ is an isomorphism in $[\mathcal{C},\mathcal{D}]$ iff each $\alpha_A$ is an isomorphism in $\mathcal{D}$.
    \begin{proof}
        Forward is trivial. For backward, suppose each $\alpha_A$ has an inverse $\beta_A$. Given $f:A \to B$ in $\mathcal{C}$, we need to show that
        \begin{equation*}
            \begin{aligned}
                &GA &\xrightarrow{Gf} &GB\\
                &\downarrow \beta_A & &\downarrow \beta_B\\
                &FA &\xrightarrow{Ff} & FB
            \end{aligned}
        \end{equation*}
    \end{proof}
    commutes. But as $\alpha$ is natural,
    $$(Ff)\beta_A = \beta_B \alpha_B (Ff)\beta_A = \beta_B (Gf) \alpha_A \beta_A = \beta_B (Gf)$$
    So $\beta$ is a natural transformation as well.
\end{lemma}

\begin{defi} (1.9)\\
    Let $\mathcal{C}$ and $\mathcal{D}$ be categories. By an \emph{equivalence} between $\mathcal{C}$ and $\mathcal{D}$, we mean a pair of functors $F:\mathcal{C} \to \mathcal{D}$, $G:\mathcal{D} \to \mathcal{C}$ together with natural isomorphisms $\alpha: 1_\mathcal{C} \to GF$ and $\beta: FG \to 1_\mathcal{D}$.\\
    We write $\mathcal{C} \cong \mathcal{D}$ if $\mathcal{C}$ and $\mathcal{D}$ are equivalent.\\
    We say a property $P$ of categories is a \emph{categorical property} if whenever $\mathcal{C}$ has $P$ and $\mathcal{C} \cong \mathcal{D}$, then $\mathcal{D}$ has $P$.\\
    For example, being a groupoid or a preorder are categorical properties, but being a group or a partial order are not.
\end{defi}

\begin{eg} (1.10)\\
    (a) The category $\mathbf{Part}$ is equivalent to the category $\mathbf{Set}_*$ of pointed sets (and basepoint preserving functions (as morphisms)):\\
    $\bullet$ We define $F:\mathbf{Set}_* \to \mathbf{Part}$ by $F(A,a) = A \setminus \{a\}$, and if $f:(A,a) \to (B,b)$, then $Ff(x) = f(x)$ if $f(x) \neq b$, and undefined otherwise;\\
    $\bullet$ and $G: \mathbf{Part} \to \mathbf{Set}_*$ by $G(A) = A^+ = (A \cup \{A\},A)$, and if $f:A \to B$ is a partial function, we define $Gf:A^+ \to B^+$ by $Gf(x) = f(x)$ if $x \in A$ and $f(x)$ defined, and equals $B$ otherwise.\\
    The composite $FG$ is the identity on $\mathbf{Part}$, but $GF$ is not the identity. However, there is an isomoprhism $(A,a) \to ((A \setminus \{a\})^+,A \setminus\{a\})$ sending $a$ to $A \setminus \{a\}$ and everything else to itself and this is natural.\\
    Note that there can be no isomoprhism from $\mathbf{Set}_*$ to $\mathbf{Part}$, since $\mathbf{Part}$ has a 1-element isomorphism class $\{\phi\}$ but $\mathbf{Set}_*$ doesn't.\\
    (So we see that equivalent categories can be non-isomorphic. According to a \href{https://mathoverflow.net/questions/30032/equivalence-versus-isomorphism-of-categories}{post} on SO, this usually happens when there are multiple copies of the \emph{same} thing in one but not the other. However, we can't generally \emph{discard obsolete copies} in one as that generally requires AC and is not a very useful thing to do anyway -- In short, \emph{identifying isomorphic objects is often an extremely bad idea}.)\\
    (b) The category $\mathbf{fdMod_K}$ of finite-dimensional vector spaces over $K$ is equivalent to $\mathbf{fdMod_K}^{op}$, the functors in both directions are $*$ (the dual operator) and both isomorphisms are the natural transformations of 1.7(a) (double dual).\\
    (c) $\mathbf{fdMod_K}$ is also equivalent to $\mathbf{Mat}_K$ (1.3(j)):\\
    We define $F:\mathbf{Mat_K} \to \mathbf{fdMod_K}$ by $F(n) = K^n$, and $F(A)$ is the linear map represented by $A$ w.r.t. the standard bases of $K^n$ and $K^p$.\\
    To define $G:\mathbf{fdMod_K} \to \mathbf{Mat_K}$, choose a basis for each finite dimensional vector space, and define $G(V) = \dim V$, $G(V \xrightarrow{f} W)$ to be the matrix representing $f$ w.r.t. chosen bases. $GF$ is the identity, provided we choose the standard bases for the spaces $K^n$; $FG \neq 1$, but the chosen bases give isomorphisms $FG(V) = K^{\dim V} \to V$ for each $V$, which form a natural isomorphism.
\end{eg}

---Lecture 4---

\begin{defi} (1.11)\\
    Let $\mathcal{C} \xrightarrow{F} \mathcal{D}$ be a functor.\\
    (a) We say $F$ is \emph{faithful} if, given $f,f' \in \mor \mathcal{C}$ with $\dom f = \dom f'$, $\cod f = \cod f'$, and $Ff = Ff'$, then $f=f'$ (injectivity on morphisms. The name comes more from representation theory);\\
    (b) We say $F$ is \emph{full} if, given $FA \xrightarrow{g} FB$ in $\mathcal{D}$, there exists $A \xrightarrow{f} B$ in $\mathcal{C}$ with $Ff = g$. (this is something like surjectivivity on morphisms, but see below);\\
    (c) We say  $F$ is \emph{essentially surjective} if, for every $B \in \ob \mathcal{D}$, there exists $A \in \ob \mathcal{C}$ and isomorphism $FA \to B$ in $\mathcal{D}$.\\
    We say a subcategory $\mathcal{C}' \subseteq \mathcal{C}$ is full if the inclusion $\mathcal{C}' \to \mathcal{C}$ is a full functor (basically, if the objects are kept, any morphism between them must be kept). For example, $\mathbf{Gp}$ is a full subcategory of $\mathbf{Mon}$ (the category of all monoids), but $\mathbf{Mon}$ is not a full subcategory of the category $\mathbf{SGp}$ of semigroups (consider e.g. the homomorphism that sends everything in $(\Z,\cdot)$ to $(0,\cdot)$ (which is also a semigroup); but this doesn't preserve 1 so is not a morphism in $\mathbf{Mon}$).
\end{defi}

\begin{lemma} (1.12)\\
    Assuming the axiom of choice, a functor $F:\mathcal{C} \to \mathcal{D}$ is part of an equivalence $\mathcal{C} \simeq \mathcal{D}$ if it's full, faithful, and essentially surjective.
    \begin{proof}
        $\Rightarrow$: Suppose given $G,\alpha,\beta$ as in (1.9). Then for each $B \in \ob\mathcal{D}$, $\beta_B$ is an isomorphism $FGB \to B$, so $F$ is essentially surjective.\\
        Given $A \xrightarrow{f} B$ in $\mathcal{C}$, we can recover $f$ from $Ff$ as composite $A \xrightarrow{\alpha_A} GFA \xrightarrow{GFf} GFB \xrightarrow{\alpha_b^{-1}} B$. Hence if $A \xrightarrow{f'}B$ satisfies $Ff = Ff'$, then $f=f'$. So $F$ is faithful;\\
        Lastly, for fullness, given $FA \xrightarrow{g} FB$, define $f$ to be the composite $A \xrightarrow {\alpha_A} GFA \xrightarrow{Gg} GFB \xrightarrow{\alpha_B^{-1}} B$. Then $GFf = \alpha_B f \alpha_A^{-1}$, which by construction is just $Gg$. But $G$ is faithful for the same reason as $f$, so $Ff = g$.

        $\Leftarrow$: (need to find suitable $G,\alpha,\beta$ for $F$.) For each $B \in \ob \mathcal{D}$, choose $GB \in \ob \mathcal{C}$ and an isomorphism $\beta_B : FGB \to B$ in $\mathcal{D}$. Given $B \xrightarrow{g} B'$, define $Gg:GB \to GB'$ to be the unique morphism whose image under $F$ is $FGB \xrightarrow{\beta_B} B \xrightarrow{g} B' \xrightarrow{\beta_{B'}^{-1}} FGB'$.\\
        Uniqueness implies functoriality: given $B' \xrightarrow{g'} B''$, $(Gg')(Gg)$ and $G(g'g)$ have the same image under $F$, so they are equal.\\
        By construction, $\beta$ is a natural transformation $FG \to 1_\mathcal{D}$.\\
        Given $A \in \ob \mathcal{C}$, define $\alpha_A: A \to GFA$ to be the unique morphism whose image under $F$ is $FA \xrightarrow{\beta_{FA}^{-1}} FGFA$. $\alpha_A$ is an isomorphism, since $\beta_{FA}$ also has a unique pre-image under $F$. And $\alpha$ is a natural transformation, since any naturality square for $\alpha$ (the commutative square when we defined natural transformation) is mapped by $F$ to a commutative square, and $F$ is faithful.
    \end{proof}
\end{lemma}

\begin{defi} (1.13) \\
    By a \emph{skeleton} of a category, we mean a full subcategory $\mathcal{C}_0$ containing one object from each isomorphism class. We say $\mathcal{C}$ is \emph{skeletal} if it's a skeleton of itself.\\
    For example, $\mathbf{Mat_K}$ is a skeletal, and the image of $F:\mathbf{Mat_K} \to \mathbf{fdMod_K}$ of 1.10(c) is a skeleton of $\mathbf{fdMod_K}$.\\
    (there are some examples on wikipedia)
\end{defi}

Warning: almost any assertion about skeletons is equivalent to axiom of choice (see q2 on example sheet 1).

\begin{defi} (1.14)\\
    Let $A \xrightarrow{f} B$ be a morphism in $\mathcal{C}$.\\
    (a) We say $f$ is a \emph{monomorphism} (or $f$ is \emph{monic}) if, given any pair $C \stackrel[h]{g}{\rightrightarrows} A$, $fg=fh$ implies $g=h$.\\
    (b) We say $f$ is an \emph{epimorphism} (or \emph{epic}) if it's a monomorphism in $\mathcal{C}^{op}$, i.e. if $gf = hf$ implies $g=h$.\\
    We denote monomorphisms by $A \stackrel{f}{\rightarrowtail} B$, and epimorphisms by $A \stackrel{f}{\twoheadrightarrow} B$.\\
    Any isomorphism is monic and epic: more generally, if $f$ has a left inverse (i.e. $\exists g$ s.t. $gf$ is an identity), then it's monic. We call such monomorphisms \emph{split}.\\
    We say $\mathcal{C}$ is a \emph{balanced} category if any morphism which is both monic and epic is an isomorphism.
\end{defi}

\begin{eg} (1.15)\\
    (a) As usual we consider $\mathbf{Set}$ first. In $\mathbf{Set}$, monomorphisms correspond to injections ($\Leftarrow$ is easy (ok); for $\Rightarrow$, take $C \rightrightarrows 1 = \{*\}$), and epimorphsims correspond to surjections ($\Leftarrow$ is easy; for $\Rightarrow$, use morphisms $B \rightrightarrows 2 = \{0,1\}$). So $\mathbf{Set}$ is balanced.\\
    (b) In $\mathbf{Gp}$, monomorphisms again correspond to injections (for $\Rightarrow$ use homomorphisms $\Z \to A$); epimorphisms again correspond to surjections ($\Rightarrow$ use \href{https://en.wikipedia.org/wiki/Free_product#Generalization:_Free_product_with_amalgamation}{free products with amalgamation} -- this is a non-trivial fact about groups, read more if free). So $\mathbf{Gp}$ is also balanced.\\
    (c) In $\mathbf{Rng}$ (obvious notation), monomorphisms correspond to injections (proof is much like for $\mathbf{Gp}$). However, not all epimorphisms are surjective. For example the inclusion $\Z \to \Q$ is an epimorphism, since if $\Q \stackrel[g]{f}{\rightrightarrows} R$ (any ring) agree on all integers, they agree everywhere. So $\mathbf{Rng}$ is not balanced.\\
    (d) One final example is $\mathbf{Top}$. Again, monomorphisms are injections and epimorphisms are surjections (and vice versa): proof is similar to $\mathbf{Set}$ (check). However, $\mathbf{Top}$ is not balanced since a continuous bijection need not have continuous inverse.
\end{eg}

\newpage

\section{The Yoneda Lemma}

---Lecture 5---
\begin{defi} (2.1)\\
    We say a category $\mathcal{C}$ is \emph{locally small} if, for any two objects $A,B$, the morphisms $A\to B$ in $\mathcal{C}$ form a set $\mathcal{C}(A,B)$.\\
    If we fix $A$ and let $B$ vary, the assignment $B \to \mathcal{C}(A,B)$ becomes a functor $\mathcal{C}(A,-):\mathcal{C} \to \mathbf{Set}$: given $B \xrightarrow{f} C$, $\mathcal{C}(A,f)$ is the mapping $g \to fg$ for all $g \in \mathcal{C}(B,C)$. Similarly, $A \to \mathcal{C}(A,B)$ defines a functor $\mathcal{C}(-,B):\mathcal{C}^{op} \to \mathbf{Set}$ (for $A \xrightarrow{f} C \in \mor \mathcal{C}^{op}$, maps $g \to gf$).
\end{defi}

\begin{lemma} (2.2)\\
    (i) Let $\mathcal{C}$ be a locally small category, $A \in \ob \mathcal{C}$ and $F:\mathcal{C} \to \mathbf{Set}$ a functor. Then natural transformations $\mathcal{C}(A,-) \to F$ are in bijection with elements of $FA$;\\
    (ii) Moreover, this bijection is natural in $A$ and $F$.
    \begin{proof}
        (i) Given $\alpha$:$\mathcal{C}(A,-) \to F$, we define $\Phi(\alpha) = \alpha_A(1_A) \in FA$.\footnote{Note $1_A \in \mathcal{C}(A,A)$, and $\alpha_A \in \mor \mathbf{Set}$ but $\mor \mathbf{Set}$ are just functions between sets, so this makes sense.}\\
        Conversely, given $x \in FA$, we define $\Psi(x): \mathcal{C}(A,-) \to F$ by $\Psi(x)_B (A \xrightarrow{f} B) = (Ff)(x) \in FB$.\footnote{It seems a bit confusing why this is a natural transformation, but looking carefully it basically defines a function between sets, i.e. is in $\mor \mathbf{Set}$.}\\
        $\Psi(x)$ is natural: given $g:B \to C$, we have
        \begin{equation*}
            \begin{aligned}
                \Psi(x)_C \mathcal{C}(A,g) (f) &= \Psi(x)_C (gf) = F(gf)(x),\\
                (Fg) \Psi(x)_B(f) &= (Fg)(Ff)(x) = F(gf)(x)
            \end{aligned}
        \end{equation*}
        Now given $x \in FA$, $\Phi\Psi(x) = \Psi(X)_A (1_A) = F(1_A)(x) = x$; given $\alpha$,
        \begin{equation*}
            \begin{aligned}
                \Psi\Phi(\alpha)_B(f) \Psi(\alpha_A(1_A))_B(f) &= Ff(\alpha_A(1_A))\\
                &= \alpha_B\mathcal{C}(A,f)(1_A) = \alpha_B(f)
            \end{aligned}
        \end{equation*}
        So $\Psi\Phi(\alpha)=\alpha$. So $\Psi\Phi$ and $\Phi\Psi$ are both identities on their respective domain (so we have a bijection).
    \end{proof}
\end{lemma}

\begin{coro} (2.3)\\
    The assignment $A \to \mathcal{C}(A,-)$ defines a full and faithful functor $\mathcal{C}^{op} \to [\mathcal{C},\mathbf{Set}]$.
    \begin{proof}
        Put $F = \mathcal{C}(B,-)$ in 2.2(i): we get a bijection between $\mathcal{C}(B,A)$ and morphisms $\mathcal{C}(A,-) \to \mathcal{C}(B,-)$ in $[\mathcal{C},\mathbf{Set}]$\footnote{Think very carefully about this... Given a morphism in $\mathcal{C}(A,-) \to \mathcal{C}(B,-)$, the above gives us a way to identify it uniquelly with an element in $\mathcal{C}(B,A)$ which is in $\mor \mathcal{C}^{op}$. But that alone is not enough; we also need the above functor to take that morphism \emph{directly} to the original morphism. Luckily this is the case by the proof of 2.2(i), which is also explained in the later half of the sentence above.}. We need to verify this is functorial: but it sends $f:B \to A$ to the natural transformation $g \to gf$. So functoriality follows from associativity.
    \end{proof}
\end{coro}

We call this functor (or the functor $\mathcal{C} \to [\mathcal{C}^{op}, \mathbf{Set}]$ sending $A$ to $\mathcal{C}(-,A)$) the \emph{Yoneda embedding} of $\mathcal{C}$, and denote it by $Y$.

Now let's go back to prove 2.2(ii):
\begin{proof}
    (ii) Suppose for the moment that $\mathcal{C}$ is small, so that $[\mathcal{C},\mathbf{Set}]$ is locally small.\footnote{Elements in $\mor [\mathcal{C},\mathbf{Set}]$ correspond to those in $\mor \mathcal{C}^{op}$ by Yoneda.} Then we have two functors $\mathcal{C} \times [\mathcal{C},\mathbf{Set}] \to \mathbf{Set}$: one sends $(A,F)$ to $FA$, and the other is the composite: $\mathcal{C} \times [\mathcal{C},\mathbf{Set}] \xrightarrow{Y \times 1} [\mathcal{C},\mathbf{Set}]^{op} \times [\mathcal{C},\mathbf{Set}] \xrightarrow{[\mathcal{C},\mathbf{Set}](-;-)} \mathbf{Set}$.\footnote{The second operator maps two functors two the set of natural transformations between them?}\\
    2.2(ii) says that these are naturally isomorphic. We can translate this into an elementary statement, making sense even when $\mathcal{C}$ isn't small. Given $A \xrightarrow{f} B$ and $F \xrightarrow{\alpha}G$, the two ways of producing an element of $GB$ from a natural transformation $\beta:\mathcal{C}(A,-) \to F$ give the same result, namely $$\alpha_B(Ff)\beta_A(1_A) = (Gf)\alpha_A\beta_A(1_A)$$ which is equal to $\alpha_B\beta_B(f)$.
\end{proof}

\begin{defi} (2.4)\\
    We say a functor $F:\mathcal{C} \to \mathbf{Set}$ is \emph{representable} if it's isomorphic to $\mathcal{C}(A,-)$ for some $A$. By a representation of $F$, we mean a pair $(A,x)$ where $x \in FA$ is such that $\Psi(x)$ is an isomorphism.\\
    We also call $x$ a \emph{universal element} of $F$.
\end{defi}

\begin{coro} (2.5)\\
    If $(A,x)$ and $(B,y)$ are both representations of $F$, then there's a unique isomorphism $f:A \to B$ such that $(Ff)(x) = y$.
    \begin{proof}
        Consider the composite $\mathcal{C}(B,-) \xrightarrow{\Psi(y)^{-1}}F \xrightarrow{\Psi(x)} \mathcal{C}(A,-)$. By (2.3) this is of the form $Y(f)$ for a unique isomorphism $f:A \to B$, and the diagram

        \begin{tikzcd}
            \mathcal{C}(B,-) \arrow[rd,"\Psi(y)"'] \arrow[rr,"Y(f)"] & & \mathcal{C}(A,-) \arrow[dl,"\Psi(x)"]\\
            &F &
        \end{tikzcd}

        commutes iff $(Ff)(x) = y$.
    \end{proof}
\end{coro}

\begin{eg} (2.6)\\
    (a) The forgetful functor $\mathbf{Gp} \to \mathbf{Set}$ is representable by $(\Z,1)$, $\mathbf{Rng} \to \mathbf{Set}$ by $(\Z[X],X)$, and $\mathbf{Top} \to \mathbf{Set}$ by $(\{*\},*)$.\\
    (b) The functor $P^*: \mathbf{Set}^{op} \to \mathbf{Set}$ is representable by $(\{0,1\},\{1\})$: this is the bijection between subsets and characteristic functions.\\
    (c) Let $G$ be a group. The unique (up to isomorphism) representable functor $G(*,-): G \to \mathbf{Set}$ is the \emph{Cayley representation} of $G$, i.e. the set $UG$ with $G$ acting by left multiplication.\\
    (d) Let $A$ and $B$ be two objects of a small category $\mathcal{C}$. We have a functor $\mathcal{C}^{op} \to \mathbf{Set}$ sending $C$ to $\mathcal{C}(C,A) \times \mathcal{C}(C,B)$. A representation of this, if it exists, is called a (categorical) \emph{product} of $A$ and $B$, and denoted $(A \times B,(A \times B \xrightarrow{\pi_1} A, A \times B \xrightarrow{\pi_2} B))$.\\
    This pair has the property that, for any pair $(C \xrightarrow{f}A,C\xrightarrow{g}B)$, there's a unique $C \xrightarrow{h} A \times B$ with $\pi_1 h = f$ and $\pi_2 h = g$.\\
    Products exist in many categories of interest: in $\mathbf{Set}$, $\mathbf{Gp}$, $\mathbf{Rng}$, $\mathbf{Top}$,..., they are \emph{just} cartesian products, in posets they are binary meets (see sheet 1 Q1).\\
    Dually, we have the notion of \emph{coproduct} $(A+B,A \xrightarrow{\mu_1} A + B, B \xrightarrow{\mu_2}A+B)$.\\
    These also exist in many categories of interest.\\
    ---Lecture 6---\\
    (f) (Lecturer didn't like (e) so jumped to (f) directly) Let $A \stackrel[g]{f}{\rightrightarrows} B$ be morphisms in locally small category $\mathcal{C}$. We have a functor $F:\mathcal{C}^{op} \to \mathbf{Set}$ defined by
    \begin{equation*}
        \begin{aligned}
            F(C) = \{h \in \mathcal{C}(C,A) | fh = gh\}
        \end{aligned}
    \end{equation*}
    A representation (see (2.4)) of $F$, if it exists, is called an \emph{equalizer} of $(f,g)$: It consists of an object $E$ and a morphism $E \xrightarrow{e} A$ s.t. $fe=ge$, and every $h$ with $fh=gh$ factors uniquely (see proof of 2.9(i) which gives an insight of what this means) through $e$.\\
    In $\mathbf{Set}$, we take $E = \{x \in A | f(x) = g(x) \}$ and $e=$inclusion. Similar constructions work in $\mathbf{Gp},\mathbf{Rng},\mathbf{Top}$,...\\
    Dually, we have the notion of \emph{coequalizer}.
\end{eg}

\begin{rem} (2.7)\\
    If $e$ occurs as an equalizer, then it is a monomorphism, since any $h$ factors through it in at most one way. We say a monomorphism is \emph{regular} if it occurs as an equalizer.\\
    Split monomorphisms are regular (cf sheet1 Q6(i)).\\
    Note that regular epic monomorphisms are isomorphisms: if the equalizer $e$ of $(f,g)$ is epic, then $f=g$, so $e \cong 1_{\cod e}$.
\end{rem}

\begin{defi} (2.8)\\
    Let $\mathcal{C}$ be a category, $\mathcal{G}$ a class of objects of $\mathcal{C}$.\\
    (a) We say $\mathcal{G}$ is a \emph{separating family} for $\mathcal{C}$, if given $A \stackrel[g]{f}{\rightrightarrows} B$ such that $fh=gh$ for all $G \xrightarrow{h} A$ with $G \in \mathcal{G}$, then $f=g$.\\
    (i.e. the functors $\mathcal{C}(G,-),G \in \mathcal{G}$, are collectively faithful.)\\
    (b) We say $\mathcal{G}$ is a \emph{detecting family} if, given $A \xrightarrow{f} B$ such that every $G \xrightarrow{h} B$ with $G \in \mathcal{G}$ factors uniquely through $f$, then $f$ is an isomorphism.\\
    If $\mathcal{G} =\{G\}$, we call $G$ a \emph{separator/detector}.
\end{defi}

\begin{lemma} (2.9)\\
    (i) If $\mathcal{C}$ is a balanced category, then any saparating family is detecting.\\
    (ii) If $\mathcal{C}$ has equalizers, then any detecting family is separating.
    \begin{proof}
        (i) Suppose $\mathcal{G}$ is separating and $A \xrightarrow{f} B$ satisfies the condition of 2.8(b). If $B \stackrel[h]{g}{\rightrightarrows} C$ satisfy $gf=hf$, then $gx=hx$ for every $G \xrightarrow{x} B$, so $g=h$, i.e. $f$ is epic.\\
        Similarly if $D \stackrel[l]{k}{\rightrightarrows} A$ satisfy $fk=fl$, then $ky=ly$ for any $G \xrightarrow{y} D$, since both are factorizations of $fky$ through $f$. So $k=l$, i.e. $f$ is monic.\\
        But $\mathcal{C}$ is balanced. So $f$ is an isomorphism.\\
        (ii) Suppose $\mathcal{G}$ is detecting and $A \stackrel[g]{f}{\rightrightarrows} B$ satisfies the condition of 2.8(a). Then the equalizer $E \xrightarrow{e} A$ of $(f,g)$ is isomorphism, so $f=g$.
    \end{proof}
\end{lemma}

\begin{eg} (2.10)\\
    (a) In $[\mathcal{C},\mathbf{Set}]$, the family $\{\mathcal{C}(A,-)|A \in \ob\mathcal{C}\}$ is both separating and detecting (just a restatement of Yoneda Lemma).\\
    (b) In $\mathbf{Set}$. $1=\{*\}$ (any one element set) is both a separator and a detector, since it represents the identity functor $\mathbf{Set} \to \mathbf{Set}$.\\
    Similarly, $\Z$ is both in $\mathbf{Gp}$, since it represents the forgetful functor $\mathbf{Gp} \to \mathbf{Set}$.\\
    Also, $2 = \{0,1\}$ is a coseparator and a codetector in $\mathbf{Set}$, since it represents $P^*: \mathbf{Set}^{op} \to \mathbf{Set}$.\\
    (c) In $\mathbf{Top}$, $1=\{*\}$ is a separator since it represents the forgetful functor $\mathbf{Top} \to \mathbf{Set}$, but not a detector.\\
    In fact, $\mathbf{Top}$ has no detecting \emph{set} of objects (note that this doesn't mean it has no detecting family).\\
    For any infinite cardinal $\kappa$, let $X$ be a discrete space of cardinality $\kappa$, and $Y$ the same set with \emph{co-$<\kappa$} topology, i.e. $F \subseteq Y$ is closed iff $F=Y$ or $\Card F < \kappa$ (think about, e.g. cocountable topology, then this name makes sense).\\
    The identity $X \to Y$ is continuous, but not a homeomorphism (topologically). So if $\{G_i|i \in I\}$ is any set of spaces, taking $\kappa > \Card G_i$ for all $i$ yields an example to show that the set is not detecting.\\
    (d) (some Algebraic Topology stuff) Let $\mathcal{C}$ be the category of pointed connected $CW$-complexes and homotopy classes of (basepoint-preserving) continuous mappings.\\
    JHC Whitehead proved that $X \xrightarrow{f} Y$ in this category induces isomorphisms $\pi_n(X) \to \pi_n(Y)$ for all $n$, then it's an isomorphism in $\mathcal{C}$.\\
    This says that $\{S^n | n \geq 1\}$ is a detecting set of $\mathcal{C}$.\\
    But PJ Freyd showed there is no faithful functor $\mathcal{C} \to \mathbf{Set}$, so no separating \emph{set}: if $\{ G_i | i \in I\}$ were separating, then $x \to \coprod \mathcal{C}(G_i,x)$ (disjoint unions?) would be faithful.\\
    Note that any functor of the form $\mathcal{C}(A,-)$ preserves monomorphisms, but they don't normally preserves epimorphisms.
\end{eg}

\begin{defi} (2.11)\\
    We say an object $P$ is \emph{Projective} if, given
    \begin{equation*}
        \begin{aligned}
            &P\\
            &\downarrow f\\
            A\stackrel{e}{\twoheadrightarrow}&B
        \end{aligned}
    \end{equation*}
    (recall the two head right arrow means epimorphisms) there exists $P \xrightarrow{g} A$ with $eg = f$.\\
    (If $\mathcal{C}$ is locally small, this says $\mathcal{C}(P,-)$ preserves epimorphisms).\\
    Dually, an \emph{injective} object of $\mathcal{C}$ is a projective object of $\mathcal{C}^{op}$.\\
    Given a class $\mathcal{E}$ of epimorphisms, we say $P$ is $\mathcal{E}$-\emph{projective} if it satisfies the condition for all $e \in \mathcal{E}$.
\end{defi}

\begin{lemma} (2.12)\\
    Representable functors are (pointwise)(?) projective in $[\mathcal{C},\mathbf{Set}]$.
    \begin{proof}
        Suppose given
        \begin{equation*}
            \begin{aligned}
                &\mathcal{C}(A,-)\\
                &\downarrow \beta\\
                F\stackrel{\alpha}{\twoheadrightarrow}&G
            \end{aligned}
        \end{equation*}
        where $\alpha$ is pointwise surjective. By Yoneda, $\beta$ corresponds to some $y \in GA$, and we can find $x \in FA$ with $\alpha_A(x) = y$. Now if $\gamma:\mathcal{C}(A,-) \to F$ corresponds to $x$, then naturality of the Yoneda bijection yields $\alpha\gamma =\beta$.
    \end{proof}
\end{lemma}

---Leture 7---\\
First example class: Friday 26th October, 2pm MR3.

Lecture is happy to mark any question we hand in!

\newpage

\section{Adjunctions}
\begin{defi} (3.1)\\
    Let $\mathcal{C}$ and $\mathcal{D}$ be two categories and $\mathcal{C} \xrightarrow{F} \mathcal{D}$, $\mathcal{D} \xrightarrow{G} \mathcal{C}$ two functors.\\
    By an \emph{adjunction} between $F$ and $G$ we mean a bijection between morphisms $FA \xrightarrow{\hat{f}} B$ in $\mathcal{D}$ and morphisms $A \xrightarrow{f} GB$ in $\mathcal{C}$, which is natural in $A$ and $B$, i.e. given $A' \xrightarrow{g} A$ and $B \xrightarrow{h} B'$, we have $h\hat{f} (Fg) = \widehat{(Gh)fg}: FA' \to B'$.\\

    \begin{tikzcd}
        A' \arrow[r,"g"] \arrow[d,"F"] & A \arrow[r,"f"] \arrow[d,"F"] & GB \arrow[r,"Gh"] & GB'\\
        FA' \arrow[r,"Fg"] & FA \arrow[r,"\hat{f}"] & B \arrow[u,"G"] \arrow[r,"h"] & B' \arrow[u,"G"]
    \end{tikzcd}

    We say $F$ is \emph{left adjoint} to $G$, and write $(F \dashv G)$.
\end{defi}

\begin{eg} (3.2)\\
    (a) The free functor $\mathbf{Set} \xrightarrow{F} \mathbf{Gp}$ is left adjoint to the forgetful functor $\mathbf{Gp} \xrightarrow{U} \mathbf{Set}$, since any function $f:A \to UB$ extends uniquely to a homomorphisms $\hat{f}: FA \to B$.\\
    Naturality in $B$ is \emph{easy} (lecturer says so), naturality in $A$ follows from the definition of $F$ as a functor.\\
    (b) The forgetful functor $\mathbf{Top} \xrightarrow{U} \mathbf{Set}$ has a left adjoint $D$ which equips any set with the discrete topology, \emph{and} also a right adjoint $I$ which equips a set $A$ with the indiscrete topology $\{\phi,A\}$.\\
    (c) The functor $\ob: \mathbf{Cat} \to \mathbf{Set}$ (recall $\mathbf{Cat}$ is the category of small categories) has a left adjoint $D$ sending $A$ to the \emph{discrete} category with $\ob(DA) = A$ and only identity morphisms, and a right adjoint $I$ sending $A$ to the category with $\ob(IA) = A$ and one morphism $x \to y$ for each $(x,y) \in A \times A$. In this case $D$ in turn has a left adjoint $\pi_0$ sending a small category $\mathcal{C}$ to its set of \emph{connected components}, i.e. the quotient of $\ob\mathcal{C}$ by the smallest equivalence relation identifying $\dom f$ with $\cod f$ for all $f \in \mor \mathcal{C}$.\\
    (d) Let $M$ be the monoid $\{1,e\}$ with $e^2=e$. An object of $[M,\mathbf{Set}]$ is a pair $(A,e)$ (the images of the object and multiplication by $e$ (as a morphism)), where $e:A \to A$ satisfies $e^2=e$.\\
    We have a functor $G:[M,\mathbf{Set}] \to \mathbf{Set}$ sending $(A,e)$ to $\{x \in A | e(x) = x \} = \{e(x) | x \in A\}$ and a functor $F: \mathbf{Set} \to [M,\mathbf{Set}]$ sending $A$ to $(A,1_A)$.\\
    I claim $(F \dashv G \dashv F)$: given $f:(A,1_A) \to (B,e)$, it must take values in $G(B,e)$, and any $g:(B,e) \to (A,1_A)$ is determined by its values on the image of $e$.\\
    (e) Let $\mathbf{1}$ be the discrete category with one object $*$. For any $\mathcal{C}$, there's a unique functor $\mathcal{C} \to \mathbf{1}$: a left adjoint for this picks out an \emph{initial} object of $\mathcal{C}$, i.e. an object $I$ s.t. there exists a unique $I \to A$ for each $A \in \ob \mathcal{C}$.\\
    Dually, a right adjoint for $\mathcal{C} \to \mathbf{1}$ corresponds to a \emph{terminal} object of $\mathcal{C}$ (think about what this means).\\
    (f) Let $A \xrightarrow{f} B$ be a morphism in $\mathbf{Set}$. We can regard $PA$ and $PB$ as posets, and we have functors $PA \stackrel[P^*f]{Pf}{\rightleftarrows} PB$.\\
    I claim $(Pf \dashv P^*f)$: we have $Pf(A') \subseteq B' \iff f(x) \in B'$ for all $x \in A' \iff A' \subseteq P^* f(B')$.\\
    (g) (\emph{Galois Connection}) Suppose given sets $A,B$ and a relation $R \subseteq A \times B$. We define mappings $(-)^l$,$(-)^r$ between $PA$ and $PB$ by
    \begin{equation*}
        \begin{aligned}
            &S^r = \{y \in B| (\forall x \in S) ((x,y) \in R) \} \text{ for } S \subseteq A\\
            &T^l = \{x \in A | (\forall y \in T) ((x,y) \in R)\} \text{ for } T \subseteq B
        \end{aligned}
    \end{equation*}
    The mappings are order-reversing (i.e. contravariant functors), and $T \subseteq S^r \iff S \times T \subseteq R \iff S \subseteq T^l$.\\
    We say $()^r$ and $()^l$ are \emph{adjoint on the right}.(?)\\
    (h) Let's now consider, as a functor, $P^* : \mathbf{Set}^{op} \to \mathbf{Set}$ is self-adjoint on the right, since functions $A \to PB$ correspond bijectively to subsets of $A \times B$, and hence to functions $B \to PA$.
\end{eg}

\begin{thm} (3.3)\\
    Let $G:\mathcal{D} \to \mathcal{C}$ be a functor. Then specifying a left adjoint for $G$ is equivalent to specifying an initial object of $(A \downarrow G)$ for each $A \in \ob \mathcal{C}$, where $(A \downarrow G)$ has objects pairs $(B,f)$ with $A \xrightarrow{f} GB$, and morphisms $(B,f) \to (B',f')$ are morphisms $B \xrightarrow{g} B'$ such that

    \begin{tikzcd}
        A \arrow[rd,"f'"'] \arrow[rr,"f"] & & GB \arrow[dl,"Gg"]\\
        &GB' &
    \end{tikzcd}

    commutes.
    \begin{proof}
        Suppose given $(F \dashv G)$. Consider the morphism $\eta_A:A \to GFA$ correspond to $FA \xrightarrow{1_{FA}} FA$. Then $(FA,\eta_A)$ is an object of $(A \downarrow G)$. Moreover, given $g:FA \to B$ and $f:A \to GB$, the diagram

        \begin{tikzcd}
            A \arrow[rd,"f"'] \arrow[rr,"\eta_A"] & & GFA \arrow[dl,"Gg"]\\
            &GB &
        \end{tikzcd}

        commutes iff

        \begin{tikzcd}
            FA \arrow[rd,"\hat{f}"'] \arrow[rr,"1_{FA}"] & & FA \arrow[dl,"g"]\\
            &B &
        \end{tikzcd}

        commutes, i.e. $g=\hat{f}$.\\
        So $(FA,\eta_A)$ is initial in $(A \downarrow G)$.\\
        Conversely, suppose given an initial object $(FA,\eta_A)$ for each $(A \downarrow G)$. Given $A \xrightarrow{f} A'$, we define $Ff : FA \to FA'$ to be the unique morphism (uniqueness by initiality of $FA$, commutativeness by the definition of morphsims in $(A\downarrow G)$ (see above)) making

        \begin{tikzcd}
            A \arrow[r,"\eta_A"] \arrow[d,"f"] & GFA \arrow[d,"GFf"]\\
            A' \arrow[r,"\eta_{A'}"] & GFA'
        \end{tikzcd}

        commute.\\
        Functoriality follows from uniqueness: given $f': A' \to A''$, $F(f'f)$ and $(Ff')(Ff)$ are both morphisms $(FA,\eta_A) \to (FA'',\eta_{A''}F'f)$ in $(A \downarrow G)$.\\
        Note that we haven't finished: we still have to verify natural adjunctions. We'll finish off this next monday.

        ---Lecture 8---\\
        It's next monday now! Let's finish the proof:\\
        To show $F \dashv G$: given $A \xrightarrow{f} GB$, we define $\hat{f}:FA \to B$ to be the unique morphism $(FA,\eta_A) \to (B,f)$ in $(a \downarrow G)$. This is a bijection with inverse $(FA \xrightarrow{g} B) \to (A \xrightarrow{\eta_a} GFA \xrightarrow{Gg} GB)$. The latter mapping is natural in $B$, as $G$ is a functor; and also in $A$, since by construction, $\eta$ is a natural transformation $1_{\mathcal{C}} \to GF$.
    \end{proof}
\end{thm}

Given an adjunction $(F \dashv G)$, the natural transformation $\eta:1_{\mathcal{C}} \to GF$ emerging in the above proof (3.3) is called the \emph{unit} of the adjunction.\\
Dually, we have a natural transformation traditionally denoted $\varepsilon: FG \to 1_{\mathcal{D}}$ s.t. $\varepsilon_B:FGB \to B$ corresponds to $GB \xrightarrow{1_{GB}} GB$, is called the \emph{counit}.

\begin{coro} (3.4)\\
    If $F$ and $F'$ are both left adjoint to $G:\mathcal{D} \to \mathcal{C}$, then they are naturally isomorphic.
    \begin{proof}
        For any $A$, $(FA,\eta_A)$ and $(F'A,\eta'_A)$ are both initial in $(A\downarrow G)$, so there's a unique isomorphism $\alpha_A:(FA,\eta_A) \to (F'A,\eta'_A)$.\\
        In any naturality square for $\alpha$, the two ways round are both morphisms in $(A\downarrow G)$ whose domain is initial, so they are equal. So $\alpha$ is not only just an isomorphism (but also natural).
    \end{proof}
\end{coro}

\begin{lemma} (3.5)\\
    Given $\mathcal{C} \stackrel[G]{F}{\rightleftarrows} \mathcal{D} \stackrel[K]{H}{\rightleftarrows} \mathcal{E}$, with $(F \dashv G)$ and $(H \dashv K)$, we have $(HF \dashv GK)$.
    \begin{proof}
        We have bijections between morphisms $A \to GKC$, morphisms $FA \to KC$ and morphisms $HFA \to C$, which are both natural in $A$ and $C$.
    \end{proof}
\end{lemma}

\begin{coro} (3.6)\\
    Given a commutative square

    \begin{tikzcd}
        \mathcal{C} \arrow[r] \arrow[d] & \mathcal{D} \arrow[d]\\
        \mathcal{E} \arrow[r] & \mathcal{F}
    \end{tikzcd}

    \begin{equation*}
        \begin{aligned}
            &\mathcal{C}\to &\mathcal{D}\\
            &\downarrow & \downarrow\\
            &\mathcal{E} \to &\mathcal{F}
        \end{aligned}
    \end{equation*}
    of categories and functors, if the functors all have left adjoints, then the diagram of left adjoints commutes up to natural isomorphisms.
    \begin{proof}
        By (3.5), both ways round the diagram of left adjoinst are left adjoint to the composite $\mathcal{C} \to \mathcal{F}$, so by (3.4) they are isomorphic.
    \end{proof}
\end{coro}

\begin{thm} (3.7)\\
    Given functors $\mathcal{C} \stackrel[G]{F}{\rightleftarrows} \mathcal{D}$, specifying an adjunction $(F \dashv G)$ is equivalent to specifying natural transformations $\eta: 1_{\mathcal{C}} \to GF$, $\varepsilon:FG \to 1_{\mathcal{D}}$ satisfying the commutative diagrams,

    \begin{tikzcd}
        F \arrow[rd,"1_F"'] \arrow[r,"F\eta"] & FGF \arrow[d,"\varepsilon F"]\\
        &F
    \end{tikzcd}
    and
    \begin{tikzcd}
        G \arrow[rd,"1_G"'] \arrow[r,"\eta G"] & GFG \arrow[d,"G\varepsilon"]\\
        &G
    \end{tikzcd}

    which are sometimes called the \emph{triangular identities} (for obvious reason).\\
    The composition of functors and natural transformations in the above diagrams are sometimes called \href{https://ncatlab.org/nlab/show/whiskering}{\emph{whiskering}}.
    \begin{proof}
        First suppose we are given $(F \dashv G)$. Define $\eta$ and $\varepsilon$ as in (3.3) and its dual; now consider the composite
        $$FA \xrightarrow{F \eta_A} FGFA \xrightarrow{\varepsilon_{FA}} FA$$
        under the adjunction, this corresponds to
        $$A \xrightarrow{\eta_A} GFA \xrightarrow{1_{GFA}} GFA$$
        But this also corresponds to $1_{FA}$, so $\varepsilon_{FA} \cdot F \eta_A = 1_{FA}$.\\
        The other identity is dual to this one.\\
        Conversely, suppose we are given $\eta$ and $\varepsilon$ satisfying the trianglular identities. Given $A \xrightarrow{f} GB$, let $\Phi(f)$ be the composite $FA \xrightarrow{Ff} FGB \xrightarrow{\varepsilon_B} B$; and given $FA \xrightarrow{g} B$, let $\Psi(g)$ be $A \xrightarrow{\eta_A} GFA \xrightarrow{Gg} GB$. Then $\Phi$ and $\Psi$ are both natural; we now need to show they are inverse to each other. Let's do $\Psi\Phi$, say: now
        \begin{equation*}
            \begin{aligned}
                \Psi\Phi(A \xrightarrow{f} GB) &= A \xrightarrow{\eta_A} GFA \xrightarrow{GFf} GFGB \xrightarrow{G\varepsilon_B} GB\\
                &= A \xrightarrow{f} GB \xrightarrow{\eta_{GB}} GFGB \xrightarrow{G \varepsilon_B} GB\\
                &= f
            \end{aligned}
        \end{equation*}
        where the last equality is triangular equality; and dually, $\Phi\Psi(g) = g$.
    \end{proof}
\end{thm}

\begin{lemma} (3.8)\\
    Suppose given $\mathcal{C} \stackrel[G]{F}{\rightleftarrows} \mathcal{D}$ and natural isomorphisms $\alpha:1_{\mathcal{C}} \to GF$, $\beta: FG \to 1_{\mathcal{D}}$. Then there are isomorphisms $\alpha': 1_{\mathcal{C}} \to GF$, $\beta':FG \to 1_{\mathcal{D}}$ which satisfy the triangular identities. So $(F \dashv G)$ (and $(G \dashv F)$ ).
    \begin{proof}
        We define $\alpha'=\alpha$ and, in attempt to fix $\beta'$, define $\beta'$ to be the composite
        $$FG \xrightarrow{(FG\beta)^{-1}} FGFG \xrightarrow{(F\alpha_G)^{-1}} FG \xrightarrow{\beta} 1_{\mathcal{D}}$$
        Note that $FG\beta = \beta_{FG}$, since

        \begin{tikzcd}
            FGFG \arrow[r,"FG\beta"] \arrow[d,"\beta_{FG}"] &FG \arrow[d,"\beta"]\\
            FG \arrow[r,"\beta"] & 1_{\mathcal{D}}
        \end{tikzcd}

        commutes by naturality of $\beta$, and $\beta$ is monic. So it doesn't matter which way we choose above.\\
        Now $(\beta'_F)(F\alpha')$ is the composite
        \begin{equation*}
            \begin{aligned}
                &F \xrightarrow{F\alpha} FGF \xrightarrow{(\beta_{FGF})^{-1}} FGFGF \xrightarrow{(F\alpha_{GF})^{-1}} FGF \xrightarrow{\beta_F} F\\
                &=F\xrightarrow{(\beta_F)^{-1}} FGF \xrightarrow{FGF\alpha} FGFGF \xrightarrow{(F\alpha_{GF})^{-1}} FGF \xrightarrow{\beta_F} F\\
                &= F \xrightarrow{(\beta_F)^{-1}} FGF \xrightarrow{\beta_F} F\\
                &= 1_F
            \end{aligned}
        \end{equation*}
        Since $GF\alpha = \alpha_{GF}$ (similar reasoning as previous).\\
        Now similarly $(G\beta')(\alpha'G)$ is
        \begin{equation*}
            \begin{aligned}
                &G \xrightarrow{\alpha_G} GFG \xrightarrow{(GFG\beta)^{-1}} GFGFG\xrightarrow{(GF\alpha_G)^{-1}} GFG \xrightarrow{G\beta} G\\
                &= G \xrightarrow{(G\beta)^{-1}} GFG \xrightarrow{\alpha_{GFG}} GFGFG \xrightarrow{(GF\alpha_G)^{-1}} GFG \xrightarrow{G\beta} G\\
                &= G\xrightarrow{(G\beta)^{-1}} GFG \xrightarrow{G\beta} G\\
                &= 1_G
            \end{aligned}
        \end{equation*}
    \end{proof}
\end{lemma}

\begin{lemma} (3.9)\\
    Suppose $G:\mathcal{D} \to \mathcal{C}$ has a left adjoint $F$ with counit $\varepsilon:FG \to 1_{\mathcal{D}}$, then:\\
    (i) $G$ is faithful iff $\varepsilon$ is pointwise epic;\\
    (ii) $G$ is full and faithful iff $\varepsilon$ is an isomorphism.\\
    (and of course the dual results for unit -- change epic to monic).\\
    \begin{proof}
        (i) Given $B \xrightarrow{g} B'$, $Gg$ corresponds, under the adjunction, to the composite $FGB \xrightarrow{\varepsilon_B} B \xrightarrow{g} B'$. Hence the mapping $g \to Gg$ is injective on morphisms with domain $B$ (and specified codomain) iff $g \to g\varepsilon_B$ is injective, i.e. iff $\varepsilon_B$ is an epimorphism.\\
        (ii) The proof of this is actually very similar: $G$ is full and faithful iff $g \to g\varepsilon_B$ is bijective, but that forces $\varepsilon$ to be an isomorphism: if $\alpha:B \to FGB$ is such that $\alpha\varepsilon_B = 1_{FGB}$, then this must be a two sided inverse as $\varepsilon_B \alpha \varepsilon_B = \varepsilon_B$, whence $\varepsilon_B \alpha = 1_B$. So $\varepsilon_B$ is an isomorphism, for all $B$.
    \end{proof}
\end{lemma}

---Lecture 9---

\begin{defi} (3.10)\\
    By a \emph{reflection}, we mean an adjunction in which the right adjoint is full and faithful (equivalently, the counit is an isomorphism).\\
    We say a full subcategory $\mathcal{C}' \subseteq \mathcal{C}$ is \emph{reflective} if the inclusion $\mathcal{C}'\to\mathcal{C}$ has a left adjoint.
\end{defi}

\begin{eg} (3.11)\\
    (a) The category $\mathbf{AbGp}$ of abelian groups is reflective in $\mathbf{Gp}$, the left adjoint sends a group $G$ to its \emph{abelianization} $G/G'$, where $G'$ is the subgroup generated by all commutators $[x,y] =xyx^{-1}y^{-1}, x,y \in G$, which is always a normal subgroup of $G$ (see part II Galois Theory).\\
    The unit of the adjunction is the quotient map $G \to G/G'$.\\
    (b) Given an abelian group $A$, let $A_t$ denote the torsion subgroup, i.e. the subgroup of elements of finite order. The assignment $A \to A/A_t$ gives a left adjoint to the inclusion $\mathbf{tfAbGp} \to \mathbf{AbGp}$ where $\mathbf{tfAbGp}$ is the full subcategory of torsion-free abelian groups. $A \to A_t$ is right adjoint to the inclusion $\mathbf{tAbGp} \to \mathbf{AbGp}$, so this subcategory is coreflective.\\
    (c) Let $\mathbf{KHaus} \subseteq \mathbf{Top}$ be the full subcategory of compact Hausdorff spaces (see part IB Metric and Topological Spaces). The inclusion $\mathbf{KHaus} \to \mathbf{Top}$ has a left adjoint $\beta$, the \emph{Stone-Čech compactification}.\\
    (d) Let $x$ be a topological space. We say $A \subseteq X$ is \emph{sequentially closed} if $x_n \to x_\infty$ and $x_n \in A$ for all $n$ implies $x_\infty \in A$.\\
    We say $x$ is \emph{sequential} if all sequentially closed sets are closed. Given a non-sequential space $X$, let $X_s$ be the same set with topology given by the sequentially open sets in $X$; the identity $X_s \to X$ is continuous, and defines the counit of an adjunction betwen the inclusion $\mathbf{Seq} \to \mathbf{Top}$ and the functor $X \to X_s$.\\
    (e) If $X$ is a topological space, the poset $CX$ of closed subsets of $X$ is reflective in the full power set $\mathcal{P}X$, with reflector given by closure, and the poset $OX$ of open subsets is coreflective, with reflector given by interior.
\end{eg}

\newpage

\section{Limits}

\begin{defi} (4.1)\\
    (a) Let $\mathcal{J}$ be a category (almost always small, and often finite). By a \emph{diagram of shape} $\mathcal{J}$ in $\mathcal{C}$, we mean a functor $D:\mathcal{J} \to \mathcal{C}$. The objects $D(j), j \in \ob \mathcal{J}$, are called \emph{vertices} of the diagram, and the morphism $D(\alpha)$, $\alpha \in \mor\mathcal{J}$ are called \emph{edges} of $D$.\\
    For example, if $\mathcal{J}$ is the category

    \begin{tikzcd}
        \cdot \arrow[r] \arrow [dr] \arrow [d] & \cdot \arrow[d]\\
        \cdot \arrow[r] & \cdot
    \end{tikzcd}

    with 4 objects and 5 non-identity morphisms, a diagram of shape $\mathcal{J}$ is a commutative square

    \begin{tikzcd}
        A \arrow[r,"f"] \arrow[d,"g"] & B \arrow[d,"h"]\\
        C \arrow[r,"k"] & D
    \end{tikzcd}

    If $\mathcal{J}$ is
    \begin{tikzcd}
        \cdot \arrow[r] \arrow [dr, shift left] \arrow[dr, shift right] \arrow [d] & \cdot \arrow[d]\\
        \cdot \arrow[r] & \cdot
    \end{tikzcd}
    , a diagram of shape $\mathcal{J}$ is a not-necessarily-commutative square.

    (b) Given $D:\mathcal{J} \to \mathcal{C}$, a \emph{cone} over $D$ consists of an object $A$ of $\mathcal{C}$ (the \emph{apex} of the cone) together with morphisms $A\xrightarrow{\lambda_j} D(j)$ for each $j \in \ob \mathcal{J}$, such that
    \begin{tikzcd}
        & A \arrow[dl,"\lambda_j"'] \arrow[dr,"\lambda_{j'}"] &\\
        D(j) \arrow[rr,"D(\alpha)"] & & D(j')
    \end{tikzcd}
    commutes for all $j \xrightarrow{\alpha} j'$ in $\mor \mathcal{J}$.\\
    (The $\lambda_j$ are called the \emph{legs} of the cone).

    \includegraphics[scale=0.5]{image/Cat_07.png}

    Given cones $(A,(\lambda_j)_{j \in \ob \mathcal{J}})$ and $(B,(\mu_j)_{j \in \ob \mathcal{J}})$, a \emph{morphism} of cones between them is a morphism $A \xrightarrow{f} B$ s.t.
    \begin{tikzcd}
        A \arrow[rr,"f"] \arrow[rd,"\lambda_j"'] & & B \arrow[dl, "\mu_j"]\\
        & D(j) &
    \end{tikzcd}
    commutes for all $j$.

    We write $\mathbf{Cone}(D)$ for the category of cones over $D$ (I guess with morphisms being all the possible ones from above?).\\
    (c) A \emph{limit} for $D$ is a terminal object of $\mathbf{Cone}(D)$, if this exists.\\
    Dually, we have the notion of cone under a diagram, and of colimit ($=$ initial cone under $D$).\\
    Alternatively, if $\mathcal{C}$ is locally small, and $\mathcal{J}$ is small, we have a functor $\mathcal{C}^{op} \to \mathbf{Set}$ sending $A$ to the set of cones with apex $A$. A limit for $D$ is a representation of this functor.\\
    If $\triangle A$ denotes the constant diagram of shape $\mathcal{J}$ with all vetices $A$ and all edges $1_A$, then a cone over $D$ with apex $A$ is the same thing as a natural transformation $\triangle A \to D$.\\
    $\triangle$ is a functor $\mathcal{C} \to [\mathcal{J}, \mathcal{C}]$ and $\mathbf{Cone}(D)$ is the category $(\triangle \downarrow D)$ in the notation of ($3.3^{op}$) (the dual case of (3.3)...). So to say that every diagram of shape $J$ in $\mathcal{C}$ has a limit is equivalent to saying that $\triangle$ has a right adjoint. (We say $\mathcal{C}$ \emph{has limits} of shape $\mathcal{J}$).\\
    Dually, $\mathcal{C}$ has colimits of shape $J$ iff $\triangle:\mathcal{C} \to [\mathcal{J},\mathcal{C}]$ has a left adjoint.
\end{defi}

\begin{eg} (4.2)\\
    (a) (Lecturer says he'll give a very simple example) Suppose $\mathcal{J} = \phi$ (a diagram of that here. It's easy to draw, but a bit hard to see). There's a unique diagram of shape $\mathcal{J}$ in $\mathcal{C}$, a cone over it is just an object (with no legs), and a morphism of cones is a morphism of $\mathcal{C}$ (any one). So a limit for the empty diagram is a terminal object of $\mathcal{C}$.\\
    Dually, a colimit for it is an initial object.\\
    (Indeed a very simple example)

    ---Lecture 10---

    (b) Let $\mathcal{J}$ be the category with two objects and no non-identity morphisms. A diagram of shape $\mathcal{J}$ is a pair of objects $A,B$; a cone over it is a span
    \begin{tikzcd}
        & C \arrow[dl] \arrow[dr] &\\
        A & & B
    \end{tikzcd}
    ; and a limit for it is a product
    \begin{tikzcd}
        & A\times B \arrow[dl,"\pi_1"] \arrow[dr, "\pi_2"] &\\
        A & & B
    \end{tikzcd}
    as defined in 2.6(e). Dually, a colimit for it is a coproduct
    \begin{tikzcd}
        A \arrow[dr,"\nu_1"] & & B \arrow[dl,"\nu_2"]\\
        & A+B &
    \end{tikzcd}

    (c) More generally, if $\mathcal{J}$ is a small discrete category, a diagram of shape $\mathcal{J}$ is a $\mathcal{J}$-indexed family $(A_j|j \in \mathcal{J})$, and a limit for it is a product $(\prod_{j \in J} A_j \xrightarrow{\pi_j} A_j | j \in \mathcal{J})$ (Dually, $(A_j \xrightarrow{\nu_j} \sum_{j \in \mathcal{J}} A_j | j \in \mathcal{J})$, or $\coprod_{j \in \mathcal{J}} A_j$, but we usually use the first notation).

    (d) Let $\mathcal{J}$ be the category
    \begin{tikzcd}
        \cdot \arrow[r,shift left, "f"] \arrow[r, shift right, "g"'] & \cdot
    \end{tikzcd}
    . A diagram of shape $\mathcal{J}$ is a parallel pair $A \stackrel[g]{f}{\rightrightarrows} B$; a cone over this is
    \begin{tikzcd}
        & C \arrow[dl,"h"] \arrow[dr,"k"] &\\
        A & & B
    \end{tikzcd}
    satisfying $fh=k=gh$, or equivalently a morphism $C \xrightarrow{h} A$ satisfying $fh = gh$. A (co)limit for the diagram is a (co)equalizer as defined in 2.6(f).

    (e) Let $\mathcal{J}$ be the category
    \begin{tikzcd}
        & \cdot \arrow[d]\\
        \cdot \arrow[r] & \cdot
    \end{tikzcd}
    . A diagram of shape $\mathcal{J}$ is a cospan
    \begin{tikzcd}
        & A \arrow[d,"f"]\\
        B \arrow[r,"g"] & C
    \end{tikzcd}
    , a cone over it is
    \begin{tikzcd}
        D \arrow[r,"p"] \arrow[d,"q"] \arrow[dr, "r"] & A\\
        B & C
    \end{tikzcd}
    satisfying $fp=r=gq$, or equivalently, a span $(p,q)$ completing the diagram to a commutative square. A limit for the diagram is called a \emph{pullback} of $(f,g)$. In $\mathbf{Set}$, the apex of the pullback is the \emph{fibre product}
    $$ A \times_C B = \{(x,y) \in A \times B | f(x) = g(y)\}$$
    Dually, colimits of shape $\mathcal{J}^{op}$ are called \emph{pushouts}. Given
    \begin{tikzcd}
        A \arrow[r,"f"] \arrow[d,"g"] & B\\
        C & \\
    \end{tikzcd}
    , we \emph{push $g$ along $f$} to get the RH side of the colimit square.

    (f) (not very important for this course, but might explain why the term \emph{limit} is used) Let $J$ be the poset of natural numbers. A diagram of shape $J$ is a \emph{direct system} $A_0 \xrightarrow{f_0} A_1 \xrightarrow{f_1} A_2 \xrightarrow{f_2} ...$\\
    A colimit for this is called a \emph{direct limit}: it consists of $A_\infty$ equipped with morphisms $A_n \xrightarrow{g_n} A_\infty$ satisfying $g_n = g_{n+1}f_n$ for all $n$, and universal among such.\\
    Dually, we have \emph{inverse system} and \emph{inverse limit}.
\end{eg}

\begin{thm} (4.3)\\
    (i) Suppose $\mathcal{C}$ has equalizers and all finite (respectively, small) products. Then $\mathcal{C}$ has all finite (respectively, small) limits.\\
    (ii) Suppose $\mathcal{C}$ has pullbacks and a terminal object, then $\mathcal{C}$ has all finite limits.
    \begin{proof}
        (i) Suppose given $D:\mathcal{J} \to \mathcal{C}$. Form the products $P=\prod_{j \in \ob\mathcal{J}} D(j)$ and $Q = \prod_{\alpha \in \mor\mathcal{J}} D(\cod \alpha)$.\\
        We have morphisms $P \stackrel[g]{f}{\rightrightarrows} Q$ defined by $\pi_\alpha f = \pi_{\cod(\alpha)}$, $\pi_\alpha g = D(\alpha) \pi_{\dom \alpha}$ for all $\alpha$ since $Q$ is a product.\\
        Let $E \xrightarrow{e} P$ be an equalizer of $(f,g)$. The composites $\lambda_j = \pi_j e: E \to D(j)$ form a cone over $D$: given $\alpha: j \to j'$ in $\mathcal{J}$,
        $$D(\alpha) \lambda_j = D(\alpha) \pi_j e = \pi_\alpha ge = \pi_\alpha fe = \pi_{j'} e = \lambda_{j'}$$
        Given any cone $(A,(\mu_j | j \in \ob\mathcal{J}))$ over $D$, there's a unique $\mu:A \to P$ with $\pi_j \mu = \mu_j$ for each $j$, and $\pi_\alpha f \mu = \mu_{\cod \alpha} = D(\alpha) \mu_{\dom \alpha} = \pi_\alpha g\mu$ for all $\alpha$, and hence $f\mu = g\mu$. So there is a unique $\nu:A \to E$ with $e\nu = \mu$. So $(E,(\lambda_j | j \in \ob \mathcal{J}))$ is a limit cone.

        (ii) It's enough to construct finite products and equalizers. But if $1$ is the terminal object, then a pullback for
        \begin{tikzcd}
                        & A \arrow[d]\\
            B \arrow[r] & 1
        \end{tikzcd}
        has the universal property of a product $A \times B$, and we can form $\prod_{i=1}^n A_i$ inductively as $A_1 \times (A_2 \times (A_3 \times ... (A_{n-1} \times A_n)))$.\\
        Now, to form the equalizer of $A \stackrel[g]{f}{\rightrightarrows} B$, consider the cospan
        \begin{tikzcd}
            & A \arrow[d,"{(1_A,f)}"]\\
            A \arrow[r,"{(1_A,g)}"] & A \times B
        \end{tikzcd}
        . A cone over this consists of
        \begin{tikzcd}
            P \arrow[r,"h"] \arrow[d,"k"] & A\\
            A &
        \end{tikzcd}
        satisfying $(1_A,f) h = (1_A,g) k$, or equivalently $1_A h = 1_A k$, and $fh = gk$, or equivalently, a morphism $P \xrightarrow{h} A$ satisfying $fh = gh$ (think). So a pullback for $(1_A,f)$ and $(1_A,g)$ is an equalizer of $(f,g)$.\\
        We say a category $\mathcal{C}$ is \emph{complete} if it has all small limits. Dually, \emph{cocomplete} means it has all small colimits.\\
        $\mathbf{Set}$ is both complete and cocomplete: products are cartesian products, coproducts are disjoint unions.\\
        Similarly, $\mathbf{Gp}$, $\mathbf{AbGp}$, $\mathbf{Rng}$, $\mathbf{Mod}_R$,... are all complete and cocomplete (nice to know that). $\mathbf{Top}$ is also complete and cocomplete, ...
    \end{proof}
\end{thm}

\begin{defi} (4.4)\\
    Let $F: \mathcal{C} \to \mathcal{D}$ be a functor.\\
    (a) We say $F$ \emph{preserves limits} of shape $\mathcal{J}$ if, given $D:\mathcal{J} \to \mathcal{C}$ and a limit cone $(L,(\lambda_j|j \in \ob\mathcal{J}))$ in $\mathcal{C}$, $(FL, (F\lambda_j | j \in \ob \mathcal{J}))$ is a limit for $FD$.\\
    (b) We say $F$ \emph{reflects limits} of shape $\mathcal{J}$ if, given $D:\mathcal{J} \to \mathcal{C}$ and a cone $(L,(\lambda_j)_j)$ s.t. $(FL,(F\lambda_j)_j)$ is a limit for $FD$, then $(L,(\lambda_j)_j)$ is a limit for $D$.\\
    (c) We say $F$ \emph{creates limits} of shape $\mathcal{J}$ if, given $D : \mathcal{J} \to \mathcal{C}$ and a limit $(M,(\mu_j)_j)$ for $FD$, there exists a cone $(L,(\lambda_j)_j)$ over $D$ whose image under $F$ is isomorphic to the limit cone, and any such cone is a limit in $\mathcal{C}$.\footnote{Note that all limits are isomorphic, so the first part of this basically says $F$ reflects the existence of limits.} (This is stronger than both of above and implies them. Note that a lot of textbooks get this wrong; the definitions given by them are usually not categorical)\\
    From some later parts of the notes, the definitions of these three words (\emph{preserve, reflect, create}) seem to apply to other things as well but restricted to limits only.
\end{defi}

---Lecture 11---

\begin{rem} (4.5)\\
    (a) If $\mathcal{C}$ has limits of shape $\mathcal{J}$, $F: \mathcal{C} \to \mathcal{D}$ preserves them and $F$ reflects isomorphisms, then $F$ reflects limits of shape $\mathcal{J}$.\\
    (b) $F$ reflects limits of shape $1$ $\iff$ $F$ reflects isomorphisms.\\
    (c) If $\mathcal{D}$ has limits of shape $\mathcal{J}$ and $F:\mathcal{C} \to \mathcal{D}$ creates them, then $F$ both preserves and reflects them.\\
    (d) In any of the statements of (4.3), we may replace both instances of \emph{$\mathcal{C}$ has} by either \emph{$\mathcal{C}$ has and $F:\mathcal{C} \to \mathcal{D}$ preserves} or \emph{$\mathcal{D}$ has and $F:\mathcal{C} \to \mathcal{D}$ creates}.
\end{rem}

We shall have some examples, as usual.

\begin{eg} (4.6)\\
    (a) $U : \mathbf{Gp} \to \mathbf{Set}$ creates all small limits: given a family $(G_i | i \in I)$ of groups, there's a unique group structure on $\prod_{i \in I} UG_i$ making the projections $\pi_i$ into homomorphisms, and this makes it into a product in $\mathbf{Gp}$.\\
    Similarly for equalizers.\\
    But $U$ doesn't preserve coproducts; $U(G * H) \not\cong UG \coprod UH$.\\
    (b) $U:\mathbf{Top} \to \mathbf{Set}$ preserves all small limits and colimits, but this times it doesn't reflect them: if $L$ is a limit for $D: \mathcal{J} \to \mathbf{Top}$, and $L$ is not discrete, there's another cone with apex $L_d$ (take the underlying set and \emph{retopologize} with discrete topology) mapping to the limit in $\mathbf{Set}$.\\
    (c) The inclusion functor $I:\mathbf{AbGp} \to \mathbf{Gp}$ reflects coproducts, but doesn't preserve them: the direct sum $A \oplus B$ (coproducts in $\mathbf{AbGp}$) is not normally isomorphic to the free product $A*B$; $A*B$ is not abelian unless either $A$ or $B$ is $\{e\}$.\\
    But if $A \cong \{e\}$, then $A*B \cong A \oplus B \cong B$.
\end{eg}

\begin{lemma} (4.7)\\
    If $\mathcal{D}$ has limits of shape $\mathcal{J}$, then so does the functor category $[\mathcal{C},\mathcal{D}]$ for any $\mathcal{C}$, and the forgetful functor $[\mathcal{C},\mathcal{D}] \to \mathcal{D}^{\ob \mathcal{C}}$ creates them.
    \begin{proof}
        Suppose given a diagram of shape $\mathcal{J}$ in $[\mathcal{C},\mathcal{D}]$; think of it as a functor $D:\mathcal{J} \times \mathcal{C} \to \mathcal{D}$. For each $A \in \ob\mathcal{C}$, let $(LA,(\lambda_{j,A}|j \in \ob \mathcal{J}))$ be a limit cone for the diagram $D(-,A): \mathcal{J} \to \mathcal{D}$.\\
        Given $A \xrightarrow{f} B$ in $\mathcal{C}$, the composites $LA \xrightarrow{\lambda_{j,A}} D(j,A) \xrightarrow{D(j,f)} D(j,B)$ form a cone over $D(-,B)$, since the sqaures
        \begin{tikzcd}
            D(j,A) \arrow[r,"{D(j,f)}"] \arrow[d,"{D(\alpha,A)}"] & D(j,B) \arrow[d,"{D(\alpha,B)}"]\\
            D(j',A) \arrow[r,"{D(j',f)}"] & D(j',B)
        \end{tikzcd}
        commute. So there's a unique $LF:LA \to LB$ making
        \begin{tikzcd}
            LA \arrow[r,"{\lambda_{j,A}}"] \arrow[d,"Lf"] & D(j,A) \arrow[d,"{D(j,f)}"]\\
            LB \arrow[r,"{\lambda_{j,B}}"] & D(j,B)
        \end{tikzcd}
        commute for all $j$.\\
        As usual, uniqueness implies functoriality: given $g:B \to C$, $L(gf)$ and $(Lg)(Lf)$ are factorizations of the same cone through the limit $LC$. And this is the unique functor structure on $(A \to LA)$ making the $\lambda_{j,-}$ into natural transformations.\\
        The cone $(L,(\lambda_{j,-} | j \in \ob\mathcal{J}))$ is a limit: suppose given another cone $(M,(\mu_{j,-} | j \in \ob\mathcal{J}))$, then for each $A$, $(MA,(\mu_{j,A} | j \in \ob\mathcal{J}))$ is a cone over $D(-,A)$, so induces a unique $\alpha_A:MA \to LA$. Naturality of $\alpha$ follows from uniqueness of factorizations through a limit. So $(M,(\mu_j))$ factors uniquely through $(L,(\lambda_j))$.
    \end{proof}
\end{lemma}

\begin{rem} (4.8)\\
    Now we can prove something that I promised very long ago (see Sheet 1 Q4 as well). In any category, a morphism $A \xrightarrow{f} B$ is monic iff
    \begin{tikzcd}
        A \arrow[r,"1_A"] \arrow[d,"1_A"] & A \arrow[d,"f"]\\
        A \arrow[r,"f"] & B
    \end{tikzcd}
    is a pullback. Hence any functor which preserves pullbacks preserves monomorphisms.\\
    In particular, if $\mathcal{D}$ has pullbacks, then monomorphisms in $[\mathcal{C},\mathcal{D}]$ are just pointwise monomorphisms.\\
    The dual is the statement in comment of Sheet 1 Q4.
\end{rem}

\begin{thm} (4.9)\\
    Suppose $G:\mathcal{D} \to \mathcal{C}$ has a left adjoint $F$. Then $G$ preserves all limits which exist in $\mathcal{D}$.\\
    We'll present two proofs: the first (slick) proof is more for you to understand why this is true, while the second proof is more elementary.
    \begin{proof} (1)\\
        Suppose $\mathcal{C}$ and $\mathcal{D}$ both have limits of shape $\mathcal{J}$. We have a commutative diagram
        \begin{tikzcd}
            \mathcal{C} \arrow[r,"F"] \arrow[d,"\triangle"] & \mathcal{D} \arrow[d,"\triangle"]\\
            \left[\mathcal{J},\mathcal{C}\right] \arrow[r,"{[\mathcal{J},F]}"] & \left[\mathcal{J},\mathcal{D}\right]
        \end{tikzcd}
        , and all functors in it have right adjoints.\\
        In particular, $([\mathcal{J},F] \dashv [\mathcal{J},G])$.\\
        So by (3.6), the diagram of right adjoints
        \begin{tikzcd}
            \mathcal{D} \arrow[r,"G"] & \mathcal{C}\\
            \left[\mathcal{J},D\right] \arrow[u,"\lim_{\mathcal{J}}"] \arrow[r,"{[\mathcal{J},G]}"] & \left[\mathcal{J},\mathcal{C}\right] \arrow[u,"\lim_{\mathcal{J}}"]
        \end{tikzcd}
        commutes up to isomorphism, i.e. $G$ preserves limits of shape $\mathcal{J}$.\\
        This is the real reason why this theorem works, because right adjoint commute with right adjoints.\\
        However, this proof won't work if we don't know we have limits.
    \end{proof}

    \begin{proof} (2)\\
        Suppose given $D:\mathcal{J} \to \mathcal{D}$ and a limit cone $(L,(L \xrightarrow{\lambda_j} D(j) | j \in \ob \mathcal{J}))$. Given a cone $(A,(A \xrightarrow{\alpha_j} GD(j) | j \in \ob\mathcal{J}))$ over $GD$, the morphisms $FA \xrightarrow{\hat{\alpha}_j} D(j)$ form a cone over $D$, so they induce a unique $FA \xrightarrow{\hat{\beta}} L$ such that $\lambda_j \hat{\beta} = \hat{\alpha}_j$ for all $j$.\\
        Then $A \xrightarrow{\beta} GL$ is the unique morphism satisfying $(G \lambda_j) \beta = \alpha_j$ for all $j \in \mathcal{J}$. So $(GL,(G\lambda_j | j \in \ob\mathcal{J}))$ is a limit cone in $\mathcal{C}$.\\
        The \emph{primeval Adjoint Functor Theorem} says that the converse of (4.9) is true: if $\mathcal{D}$ has (limits), and $G:\mathcal{D} \to \mathcal{C}$ preserves \emph{all} limits, then $G$ has a left adjoint.
    \end{proof}
\end{thm}

---Lecture 12---

Second example class: Friday 9 November, 14:00, MR3.

\begin{lemma} (4.10)\\
    Suppose $\mathcal{D}$ has and $G:\mathcal{D} \to \mathcal{C}$ preserves limits of shape $\mathcal{J}$. Then for any $A \in \ob \mathcal{C}$, the arrow category $(A \downarrow G)$ has limits of shape $\mathcal{J}$, and the forgetful functor $U:(A \downarrow G) \to \mathcal{D}$ creates them.
    \begin{proof}
        Suppose given $D:\mathcal{J} \to (A\downarrow G)$; write $D(j)$ as $(UD(j),f_j)$.\\
        Let $(L,(\lambda_j:L \to UD(j))_{j \in \ob\mathcal{J}}$ be a limit for $UD$; then $(GL,(G\lambda_j)_{j \in \ob\mathcal{J}})$ is a limit for $GUD$. Since the edges of $UD$ are morphisms in $(A \downarrow G)$, the $f_j$ form a cone over $GUD$.\\
        So there's a unique $h:A \to GL$ s.t. $(G\lambda_j)h = f_j$ for all $j$, i.e. there is a unique $h$ s.t. the $\lambda_j$ are all morphisms $(L,h) \to (UD(j),f_j)$ in $(A \downarrow G)$.\\
        We need to show that $((L,h),(\lambda_j)_{j \in \ob\mathcal{J}})$ is a limit cone in $(A \downarrow G)$.\\
        If $((C,k),(\mu_j)_{j \in \ob\mathcal{J}})$ is any cone over $D$, then $(C,(\mu_j)_{j \in \ob\mathcal{J}})$ is a cone over $UD$. So there's a unique $l:C \to L$ with $\lambda_j l = \mu_j$ for all $j$. We need to show $(Gl)k = h$: but $(G\lambda_j) (Gl)k = (G\mu_j)k = f_j = (G\lambda_j) h$ for all $j$. So $(Gl)k = h$ by uniqueness of factorizations through limits.
    \end{proof}
\end{lemma}

\begin{lemma} (4.11)\\
    A category $\mathcal{C}$ has an initial object iff $1_{\mathcal{C}}:\mathcal{C} \to \mathcal{C}$, regarded as a diagram of shape $\mathcal{C}$ in $\mathcal{C}$, has a limit.
    \begin{proof}
        First, suppose $\mathcal{C}$ has an initial object $I$. Then the unique morphisms $(I \to A | A \in \ob\mathcal{C})$ form a cone over $1_{\mathcal{C}}$; and given any cone $(C \xrightarrow{\lambda_A} A |A \in \ob\mathcal{C})$, then for any $A$ the triangle
        \begin{tikzcd}
            C \arrow[rd,"\lambda_A"'] \arrow[r,"\lambda_I"] & I \arrow[d]\\
            & A
        \end{tikzcd}
        commutes, so $\lambda_I$ is the unique factorization of $(\lambda_A|A \in \ob\mathcal{C})$ through $(I \to A|A\in\ob\mathcal{C})$.\\
        Conversely, suppose $(I,(\lambda_A:I \to A|A \in \ob\mathcal{C}))$ is a limit. Then for any $I \xrightarrow{f} A$, the diagram
        \begin{tikzcd}
            I \arrow[r,"\lambda_I"] \arrow[rd,"\lambda_A"] & I \arrow[d,"f"]\\
            & A
        \end{tikzcd}
        commutes. In particular, putting $f = \lambda_A$, we see that $\lambda_I$ is a factorization of the limit cone through itself, so $\lambda_I = 1_I$. Hence every $f:I \to A$ satisfies $f=\lambda_A$. So $I$ is initial.
    \end{proof}
\end{lemma}

The primeval adjoint functor theorem follows immediately from (4.10), (4.11) and (3.3).\\
However, it only applies to functors between preorders (since that's the only category that satisfies the conditions; c.f. Sheet 2 Q6).

\begin{thm} (4.12, General Adjoint Functor Theorem)\\
    Suppose that $\mathcal{D}$ is locally small and complete. Then $G:\mathcal{D} \to \mathcal{C}$ has a left adjoint $\iff$ $G$ preserves all small limits (some people use the word \emph{continuous} for this) and, for each $A \in \ob\mathcal{C}$, there exists a \emph{set} of morphisms $\{A \xrightarrow{f_i} GB_i | i \in I\}$ s.t. every $A \xrightarrow{h} GC$ factors as $A \xrightarrow{f_i} GB_i \xrightarrow{Gg} GC$ for some $i$ and some $g:B_i \to C$.\\
    (We say $G$ satisfies the \emph{solution set condition}.)
    \begin{proof}
        $\implies$: If $(F \dashv G)$, $G$ preserves limits by (4.9), and $\{A \xrightarrow{\eta_A} GFA\}$ is a singleton solution set, by (3.3).\\
        $\Leftarrow$: By (4.10) $(A\downarrow G)$ is complete, and it inherits local smallness from $\mathcal{D}$. So we need to show: if $\mathcal{A}$ is compelte and locally small, and has a weakly initial set of objects $\{B_i | i \in I\}$, then $\mathcal{A}$ has an initial object.\\
        First form $P=\prod_{i \in I} B_i$, then $P$ is weakly initial. Now form the limit of $P \stackrel[\to]{\to}{...} P$ (*) whose edges are all the endomorphisms of $P$; denote it $I \xrightarrow{i} P$. $I$ is also weakly initial in $\mathcal{A}$; suppose given $I \stackrel[g]{f}{\rightrightarrows} C$. Form equalizer $E \xrightarrow{e} I$ of $(f,g)$; then there exists $P\xrightarrow{h} E$ since $P$ is weakly initial.\\
        $ieh:P \to P$ and $1_P$ are edges of the diagram (*) above, so $i=iehi$. But $i$ is monic, so $ehi = 1_I$; in particular, $e$ is split epic. So $f=g$.\\
        Hence $I$ is initial.
    \end{proof}
\end{thm}

\begin{eg} (4.13)\\
    (a) Suppose you've never heard of free groups nor how to construct them. Consider the forgetful functor $U: \mathbf{Gp} \to \mathbf{Set}$. By (4.6 a), $U$ creates all small limits, so $\mathbf{Gp}$ has them and $U$ preserves them. $\mathbf{Gp}$ is locally small; now given a set $A$, any $f:A \to UG$ factors as $A \to UG' \to UG$, where $G' \leq G$ is the subgroup generated by $\{f(x) |x \in A\}$, and $\Card G' \leq \max\{\aleph_0,\Card A\}$.\\
    Let $B$ be a set of this cardinality, and consider all possible subsets $B' \subseteq B$. All group structures on $B'$ and all mappings $A \to B'$. So these give us a solution set at $A$.\footnote{However this is not a very good example -- how did we know the upper bound of $\Card G'$? We knew it because we've already known free group consists of all words generated by set elements. Indeed this is almost always the case: if you've known enough about the functor so that you can find a solution set to apply GAFT, almost always you could have constructed the adjoint explicitly.}\\
    (b) Consider the category $\mathbf{CLat}$ of complete lattices, i.e. posets with all meets and joins. Again, $U:\mathbf{CLat} \to \mathbf{Set}$ creates all small limits. But A.W.Hales (1964) showed that, for any cardinal $\kappa$, there exist complete lattices of cardinality $\geq \kappa$ generated by three elements; so the SSC fails at $A=\{x,y,z\}$. Hence $U$ doesn't have a left adjoint.
\end{eg}

---Lecture 13---

\begin{defi} (4.14)\\
    By a \emph{subobject} of an object $A$ of $\mathcal{C}$, we mean a monomorphism $A' \rightarrowtail A$. The subobjects of $A$ are preordered by $A'' \leq A'$, if there exists a factorization
    \begin{tikzcd}
        A'' \arrow[rr] \arrow[rd,tail] & & A' \arrow[ld, tail]\\
        & A &
    \end{tikzcd}
    i.e. a factorization of $A''$ through $A'$.\\
    We say $\mathcal{C}$ is \emph{well-powered} if each $A \in \ob\mathcal{C}$ has a set of subobjects $\{A_i \rightarrowtail A | i \in I\}$ s.t. every subobject of $A$ is isomorphic to some $A_i$ (e.g. in $\mathbf{Set}$ we can take the inclusions $\{A' \hookrightarrow A| A'\in PA\})$.\\
    If $\mathcal{C}^{op}$ is well-powered, we say $\mathcal{C}$ is \emph{well-copowered}\footnote{Some people use \emph{cowell-powered}, but lecturer thought that meant \emph{not well-powered} so decided not to use that.}.
\end{defi}

\begin{lemma} (4.15)\\
    Suppose given a pullback square
    \begin{tikzcd}
        P \arrow[r,"h"] \arrow[d,"k"] & A \arrow[d,tail,"f"]\\
        B \arrow[r,"g"] & C
    \end{tikzcd}
    with $f$ monic. Then $k$ is monic.
    \begin{proof}
        Suppose $D \stackrel[y]{x}{\rightrightarrows} P$ satisfy $kx=ky$. Then $fhx=gkx=gky=fhy$. But $f$ is monic, so $hx=hy$. So $x$ and $y$ are factorizations of the same cone through the limit cone $(h,k)$.
    \end{proof}
\end{lemma}

\begin{thm} (4.16, Special AFT)\\
    Suppose $\mathcal{C}$ and $\mathcal{D}$ are both locally small, and that $\mathcal{D}$ is complete and well-powered and has a coseparating set (see (2.8)). Then a functor $G:\mathcal{D} \to \mathcal{C}$ has a left adjoint iff it preserves all small limits.
    \begin{proof}
        $\implies$: by (4.9).\\
        $\Leftarrow$: For any $A \in \ob\mathcal{C}$, $(A \downarrow G)$ is complete by (4.10), locally small, and well-powered, since the subobjects of $(B,f)$ in $(A\downarrow G)$ are just those subobjects $B' \rightarrowtail B$ in $\mathcal{D}$ for which $f$ factors through $GB' \rightarrowtail GB$.\\
        Also, if $\{S_i | i \in I\}$ is a coseparating set for $\mathcal{D}$, then the set $\{(S_i, f)|i \in Im f \in \mathcal{C}(A,GS_i)\}$ is coseparating in $(A \downarrow G)$: given $(B,f) \stackrel[h]{g}{\rightrightarrows} (B',f')$ in $(A \downarrow G)$ with $g \neq h$, there exists some morphism $k:B' \to S_i$ for some $i$ with $kg \neq kh$, and then $k$ is also a morphism $(B',f') \to (S_i,(Gk)f')$ in $(A \downarrow G)$.\\
        So we need to show that if $\mathcal{A}$ is complete, locally small and well-powered and has a coseparating set $\{S_i|i \in I\}$, then $\mathcal{A}$ has an initial object: form the product $P=\prod_{i \in I} S_i$. Now consider the diagram

        \begin{tikzcd}
            & & & & P_i \arrow[ddd, tail]\\
            & & P_j \arrow[ddrr, tail] \arrow[lldd, bend right = 15, dotted, no head] & &\\
            & & & &\\
            P' \arrow[rrrr,tail] & & & & P
        \end{tikzcd}

        whose edges are a representative set of subobjects of $P$, and form its limit

        \begin{tikzcd}
            I \arrow[rrr] \arrow[rrd] \arrow[ddd] & & & P_i\\
            & & P_j \arrow[lldd, dotted, no head, bend left = 15] &\\
            & & &\\
            P' & & &
        \end{tikzcd}

        By the argument of (4.15), the legs of this cone are all monic; in particular, $I \rightarrowtail P$ is monic, and it's a least subobject of $P$. Hence $I$ has no proper subobjects.\\
        So, given $I \stackrel[g]{f}{\rightrightarrows} A$, their equalizer is an isomorphism, hence $f=g$.\\
        Now let $A$ be any object of $\mathcal{A}$; form the product
        $$Q = \prod_{i \in I, f \in \mathcal{A}(A,S_i)} S_i$$
        There's an \emph{obvious} $h:A \to Q$ defined by $\pi_{i,f} h = f$; and $h$ is monic, since the $S_i$ are a coseparating set.\\
        We alsk have a morphism $k:P \to Q$ defined by $\pi_{i,f} k = \pi_i$.\\
        Now form the pullback
        \begin{tikzcd}
            B \arrow[r] \arrow[d,tail] & A \arrow[d,tail,"h"]\\
            P \arrow[r,"k"] & Q
        \end{tikzcd}
        ; by (4.15), $P$ is monic, so $B$ is a subobject of $P$. Hence there exists
        \begin{tikzcd}
            I \arrow[rr] \arrow[rd] & & B \arrow[ld]\\
            & P &
        \end{tikzcd}
        hence a morphism $I \to B \to A$.\footnote{This proof was first mentioned in a book where the author left as an exercise to the readers}
    \end{proof}
\end{thm}

\begin{eg} (4.17)\\
    Consider the inclusion $\mathbf{KHaus} \xrightarrow{I} \mathbf{Top}$, where $\mathbf{KHaus}$ is the full subcategory of compact Hausdorff spaces (see (3.11 b)). $\mathbf{KHaus}$ has, and $I$ preserves all small products (by Tychonoff's theorem), and equalizers (since equalizers of pairs $X\stackrel[g]{f}{\rightrightarrows} Y$ with $Y$ Hausdorff are closed subspaces).\\
    Both categories are locally small and $\mathbf{KHaus}$ is well-powered (subobjects of $X$ are all isomorphic to closed subspaces). The closed intervals $[0,1]$ is a coseparator in $\mathbf{KHaus}$, by Uryson's Lemma which is well-known in Topology (ok). So we have everything in (4.16), so this functor $I$ has a left adjoint $\beta$ (known as \href{https://en.wikipedia.org/wiki/Stone%E2%80%93%C4%8Cech_compactification}{\emph{Stone-\u{C}ech compactification}}).
\end{eg}

\begin{rem} (4.18)\\
    (a) We've proved the existence in above, but it might also be interesting to see how $\beta$ actually might look like.\\
    \u{C}ech's construction of $\beta$: given $X$, form $Q = \prod_{f:X \to [0,1]} [0,1]$ and define $h:X \to P$ by $\pi_f h = f$. Define $\beta X$ to be the closure of the image of $h$.\\
    \u{C}ech's proof that this works is essentially the same as (4.16).\\
    (b) We could have used GAFT to construct $\beta$ as well: we get a solution set at $X$ by considering all continuous $X \xrightarrow{f} Y$ with $Y$ compact Hausdorff, and $\im f$ dense in $Y$ and such $Y$ have cardinality at most $2^{2^{\Card X}}$.
\end{rem}

\newpage

\section{Monads}

---Lecture 14---

Suppose we are given $\mathcal{C} \stackrel[G]{F}{\rightleftarrows} \mathcal{D}$ with $(F \dashv G)$. How much of this structure can we describe without even mentioning $\mathcal{D}$?\\
Obviously we can't just use $F$ or $G$ as both of them needs $\mathcal{D}$. However we have the functor $T=GF:\mathcal{C} \to \mathcal{C}$, the unit $\eta: 1_{\mathcal{C}} \to T = GF$, and the natural transformation $\mu=G\varepsilon F: TT=GFGF \to GF = T$ (whiskering).\\
These satisfy the commutative diagrams

\begin{tikzcd}
    T \arrow[r, "T\eta"] \arrow[rd, "1_T"] & TT \arrow[d, "\mu"] & T \arrow[l,"\eta T"] \arrow[ld,"1_T"]\\
    & T &
\end{tikzcd}

by the triangular identities (we'll use (1) and (2) to denote the left and right half of this diagram), and

\begin{tikzcd}
    TTT \arrow[r,"T\mu"] \arrow[d,"\mu T"] & TT \arrow[d,"\mu"]\\
    TT \arrow[r,"\mu"] & T
\end{tikzcd}

by naturality of $\varepsilon$ (we'll use (3) to denote this diagram).

\begin{defi} (5.1)\\
    A \emph{monad}\footnote{Historically this was called \emph{the standard construction} or \emph{triples}, but later people found that it needed a name. This name is probably because it sounds like \emph{monoid}?} $\mathbb{T} = (T,\eta,\mu)$ on a category $\mathcal{C}$ consists of a functor $T:\mathcal{C} \to \mathcal{C}$ and natural transformations $\eta:1_{\mathcal{C}} \to T, \mu:TT \to T$ satisfying (1)-(3).\\
    $\eta$ and $\mu$ are called the \emph{unit} and \emph{multiplication} of $\mathbb{T}$.
\end{defi}

\begin{eg} (5.2)\\
    (a) Any adjunction $(F \dashv G)$ induces a monad $(GF,\eta,G\varepsilon F)$ on $\mathcal{C}$ and a comonad $(FG,\varepsilon, F\eta G)$ on $\mathcal{D}$.\\
    (b) Let $M$ be a monoid. The functor $(M \times -): \mathbf{Set} \to \mathbf{Set}$ has a monad structure with unit given by $\eta_A(a) = (1_M,a)$, and multiplication $\mu_A(m,m',a) = (mm',a)$.\\
    The monad identities follow from the mononid ones.\\
    (c) Let $\mathcal{C}$ be any category with finite products, $A \in \ob\mathcal{C}$. The functor $(A \times -):\mathcal{C} \to \mathcal{C}$ has a comonad structure with counit $\varepsilon_B: A \times B \to B$ given by $\pi_2$, and comultiplication $\delta_B:A \times B \to A \times A \times B$ given by $(\pi_1,\pi_1,\pi_2)$.
\end{eg}

Does every monad arise from an adjunction? In 5.2(b) we have the category $[M,\mathbf{Set}]$. Its forgetful functor to $\mathbf{Set}$ has a left adjoint, sending $A$ to $M \times A$ with $M$ acting by multiplication on the left factor. This adjunction gives rise to the monad of 5.2(b).

\begin{defi} (5.3, Eilenberg-Moore)\\
    Let $\mathbb{T}$ be a monad on $\mathcal{C}$. A \emph{$\mathbb{T}$-algebra} is a pair $(A,\alpha)$ with $A \in \ob\mathcal{C}$ and $TA \xrightarrow{\alpha} A$, satisfying the commutative diagrams

    \begin{tikzcd}
        A \arrow[r,"\eta_A"] \arrow[rd,"1_A"] & TA \arrow[d,"\alpha"]\\
        & A
    \end{tikzcd}
    and
    \begin{tikzcd}
        TTA \arrow[r,"T\alpha"] \arrow[d,"\mu_A"] & TA \arrow[d,"\alpha"]\\
        TA \arrow[r,"\alpha"] & A
    \end{tikzcd}

    We shall call these diagrams (4) and (5) respectively.\\
    A \emph{homomorphism} $f:(A,\alpha) \to (B,\beta)$ is a morphism $A \xrightarrow{f} B$ s.t.
    \begin{tikzcd}
        TA \arrow[r,"Tf"] \arrow[d,"\alpha"] & TB \arrow[d,"\beta"]\\
        A \arrow[r,"f"] & B
    \end{tikzcd}
    commutes (label this diagram (6)).\\
    The category of $\mathbb{T}$-algebras (on $\mathcal{C}$) is denoted $\mathcal{C}^{\mathbb{T}}$.
\end{defi}

\begin{lemma} (5.4)\\
    The forgetful functor $G^{\mathbb{T}}: \mathcal{C}^\mathbb{T} \to \mathcal{C}$ has a left adjoint $F^\mathbb{T}$, and the adjunction induces $\mathbb{T}$.
    \begin{proof}
        We need to find something like a \emph{free} functor. We define $F^\mathbb{T} A = (TA,\mu_A)$ (on algebra by (2) and (3)), and $F^\mathbb{T}(A\xrightarrow{f} B) = Tf$ (a homomorphism by naturality of $\mu$).\\
        Clearly $G^\mathbb{T} F^\mathbb{T} = T$; the unit of the adjunction is $\eta$.\\
        We define the counit $\varepsilon_{(A,\alpha)}= \alpha:(TA,\mu_A) \to (A,\alpha)$ (a homomorphism by (5)); $\varepsilon$ is natural by (6). For the triangular identities, $\varepsilon_{FA}(F\eta_A) = 1_{FA}$ is (1), $G\varepsilon_{(A,\alpha)} \eta_A = 1_A$ is (4), so we have all of the diagrams.\\
        The monad induced by $(F^\mathbb{T} \dashv G^\mathbb{T})$ has functor $T$ and unit $\eta$, and $G^\mathbb{T} \varepsilon_{F^\mathbb{T} A} = \mu_A$ by definition of $F^\mathbb{T} A$.
    \end{proof}

    Kleisli took a \emph{minimalist} approach: if $\mathcal{C} \stackrel[G]{F}{\rightleftarrows} \mathcal{D}$ induces $\mathbb{T}$, then so does $\mathcal{C} \stackrel[G|_{\mathcal{D}'}]{F}{\rightleftarrows} \mathcal{D}'$ where $\mathcal{D}'$ is the full subcategory of $\mathcal{D}$ on objects $FA$.\\
    So in trying to construct $\mathcal{D}$, we may assume $F$ is surjective (or indeed bijective) on objects. But then morphisms $FA \to FB$ correspond bijectively to morphsims $A \to GFB = TB$ in $\mathcal{C}$.
\end{lemma}

\begin{defi} (5.5)\\
    Given an algebra monad $\mathbb{T}$ on $\mathcal{C}$, the \emph{Kleisli category} $\mathcal{C}_\mathbb{T}$ has $\ob\mathcal{C}_\mathbb{T} = \ob\mathcal{C}$ (and because of this, we'll use green for morphisms in $\mathcal{C}_\mathbb{T}$. It might be useful to bring pens of different colours in the next few lectures), and morphisms
    \begin{tikzcd}
        A \arrow[r,green] & B
    \end{tikzcd}
    are morphisms $A \to TB$ in $\mathcal{C}$. The composite
    \begin{tikzcd}
        A \arrow[r,green,"f"] & B \arrow[r,green,"g"] & C
    \end{tikzcd}
    is $A \xrightarrow{f} TB \xrightarrow{Tg} TTC \xrightarrow{\mu_C} TC$, and the identity
    \begin{tikzcd}
        A \arrow[r,green] & A
    \end{tikzcd}
    is $A \xrightarrow{\eta_A} TA$.\\
    To verify associativity, suppose given
    \begin{tikzcd}
        A \arrow[r,green,"f"] & B \arrow[r,green,"g"] & C \arrow[r,green,"h"] & D
    \end{tikzcd}. Then

    \begin{tikzcd}
        A \arrow[r,"f"] & TB \arrow[r,"Tg"] & TTC \arrow[r,"TTh"] \arrow[d,"\mu_C"] & TTTD \arrow[r,"T \mu_D"] \arrow[d,"\mu_{TD}"] & TTD \arrow[d,"\mu_D"]\\
        & &TC \arrow[r,"Th"] & TTD \arrow[r,"\mu_D"] & TD
    \end{tikzcd}

    commutes: the upper way round is \textcolor{green}{$(hg)f$}, the lower is \textcolor{green}{$h(gf)$} (the rightmost square is diagram (3)).

    The unit laws similar follow from, using diagram (1) and (2) in the two triangles respectively,

    \begin{tikzcd}
        A \arrow[r,"f"] & TB \arrow[r,"T \eta_B"] \arrow[rd,"1_{\mathbb{T}B}"] & TTB \arrow[d,"\mu_B"]\\
        & & TB
    \end{tikzcd}
    and
    \begin{tikzcd}
        A \arrow[r,"f"] \arrow[d,"\eta_A"] & TB \arrow[d,"\eta_{TB}"] \arrow[rd,"1_{TB}"] &\\
        TA \arrow[r,"Tf"] & TTB \arrow[r,"\mu_B"] & TB
    \end{tikzcd}
\end{defi}

---Lecture 15---

\begin{lemma} (5.6)\\
    There exists an adjunction $\mathcal{C} \stackrel[G_\mathbb{T}]{F_\mathbb{T}}{\rightleftarrows} \mathcal{C}_T$ inducing the monad $\mathbb{T}$.
    \begin{proof}
        We define $F_\mathbb{T} A = A$, $F_\mathbb{T}(A \xrightarrow{f}B) = A\xrightarrow{f} B \xrightarrow{\eta_B} TB$.\\
        $F_\mathbb{T}$ preserves identities by definition; for composites, consider $A \xrightarrow{f} B \xrightarrow{g} C$, we get, using diagram (1) at bottomright,

        \begin{tikzcd}
            A \arrow[r,"f"] & B \arrow[d,"g"] \arrow[r,"\eta_B"] & TB \arrow[d,"Tg"] & \\
            & C \arrow[r,"\eta_C"] & TC \arrow[r,"T\eta_C"] \arrow[rd,"1_{TC}"] & TTC \arrow[d,"\mu_C"]\\
            & & & TC
        \end{tikzcd}

        We define $G_\mathbb{T} A = TA$,
        \begin{tikzcd}
            G_\mathbb{T}(A \arrow[r,green,"f"] & B)
        \end{tikzcd}
        $=TA\xrightarrow{Tf} TTB \xrightarrow{\mu_B} TB$.\\
        $G_\mathbb{T}$ preserves identities by (1); for composites, consider
        \begin{tikzcd}
            A \arrow[r,green,"f"] & B \arrow[r,green,"g"] & C
        \end{tikzcd}
        We get, using the naturality square (3),

        \begin{tikzcd}
            TA \arrow[r,"Tf"] & TTB \arrow[d,"\mu_B"] \arrow[r,"TTg"] & TTTC \arrow[r,"T\mu_C"] \arrow[d,"\mu_{TC}"] & TTC \arrow[d,"\mu_C"]\\
            & TB \arrow[r,"Tg"] & TTC \arrow[r,"\mu_C"] & TC
        \end{tikzcd}

        Now we verify that $G_\mathbb{T} F_\mathbb{T} A = TA$, $G_\mathbb{T} F_\mathbb{T} f = \mu_B (T\eta_B) Tf = Tf$.\\
        So we take $\eta:1_{\mathcal{C}} \to T$ as the unit of $(F_\mathbb{T} \dashv G_\mathbb{T})$;\\
        The counit
        \begin{tikzcd}
            TA \arrow[r,green,"\varepsilon_A"] & A
        \end{tikzcd}
        is $1_{TA}$.\\
        To verify naturality, we have to verify the commutative diagram

        \begin{tikzcd}
            TA \arrow[r,green,"F_\mathbb{T}G_\mathbb{T}f"] \arrow[d,green,"\varepsilon_A"] & TB \arrow[d,green,"\varepsilon_B"]\\
            A \arrow[r,green,"f"] & B
        \end{tikzcd}

        This expands to, by triangle (2),

        \begin{tikzcd}
            TA \arrow[r,"Tf"] & TTB \arrow[r,"\mu_B"] & TB \arrow[r,"\eta_{TB}"] \arrow[rd,"1_{TB}"] & TTB \arrow[d,"\mu_B"]\\
            & & & TB
        \end{tikzcd}

        So $\varepsilon$ is natural.\\
        Finally we need to verify triangular equalities:
        \begin{tikzcd}
            G_\mathbb{T}(T_A \arrow[r,green,"\varepsilon_A"] & A)
        \end{tikzcd}
        $=\mu_A$, so $G_\mathbb{T}($\textcolor{green}{$\varepsilon_A$}$)\eta_{G_\mathbb{T}A} = \mu_A \cdot \eta_{TA} = 1_{TA}$;\\
        And \textcolor{green}{$(\varepsilon_{F_\mathbb{T}A})(F_\mathbb{T} \eta_A)$} is

        \begin{tikzcd}
            A \arrow[r,"\eta_A"] & TA \arrow[r,"\eta_{TA}"] \arrow[rd,"1_{TA}"] & TTA \arrow[d,"\mu_A"]\\
            & & TA
        \end{tikzcd}

        which is \textcolor{green}{$1_{F_\mathbb{T} A}$}.\\
        Also, $G_\mathbb{T}($\textcolor{green}{$\varepsilon_{F_\mathbb{T} A}$})$=\mu_A$, so $(F_\mathbb{T} \dashv G_\mathbb{T})$ induces $\mathbb{T}$.
    \end{proof}
\end{lemma}

Note that although this is quite a lengthy proof, there's only one way we can go, i.e. verify everything we need.

\begin{thm} (5.7)\\
    Given a monad $\mathbb{T}$ on $\mathcal{C}$, let $\mathbf{Adj}(\mathbb{T})$ be the category whose objects are the adjunctions $(\mathcal{C}\stackrel[G]{F}{\rightleftarrows} \mathcal{D})$ inducing $\mathbb{T}$, and whose morphisms $(\mathcal{C} \stackrel[G]{F}{\rightleftarrows} \mathcal{D}) \to (\mathcal{C} \stackrel[G']{F'}{\rightleftarrows} \mathcal{D}')$ are functors $H:\mathcal{D} \to \mathcal{D}'$, satisfying $HF = F'$ and $G'H = G$ (note that we might have expected just natural isomorphisms here, but we do need equalities for things to work). Then the Kleisli adjunction is an initial object of $\mathbf{Adj}(\mathbb{T})$, and the Eilenberg-Moore adjunction is terminal.\\
    (Question from student: how non-trivial are these adjunction categories?\\
    A: I know they have an initial and a terminal object!)\\
    \begin{proof}
        Let $(\mathcal{C} \stackrel[G]{F}{\rightleftarrows} \mathcal{D})$ be an object of $\mathbf{Adj}(\mathbb{T})$. We define $K:\mathcal{D} \to \mathcal{C}^\mathbb{T}$ (the \emph{E-M comparison functor}) by $KB = (GB,G\varepsilon_B)$ where $\varepsilon$ is the counit of the adjunction $(F \dashv G)$ we started from; note this is an algebra by one of the triangular identities for $(F\dashv G)$ and naturality of $\varepsilon$. And $K(B\xrightarrow{g}B') = Gg$ (a homomorphism by naturalitty of $\varepsilon'$). Because $G$ is functorial, this is functorial as well.\\
        Clearly, $G^\mathbb{T} K = G$, and $KFA = (GFA,G\varepsilon_{FA}) = (TA,\mu_A)=F^\mathbb{T} A$. Also $KF(A\xrightarrow{f}A') = Tf = F^\mathbb{T} f$.\\
        So $K$ is a morphism of $\mathbf{Adj}(\mathbb{T})$.\\
        Suppose $K':\mathcal{D} \to \mathcal{C}^\mathbb{T}$ is another such; then since $G^\mathbb{T} K' = G$, we know $K'B = (GB,\beta_B)$ where $\beta$ is a natural transformation $GFG \to G$.\\
        Also, since $K'F = F^\mathbb{T}$, we have $\beta_{FA} = \mu_A = G\varepsilon_{FA}$.\\
        Now, given any $B\in\ob\mathcal{D}$, consider the diagram

        \begin{tikzcd}
            GFGFGB \arrow[r,"GFG\varepsilon_B"] \arrow[d,shift right, "G\varepsilon_{FGB}"'] \arrow[d,shift left,"\beta_{FGB}"] & GFGB \arrow[d,shift right, "G\varepsilon_B"'] \arrow[d,shift left,"\beta_B"]\\
            GFGB \arrow[r,"G\varepsilon_B"] & GB
        \end{tikzcd}

        Both squares commute (note that $G\varepsilon_{FGB} = \beta_{FGB}$), so $G\varepsilon_B$ and $\beta_B$ have the same composite with $GFG\varepsilon_B$. But this is split epic, with splitting $GF\eta_{GB}$; so $\beta = G\varepsilon$. Hence $K' = K$.

        We now define the Kleisli comparison functor $L:\mathcal{C}_\mathbb{T} \to \mathcal{D}$ by $LA = FA$,
        \begin{tikzcd}
            L(A \arrow[r,green,"f"] & B)
        \end{tikzcd}
        $=FA\xrightarrow{Ff} FGFB \xrightarrow{\varepsilon_{FB}} FB$.\\
        $L$ preserves identities by one of the triangular equalities for $(F\dashv G)$; given
        \begin{tikzcd}
            A \arrow[r,green,"f"] & B \arrow[r,green,"g"] & C
        \end{tikzcd}
        , we have

        \begin{tikzcd}
            FA \arrow[r,"Ff"] & FGFB \arrow[r,"FGFg"] \arrow[d,"\varepsilon_{FB}"] & FGFGFC \arrow[r,"FG\varepsilon_{FC}"] \arrow[d,"\varepsilon_{FGFC}"] & FGFC \arrow[d,"\varepsilon_{FC}"]\\
            & FB \arrow[r,"Fg"] & FGFC \arrow[r,"\varepsilon_{FC}"] & FC
        \end{tikzcd}

        Some more verifications: $GLA=TA=G_\mathbb{T}A$,
        \begin{tikzcd}
            GL(A \arrow[r,green,"f"] & B)
        \end{tikzcd}
        $= (G\varepsilon_{FB}) (GFf) = \mu_B(Tf) = G_\mathbb{T}f$.\\
        $LF_\mathbb{T} A = FA, LF_\mathbb{T}(A\xrightarrow{f}B) = (\varepsilon_{FB})(F\eta_B) (Ff) = Ff$.\\
        Note that (lecturer murmured \emph{for future reference}?) $L$ is full and faithful; its effect on morphisms (with given $\dom$ and $\cod$) is that of transposition across $(F\dashv G)$.\\
        Suppose $L':\mathcal{C}_\mathbb{T} \to \mathcal{D}$ is a morphsim of $\mathbf{Adj}(\mathbb{T})$. We must have $L'A =FA$, and $L'$ maps the counit
        \begin{tikzcd}
            TA \arrow[r,green] & A
        \end{tikzcd}
        to the counit $FGFA \xrightarrow{\varepsilon_{FA}} FA$.\\
        For any
        \begin{tikzcd}
            A \arrow[r,green,"f"] & B
        \end{tikzcd}
        , we have \textcolor{green}{$f=1_{TA}(F_\mathbb{T}f)$}, so $L'($\textcolor{green}{$f$}$) = \varepsilon_{FA} (Ff) = Lf$.
    \end{proof}
\end{thm}

---Lecture 16---

If $\mathcal{C}$ has coproducts, then so does $\mathcal{C}_\mathbb{T}$, since $F_\mathbb{T}$ preserves them.\\
In general, however, it has few other limits or colimits. In contrast, we have

\begin{thm} (5.8)\\
    (i) The forgetful functor $G:\mathcal{C}^\T \to \mathcal{C}$ creates all limits which exist in $\mathcal{C}$.\\
    (ii) If $\mathcal{C}$ has colimits of shape $\mathcal{J}$, then $G:\mathcal{C}^\T \to \mathcal{C}$ creates them iff $T$ preserves them.
    \begin{proof}
        Suppose given $D:\mathcal{J} \to \mathcal{C}^\T$; write $D(j) = (GD(j),\delta_j)$, and suppose we have a limit cone $(L,(\mu_j:L \to GD(j) | j \in \ob\mathcal{J}))$ is a limit cone for $GD$.\\
        Then the composites $TL \xrightarrow{T \mu_j} TGD(j) \xrightarrow{\delta_j} GD(j)$ form a cone over $GD$, since the edges of $GD$ are homomorphisms, so they induce a unique $\lambda:TL \to L$ s.t. $\mu_j \lambda = \delta_j(T\mu)$ for all $j$.\\
        The fact that $\lambda$ is a $\T$-algebra structure on $L$ follows from the fact that the $\delta_j$ are algebra structures and uniqueness of factorizations through limits.\\
        So $((L,\lambda)(\mu_j|j \in \ob\mathcal{J}))$ is the unique lifting of the limit cone over $GD$ to a cone over $D$; and it's a limit, since given a cone over $D$ with apex $(A,\alpha)$, we get a unique factorization $A \xrightarrow{f} L$ in $\mathcal{C}$, and $F$ is an algebra homomorphism by uniqueness of factorizations through $L$.\\
        (ii) $\implies$: $F:\mathcal{C} \to \mathcal{C}^\T$ preserves colimits since it's a left adjoint, so $T=GF$ preserves colimits of shape $\mathcal{J}$.\\
        $\Leftarrow$: Suppose given $\mathcal{J} \to \mathcal{C}^\T$ as in (i), and a colimit cone $(GD(j) \xrightarrow{\mu_j} L| j \in \ob\mathcal{J})$ in $\mathcal{C}$.\\
        Then $(TGD(j) \xrightarrow{T\mu_j} TL | j \in \ob\mathcal{J})$ is also a colimit cone, so the composites $TGD(j) \xrightarrow{f_j} GD(j) \xrightarrow{\mu_j} L$ induce a unique $\lambda:TL \to L$.\\
        The rest of the argument is similar to that of (i) (verifying unique factorizations).
    \end{proof}
\end{thm}

\begin{defi} (5.9)\\
    Given an adjunction $(\mathcal{C} \stackrel[G]{F}{\rightleftarrows} \mathcal{D})$, $(F \dashv G)$, we say the adjunction (or the functor $G$) is \emph{monadic} if the comparison functor $K:\mathcal{D} \to \mathcal{C}^\T$ is part of an equivalence of categories.\footnote{In some textbooks the author require $K$ to be an isomorphism here; but that is because they required stronger definition of creating limits.}\\
    (Note that, since the Kleiski comparison $\mathcal{C}_\T \to\mathcal{D}$ is always full and faithful, it's part of an equivalence iff it (equivalently, $F$) is essentially surjective on objects).
\end{defi}

\begin{rem}
    Given any adjunction $(F \dashv G)$, for each object $B$ of $\mathcal{D}$ we have a diagram
    \begin{tikzcd}
        FGFGB \arrow[r,shift left, "FG\varepsilon_B"] \arrow[r, shift right, "\varepsilon_{FGB}"'] & FGB \arrow[r,"\varepsilon_B"] & B
    \end{tikzcd}
    with equal composites. The \emph{primeval monadicity theorem} asserts that $\mathcal{C}^\T$ is characterized in $\mathbf{Adj}(\T)$ by the fact that these diagrams are all coequalizers.
\end{rem}

\begin{defi} (5.10)\\
    We say a parallel pair $A \stackrel[g]{f}{\rightrightarrows} B$ is \emph{reflexive} if there exists $B \xrightarrow{r} A$ s.t. $fr = gr = 1_B$.\\
    (Note that in our previous remark,
    \begin{tikzcd}
        FGFGB \arrow[r,shift left, "FG\varepsilon_B"] \arrow[r,shift right, "\varepsilon_{FGB}"'] & FGB
    \end{tikzcd}
    is reflexive, with $r = F\eta_{GB}$ by triangular identities).\\
    We say $\mathcal{C}$ has reflexive coequalizers if it has coequalizers of all reflexive pairs (equivalently, colimits of shape $\mathcal{J}$ where
    \begin{tikzcd}
        \cdot \arrow[loop, out=105, in=165,looseness = 4] \arrow[loop, out=255, in=195, looseness=4] \arrow[r,shift left] \arrow[r,shift right] & \cdot \arrow[l]
    \end{tikzcd}
    ).\\
    (b) By a \emph{split coequalizer diagram}, we mean a diagram
    \begin{tikzcd}
        A \arrow[r,shift left, "f"] \arrow[r,shift right, "g"'] & B \arrow[r,"h"] \arrow[l,bend left=40,"t"] & C \arrow[l,bend left = 20,"s"]
    \end{tikzcd}
    satisfying $hf=hg,hs=1_C,gt=1_B$ and $ft = sh$.\\
    These equations imply that $h$ is a coequalizer of $(f,g)$: if $B \xrightarrow{x} D$ satisfies $xf = xg$, then $x=xgt=xft=xsh$, so $x$ factors through $h$, and the factorization is unique since $h$ is split epic.\\
    Note that split coequalizers are preserved by \emph{all} functors.\\
    (c) Given a functor $G:\mathcal{D} \to \mathcal{C}$, a parallel pair $A \stackrel[g]{f}{\rightrightarrows} B$ is called \emph{$G$-split} if there exsts a split coequalizer diagram
    \begin{tikzcd}
        GA \arrow[r,shift left,"Gf"] \arrow[r,shift right,"Gg"'] & GB \arrow[r,"h"] \arrow[l, bend left=40, "t"] & C \arrow[l, bend left=20, "s"]
    \end{tikzcd}
    in $\mathcal{C}$.\\
    Note that
    \begin{tikzcd}
        FGFGB \arrow[r,shift left, "FG\varepsilon_B"] \arrow[r,shift right, "\varepsilon_{FGB}"'] & FGB
    \end{tikzcd}
    is $G$-split, since
    \begin{tikzcd}
        GFGFGB \arrow[r,shift left, "GFG\varepsilon_B"] \arrow[r,shift right,"G\varepsilon_{FGB}"'] & GFGB \arrow[l,bend left=35, "\eta_{GFGB}"] \arrow[r,"G\varepsilon_B"] & GB \arrow[l,bend left=20, "\eta_{GB}"]
    \end{tikzcd}
    is a split coequalizer.
\end{defi}

\begin{lemma} (5.11)\\
    Suppose we are given an adjunction $\mathcal{C} \stackrel[G]{F}{\rightleftarrows} \mathcal{D}$, inducing a monad $\T$ on $\mathcal{C}$, then $K:\mathcal{D} \to \mathcal{C}^\T$ has a left adjoint provided, for every $\T$-algebra $(A,\alpha)$, the pair
    \begin{tikzcd}
        FGFA \arrow[r,shift right, "\varepsilon_{FA}"'] \arrow[r,shift left, "F\alpha"] & FA
    \end{tikzcd}
    has a coqeualizer in $\mathcal{D}$.
    \begin{proof}
        We define $L:\mathcal{C}^\T \to \mathcal{D}$ by taking $FA \to L(A,\alpha)$ to be a coequalizer for $(F\alpha,\varepsilon_{FA})$. Note that this is a functor $\mathcal{C}^\T \to \mathcal{D}$.\\
        Recall that $K$ is defined by $KB=(GB,G\varepsilon_B)$.\\
        For any $B$, morphisms $FA \xrightarrow{f} B$ satisfying $f(F\alpha) = f(\varepsilon_{FA})$.\\
        These correspond to morphisms $A \xrightarrow{\check{f}} GB$ satisfying
        $$\check{f}\alpha = Gf = G(\varepsilon_B (F\check{f})) = (G\varepsilon_B) (T\check{f})$$
        i.e. to algebra homomorphisms $(A,\alpha) \to KB$.\\
        It's tedious but entirely straightforward to verify that these bijections are natural in $(A,\alpha)$ and in $B$.
    \end{proof}
\end{lemma}

---Lecture 17---

\begin{thm} (5.12, Precise Monadicity Theorem)\\
    $G:\mathcal{D} \to \mathcal{C}$ is monadic iff $G$ has a left adjoint and creates coequalizers of $G$-split pairs.
\end{thm}

\begin{thm} (5.13, Refined/Reflexive Monadicity Theorem)\\
    Suppose $\mathcal{D}$ has and $G:\mathcal{D} \to \mathcal{C}$ preserves reflexive coequalizers, and that $G$ reflects isomorphisms and has a left adjoint. Then $G$ is monadic.
    \begin{proof}
        (5.12) $\implies$: It's sufficient to show that $G^\mathbb{T}:\mathcal{C}^\mathbb{T} \to \mathcal{C}$ creates coequalizers of $G^\mathbb{T}$-split pairs. But this follows from the argument of 5.8(ii), since if $(A,\alpha) \stackrel[g]{f}{\rightrightarrows} (B,\beta)$ is a $G^\T$-split pair, the coequalizer of $A \stackrel[g]{f}{\rightrightarrows} B$ is preserved by $T$ and by $TT$.\\
        (5.12) $\Leftarrow$ and (5.13): Let $\T$ denotes the monad induced by $(F \dashv G)$. For any $\T$-algebra $(A,\alpha)$, the pair
        \begin{tikzcd}
            FGFA \arrow[r,shift right, "\varepsilon_{FA}"'] \arrow[r,shift left, "F\alpha"] & FA
        \end{tikzcd}
        is both reflexive and $G$-split, so has coequalizer in $\mathcal{D}$; and hence by (5.11), $K:\mathcal{D} \to \mathcal{C}^\T$ has a left adjoint $L$.\\
        The unit of $(L \dashv K)$ at an algebra $(A,\alpha)$: the coequalizer defining $L(A,\alpha)$ is mapped by $K$ to the diagram

        \begin{tikzcd}
            F^\T TA \arrow[r,shift left, "F^\T \alpha"] \arrow[r,shift right, "\mu_A"'] & F^\T A \arrow[rr] \arrow[rd,"\alpha"'] & & KL(A,\alpha) \\
            & & (A,\alpha) \arrow[ru,dashed,"{\iota_{(A,\alpha)}}"] &
        \end{tikzcd}

        and $\iota_{(A,\alpha)}$ is the factorization of this through the ($G^\T$-split) coequalizer of $\alpha$.\\
        But either set of hypotheses implies that $G$ preserves the coequalizers defining $L(A,\alpha)$, so $\iota_{(A,\alpha)}$ is an isomorphism.\\
        For the counit $\xi_B: LKB \to B$, we have a coequalizer

        \begin{tikzcd}
            FGFGB \arrow[r,shift left, "FG\varepsilon_B"] \arrow[r,shift right, "\varepsilon_{FGB}"'] & FGB \arrow[r,two heads] \arrow[rd,"\varepsilon_B"'] & LKB \arrow[d,dashed, "\xi_B"]\\
            & & B
        \end{tikzcd}

        Again, either set of hypothesis implies that $\varepsilon_B$ is a coequalizer of the pair $(FG\varepsilon_B, \varepsilon_{FGB})$, so $\xi_B$ is an isomorphism.
    \end{proof}
\end{thm}

\begin{eg} (5.14)\\
    (a) The forgetful functor $\mathbf{Gp} \to \mathbf{Set}$, $\mathbf{Rng} \to \mathbf{Set}$, $\mathbf{Mod}_R \to \mathbf{Set}, ...$ all satisfy the hypotheses of (5.13), for the reflexive coequalizers, use Sheet 4 Question 3\footnote{Lecturer: I usually prove it as a lemma here, but this year I'm not going to do it because I want you to do it in the fourth example sheet. It's a nice exercise to do it by yourself.} which shows that if $A \stackrel[g]{f}{\rightrightarrows} B \xrightarrow{h} C$ is a reflexive coequalizer diagram in $\mathbf{Set}$, then so is
    \begin{tikzcd}
        A^n \arrow[r,shift left, "f^n"] \arrow[r,shift right, "g^n"'] & B \arrow[r,"h^n"] & C^n
    \end{tikzcd}
    .\\
    (b) Any reflection is monadic: this follows from Sheet 3 Question 2, but can also be proved using (5.12). Let $\mathcal{D}$ be a reflective (so full) subcategory of $\mathcal{C}$, and suppose a pair $A \stackrel[g]{f}{\rightrightarrows} B$ in $\mathcal{D}$ fits into a split coequalizer diagram
    \begin{tikzcd}
        A \arrow[r,shift left, "f"] \arrow[r,shift right, "g"'] & B \arrow[r,green, "h"] \arrow[l,green, bend left=40,"t"] & \textcolor{green}{C} \arrow[l,green, bend left=40, "s"]
    \end{tikzcd}
    in $\mathcal{C}$. Then $t$ and $ft=sh$ belong to $\mathcal{D}$, since $\mathcal{D}$ is full, and hence $s$ is in $\mathcal{D}$ since it's an equalizer of $(1_B,sh)$ and $\mathcal{D}$ is closed under limits in $\mathcal{C}$. Hence also $h \in \mor\mathcal{D}$.\\
    (c) This is a non-example but an important one: Consider the composite adjunction

    \begin{tikzcd}
        \mathbf{Set} \arrow[r, shift left, "F"] & \mathbf{AbGp} \arrow[l, shift left, "U"] \arrow[r, shift left, "L"] & \mathbf{tfAbGp} \arrow[l,shift left, "I"]
    \end{tikzcd}

    The two factors are monadic by (a) and (b) respectively, but the composite isn't since the monad it induces on $\mathbf{Set}$ is isomorphic to that induced by $(F \dashv U)$. So monadic adjunctions are not stable under composition -- that's why we have to have the conditions in (5.13) -- note that those adjunction are stable under compositions (I think lecturer said so but didn't write it down).\\
    (d) Consider the forgetful functor $\mathbf{Top} \xrightarrow{U} \mathbf{Set}$. This is faithful and has both left and right adjoints (so preserves all coequalizers), but the monad induced on $\mathbf{Set}$ is $(1,1,1)$, and the category of algebras is $\mathbf{Set}$. So we see that we can't weaken the condition in (5.13) of $G$ reflecting isomorphisms to only be faithful.\\
    (e) Consider the composite function

    \begin{tikzcd}
        \mathbf{Set} \arrow[r,shift left, "D"] & \mathbf{Top} \arrow[l,shift left, "U"] \arrow[r,shift left,"\beta"] & \mathbf{KHaus} \arrow[l, shift left, "I"]
    \end{tikzcd}

    We'll show that this satisfies the hypotheses of (5.12) (with use of a lemma in general topology which lecturer is not going to prove): Let
    \begin{tikzcd}
        X \arrow[r,shift left, "f"] \arrow[r, shift right, "g"'] & Y \arrow[l, green, bend left=40, "t"] \arrow[r,green, "h"] & \textcolor{green}{Z} \arrow[l,green,bend left=40, "s"]
    \end{tikzcd}
    be a split coequalizer in $\mathbf{Set}$, where $X$ and $Y$ have compact Hausdorff topologies and $f,g$ are continuonus. Note that the quotient topology on $Z \cong Y/R$ is compact, so it's the only possible candidate for a compact Hausdorff topology making $h$ continuous.\\
    We use the lemma from general topology: if $Y$ is compact Hausdorff, then a quotient $Y/R$ is Hausdorff iff $R \subseteq Y \times Y$ is closed.\\
    We note $R = \{(y,y') | h(y) = h(y') \} = \{(y,y') | sh(y) = sh(y')\} = \{(y,y') | ft(y) = ft(y')\}$.\\
    So if we define $S = \{(x,x')|f(x) = f(x')\} \subseteq X \times X$, then $R \subseteq (g \times g) (S)$; but the reverse inclusion also holds. But
    \begin{tikzcd}
        S \arrow[r] & X \times X \arrow[r,shift left, "f\pi_1"] \arrow[r,shift right, "f\pi_2"'] & Y
    \end{tikzcd}
    is an equalizer, and $Y$ is Hausdorff, so $S$ is closed in $X \times X$ and hence compact. So $R=(g \times g)(S)$ is compact and hence closed in $Y \times Y$.
\end{eg}

---Lecture 18---

\begin{defi} (5.15)\\
    Let $\mathcal{C} \stackrel[G]{F}{\rightleftarrows} \mathcal{D}$ be an adjunction, and suppose $\mathcal{D}$ has reflexive coequalizers. The \emph{monadic tower} of $(F \dashv G)$ is the diagram

    \begin{tikzcd}
        \mathcal{D} \arrow[rrrd,shift left,"K'"] \arrow[rrddd,shift left,"K"] \arrow[rddddd,shift left,"G"] & & ...\\
        & & & (\mathcal{C}^\T)^\mathbb{S} \arrow[lllu,shift left,"L'"] \arrow[ldd,shift left]\\
        & & & \\
        & & \mathcal{C}^\T \arrow[uuull,shift left,"L"] \arrow[uur,shift left] \arrow[ldd,shift left] &\\
        & & & &\\
        & \mathcal{C} \arrow[uuuuul,shift left,"F"] \arrow[uur,shift left] & &
    \end{tikzcd}

    where $\T$ is the monad induced by $(F \dashv G)$, $K$ is as in (5.7), $L$ as in (5.11), $\mathbb{S}$ is the monad induced by $(L \dashv K)$, and so on.\\
    We say $(F \dashv G)$ has \emph{monadic length} $n$ if we reach an equivalence after $n$ steps.\\
    For example, the adjunction of 5.14(c) has monadic length 2, the adjunction of 5.14(d) has monadic length $\infty$ (the tower never reaches an equivalence).
\end{defi}

Lecturer: Normally this is where I end chapter 5, but since this year we'll be doing topos I realized that we'll need an example in chapter 7 which is purely about monads and adjunctions, so we'd rather do it here.

\begin{thm} (5.16)\\
    Suppose given an adjunction $\mathcal{C} \stackrel[R]{L}{\rightleftarrows} \mathcal{D}$ and monads $\T,\mathbb{S}$ on $\mathcal{C},\mathcal{D}$ respectively, and a functor $\bar{R}:\mathcal{D}^\mathbb{S} \to \mathcal{C}^\T$ such that
    \begin{tikzcd}
        \mathcal{D}^\mathbb{S} \arrow[r,"R"] \arrow[d,"G^\mathbb{S}"] & \mathcal{C}^\T \arrow[d,"G^\T"]\\
        \mathcal{D} \arrow[r,"R"] & \mathcal{C}
    \end{tikzcd}
    commutes up to isomorphism.\\
    Suppose also $\mathcal{D}^\mathbb{S}$ has reflexive coequalizers. Then $\bar{R}$ has a left adjoint $\bar{L}$.\\
    (Note that there's also a version of this for right adjoint, but it is \emph{not} the dual of this.)
    \begin{proof}
        Note that if $\bar{L}$ exists, we must have $\bar{L} F^\T = F^\mathbb{S} L$, by (3.6). So we'd expect $\bar{L}(A,\alpha)$ to be a coequalizer of two morphisms
        \begin{tikzcd}
            F^\mathbb{S} LTA \arrow[r,shift left, "F^\mathbb{S} L\alpha"] \arrow[r,shift right, "?"'] & F^\mathbb{S} LA
        \end{tikzcd}
        .\\
        To contruct the second morphism, note first that we can assume, WLOG, that $G^\T \bar{R} = RG^\mathbb{S}$, by transporting $\T$-algebra structures along the isomorphism $G^\T \bar{R} (B,\beta) \to RB$.\\
        We obtain $\theta:TR \to RS$ by
        \begin{equation*}
            \begin{aligned}
                \frac{R \xrightarrow{R\iota} RS = RG^\mathbb{S} F^\mathbb{S} = G^\T \bar{R} F^\mathbb{S}}{\frac{F^\T R \to \bar{R} F^\mathbb{S}}{TR = G^\T F^\T R \xrightarrow{\theta} G^\T \bar{R} F^\mathbb{S} = RG^\mathbb{S} F^\mathbb{S} = RS}}
            \end{aligned}
        \end{equation*}
        Convert it to $\phi:LT \to SL$ by
        \begin{tikzcd}
            LT \arrow[r,"LT\gamma"] & LTRL \arrow[r,"L\theta_L"] & LRSL \arrow[r,"\delta_{SL}"] & SL
        \end{tikzcd}
        where $\gamma$ and $\delta$ are the unit and counit of $(L\dashv R)$.\\
        Transposing across $(F^\mathbb{S} \dashv G^\mathbb{S})$, we get $F^\mathbb{S} LT \xrightarrow{\bar{\phi}} F^\mathbb{S}L$.\\
        The pair $(F^\mathbb{S} L\alpha,\bar{\phi}_A)$ is reflexive, with common splitting $F^\mathbb{S} L\eta$.\\
        It can be verified that the coequalizer of this pair has the universal property we require for $I(A,\alpha)$. (Not saying this is examinable, but useful to know.)
    \end{proof}
\end{thm}

\newpage

\section{Cartesian Closed Categories}

\begin{defi} (6.1)\\
    Let $\mathcal{C}$ be a category with finite products. We say $A \in \ob\mathcal{C}$ is \emph{exponentiable} if the functor $(-) \times A: \mathcal{C} \to \mathcal{C}$ has a right adjoint $(-)^A$.\\
    If every object of $\mathcal{C}$ is exponentiable, then we say $\mathcal{C}$ is \emph{cartesian closed}.
\end{defi}

\begin{eg} (6.2)\\
    (a) We'll expect $\mathbf{Set}$ to be cartesian closed, and it is indeed, with $B^A = \mathbf{Set}(A,B)$. A function $f:C \times A \to B$ (sometimes called \emph{lambda conversion}) corresponds to $\bar{f}: C \to B^A$.\\
    (b) $\mathbf{Cat}$ is cartesian closed, with $\mathcal{D}^\mathcal{C} = [\mathcal{C},\mathcal{D}]$.\\
    (c) In $\mathbf{Top}$, if an exponential $Y^X$ exists, its points must be the continuous maps $X \to Y$.\\
    The \href{https://en.wikipedia.org/wiki/Compact-open_topology}{compact-open topology} on $\mathbf{Top}(X,Y)$ has the universal property of an exponential iff $X$ is locally compact.\\
    Note that finite products of exponentiable objects are exponentiable: since $(-) \times (A \times B) \cong (- \times A) \times B$, we have $(-)^{A \times B} \cong ((-)^B)^A$.\\
    However, even if $X$ and $Y$ are locally compact, $X^Y$ need not be (take both $X$ and $Y$ be the real line, and $\R^\R$ is too big to be locally compact). So the exponentiable objects don't form a cartesian closed full subcategory.\\
    (d) A cartesian closed poset, is called a \emph{Heiting semilattice}: it's a poset with finite meets and a binary operation $\implies$ satisfying $a \leq (b \implies c)$ iff $a \wedge b \leq c$.\\
    For example, a complete poset is a Heyting semillatice iff it satisfies the infinite distributive law
    $$a \wedge \bigvee \{b_i | i \in I\} = \bigvee \{a \wedge b_i | i \in I\}$$
    For any topological space $X$, the lattice $\mathcal{O}(X)$ of open subsets satisfies this condition, since $\wedge$ and $\bigvee$ coincide with $\cap$ and $\bigcup$.
\end{eg}

Recall that, if $B \in ob\mathcal{C}$, we define $\mathcal{C}/B$ to have objects which are morphisms $\begin{pmatrix}A\\\downarrow\\B\end{pmatrix}$ in $\mathcal{C}$, and morphisms are commutative triangles
\begin{tikzcd}
    A \arrow[rr] \arrow[rd] & & A' \arrow[ld]\\
    & B &
\end{tikzcd}
. The forgetful functor $\mathcal{C}/B \to \mathcal{C}$ will be denoted $\sum_B$.\\
If $\mathcal{C}$ has finite products, $\sum_B$ has a left adjoint $B^*$ which sends $A$ to $\begin{pmatrix}A \times B\\\downarrow \pi_2\\B\end{pmatrix}$, since morphisms
\begin{tikzcd}
    C \arrow[rr,"{(f,g)}"] \arrow[rd, "g"'] & & A \times B \arrow[ld,"\pi_2"]\\
    & B &
\end{tikzcd}
corresponds to morphisms $C = \sum_B g \xrightarrow{f} A$.

\begin{lemma} (6.3)\\
    If $\mathcal{C}$ has all finite limits, then an object $B$ is exponetniable iff $B^*:\mathcal{C} \to \mathcal{C}/B$ has a right adjoint $\prod_B$.
    \begin{proof}
        $\Leftarrow$: the composite $\sum_B B^*$ is equal to $(-) \times B$, so we take $(-)^B$ to be $\prod_B B^*$.\\
        $\implies$: Now we have an exponential and we want to build $\prod_B$. What we'll do is to use a pullback: for any $A \xrightarrow{f} B$, we define $\prod_B(f)$ to be the pullback

        \begin{tikzcd}
            \prod_B(f) \arrow[r] \arrow[d] & A^B \arrow[d,"f^B"]\\
            1 \arrow[r,"\bar{\pi_2}"] & B^B
        \end{tikzcd}

        The morphisms $C \to \prod_B(f)$ corresponds to morphisms $C \to A^B$ making
        \begin{tikzcd}
            C \arrow[r] \arrow[d] & A^B \arrow[d,"f^B"] \\
            1 \arrow[r,"\bar{\pi_2}"] & B^B
        \end{tikzcd}
        commute, i.e. to morphisms $C \times B \to A$ making
        \begin{tikzcd}
            C \times B \arrow[r] \arrow[rd,"\pi_2"'] & A \arrow[d,"f"]\\
            & B
        \end{tikzcd}
        commute.
    \end{proof}
\end{lemma}

---two lectures (19,20) to be typesetted---

--Lecture 19---

\begin{lemma} (6.4)\\
    Suppose $\mathcal{C}$ has all finite limits. If $A$ is exponentiable in $\mathcal{C}$, then $B^*A$ is exponentiable in $\mathcal{C}/B$ for any $B$.\\
    Moreover, $B^*$ preserves exponentials.
    \begin{proof}
        Given an object $\begin{pmatrix}C\\\downarrow f\\B\end{pmatrix}$, form the pullback
            \begin{tikzcd}
                P \arrow[r] \arrow[d,"f^{(b^*A)}"] & C^A \arrow[d,"f^A"]\\
                B \arrow[r,"\bar{\pi_1}"] & B^A
            \end{tikzcd}
            . Then for any
            \begin{tikzcd}
                D \arrow[d,"g"]\\
                B
            \end{tikzcd}
            , morphisms $g \to f^{B^*A}$ in $\mathcal{C}/B$ corresponds to morphisms $D \xrightarrow{\bar{h}} C^A$ making
            \begin{tikzcd}
                D \arrow[r,"\bar{h}"] \arrow[d,"g"] & C^A \arrow[d,"f^A"]\\
                B \arrow[r,"\bar{\pi}_1"] & B^A
            \end{tikzcd}
            commute, and hence to morphisms $D \times A \xrightarrow{h} C$ making
            \begin{tikzcd}
                D \times A \arrow[r,"h"] \arrow[rd,"g\pi_1"'] & C \arrow[d,"f"]\\
                & B
            \end{tikzcd}
            commute. But
            \begin{tikzcd}
                D \times A \arrow[r,"g \times 1_A"] \arrow[d,"\pi_1"] & B \times A \arrow[d,"\pi_1"]\\
                D \arrow[r,"g"] & B
            \end{tikzcd}
            is a pullback in $\mathcal{C}$, i.e. a product in $\mathcal{C}/B$.\\
            For the second assertion, note that if
            \begin{tikzcd}
                C \arrow[d,"f"]\\
                B
            \end{tikzcd}
            is of the form
            \begin{tikzcd}
                B \times E \arrow[d,"\pi_1"]\\
                B
            \end{tikzcd}
            , then the pullback defining $f^{B^*A}$ becomes
            \begin{tikzcd}
                B \times E^A \arrow[r,"\bar{\pi}_1 \times 1"] \arrow[d,"\pi_1"] & B^A \times E^A \arrow[d,"\pi_1"]\\
                B \arrow[r,"\bar{\pi}_1"] & B^A
            \end{tikzcd}
            , so $f^{B^*A} \cong B^*(E^A)$.
    \end{proof}
\end{lemma}

\begin{rem}
    $\mathcal{C}/B$ is isomorphic to the category of coalgebras for the monad structure on $(-) \times B$ (5.2(c)); so the first part of (6.4) could have been proved using (5.16).
\end{rem}

\begin{defi} (6.5)\\
    We say $\mathcal{C}$ is \emph{locally Cartesian closed} if it has all finite limits and each $\mathcal{C}/B$ is cartesian closed.\\
    Note that this includes the fact that $\mathcal{C}/1 \cong \mathcal{C}$ is cartesian closed, so being \emph{locally} Cartesian closed is actually stronger than being cartesian closed!
\end{defi}

\begin{eg} (6.6)\\
	(a) $\mathbf{Set}$ is locally cartesian closed, since $\mathbf{Set}/B \cong \mathbf{Set}^B$ for any $B$.\\
	(b) For any small category $\mathcal{C}$, $[\mathcal{C},\mathbf{Set}]$ is cartesian closed: by Yoneda, $G^F(A) \cong [\mathcal{C},\mathbf{Set}](\mathcal{C}(A,-),G^F) \cong  [\mathcal{C},\mathbf{Set}](\mathcal{C}(A,-) \times F,G)$.\\
	So we take RHS as a definition of $GF(A)$, and define $G^F$ on morphisms $A \xrightarrow{f} B$ by composition with $\mathcal{C}(f,-) \times 1_F$.\\
	Note that the class of functors $H$ for which we have $[\mathcal{C},\mathbf{Set}](H,G^F) \cong [\mathcal{C},\mathbf{Set}](H \times F,G)$ is closed under colimits; but every functor $\mathcal{C} \to \mathbf{Set}$ is a colimit of representables.\\
	In fact, $[\mathcal{C},\mathbf{Set}]$ is locally cartesian closed, since all its slice categories $[\mathcal{C},\mathbf{Set}]/F$ are of the same form (see q6 on sheet 4).\\
	(c) Any Heyting semilattice $H$ is locally cartesian closed, since $H/b\Z \downarrow (b)$, the poset of elements $\leq b$, and $b^* = (-) \wedge b$ is surjective.\\
	(d) (non-example) $\mathbf{Cat}$ is not locally cartesian closed, since not all strong epimorphisms are regular (sheet 3 q6).\\
\end{eg}

Note that, given
\begin{tikzcd}
A \arrow[d,"f"]\\
B
\end{tikzcd}
in $\mathcal{C}/B$, the iterated slice $(\mathcal{C}/B)/f$ is isomorphic to $\mathcal{C}/A$, and this identifies $f^*:\mathcal{C}/B \to (\mathcal{C}/B)/f$ with the operation of pulling back morphisms along $f$. So by (6.3), $\mathcal{C}$ is lcc iff it has finite limits and $f^*:\mathcal{C}/B \to \mathcal{C}/A$ has a right adjoint $\Pi_f$ for every $A \xrightarrow{f} B$ in $\mathcal{C}$.

\newpage

\section{Toposes}

---Lecture 21---

Some introduction by lecturer: Grothendick introduced toposes as categories of \emph{generalized sheaves}. J.Giraud gave a characterization of such categories by (set-theoretic) categorical properties.

F.W.Lawvere and M Tierney investigated the elementary categorical properties of these categories, and come up with the elementary definition.

In fact, a Grothendieck topos is exactly a Lawvere-Tierneg topos which is (co)complete and locally small, and has a separating set of objects.

\begin{defi} (7.1)\\
    (a) Let $\mathcal{E}$ be a category with finite limits. A \emph{subobject classifier} for $\mathcal{E}$ is a monomorphism $\Omega' \stackrel{\top}{\rightarrowtail} \Omega$ s.t., for every monomorphism $A' \stackrel{m}{\rightarrowtail} A$ in $\mathcal{E}$, there's a unique $\chi_m:A \to \Omega$ for which there is a pullback square

    \begin{tikzcd}
        A' \arrow[r] \arrow[d,tail,"m"] & \Omega' \arrow[d,"\top"] \\
        A \arrow[r,"\chi_m"] & \Omega
    \end{tikzcd}

    Note that, for any $A$, there's a unique $A\to \Omega$ which factors through $\Omega' \stackrel{\top}{\rightarrowtail} \Omega$, so the domain of $\top$ is actually a terminal object.\\
    If $\mathcal{E}$ is well-powered, we have a functor $Sub_\mathcal{E} (-):\mathcal{E}^{op} \to \mathbf{Set}$ sending $A$ to the set of (isomorphism classes of) subobjects of $A$, and acting on morphisms by pullback, and a subobject classifier is a representation of this functor.

    (b) A \emph{topos} is a category which has finite limits, is cartesian closed, and has a subobject classifier.

    (c) If $\mathcal{E}$ and $\mathcal{F}$ are toposes, a \emph{logical functor} $F:\mathcal{E} \to \mathcal{F}$ is one which preserves finite limits, exponentials and the subobject classifier.
\end{defi}

\begin{eg} (7.2)\\
    (a) $\mathbf{Set}$ is a topos, with $\Omega =\{0,1\}$ and $t=1:1 \to \{0,1\}$, and of course $\chi_m$ is just the characteristic function of $A'$.\\
    So also is the category of finite sets $\mathbf{Set}_F$, or the category of sets of cardinality less than $\kappa$, $\mathbf{Set}_\kappa$, where $\kappa$ is an infinite cardinal s.t. $\lambda < \kappa \implies 2^\lambda < \kappa$.

    (b) For any small category $\mathcal{C}$, $[\mathcal{C}^{op},\mathbf{Set}]$ is a topos: we've seen that it's cartesian closed, and $\Omega$ is determined by Yoneda: we have\\
    $\Omega(A) = \cong [\mathcal{C}^{op},\mathbf{Set}](\mathcal{C}(-,A),\Omega) \cong \{$subfunctors of $\mathcal{C}(-,A)\}$.\\
    So we define $\Omega(A)$ to be the set of \emph{sieves} on $A$, i.e. sets $R$ of morphisms with codomain $A$, s.t. $f \in R \implies fg \in R$ for any $g$.\\
    Given $B\xrightarrow{f} A$ and a sieve $R$ on $A$, we need a pullback: define $f^* R$ to be the set of $g$ with codomain $B$ s.t. $fg \in R$.\\
    This makes $\Omega$ into a functor $\mathcal{C}^{op} \to \mathbf{Set}$: $T:1 \to \Omega$ is defined by $T_A(*) = \{$all morphisms withcodomain $A\}$.\\
    Given a subfunctor $F' \stackrel{m}{\rightarrowtail} F$, we define $\chi_m:F \to \Omega$ by $(\chi_m)_A(x) = \{f:B \to A|Ff(x) \in F'(b)\}$ (lecturer: if you find this not obvious, then write it down and you'll find it obvious).\\
    This is the unique natural transformation making

    \begin{tikzcd}
        F' \arrow[r] \arrow[d,tail,"m"] & 1 \arrow[d,tail,"\top"]\\
        F \arrow[r] & \Omega
    \end{tikzcd}

    (c) For any space $X$, $\mathbf{Sh}(X)$ is a topos. It's cartesian closed by 6.12(ii); for the subobject classifier, we take $\Omega(U) = \{V \in \mathcal{O}(X) | V \subseteq U\}$. $\Omega(U' \to U)$ is the map $V \to V\cap U'$ and $\Omega$ is a sheaf since if we have $U=\cup_{i \in I} U_i$, and $V_i \subseteq U_i$ s.t. $V_i \cap U_j = V_j \cap U_i$ for each $i,j$, then $V = \cup_{i \in I} V_i$ is the unique open subset of $U$ with $V \cap U_i = V_i$ for each $i$.\\
    If $F' \stackrel{m}{\rightarrowtail} F$ is a subsheaf, then for any $x \in F(U)$, the sieve $\{V \subseteq U | x|_V \in F'(V)\}$ has a greatest element since $F'$ is a sheaf, so we define $\chi_m:F \to \Omega$ to send $x$ to this (the previous greatest) element.

    (d) Let $\mathcal{C}$ be a group $G$. The topos structure on $[G,\mathbf{Set}]$ is particularly simplel: $B^A$ is the set of all $G$-equivariant maps $A\times G \xrightarrow{f} B$, but such an $f$ is determined by its values at elements of the form $(a,1)$, since $f(a,g) = g \cdot f(g^{-1}\cdot a, 1)$, and this restriction can be any mapping $A \times \{1\} \to B$. So we can take $B^A$ to be the set of functions $A \to B$, with $G$ acting by $(g \cdot f) (a) = g(f(g^{-1} \cdot a))$. And $\Omega = \{0,1\}$ with trivial $G$-action.\\
    So the forgetful functor $[G,\mathbf{Set}] \to \mathbf{Set}$ is logical, as is the functor which equips a set $A$ with trivial $G$-action.\\
    Moreover, even if $G$ is infinite, $[G,\mathbf{Set}_f]$ is a topos, and the inclusion $[G,\mathbf{Set}_f] \to [G,\mathbf{Set}]$ is logical. Similarly, if $\mathcal{G}$ is a large (contrast to small?) group, then $[\mathcal{G},\mathbf{Set}]$ is a topos.

    (e) Let $\mathcal{C}$ be a category such that every slice $\mathcal{C}/A$ is equivalent to a finite category. Then $[\mathcal{C}^{op},\mathbf{Set}_f]$ is a topos just by checking definitions. Similarly, if $\mathcal{C}$ is large, but all $\mathcal{C}/A$ are small, then $[\mathcal{C}^{op},\mathbf{Set}]$ is a topos, then $[\mathcal{C}^{op},\mathbf{Set}]$ is a topos. In particular, $[\mathbf{On}^{op},\mathbf{Set}]$ is a topos which is not locally small.
\end{eg}

---Lecture 22---

\begin{lemma} (7.3)\\
    Suppose $\mathcal{E}$ has finite limits and a subobject classifier. Then every monomorphism in $\mathcal{E}$ is regular. In particular, $\mathcal{E}$ is balanced.
    \begin{proof}
        The universal monomorphism $1 \stackrel{\top}{\rightarrowtail} \Omega$ is split and hence regular (ES1 Q5). But any pullback of a regular monomorphism is regular: if $f$ is an equalizer of $(g,h)$ then $K^*(f)$ is an equalizer of $(gk,hk)$. The second assertion follows since regular epic monomorphism is an isomorphism.
    \end{proof}
\end{lemma}

Given an object $A$ in a topos $\mathcal{E}$, we write $PA$ for the exponential $\Omega^A$, and $\ni_A \rightarrowtail PA \times A$ for the subobject corresponding to $PA \times A \xrightarrow{ev} \Omega$. This has the property that, for any $B$ and any $R \stackrel{m}{\rightarrowtail} B \times A$, there's a unique ${}^{\lceil}m^\rceil): B \to PA$ s.t.

\begin{tikzcd}
    R \arrow[r] \arrow[d,tail,"m"] & \ni_A \arrow[d,tail]\\
    B \times A \arrow[r,"{}^{\lceil}m^\rceil) \times 1_A"] & PA \times A
\end{tikzcd}

is a pullback.

\begin{defi} (7.4)\\
    By a \emph{power-object} for $A$ in a category $\mathcal{E}$ with finite limits, we mean an object $PA$ equipped with $\ni_A \rightarrowtail PA \times A$ satisfying the above.\\
    We say $\mathcal{E}$ is a \emph{weak topos} if every $A \in \ob\mathcal{E}$ has a power-object. Similarly, we say $F:\mathcal{E} \to \mathcal{F}$ is \emph{weakly logical} if $F(\ni_A) \rightarrowtail F(PA) \times FA$ is a power-object for $FA$, for every $A \in \ob\mathcal{E}$.
\end{defi}

\begin{lemma} (7.5)\\
    $P$ is a functor $\mathcal{E}^{op} \to \mathcal{E}$. Moreover, it is self-adjoint on the right.
    \begin{proof}
        Given $A \xrightarrow{f} B$, we define $PB \xrightarrow{PF} PA$ to correspond to the pullback

        \begin{tikzcd}
            E_f \arrow[r] \arrow[d,tail] & \ni_B \arrow[d,tail]\\
            PB \times A \arrow[r,"1\times f"] & PB \times B
        \end{tikzcd}

        For any morphism $C \xrightarrow{{}^{\lceil}m^\rceil)} PB$, it's easy to see that $(Pf){}^{\lceil}m^\rceil)$ correspond to $(1_C \times f)^*(m)$; hence $f \to Pf$ is functorial. For any $A$ and $B$, we have a bijection between subobjects of $A \times B$ and of $B \times A$, given by composition with $(\pi_2,\pi_1): A \times B \to B \times A$; this yields a (natural) bijection between morphisms $A \to PB$ and $B \to PA$.
    \end{proof}
\end{lemma}

We write $\{\}_A$ (pronounced as \emph{singleton}) $:A \to PA$ for the morphism correponding to $A \stackrel{(1_A,1_A)}{\rightarrowtail} A \times A$.

\begin{lemma} (7.6)\\
    Given $A \xrightarrow{f} B$, $\{\}_B f$ corresponds to $A \stackrel{(1_A,f)}{\rightarrowtail} A \times B$ and $(Pf) \{\}_B$ corresponds to $A \stackrel{(f,1_A)}{\rightarrowtail} B \times A$.
    \begin{proof}
        The square

        \begin{tikzcd}
            A \arrow[r,"f"] \arrow[d,tail,"{(1,f)}"] & B \arrow[d,tail,"{(1,1)}"] \\
            A \times B \arrow[r,"f \times 1"] & B \times B
        \end{tikzcd}

        is a pullback. Similarly for the second assertion.
    \end{proof}
\end{lemma}

\begin{coro} (7.7)\\
    (i) $\{\} : A \to PA$ is monic.\\
    (ii) $P$ is faithful.
    \begin{proof}
        (i) If $\{\} f = \{\} g$, then $(1_A,f)$ and $(1_A,g)$ are isomorphic as subobjects of $A \times B$, which forces $f=g$.\\
        (ii) Similarly, if $Pf = Pg$, then $(Pf)\{\} = (Pg)\{\}$, so we again deduce $f=g$.
    \end{proof}
\end{coro}

Given monomorphism $A \stackrel{f}{\rightarrowtail} B$ in $\mathcal{E}$, we define $\exists f:PA \to PB$ to correspond to the composite $\ni_A \rightarrowtail PA \times A \stackrel{1\times f}{\rightarrowtail} PA \times B$. Then, for any $C \xrightarrow{{}^{\lceil}m^\rceil)} PA$, $(\exists f) {}^{\lceil}m^\rceil)$ corresponds to $R \stackrel{m}{\rightarrowtail} C \times A \rightarrowtail{1 \times f} C \times B$.\\
So $f \to \exists f$ is a functor $Mono(\mathcal{E}) \to \mathcal{E}$.

\begin{lemma} (7.8, Beck-Chevalley condition)\\
    Suppose

    \begin{tikzcd}
        D \arrow[r,"h"] \arrow[d,tail,"k"] & A \arrow[d,tail,"f"]\\
        B \arrow[r,"g"] & C
    \end{tikzcd}

    is a pullback with $f$ monic. Then the diagram

    \begin{tikzcd}
        PA \arrow[r,"\exists f"] \arrow[d,"Ph"] & PC \arrow[d,"Pg"]\\
        PD \arrow[r,"\exists k"] & PB
    \end{tikzcd}

    commutes.
    \begin{proof}
        Consider the diagram

        \begin{tikzcd}
            E_h \arrow[r] \arrow[d,tail] & \ni_A \arrow[d,tail]\\
            PA \times D \arrow[r,"1 \times h"] \arrow[d,"1 \times k"] & PA \times A \arrow[d,"1 \times f"]\\
            PA \times B \arrow[r,"1 \times g"] & PA \times C
        \end{tikzcd}

        The lower square is a pullback, so the upper square is a pullback iff the composite is a pullback.
    \end{proof}
\end{lemma}

\begin{thm} (7.9, Par\'e)\\
    The functor $P:\mathcal{E}^{op} \to \mathcal{E}$ is monadic.
    \begin{proof}
        It has a left adjoint $P :\mathcal{E} \to \mathcal{E}^{op}$ by (7.5). It's faithful by 7.7(ii), and hence reflects isomorphsms by (7.3). $\mathcal{E}^{op}$ has coequalizers, since $\mathcal{E}$ has equalizers. Suppose now that $A \stackrel[\stackrel{\to}{g}]{\xrightarrow{f}}{\stackrel{r}{\leftarrow}} B$ is a coreflexive pair in $\mathcal{E}$; then $f$ and $g$ are (split) monic, and the equalizer $E \xrightarrow{e} A$ makes

        \begin{tikzcd}
            E \arrow[r,"e"] \arrow[d,"e"] & A \arrow[d,"g"]\\
            A \arrow[r,"f"] & B
        \end{tikzcd}

        a pullback square, since any cone over
        \begin{tikzcd}
            & A \arrow[d,"g"]\\
            A \arrow[r,"f"] & B
        \end{tikzcd}
        has both legs equal.\\
        So by (7.8) we have $(Pf)(\exists g) =(\exists e)(Pe)$; but we also have $(Pg)(\exists g) = 1_{PA}$ since

        \begin{tikzcd}
            A \arrow[r,"1"] \arrow[d,"1"] & A \arrow[d,"g"]\\
            A \arrow[r,"g"] & B
        \end{tikzcd}

        is a pullback, and similarly $(Pe)(\exists e) = 1_{PE}$. So

        \begin{tikzcd}
            PB \arrow[r,shift left, "Pf"] \arrow[r,shift right,"Pg"'] & PA \arrow[r,"Pe"] \arrow[l, bend left = 40, "\exists g"] & PE \arrow[l,bend left=20,"\exists e"]
        \end{tikzcd}

        is a split coequalizer, and in particular a coequalizer. Hence by (5.13) $P$ is monadic.
    \end{proof}
\end{thm}

\begin{coro} (7.10)\\
    (i) A weak topos has finite colimits. Moreover, if it has any infinite limits, then it has the corresponding colimits.\\
    (ii) If a weakly logical functor has a left adjoint, then it has a right adjoint.
    \begin{proof}
        (i) $P$ creates all limits which exist, by (5.8).\\
        (ii) By definition, if $F$ is weakly logical, then

        \begin{tikzcd}
            \mathcal{E}^{op} \arrow[r,"F"] \arrow[d,"P"] & \mathcal{F}^{op} \arrow[d,"P"]\\
            \mathcal{E} \arrow[r,"F"] & \mathcal{F}
        \end{tikzcd}

        commutes up to isomorphism. So this follows from (5.16).
    \end{proof}
\end{coro}

---Lecture 23---

\begin{lemma} (7.11)\\
    Let $\mathcal{E}$ be a category with finite limits, and suppose $A \in \ob\mathcal{E}$ has a power-object $PA$. Then, for any $B$, $B^*(PA)$ is a power-object for $B^*A$ in $\mathcal{E}/B$.
    \begin{proof}
        Given
        \begin{tikzcd}
            C \arrow[d,"g"]\\
            B
        \end{tikzcd}
        , we have a pullback square

        \begin{tikzcd}
            C \times A \arrow[r,"g \times 1"] \arrow[d,"\pi_1"] & B \times A \arrow[d,"\pi_1"]\\
            C \arrow[r,"g"] & B
        \end{tikzcd}

        So $\sum_B(g \times B^* A) \cong C \times A$.\\
        Hence $Sub_{\mathcal{E}/B}(g \times B^* A) \cong Sub_{\mathcal{E}}(C \times A)$, but if $C \xrightarrow{h} PA$ corresponds to
        \begin{tikzcd}
            R \arrow[d,tail]\\
            C \times A
        \end{tikzcd}
        , then

        \begin{tikzcd}
            R \arrow[d,tail] \arrow[rr] & & B \times \ni_A \arrow[d,tail]\\
            C \times A \arrow[rr,"{(g,h) \times 1_A}"] \arrow[rd,"g\pi_1"'] & & B \times PA \times A \arrow[ld,"\pi_1"]\\
            & B &
        \end{tikzcd}

        is a pullback. So
        \begin{tikzcd}
            B \times PA \arrow[d,"\pi_1"]\\
            B
        \end{tikzcd}
        equipped with $B^*(\ni_A) \rightarrowtail B^*(PA\times A)$ is a power object for $B^* A$.
    \end{proof}
\end{lemma}

\begin{thm} (7.12)\\
    Suppose $\mathcal{E}$ is a weak topos. Then for any $B \in \ob\mathcal{E}$, $\mathcal{E}/B$ is a weak topos and $B^*:\mathcal{E} \to \mathcal{E}/B$ is weakly logical.
    \begin{proof}
        The second assertion follows from (7.11). For the first, we need to construct a power-object for an arbitrary
        \begin{tikzcd}
            A \arrow[d,"f"]\\
            B
        \end{tikzcd}
        in $\mathcal{E}/B$. Then the pullback

        \begin{tikzcd}
            \sum_B(g \times f) \arrow[r] \arrow[d] & A \arrow[d,"f"]\\
            C \arrow[r,"g"] & B
        \end{tikzcd}

        is a subobject of $C \times A$, namely the equalizer of $C \times A \stackrel[g\pi_1]{f\pi_2}{\rightrightarrows} B$.\\
        DEfine $\wedge: PA \times PA \to PA$ to correspond to the intersection of $\pi_{13}^* (\ni_A \rightarrowtail PA \times A)$ and $\pi_{23}^*(\ni_A \rightarrowtail PA \times A)$, and define $P_1A \rightarrowtail PA \times PA$ to be the equalizer of $PA \times PA \stackrel[\pi_1]{\wedge}{\rightrightarrows} PA$.\\
        Then, for any $C$, $C \xrightarrow{({}^{\lceil}m^\rceil),{}^{\lceil}n^\rceil))} PA \times PA$ factors through $P_1 A$ iff $m \leq n$ in $Sub_{\mathcal{E}}(C \times A)$.\\
        Now form the pullback

        \begin{tikzcd}
            Q \arrow[rr] \arrow[d,tail,"({h,k)}"] & & P_1 A \arrow[d,tail]\\
            PA \times B \arrow[r,"1 \times \{\}"] & PA \times PB \arrow[r,"1 \times Pf"] & PA \times PA
        \end{tikzcd}

        Given any
        \begin{tikzcd}
            C \arrow[d,"g"]\\
            B
        \end{tikzcd}
        , the morphisms $g \xrightarrow{l} k$ in $\mathcal{E}/B$ correspond to morphisms $C \xrightarrow{hl} PA$ s.t. the subobject named by $hl$ is contained in that named by $(Pf)(\{\}) g$. But the latter is indeed $\sum_B(g \times f) \rightarrowtail C \times A$.\\
        So $k$ is a power-object for $f$ in $\mathcal{E}/B$.
    \end{proof}
\end{thm}

\begin{coro} (7.13)\\
    A weak topos is locally cartesian closed (in particular, it's a topos).
    \begin{proof}
        For any $f:A \times B$ in $\mathcal{E}$, we can identify $(\mathcal{E}/B) / f$ with $\mathcal{E}/A$, and $f^*:\mathcal{E}/B \to \mathcal{E}/A$ with pullback along $f$. Hence all such functors are weakly logical.\\
        But $f^*$ has a left adjoint $\sum_f$, so by 7.10(ii) it has a right adjoint $\pi_f$. Hence by (6.3) $\mathcal{E}/B$ is cartesian closed for any $B$.
    \end{proof}
\end{coro}

\begin{rem}
    It can be shown that a weakly logical functor is cartesian closed (and hence logical).
\end{rem}

\begin{coro} (7.14)\\
    (i) Any epimorphism in a topos is regular.\\
    (ii) Any $A \xrightarrow{f} B$ in a topos factors uniquely up to isomorphism as
    \begin{tikzcd}
        A \arrow[r,two heads,"q"] & I \arrow[r,tail,"m"] & B
    \end{tikzcd}
    \begin{proof}
        $\mathcal{E}$ is locally cartesian closed by (7.13) and has coequalizers by 7.10(i), so by (6.7), every $f$ factors uniquely as regular epimorphism + monomorphism. If $f$ itself is epic, then the monic part of this factorization is so by (7.3), so $f$ is regular epic.
    \end{proof}
\end{coro}

---end of examinable course material---

Recall that $\mathbf{Sh}(x) \subseteq [\mathcal{O}(X)^{op},\mathbf{Set}]$ is a full subcategory closed under limits (pretty easy to verify); in fact it's reflective, and moreover, the reflector $L:[\mathcal{O}(X)^{op},\mathbf{Set}] \to \mathbf{Sh}(X)$ preserves finite limits.\\
This suggests considering reflective subcategories $\mathcal{D} \subseteq \mathcal{E}$ for which the reflector preserves finite limits (equivalently, pullbacks).

\begin{lemma} (7.15)\\
    Given such a reflective subcategory and a monomorphism $A'\rightarrowtail A$ in $\mathcal{E}$, define $c(A') \rightarrowtail A$ by the pullback diagram

    \begin{tikzcd}
        c(A') \arrow[r] \arrow[d,tail] & LA' \arrow[d,tail]\\
        A \arrow[r,"\eta_A"] & LA
    \end{tikzcd}

    Then $A' \rightarrow c(A')$ is a closure operation on $Sub_\mathcal{E}(A)$, and commutes with pullback along a fixed morphism of $\mathcal{E}$.
    \begin{proof}
        Since

        \begin{tikzcd}
            A' \arrow[r,"\eta_{A'}"] \arrow[d,tail] & LA' \arrow[d,tail]\\
            A \arrow[r,"\eta_A"] & LA
        \end{tikzcd}

        commutes, we have $A' \leq c(A')$, and $A' \leq A''$ in $Sub(A)$ implies $LA' \leq LA''$ in $Sub(LA)$, and hence $c(A') \leq c(A'')$.\\
        Since $L\eta$ is an isomorphism,

        \begin{tikzcd}
            LA' \arrow[r,"L\eta_{A'}"] \arrow[d,tail] & LLA' \arrow[d,tail]\\
            LA \arrow[r,"L\eta_A"] & LLA
        \end{tikzcd}

        is a pullback, and since $L$ preserves pullbacks, we deduce $Lc(A') \cong LA'$ is $Sub(LA)$.\\
        Hence $c(c(A')) \cong c(A')$.\\
        For stability under pullback, suppose

        \begin{tikzcd}
            A' \arrow[r] \arrow[d,tail] & B' \arrow[d,tail]\\
            A \arrow[r,"f"] & B
        \end{tikzcd}

        is a pullback. Then in the cube (!!??)

        \begin{tikzcd}
            c(A') \arrow[rr] \arrow[dd] \arrow[rd] & & LA'\arrow[dd] \arrow[rd]\\
            & c(B') \arrow[rr, crossing over] \arrow[dd, crossing over] & & LB' \arrow[dd]\\
            A \arrow[rr,"\eta_A"] \arrow[rd,"f"'] & & LA \arrow[rd,"Lf"]\\
            & B \arrow[rr,"\eta_B"] & & LB
        \end{tikzcd}

        the front, back and right faces are pullbacks; whence the left face is too.
    \end{proof}
\end{lemma}

\begin{defi} (7.16)\\
    Let $\mathcal{E}$ be a topos. By a local operator on $\mathcal{E}$, we mean a morphism $j:\Omega \to \Omega$ satisfying the commutative diagrams

    \begin{tikzcd}
        1 \arrow[r,"T"] \arrow[rd,"T"'] & \Omega \arrow[d,"j"] & \Omega \arrow[l,"j"'] \arrow[ld,"j"]\\
        & \Omega &
    \end{tikzcd}
    and
    \begin{tikzcd}
        \Omega_1 \arrow[r] \arrow[d,tail] & \Omega_1 \arrow[d,tail]\\
        \Omega \times \Omega \arrow[r,"j \times j"] & \Omega \times \Omega
    \end{tikzcd}

    where $\Omega_1$ is the order-relation on $\Omega$, defined as in (7.12).
\end{defi}

Given a closure opeartor on subobjects as in (7.15), define $J \rightarrowtail \Omega$ to be the closure of $1 \stackrel{T}{\rightarrowtail} \Omega$, and $j:\Omega \to \Omega$ to be the classifying map of $J \rightarrowtail \Omega$.\\
Then, for any $A' \rightarrowtail A$ with classifying map $\chi_m: A \to \Omega$, the composite $j\chi_m$ classifies $c(A') \rightarrowtail A$.

---Lecture 24---

Given a pullback-stable closure operator $c$ on subobjects, we say $A' \rightarrowtail A$ is \emph{dense} if $c(A') \rightarrowtail A$ is an isomorphism, and \emph{closed} if $A' \rightarrowtail c(A')$ is an isomorphism.

\begin{lemma} (7.17)\\
    Suppose given a commutative square

    \begin{tikzcd}
        B' \arrow[r,"f'"] \arrow[d,tail,"n"] & A' \arrow[d,tail,"m"]\\
        B \arrow[r,"f"] & A
    \end{tikzcd}

    with $n$ dense and $m$ closed. Then there's a unique $B \xrightarrow{g} A'$ with $mg = f$ (and $gn = f'$).
    \begin{proof}
        We have $n \leq f^*(m)$ in $Sub(B)$, so $1_B \cong c(n) \leq f^*(c(m)) \cong f^*(m)$. So we define $g$ as $B \stackrel{\cong}{\rightarrow} f^*(A') \to A'$.
    \end{proof}
\end{lemma}

Note that $c(A')$ may be characterized as the unique (up to isomorphism) subobject $A''$ s.t. $A' \rightarrowtail A''$ is dense and $A'' \rightarrowtail A$ is closed.

\begin{lemma} (7.18)\\
    Suppose $c$ is induced as in (7.15) by a reflector $L:\mathcal{E} \to \mathcal{D}$ preserving finite limits. Then an object $A$ of $\mathcal{E}$ belongs to $\mathcal{D}$ (up to isomorphism) iff, given any diagram

    \begin{tikzcd}
        B' \arrow[r,"f'"] \arrow[d,tail,"m"] & A\\
        B &
    \end{tikzcd}

    with $m$ dense, there exists a unique $B \xrightarrow{f} A$ with $fm = f'$.
    \begin{proof}
        Note first that $m$ is dense $\iff$ $Lm$ is an isomorphism. $\Leftarrow$ follows from the definition; $\Rightarrow$ follows since by the proof of (7.15), we know $L(B')$ and $L(c(B'))$ are isomorphic in $Sub(B)$.\\
        Given this, if $A$ is in $\mathcal{D}$, then the given diagram extends uniquely to

        \begin{tikzcd}
            B' \arrow[r,"\eta_{B'}"] \arrow[d,tail] & LB' \arrow[r] \arrow[d,"\cong"] & A\\
            B \arrow[r,"\eta_B"] & LB \arrow[ur] &
        \end{tikzcd}

        Conversely, suppose $A$ satisfies the condition. Let $R \stackrel[b]{a}{\rightrightarrows} A$ be the kernel-pair of $A \xrightarrow{\eta_A} LA$, and $d:\rightarrowtail R$ the factorization of $(1_A,1_A)$ through $(a,b)$. Since $L\eta_A$ is an isomorphism and $L$ preserves pullbacks, $Ld$ is an isomorphism, so $d$ is dense.\\
        This forces $a=b$, so $\eta_A$ is monic. And $\eta_A$ is dense, so we get a unique $r:LA \to A$ with $r \eta_A = 1_A$. Now $\eta_A r \eta_A = \eta_A$, and since $LA$ satisfies the condition we have $\eta_A r = 1_{LA}$.
    \end{proof}
\end{lemma}

We say $A$ is a \emph{sheaf} (for $c$, or for $j$) if it satisfies the condition in (7.18). Given a local operator $j$ on $\mathcal{E}$, we write $sh_j(\mathcal{E})$ for the full subcategory of $j$-sheaves in $\mathcal{E}$.

\begin{lemma} (7.19)\\
    $sh_j(\mathcal{E})$ is closed under limits in $\mathcal{E}$, and an exponential ideal.
    \begin{proof}
        The first assertion follows since the definition involves only morphisms with codomain $A$.\\
        For the second, note that if $B' \stackrel{m}{\rightarrowtail} B$ is dense, then so is $B'\times C \stackrel{m \times 1}{\rightarrowtail} B \times C$ for any $C$ (since it's $\pi_1^*(m)$), and so if $A$ is a sheaf then any morphism $B' \to A^C$ extends uniquely to a morphism $B \to A^C$.
    \end{proof}
\end{lemma}

\begin{lemma} (7.20)\\
    If $A$ is a sheaf, then a subobject $A' \stackrel{m}{\rightarrowtail} A$ in $\mathcal{E}$ is a sheaf iff it's closed.
    \begin{proof}
        $\Leftarrow$ is immediate from (7.17).\\
        $\Rightarrow$: Consider $A \stackrel{p}{\rightarrowtail} c(A') \stackrel{q}{\rightarrowtail} A$. $p$ is dense, so if $A$ is a sheaf we get unique $r:c(A') \to A'$ with $rp = 1_{A'}$. But $c(A')$ is a sheaf, so $prp = p$. We deduce $pr = 1_{c(A')}$ since $p$ is a monomorphism.
    \end{proof}
\end{lemma}

We define $\Omega_j \rightarrowtail \Omega$ to be the equalizer of $\Omega \stackrel[1_\Omega]{j} \Omega$. Then, for any $A$, morphsims $A \to \Omega_j$ corresponds to closed subobjects of $A$.

\begin{lemma} (7.21)\\
    $\Omega_j$ is a $j$-sheaf.
    \begin{proof}
        We have to show that if $B \stackrel{m}{\rightarrowtail} A$ is a dense monomorphism, then pullback along $m$ yields a bijection from closed subobjects of $A$ to closed subobjects of $B$.\\
        If $A' \stackrel{n}{\rightarrowtail} A$ is closed, then in the pullback

        \begin{tikzcd}
            B' \arrow[r,tail,"m'"] \arrow[d,tail,"n'"] & A' \arrow[d,tail,"n"]\\
            B \arrow[r,tail,"m"] & A
        \end{tikzcd}

        $m'$i s dense, so $A' \rightarrowtail A$ is the closure of $B' \rightarrowtail B \rightarrowtail A$. It remains to show that if $B' \rightarrowtail B$ is closed, it is isomorphic to the pullback of its closure in $A$.\\
        But (writing $A' \rightarrowtail A$ for the closure), we have a factorization $B' \to f^* A'$ which is dense since $B' \to A'$ is dense, and closed since $B' \to B$ is closed.
    \end{proof}
\end{lemma}

\begin{thm} (7.22)\\
    For any local operator $j$ on $\mathcal{E}$, $sh_j(\mathcal{E})$ is a topos.\\
    Moreover, it's reflective in $\mathcal{E}$ and the reflector preserves finite limits.
    \begin{proof}
        $sh_j(\mathcal{E})$ is cartesian closed by (7.19), and has a subobject classifier $\Omega_j$ by (7.20) and (7.21). To construct the reflector, consider the composite
        \begin{tikzcd}
            A \arrow[r,tail,"\{\}"] & \Omega^A \arrow[r,"j^A"] & \Omega_j^A
        \end{tikzcd}
        , this corresponds to the closure $\bar{A} \rightarrowtail A \times A$ of the diagonal subobject $A \stackrel{(1_A,1_A)}{\rightarrowtail} A \times A$. I claim that $\bar{A} \stackrel[b]{a}{\rightrightarrows} A$ is the kernel-pair of $f$. Hence any morphism $g:A \to B$ where $B$ is a sheaf satisfies $ga = gb$.\\
        So if we torm(?) the image
        \begin{tikzcd}
            A \arrow[r,two heads,"q"] & I \arrow[r,tail,"m"] & \Omega_j^A
        \end{tikzcd}
        of $f$, any such $g$ factors uniquely through $q$.\\
        Now $\Omega_j^A$ is a sheaf by (7.19) and (7.21), so if we form the closure $LA \rightarrowtail \Omega_j^A$ of $m$, we get a morphism $A \to LA$ through which any morphism from $A$ to a sheaf factors uniquely. Hence $L$ becomes a functor $\mathcal{E} \to sh_j(\mathcal{E})$, left adjoint ot the inclusion.\\
        By (6.13), we know $L$ preserves finite products.\\
        In fact it preserves equalizers as well (the proof is quite elementary, but we have no time for it).
    \end{proof}
\end{thm}

There's a last thing I want to do, but I'll just state it since there's no time to prove it:
\begin{thm} (7.23)\\
    For a category $\mathcal{E}$, the following are equivalent:\\
    (i) $\mathcal{E}$ is a topos, complete and locally small, and has a separating set of objects;\\
    (ii) There exists a small category $\mathcal{C}$ and a local operator on $[\mathcal{C}^{op},\mathbf{Set}]$ s.t $\mathcal{E} \cong sh_j([\mathcal{C}^{op},\mathbf{Set}])$.
    \begin{proof}
        (ii) $\implies$ (i): since $sh_j([\mathcal{C}^{op},\mathbf{Set}])$ has given properties.\\
        (i) $\implies$ (ii): take $\mathcal{C}$ to be the full subcategory of $\mathcal{E}$ on the separating set and consider
        \begin{tikzcd}
            \mathcal{C} \arrow[r,"Y"] & \left[\mathcal{E}^{op},\mathbf{Set}\right] \arrow[r] & \left[\mathcal{C}^{op},\mathbf{Set}\right]
        \end{tikzcd}
    \end{proof}
\end{thm}

\newpage

\section{Example Class 1}
Many people wrote too much for questions. Do have the confidence to use the duality principle when it's usable!

\subsection{Question 1}
We need to verify
\begin{equation*}
    \begin{aligned}1q
        ((AB)C)_{il} &= \vee_k ((\vee_j (a_{ij} \wedge b_{jk} )) \wedge c_{kl})\\
        &= \vee_k \vee_j (a_{ij} \wedge b_{jk} \wedge c_{kl})\\
        &= (A(BC))_{il} \text{ by symmetry}
    \end{aligned}
\end{equation*}
and of course identity matrices are identities.

Define a functor $F:\mathbf{Mat}_L \to \mathbf{Rel}_f$ by $F(n) = \{1,2,...,n\}$; if $A: n \to p$ is a $p \times n$ matrix in $\mathbf{Mat}_L$, then $FA = \{(i,j) | a_{ji} = 1\}$.\\
Important: we have to verify this is functorial, which many people didn't bother to do. Why is it functorial? Well again we just have to verify explicitly that
\begin{equation*}
    \begin{aligned}
        (AB)_{ik} = 1 \iff (\exists j) (a_{ij} = b_{jk} = 1)
    \end{aligned}
\end{equation*}
so $F(AB) = FA \circ FB$. This does require verifications, because you are multiplying the matrices over lattices; for example say if you are doing it for the finite field with 2 elements then it won't work.\\
Now note that to prove they are equivalent we don't really need to find both the two functors and natural transformations; instead we can use a theorem in chapter 1, that $F$ is part of an equivalence if it is full, faithful and essentially surjective. So we just have to verify that $F$ is f,f,and es. Indeed it is, since any finite set is isomorphic to $F(n)$ for some $n$. So by (1.12), $\mathbf{Mat}_L \simeq \mathbf{Rel}_f$.

\subsection{Question 2}
Part (i) was easy, but many people had problems on part (ii).\\
(i) Given $(A_i | i \in I)$, define $\mathcal{C}$ by $\ob \mathcal{C} =\{(i,a)| i \in I, a \in A_i\}$, and $\mathcal{C}((i,a)(j,b)) = \phi$ if $i \neq j$, and is $\{*\}$ if $i=j$.\\
$\mathcal{C}$ is a groupoid; its isomorphic classes of objects are of the form $\{i\} \times A,i \in I$. If we've got a skeleton then we can pick out one from each of these, which is equivalent to AC.\\
(ii) Now take $\ob\mathcal{C} =I\times \{0,1\}$, and morphisms $(i,m) \to (i,n)$ are formal finite sums as given in the hint, and of course composition is just addition. Again this is a groupoid because every morphism can be inverted by just reverting the sign of every coefficient. So $\mathcal{C}$ has isomorphic classes $\{i\} \times \{0,1\}, i \in I$. So this has a skeleton, say we take $\mathcal{C}_0$ to be the full subcategory on objects $I\times\{0\}$.\\
But then by assumption we have an equivalence $\mathcal{C}_0 \stackrel[G]{F}{\rightleftarrows} \mathcal{C}$, then $FG(i,0) = FG(i,1)$ for all $i$. So if we have a natural transfomation $\beta:FG \to 1_{\mathcal{C}}$ which is also an isomorphism, then either $\beta_{(i,0)}$ or $\beta_{(i,1)}$ is a non-zero formal finite sum. So we just put $A_i = \{x \in A_i | x$ occurs in either $\beta_{(i,0)}$ or $\beta_{(i,1)}$ with non-zero coefficient$\}$.

\subsection{Question 3}
(i) Quite a lot of people forgot to verify that it is actually a subgroup! Suppose given automorphisms $F,G,H$ with isomorphisms $\alpha:F \to 1_{\mathcal{C}},\beta:G \to 1_{\mathcal{C}}$. Then $(F^{-1} \alpha)^{-1} : F^{-1} \to F^{-1}F = 1_{\mathcal{C}}$ is an isomorphism, so $F^{-1}$ is inner. Now $FG\xrightarrow{F\beta} F \xrightarrow{\alpha} 1_\mathcal{C}$ is isomorphism, so $FG$ is inner.\\
Now we have to verify normality: $HFH^{-1} \xrightarrow{H \alpha_{H^{-1}}} HH^{-1} = 1_{\mathcal{C}}$ is iso, so $HFH^{-1}$ is inner.\\
You don't have to spend a lot of time to verify that all these are nat transforms (ok).\\
(ii) Note that an isomorphism is in particular an equivalence. Now if $F$ is an automorphism, it is full and faithful, so for any $A$, morphism $A \to F1$ are in bijection with morphisms $F^{-1} A \to 1$, so there's just one of them.\\
Hence if $F$ is an isomorphism of $\mathbf{Set}$, $F(1) = 1$, and hence there's a unique $\alpha: \mathbf{Set} (1,-) \to F$ (this is just Yoneda).\\
We need to show $\alpha$ is iso: but for any $A$, and any $1 \xrightarrow{x} A$,
\begin{tikzcd}
    1 \arrow[r,"\alpha_1"] \arrow[d,"x"] & F1 \arrow[d,"Fx"]\\
    A \arrow[r,"\alpha_A"] & FA
\end{tikzcd}
commutes, but $F$ is full and faithful, so $\alpha_A$ is bijective. Hence by (1.8), $\alpha$ is an isomorphism.\\
(iii) Note that if $X$ has $\geq 3$ points, then it has $\geq 4$ continuous endo maps (constants and identity). If $X$ has $\leq 1$ point, then its only endo is $1_X$. So the only possibility is $X$ having 2 points. Say $X = \{0,1\}$ wit discrete or indiscrete topology, all 4 maps $X \to X$ are continuous. So the only possible topology is the Sierpinski space given in the question (or the other way), which there are 3 continuous maps $X \to X$.\\
Hence if $F$ is an autom of $\mathcal{C} \subseteq \mathbf{Top}$, we must have $FS \cong S$.\\
We also have $F1 \cong 1$, and $U:\mathcal{C} \to \mathbf{Set}$ is iso to $\mathcal{C} (1,-)$. So there's a unique nat $\alpha: U \to UF$, and $\alpha_X$ is bijective for all $X$, as before. Now we don't know if $\alpha_X$ is continuous or not for a given $X$. So we consider naturality squares
\begin{tikzcd}
    UX \arrow[r,"\alpha_X"] \arrow[d,"Uf"] & UFX \arrow[d,"UFf"]\\
    US \arrow[r,"\alpha_S"] & UFS
\end{tikzcd}
. If $\alpha_S$ is discontinuous, then for any $X$, $\alpha_X$ maps open subsets of $X$ bijecively to closed subsets of $FX$, but this is impossible if not every intersection of open sets in $X$ is open.\\
So then $\alpha_S$ is a homeomorphism, and $\alpha_X$ is a homeomorphism for all $X$.\\
(iv) This basically says that if we restrict to finite topological spaces, then we do have the other case in the above happening. Let $F:\mathbf{Top}_f \to\mathbf{Top}_f$ sending $X$ to the same set with closed sets as new opens.\\
Then $FF = 1_{\mathbf{Top}_f}$, so $F$ is an automorphism, and it is not isomorphic to the identity as there exists finite spaces $X$ with $X \not\cong FX$ (we could find one with 3 points -- lecturer didn't give the explicit example). So $F$ is not inner.\\
Now if $G$ is any non-inner autom, then $GF$ is inner(?????); so $|\Aut(\mathbf{Top}_f):Inn(Top_f)| = 2$.

\subsection{Question 4}
(i) Suppose we are given
\begin{tikzcd}
    C \arrow[r,"h"] \arrow[d,"g", two heads] & A \arrow[d,tail,"f"]\\
    D \arrow[r,"k"] & B \arrow[d,"p"',shift right] \arrow[d,"q", shift left]\\
    & E
\end{tikzcd}
where $f$ is an equalizer of $(p,q)$.\\
Then $pfh = pkg = qkg = qfh$, and $g$ is epic, so $pk = qk$, so exists unique $t$ with $ft=k$. Then $ftg = kg = fh$, and $f$ is monic, so $tg = h$.\\
(ii)
\begin{tikzcd}
    A \arrow[dr,"k"] \arrow[r,"f"] & B \arrow[d,"g"',shift right] \arrow[d,"h", shift left] & D \arrow[l,"l"] \arrow[dl,"m"]\\
    & C &
\end{tikzcd}
Note that $f$ isn't regular monic. Why not? Because it is not iso and not an equalizer of $(g,h)$, since $l$ doesn't factor through it. It is trivially monic and strong monic: the only squares with $f$ on RHS is to put the identity before $f$, but it's trivial to verify those cases.\\
In some sense we can see that this is a minimal counter-example to the statement (think a bit, there's not anything better you can do).\\
(iii) This actually has nothing to do with the previous two parts. We have
\begin{tikzcd}
    A \arrow[r,"f"] \arrow[rd,"k"] & B \arrow[d,"g"',shift right] \arrow[d,"h",shift left]\\
    & C
\end{tikzcd}
We want a commutative square
\begin{tikzcd}
    \cdot \arrow[r] \arrow[d] & \cdot \arrow[d]\\
    \cdot \arrow[r] & \cdot
\end{tikzcd}
with one vertical edge $f$ and the other one not. There are still a lot of possibilities, but almost any of it work. Say we pick
\begin{tikzcd}
    \cdot \arrow[r,"f"] \arrow[d,"f"] & \cdot \arrow[d,"g"]\\
    \cdot \arrow[r,"h"] & \cdot
\end{tikzcd}
Try $f,f,g,h$: the only possible composites are with
\begin{tikzcd}
    \cdot \arrow[r,"h"] \arrow[d,"1_B"] & \cdot \arrow[d,"1_C"]\\
    \cdot \arrow[r,"h"] & \cdot
\end{tikzcd}
or
\begin{tikzcd}
    \cdot \arrow[r,"h"] \arrow[d,"h"] & \cdot \arrow[d,"1_C"]\\
    \cdot \arrow[r,"1_C"] & \cdot
\end{tikzcd}
So $(f,g)$ is vacuously epic.

\subsection{Question 5}
This question has a lots of boring parts so lecturer is not going to write out all of it. The only a little bit tricky part is the strong part of (ii). We'll do that: suppose $gf$ is strong monic, and suppose we are given
\begin{tikzcd}
    \cdot \arrow[r,"l"] \arrow[d,"h", two heads] & \cdot \arrow[d,"f"]\\
    \cdot \arrow[r,"k"] & \cdot \arrow[d,"g"]\\
    & \cdot
\end{tikzcd}
. Then
\begin{tikzcd}
    \cdot \arrow[r,"l"] \arrow[d, "k", two heads] & \cdot \arrow[d,"gf", tail]\\
    \cdot \arrow[ru,"t", dashed] \arrow[r,"gk"] & \cdot
\end{tikzcd}
commutes. A lot of people used $g$ is monic, but we weren't given it here(oops)! Here $\exists t$ with $th = l$ (and $gft = gk$). Then $fth = fl = kh$ and $h$ is epic, so $ft = k$.\\
Suppose $gf$ is regular monic, say it's the equalizer of $\cdot \stackrel[l]{k}{\rightrightarrows} \cdot$. To show that $f$ is an equalizer of $(kg,fg)$, suppose we are given
\begin{tikzcd}
    \cdot \arrow[r,"m"] & \cdot
\end{tikzcd}
with $kgm = lgm$. Then $\exists ! n$ with $gm = gfn$. But now $g$ is monic. So $m = fn$.\\
(iv) This part is also fairly problematic. The first thing we need to work out is what equalizers look like in this category. Given $A \stackrel[g]{f}{\rightrightarrows} B$ in $\mathcal{C}$, their equalizer in $\mathbf{AbGp}$ is the subgroup of $\{a \in A | f(a) = g(a)\}$, and this belongs to $\mathcal{C}$. Since $\mathcal{C}$ is full, it's also an equalizer in $\mathcal{C}$. Now $\mathbf{Z} \xrightarrow{\times 2} \Z$ is an equalizer of $\Z \stackrel[0]{q}{\rightrightarrows} \Z/2\Z$, so it's regular monic in $\mathcal{C}$. But if $\Z \xrightarrow{\times 4} \Z$ were an equalizer of $\Z \stackrel[g]{f}{\rightrightarrows} A$, then $f(1) - g(1)$ must have order $4$ in $A$, so $A \not\in \ob\mathcal{C}$.\\
The last part of this is to find a counter-example to a previos part. We consider $\Z \xrightarrow{f} \Z \oplus \Z/2\Z \xrightarrow{g} \Z$, where $f(n) = (2n,[n])$, $g(p,q) = p$.\\
Note that $gf$ is regular monic, but $f$ isn't, as $(1,[1])$ has order $4$ modulo $Im(f)$.

\subsection{Question 6}
(i) Suppose $e = fg$, $gf$ an identity. We claim that $e$ is an equalizer of $e$ and $1_{\dom e}$: we have $ef = fgf = f$, so $f$ has equal composites with $e$ and $1_{\dom e}$; now if $h$ satisfies $eh = h$, then $h = fgh$, so it factorizes through $h$; moreover this factorization is unique, as $f$ is a split monomorphism.\\
Conversely, if $f$ is an equalizer of $(e,1_{\dom e})$, then of course $e$ must factor trough it since $ee = e$. Say $e=fg$. Now $fgf = ef = f$, and $f$ is monic, so $gf = 1_{\dom f}$.\\
(ii) $\mathcal{E} \subseteq Idem \mathcal{C}$, morphisms $e \to d$ are morphisms $\dom_e \xrightarrow{f} \dom d$ in $\mathcal{C}$ with $dfe = f$. Note that this is equivalent to the two separate equations: one way is clear, now $df=d(dfe) = dfe = f$ (remember $d$ is idempotent!!!). Similarly $fe = f$.\\
Composition in $\mathcal{C}[\check{\mathcal{E}}]$ is composition in $\mathcal{C}$: if $e \xrightarrow{f} d \xrightarrow{g} c$, then $cgf = gf = gfe$, so $gf : e \to c$. The identity on $e$ is $e \xrightarrow{e} e$.\\
(iii) We define $I:\mathcal{C} \to \mathcal{C} [\check{\mathcal{E}}]$ by $IA = 1_A$, $If = f$ (check this works). $I$ is f and f since all morphisms $A \to B$ in $\mathcal{C}$ are morphisms $1_A \to 1_B$ in $\mathcal{C} [\check{\mathcal{E}}]$.\\
For every $A \xrightarrow{e} A$ in $\mathcal{E}$, $Ie$ splits as $1_A \xrightarrow{e} e \xrightarrow{e} 1_A$.\\
So if $T = \hat{T}I$, $T$ must send idempotents in $\mathcal{E}$ to split idempotents.\\
Now we have to show the converse, where we do have to use choice here. Suppose $Te$ is split for every $A \xrightarrow{e} A$ in $\mathcal{E}$. Choose a splitting $TA \xrightarrow{g_e} \hat{T}e \xrightarrow{f_e} TA$ of it, and define $\hat{T}: \mathcal{C} [\check{\mathcal{E}}] \to \mathcal{D}$ on morphisms by $\hat{T} (e \xrightarrow{h} d) = \hat{T} e \xrightarrow{f_e}TA \xrightarrow{Th} TB \xrightarrow{g_d} \hat{T}d$ (verify that this is functorial): provided we split $T(1_A)$ as $TA \xrightarrow{1_{TA}} TA \xrightarrow{1_{TA}} TA$, we have $\hat{T} I = T$.\\
(iv) Now suppose $\mathcal{E} = \{$all idempotents of $\mathcal{C}\}$. If $e \xrightarrow{d} e$ is idempotent in $\mathcal{C} [\check{\mathcal{E}}]$, then $dd = d$ in $\mathcal{C}$, so $d \in \mathcal{E}$, and $e \xrightarrow{d} e$ splits as $e \xrightarrow{d} d \xrightarrow{d} e$.\\
(v) If $\mathcal{D}$ is Cauchy-complete, consider the functor $[\hat{\mathcal{C}},\mathcal{D}] \xrightarrow{\Phi} [\mathcal{C},\mathcal{D}]$ sending $\hat{T}$ to $\hat{T}I$ and $\alpha \to \alpha_I$. $\Phi$ is surjective on objects by (iii); so we need to show, given $S,T : \hat{\mathcal{C}} \rightrightarrows \mathcal{D}$, any nat trans $\alpha:SI \to TI$ extends uniquely to a nat trans $S \to T$. Given $A \xrightarrow{e} A$ in $\mathcal{E}$, we have a morphism $Se \xrightarrow{S(e \xrightarrow{e} 1_A)} SA \xrightarrow{\alpha_A} TA \xrightarrow{T(1_A \xrightarrow{e} e)} Te$ which we take to be $\alpha_e$.\\
This is the only possibility that makes the naturality squares for both $e \xrightarrow{e} 1_A$ and $1_A \xrightarrow{e} e$ commute:
\begin{tikzcd}
    Se \arrow[r,"S(e\xrightarrow{e} 1)"] \arrow[d,"\alpha_e"] & SA \arrow[d,"\alpha_A"]\\
    Te \arrow[r,"T(e\xrightarrow{e} 1)"] & TA
\end{tikzcd}
commutes since $\alpha_A$ is natural w.r.t. $1_A \xrightarrow{e} 1_A$. So this is the only possible way to extend it to a nat trans, and we of course have to verify naturality w.r.t. any $e \xrightarrow{f} d$ in $\mathcal{C}[\check{\mathcal{E}}]$.\\
So $\Phi$ is part of an equivalence by (1.12).

\subsection{Question 7}
For any $F: \mathcal{C} \to \mathbf{Set}$, $\coprod_{(A,x), A \in \ob\mathcal{C},x \in FA} \mathcal{C}(A,-) \to F$ is pointwise surjective, so $F$ irreducible implies that there exists $\mathcal{C}(A,-) \twoheadrightarrow F$.\\
Conversely, given $\mathcal{C}(A,-) \stackrel{\alpha}{\twoheadrightarrow} F$ and an epi $\coprod_{i \in I} G_i \stackrel{f}{\twoheadrightarrow} F$, we have
\begin{tikzcd}
    & \mathcal{C}(A,-) \arrow[dl,dashed, "\gamma"] \arrow[d,two heads, "\alpha"]\\
    \coprod_{i \in I} G_i \arrow[r,two heads,"\beta"] & F
\end{tikzcd}
$\gamma$ corresponds to an element of $\coprod_{i \in I} G_i A$, which lives in $G,A$ for some $i$. Then
\begin{tikzcd}
    & \mathcal{C}(A,-) \arrow[dl,"\gamma"] \arrow[d,two heads, "\alpha"]\\
    G_i \arrow[r,"\beta_i"] & F
\end{tikzcd}
forces $\beta_i$ to be epic.\\
(ii) If $F$ is irreducible and projective, then we get
\begin{tikzcd}
    & F \arrow[dl,"f"] \arrow[d,"1"]\\
    \mathcal{C}(A,-) \arrow[r,two heads, "\alpha"] & F
\end{tikzcd}
, so $\alpha$ is split epic.\\
Conversely, if
\begin{tikzcd}
    \mathcal{C}(A,-) \arrow[r,two heads,shift right, "\alpha"'] & F \arrow[l,tail,shift right,"\beta"']
\end{tikzcd}
is split epic, then given
\begin{tikzcd}
    & F \arrow[d,"f"]\\
    & \mathcal{C}(A,-) \arrow[ddl, dashed] \arrow[d,"\alpha"]\\
    & F \arrow[d]\\
    G \arrow[r,two heads] & H
\end{tikzcd}
so $F$ is projective.\\
The composite $\mathcal{C}(A,-) \xrightarrow{\alpha} F \xrightarrow{\beta} \mathcal{C}(A,-)$ is idenpotent; $Y:\mathcal{C}^{op} \to [\mathcal{C},\mathbf{Set}]$ is full and faithful, so it's of the form $Y(e)$ for a uniqu idempotent $A \xrightarrow{e} A$ in $\mathcal{C}$.\\
But now if this splits as $A \xrightarrow{g} B \xrightarrow{f} A$, then $\mathcal{C}(A,-) \xrightarrow{\mathcal{C}(f,-)}\mathcal{C}(B,-) \xrightarrow{\mathcal{C}(g,-)} \mathcal{C}(A,-)$ is a splitting of $\beta\alpha$. But then by Q6(i), so we must have $F \cong \mathcal{C}(B,-)$.\\
(iii) We know $[\mathcal{C},\mathbf{Set}] \simeq [\hat{\mathcal{C}},\mathbf{Set}]$ since $\mathbf{Set}$ is Cauchy-complete. If $\hat{\mathcal{C}} \simeq \hat{\mathcal{D}}$ by functors $F$ and $G$, then $T \to TF$ and $T \to TG$ give an equivalence $[\hat{\mathcal{C}},\mathbf{Set}] \simeq [\hat{\mathcal{D}},\mathbf{Set}]$.\\
But any equivalence $[\hat{\mathcal{C}},\mathbf{Set}] \simeq [\hat{\mathcal{D}},\mathbf{Set}]$ restricts to an equivalence between the full subcategories of irreducible projectives, which are equivalent to $\hat{\mathcal{C}}^{op}$ and $\hat{\mathcal{D}}^{op}$.

\subsection{Question 8}
This question is actually quite quick (and Joel says it's actually a question in one past-paper).\\
$\mathcal{C}(A,-)$ is a monofunctor just means that for any $f:B \to C$, the map $g \to fg$ is an injection $\mathcal{C}(A,B) \to \mathcal{C}(A,C)$. This holds for all $A$ iff all $f \in \mor\mathcal{C}$ are monic -- that's the equivalence between (i) and (ii).\\
We now prove (ii) $\implies$ (iii): Since we have an epi $\coprod \mathcal{C}(A,-) \twoheadrightarrow F$ and disjoint unions of monofunctors are monofunctors (?).\\
For (iii) $\implies$ (ii), if we have $F \stackrel{\alpha}{\twoheadrightarrow} \mathcal{C}(A,-)$ with $F$ a monofunctor, we have a splitting $\mathcal{C}(A,-) \stackrel{\beta}{\rightarrowtail} F$, and any subfunctor of a monofunctor is a monofunctor.\\
Given $f:A \to B$, consider the push out
\begin{tikzcd}
    \mathcal{C}(B,-) \arrow[r,"{\mathcal{C}(f,-)}"] \arrow[d,"{\mathcal{C}(f,-)}"] & \mathcal{C}(A,-) \arrow[d]\\
    \mathcal{C}(A,-) \arrow[r] & F
\end{tikzcd}
. Explicitly, $F(C) \cong \mathcal{C}(A,C) \times \{0,1\} / \sim$ where $(g,0) \sim (g,1) \iff f$ factors through $g$.\\
If this is a monofunctor, we must have $(1_A,0) \simeq (1_A,1)$ (check the relation in the middle), since $Ff$ sends them to the same thing.\\
If all morphisms of $\mathcal{C}$ are split monic, then $\mathcal{C}$ is a groupoid. And of course the converse holds (check).

\newpage

\section{Example Class 2}

\subsection{Question 1}
This is intended to be an easy question, although you could spend a lot of time if you want to go into all the details.

Define $F_0,F_1,...,F_n$ by
$$F_0(A_1 \to A_2 \to ... \to A_{n-1}) = (0 \to A_1 \to A_2 \to ... \to A_{n-1})$$
$$F_n(A_1 \to ... \to A_{n-1}) = (A_1 \to A_2 \to ... \to A_{n-1} \to 1)$$
and if $1 \leq i \leq n-1$,
$$F_i (A_1 \to ... \to A_{n-1}) = (A_1 \to A_2 \to ... \to A_i \xrightarrow{1} A_i \to A_{i+1} \to ... \to A_{n-1})$$
Similarly, $G_0,...,G_{n-1}$ by
$$G_0(B_1 \to B_2 \to ... \to B_n) = (B_2 \to ... \to B_n)$$
$$G_{n-1}(B_1 \to ... \to B_{n-1} \to B_n) = (B_1 \to ... \to B_{n-1})$$
and if $1 \leq i \leq n-2$,
$$G_i (B_1 \to B_2 \to ... \to B_n) =(B_1 \to ... \to B_i \to B_{i+2} \to ... \to B_{n-1})$$
where we compose two morphisms together.

To show $F_i \dashv G_i$ (for $i$ in the middle), consider a morphism $F_i(\mathbf{A}) \to \mathbf{B}$. This looks like

\begin{tikzcd}
    A_1 \arrow[d,"\alpha_1"] \arrow[r] & A_2 \arrow[d,"\alpha_2"] \arrow[r] & ... \arrow[r] & A_i \arrow[d,"\alpha_i"] \arrow[r] & A_i \arrow[d,"\alpha_{i+1}"] \arrow[r] & A_{i+1} \arrow[d,"\alpha_{i+2}"] \arrow[r] & ... \arrow[r] & A_{n-1} \arrow[d,"\alpha_n"]\\
    B_1 \arrow[r] & B_2 \arrow[r] & ... \arrow[r] & B_i \arrow[r] & B_{i+1} \arrow[r] & B_{i+2} \arrow[r] & ... \arrow[r] & B_n
\end{tikzcd}
Here $\alpha_{i+1}$ is uniquely determined by the other data: if we omit it, we get a morphism $\mathbf{A} \to G_i (\mathbf{B})$. Other adjunctions are similar.\\
$F_0$ doesn't preserve $\mathbf{1}$, so it can't have a left adjoint; similarly $F_n$ doesn't preserve $\mathbf{0}$.

For the last part, we have $(F_0G_0 \dashv F_1G_0 \dashv F_1G_1 \dashv ... \dashv F_n G_{n-1})$, which is a string of length $2n$; but $F_0G_0$ doesn't preserve $\mathbf{1}$, $F_nG_{n-1}$ doesn't preserve $\mathbf{0}$.

\subsection{Question 2}
We know

\begin{tikzcd}
    F \arrow[r,"F\alpha"] \arrow[d,"F\alpha"] & FGF \arrow[r,"\beta_F"] \arrow[d,"FGF\alpha"] & F \arrow[d,"F\alpha"]\\
    FGF \arrow[r,"F\alpha_{GF}"] \arrow[rd,"1_{FGF}"] & FGFGF \arrow[r,"\beta_{FGF}"] \arrow[d,"FG\beta_F"] & FGF \arrow[d,"\beta_F"]\\
    & FGF \arrow[r,"\beta_F"] & F
\end{tikzcd}

commutes by naturality of $\alpha$ and $\beta$ and the given triangular identity. So from the diagram we've proved idempotency.

If we can split $(\beta_F) (F\alpha)$ in the functor category $[\mathcal{C},\mathcal{D}]$, say as
\begin{tikzcd}
    F \arrow[r,"\delta"] & F' \arrow[r,"\gamma"] & F
\end{tikzcd}
, we define $\eta$ to be
\begin{tikzcd}
    1_\mathcal{C} \arrow[r,"\alpha"] & GF \arrow[r,"G\delta"] & GF'
\end{tikzcd}
and $\varepsilon$ to be
\begin{tikzcd}
    F'G \arrow[r,"\gamma_G"] & FG \arrow[r,"\beta"] & 1_\mathcal{D}
\end{tikzcd}

Now we just have to verify the triangular identities for these:

\begin{tikzcd}
    G \arrow[r,"\alpha_G"] \arrow[d,"\alpha_G"] & GFG \arrow[r,"G\delta_G"] \arrow[d,"GF\alpha_G"] & GF'G \arrow[d,"G\gamma_G"] \\
    GFG \arrow[r,"\alpha_{GFG}"] \arrow[rr,bend right=20, "1_{GFG}"'] & GFGFG \arrow[r, "G\beta_{FG}"] & GFG \arrow[d,"G\beta"]\\
    & & G
\end{tikzcd}

is the identity. For the other triangle,

\begin{tikzcd}
    F' \arrow[d,"\gamma"] \arrow[dd, bend right=20, "1_{F'}"'] \arrow[r,"F'\alpha"] & F'GF \arrow[d,"\gamma_{GF}"] \arrow[r,"F'G\delta"] & F'GF' \arrow[d,"\gamma_{GF'}"]\\
    F \arrow[r,"F\alpha"] \arrow[d,"\delta"] & FGF \arrow[r,"FG\delta"] \arrow[d,"\beta_F"] & FGF' \arrow[d,"\beta_{F'}"]\\
    F' \arrow[r,"\gamma"] \arrow[rr,bend right=20, "1_{F'}"'] & F \arrow[r, "\delta"] & F'
\end{tikzcd}

For the last part, take $\mathcal{C} = \mathbf{1}$, $\mathcal{D}$ to be the monoid $\{1,e|e^2 = e\}$.\\
$\mathcal{C} \stackrel[G]{F}{\rightleftarrows} \mathcal{D}$ are the unique functors, $GF=1_{\mathcal{C}}$, so take $\alpha = 1_{1_{\mathcal{C}}}$. $FG \neq 1_\mathcal{D}$, but $e$ defines a natural transformation $\beta:FG \to 1_\mathcal{D}$. Note that $\mathcal{D}$ doesn't have an initial object, so $G$ doesn't have a left adjoint (I think so?).

\subsection{Question 3}
In fact (i) and (ii) are immediately equivalent since $(\varepsilon_F) (F\eta) = 1_F$, so if one of them is an isomorphism then so is the other one.\\
(ii) implies (iii) since $G$ preserves isomorphisms.\\
(iii) implies (iv) since $\eta_{GF}$ and $GF\eta$ are both 1-sided inverses for $G\varepsilon_F$.\\
(iv) implies (v) is trivial.\\
The only nontrivial part is (v) $\implies$ (vi). Assuming (v), we need to show
\begin{tikzcd}
    GFG \arrow[r,"G\varepsilon"] & G \arrow[r,"\eta_G"] & GFG
\end{tikzcd}
is the identity, but
\begin{tikzcd}
    GFG \arrow[r,"G\varepsilon"] \arrow[d,"\eta_{GFG}"] & G \arrow[d,"\eta_G"]\\
    GFGFG \arrow[r,"GFG\varepsilon"] & GFG
\end{tikzcd}
commutes by naturality, and $(GFG\varepsilon)(GF\eta_G) = 1_{GFG}$.

\subsection{Question 4}
These $Fix$s are really only interesting when $F \dashv G$ is idempotent, since otherwise we usually have both of the $Fix$ being empty.\\
(i) If $A \in \ob(Fix(GF))$, then $F\eta_A$ is an isomorphism, so $\varepsilon_{FA}$ is isomorphism, so $FA \in \ob(Fix(FG))$, and dually $G$ maps $Fix(FG)$ to $Fix(GF)$.\\
The adjunction restricts to an adjunction $Fix(GF) \stackrel[G]{F} Fix(FG)$ (note that we are using the same letter for the restricted functors), where unit and counit are isomorphisms. So this is actually an equivalence between categories.\\
(ii) Now if the adjunction is idempotent, then $F$ maps all of $\mathcal{C}$ into $Fix(FG)$, and $G$ maps $\mathcal{D}$ into $Fix(GF)$, so these things now can't be empty. Moreover, $GF$ is a functor $\mathcal{C} \to Fix(GF)$, and we have a natural transformation $\eta:1_\mathcal{C} \to GF$ s.t. $\eta$ is an isomorphism precisely when $A \in \ob(Fix(GF))$. This yields a bijection between morphisms $A \xrightarrow{f} A'$ with $A' \in \ob Fix(FG)$ and morphisms
\begin{tikzcd}
    GFA \arrow[r,"GFf"] & GFA' \arrow[r,"\eta_{A'}^{-1}"] & A'
\end{tikzcd}
Dually, $FG$ is a right adjoint to the inclusion $Fix(FG) \hookrightarrow \mathcal{D}$. So we have

\begin{tikzcd}
    \mathcal{C} \arrow[r,shift left, "FGF"] \arrow[d,"GF"',shift right] & \mathcal{D} \arrow[l,"GFG", shift left] \arrow[d,"FG",shift left]\\
    Fix(GF) \arrow[u,shift right,"I"'] \arrow[r,"F",shift left] & Fix(FG) \arrow[u,shift left,"J"] \arrow[l,"G",shift left]
\end{tikzcd}

a factorization of $(F \dashv G)$ up to isomorphism as reflection + equivalance + coreflection.\\
Suppose given $\mathcal{C} \stackrel[G]{F}{\rightleftarrows} \mathcal{D} \stackrel[K]{H}{\rightleftarrows} \mathcal{E}$ where $(F\dashv G)$ is a reflection and $(H \dashv K)$ is a coreflection.\\
The unit of $(HF \dashv GK)$ is $1\mathcal{C} \xrightarrow{\eta} GF \stackrel[\simeq]{G\iota_F}{\longrightarrow} GKHF$, where $\eta$ and $\iota$ are the units of $(F\dashv G)$ and $(H \dashv K)$.\\
Now $F \xrightarrow{F\eta} FGF \xrightarrow{\sim} FGKHF$ is an isomorphism, so $HF \to HFGKHF$ is an isomorphism.

\subsection{Question 5}
Start with $J$ a finite connected category. For $j \in \ob\mathcal{J}$, define $d(j) = |\{j' \in \ob\mathcal{J} | \not\exists j \to j' \text{ in } \mathcal{J}\}|$. Choose $j_0 \in \ob\mathcal{J}$ with $d(j_0)$ minimal. If $d(j_0) \neq 0$, pick $k$ in the corresponding above set of $d(j_0)$, we can find a zigzag

\begin{tikzcd}
    j_0 \arrow[rd] & & k_2 \arrow[ld] \arrow[rd] & & \cdot \arrow[ld] \arrow[r, dotted, no head] & K=K_n\\
    & k_1 & & k_3 & &
\end{tikzcd}
Let $i$ be minimal s.t. $\not\exists j_0 \to K_i$. Then we have
\begin{tikzcd}
    j_0 \arrow[rd,"\alpha"] & & k_i \arrow[ld,"\beta"]\\
    & k_{i-1} &
\end{tikzcd}
. Enlarge $\mathcal{J}$ to $\mathcal{J}_1$ by adding
\begin{tikzcd}
    & j_1 \arrow[ld,"\gamma"] \arrow[rd,"\delta"] & \\
    j_0 & & k_i
\end{tikzcd}
plus composites subjects to the relation $\alpha\gamma = \beta\delta$.\\
Note that $d_{\mathcal{J}_1}(j_1) < d_{\mathcal{J}}(j_0)$.\\
If $D:J \to \mathcal{C}$ where $\mathcal{C}$ has pullbacks, we enlarge it to a diagram $D_1: \mathcal{J}_1 \to \mathcal{C}$ by requiring
\begin{tikzcd}
    & D_1(j_1) \arrow[ld] \arrow[rd] &\\
    D(j_0) \arrow[rd] & & D(k_i) \arrow[ld]\\
    & D(K_{i-1}) &
\end{tikzcd}
to be a pullback. Then any cone over $D$ extends uniquely to a cone over $D_1$, and hence $D_1$ has a limit iff $D$ does.\\
Hence, after at most $d(j_0)$ steps, we get a diagram $D': \mathcal{J}' \to \mathcal{C}$ where $\mathcal{J}'$ has a weakly initial object, s.t. the extended diagram has a limit iff the original diagram $D$ does.\\
Now suppose we are given $D:\mathcal{J} \to \mathcal{C}$ where $\mathcal{J}$ is finite and has a weakly initial object $j_0$. Let
$$\{j_0 \stackrel[\beta_i]{\alpha_i}{\rightrightarrows} j_i| 1 \leq i \leq n\}$$
be a listing of the unequal parallel pairs with domain $j_0$. Now form

\begin{tikzcd}
    E_n \arrow[r] & ... \arrow[r] & E_2 \arrow[r] & E_1 \arrow[r] & D(j_0)
\end{tikzcd}

where $E_1 \to D(j_0)$ is the equalizer of $D(\alpha_1)$ and $D(\beta_1)$, $E_2 \to E_1$ is the equalizer of $E_1 \to D(j_0) \stackrel[D(\beta_2)]{D(\alpha_2)}{\rightrightarrows} D(j_2)$, and so on.\\
Then the composites $E_n \to D(j_0) \to D(j)$ for $j \in \ob\mathcal{J}$ form a cone over $D$; moreover, if $(\lambda_j| j \in \ob\mathcal{J})$ is any cone over $D$, $\lambda_{j_0}$ factors uniquely through $D_n \to D(j_0)$, and the factorization is a moprhism of cones.

(ii) Consider
\begin{tikzcd}
    \mathcal{C}/A \arrow[r,"U"] & \mathcal{C}
\end{tikzcd}
by
\begin{tikzcd}
    \begin{pmatrix}
        B\\
        \downarrow f\\
        A
    \end{pmatrix} \arrow[r] & B
\end{tikzcd}
, and suppose given $D:\mathcal{J} \to \mathcal{C}/A$ with $\mathcal{J}$ connected, and write $D(j) = \begin{pmatrix}UD(j)\\\downarrow f_j\\A \end{pmatrix}$.\\
Given any cone $(B\xrightarrow{\beta_j} UD(j) | j \in \ob\mathcal{J})$ over $UD$, the composite $f_j \beta_j$ is independent of $j$, since if $\exists \alpha:j \to j'$, then

\begin{tikzcd}
    & B \arrow[ld,"\beta_j"'] \arrow[rd,"\beta_{j'}"] &\\
    UD(j) \arrow[rr,"UD(\alpha)"] \arrow[rd,"f_j"'] & & UD(j') \arrow[ld,"f_{j'}"] \\
    & A &
\end{tikzcd}
commutes. So there exists a unique $g:B \to A$ s.t. $\beta_j$ become a cone in $\mathcal{C}/A$ with apex $g$.\\
In particular, if the $\beta_j$ are a limit cone over $UD$, their liftings are a limit cone over $D$.

(iii) Given $F:\mathcal{C} \to \mathcal{D}$, factor it as $\mathcal{C} \xrightarrow{\hat{F}} D / F1 \xrightarrow{U} D$, where $\hat{F}(A) = \begin{pmatrix} FA\\\downarrow\\F1\end{pmatrix}$. $\hat{F}$ preserves pullbacks since $F$ preserves them and $U$ creates them. But $\hat{F}$ also preserves the terminal object. So $\hat{F}$ preserves all finite limits. And $U$ preserves all connected limits, so $U\hat{F} = F$ preserves all finite connected limits.

(Solution to question 6-10 to be typesetted)

\newpage

\section{Example Class 3}

\subsection{Question 1}
As usual this was meant to be an easy question (jfalksdjf;laskflklj;aj;sdkjflasj).

(i) If $\alpha,\beta:1_\mathcal{C} \rightrightarrows 1_\mathcal{C}$, then

\begin{tikzcd}
    A \arrow[r,"\alpha_A"] \arrow[d,"\beta_A"] & A \arrow[d,"\beta_A"]\\
    A \arrow[r,"\alpha_A"] & A
\end{tikzcd}

commutes by naturality.

(ii) If $(1_\mathcal{C},\eta,\mu)$ is a monad, then $\mu\eta = 1_{1_\mathcal{C}}$, so $\eta \mu = 1_{1_\mathcal{C}}$.

(iii) Suppose $\alpha:1_\mathcal{C} \to GC$ is a natural isomorphism. Define $\eta' = $
\begin{tikzcd}
    1_\mathcal{C} \arrow[r,"\eta'"] & GF \arrow[r,"\alpha^{-1}"] & 1_\mathcal{C}
\end{tikzcd}
,\\
$\mu'=$
\begin{tikzcd}
    1_\mathcal{C} \arrow[r,"\alpha"] & GF \arrow[r,"GF\alpha"] & GFGF \arrow[r,"\mu"] & GF \arrow[r,"\alpha^{-1}"] & 1_\mathcal{C}
\end{tikzcd}

Then $(1_\mathcal{C},\eta',\mu')$ is a monad, so $\eta'$ is an isomorphism, so $\eta = \alpha\eta'$ is an isomorphism, i.e. $F$ is full and faithful (a dual to one of the results in lecture).

(iv) We have the forgetful functor $[M,\mathbf{Set}] \xrightarrow{U} \mathbf{Set}$. $FF = M \times A$ with $M$ acting on first factor $(F \dashv U)$, but $\eta:A \to UFA$ isn't an isomorphism.\\
If $H:\mathbf{Set} \to [M,\mathbf{Set}]$, $HA = A$ with trivial $M$-action, then $UH = 1_{\mathbf{Set}}$.\\
$G:[M,\mathbf{Set}] \to \mathbf{Set}$ sends $(A,e)$ to $\{x \in A | ex = x\}$, then $GF \cong 1_{\mathbf{Set}}$.

\subsection{Question 2}
If $(A,\alpha)$ is a $\T$-algebra, then $\alpha\eta_A = 1_A$, and
\begin{tikzcd}
    TA \arrow[r,"\eta_{TA}"] \arrow[d,"\alpha"] & TTA \arrow[d,"T\alpha"]\\
    A \arrow[r,"\eta_A"] & TA
\end{tikzcd}
commutes; but $\eta_{TA} = T\eta_A$ since both are inverse to $\mu_A$, so $\eta_A \alpha = 1_{TA}$.\\
Conversely, if $A \in \ob(Fix T)$, then $\eta_A^{-1}$ is a $\T$-algebra structure on $A$, and any $A \xrightarrow{f} B$ in $Fix(T)$ is a homomorphism $(A,\eta_A^{-1}) \to (B,\eta_B^{-1})$.\\
So $G^\T: \mathcal{C}^\T \to \mathcal{C}$ maps $\mathcal{C}^\T$ isomorphically to $Fix(T)$.\\
$Fix(T)$ is reflective in $\mathcal{C}$, with reflector $T$, and $T$ is essentially surjective as a functor $\mathcal{C} \to Fix(T)$. So the Kleisli comparison $\mathcal{C}_\T \to Fix(T)$ is an equivalence.

For the last part, $M$ is the order-preserving endomorphisms of $\N$. Define $\eta:1_M \to T$ by $\eta_*(n) = n+1$, and $\mu:TT \to T$ must send $\mu_*(0) = 0$, $\mu_*(n) = n-1$ if $n>0$. But if $\alpha$ is any $\T$-algebra structure on $*$, then necessarily $\alpha(n+1) = n$ for all $n$, and $\alpha$ is order-preserving so $\alpha(0) = 0$. So the comparison $M_\T \to M^\T$ is bijective on objects.

\subsection{Question 3}
$F:\mathcal{C} \to \mathcal{D}$ induces $F^*:[\mathcal{D},\mathbf{Set}] \to [\mathcal{C},\mathbf{Set}]$ with both left and right adjoints, and hence preserving equalizers and coequalizers. So $F^*$ is monadic and comadic $\iff F^*$ reflects isomorphisms.\\
If every $B \in \ob\mathcal{D}$ is isomorphic to some $FA$, then for $\beta: G \to H$ (where $G,H: \mathcal{D} \rightrightarrows \mathbf{Set})$, $\beta_{FA}$ is isomorphism for all $A$ implies that $\beta_B$ is an isomorphism for all $B$, since

\begin{tikzcd}
    GFA \arrow[r,"G\alpha"] \arrow[d,"\beta_{FA}"] & GB \arrow[d,"\beta_B"]\\
    HFA \arrow[r,"H\alpha"] & HB
\end{tikzcd}

commutes.

For the last part, apply this to $I:\mathcal{C}_0 \to \mathcal{C}$ where $\mathcal{C}_0$ is the discrete category with same objects as $\mathcal{C}$, and $I$ is inclusion, we get $[\mathcal{C},\mathbf{Set}]$ monadic and comonadic over $[\mathcal{C}_0,\mathbf{Set}] \cong \mathbf{Set}^{ob\mathcal{C}}$.

\subsection{Question 4}
(Lecturer: This is a very fun question, and I'm pretty happy that I discovered this).\\
$x:\mathbf{Set} \times \mathbf{Set} \to \mathbf{Set}$ preserves reflexive coequalizers by ES4 Q3. But $\phi\times A = \phi$ for all $A$, so $\phi \times A \to \phi \times B$ is an isomorphism for any $A \times B$. So it's not monadic.\\
However, if $\mathcal{C}$ is the full subcategory of $\mathbf{Set} \times \mathbf{Set}$ on pairs $(A,B)$ with $A=\phi \iff B=\phi$, then $\Delta: \mathbf{Set} \to \mathcal{C}$ and $\times|_\mathcal{C}$ are still adjoint to each other (because this is a full subcategory), and $\times|_\mathcal{C}$ still preserves reflexive coequalizers, and now reflects isomorphisms (because we've thrown away the bad things).\\
A \emph{rectangular band} is a set $A$ with binary operation $b$ satisfying $b(x,x) = x$ and $b(b(x,y),b(z,w)) = b(x,w)$. The category of rectangular bands is actually isomorphic to the above $\mathcal{C}$.

\subsection{Question 5}
(i) $\implies$ (ii) because $F$ preserves coequalizers.\\
(ii) $\implies$ (i) since $\mathbf{Set}$ is balacned.\\
(ii) $\iff$ (iii) is the dual of (3.8).\\
(iii) $\implies$ (iv) is trivial.\\
(iv) $\implies$ (v) is almost equally trivial, since $F2$ has at least 2 elements.\\
(v) $\implies$ (iii): Let $(B,\beta)$ be a $\T$-algebra with $>1$ elements. Then given $A$ and two distinct elemnets, $x,y \in A$, we can find $A \xrightarrow{f} B$ with $f(x) \neq f(y)$. Then $f$ factors through $\eta_A$, so $\eta_A(x) \neq \eta_A(y)$.\\
(vii) $\implies$ (vi) by reflexive comonadicity theorem (dual to 5.13).\\
(vii) $\iff$ (viii) since $T=GF$ and $G$ creates equalizers.\\
(ix) $\implies$ (viii): if
\begin{tikzcd}
    A \arrow[r,"f"] & B \arrow[r,shift left, "g"] \arrow[r,shift right,"h"'] & C \arrow[l,"r"]
\end{tikzcd}
us a coreflexive equalizers in $\mathbf{Set}$, and $A \vDash \phi$, note that $g$ and $h$ are injective, and $g(x) = h(y)$ iff $x=y \in \im(f)$.\\
So choose $s:B \to A$ with $sf = 1_A$; then define $t:C \to B$ so that $t(z) = y$ if $z=h(y)$, $t(z) = fs(y)$ if $z=g(y)$, and $t(z) = y_0$ if $z \not\in (\im h \cup \im g)$.\\
This is a split coequalizer, so $T$ preserves it. Now suppose $A = \phi \neq B$. Then $\im g$ and $\im h$ are disjoint.\\
Suppose $x \in TB$ satisfies $Tg(x) = Th(x)$. Define $t:C \to B$ by $t(z) = y$ if $z=g(y)$, and is $z_0$ otherwise. then $x = (Tt)(Tg)(x) = (Tt)(Th)x = (Tz_0)(u)$ for some $u \in T1$.\\
Now consider

\begin{tikzcd}
    1 \arrow[r,shift left] \arrow[r,shift right] \arrow[d,"y_0"] & 2 \arrow[d,"{(gy_0,hy_0)}"]\\
    B \arrow[r,shift left, "g"] \arrow[r,shift right, "h"'] & C
\end{tikzcd}

which commutes, and the right hand map is (split) monic, so $T$ maps it to a monomorphism. So $u$ has the same images under $T1 \rightrightarrows T2$; hence it's in the image of $T\phi \to T1$.

Finally (vi) $\implies$ (ix) is a rather strange argument -- assume (ix) fails: consider the equalizer $E \rightarrowtail F1$ of $F1 \rightrightarrows F2$. We know $GE \to GF1 \rightrightarrows GF2$ is a coreflexive equalizer diagram with $GE \neq \phi$ (since $GF\phi \to GE$ is not an isomorphism). So it's split, and hence

\begin{tikzcd}
    FGE \arrow[r] & FGF1 \arrow[r,shift left] \arrow[r,shift right] & FGF2 \\
    E \arrow[u,dashed, "\theta"'] \arrow[r] & F1 \arrow[u,"F\eta_1"'] \arrow[r,shift left] \arrow[r,shift right] & F2 \arrow[u,"F\eta_2"']
\end{tikzcd}

This $\theta$ is a coalgebra structure on $E$. Now the image under the comparison of $\phi \to 1$ factors as
\begin{tikzcd}
    (F\phi,F\eta_\phi) \arrow[r] & (E,\theta) \arrow[r,tail] & (F1, F\eta_1)
\end{tikzcd}
with neither factor an isomorphism. So $(E,\theta)$ is not in the essential image (image of objects?) of the comparison.

\subsection{Question 6}
(i) (This part is \emph{straight-forward enough}) Given a $\T$-algebra homomorphsim $f:(A,\alpha) \to (B,\beta)$, consider

\begin{tikzcd}
    TA \arrow[d,"\alpha"] \arrow[r,two heads, "Te"] & TI \arrow[r,"Tm"] \arrow[d,dashed,"\iota"] & TB \arrow[d,"\beta"]\\
    A \arrow[r,two heads,"e"] & I \arrow[r,tail,"m"] & B
\end{tikzcd}

We get an induced $\iota$ since $Te$ is (strong) epic and monic, and $\iota$ is an algebra structure.\\
So $f$ is a strong epimorphsim in $\mathbf{Set}^\T$ $\implies$ $m$ is an isomorphism $\implies$ $f$ is surjective.\\
Given a surjective $(A,\alpha) \xrightarrow{f} (B,\beta)$, form the pullback

\begin{tikzcd}
    R \arrow[r,"a"] \arrow[d,"b"] & A \arrow[d,"f"]\\
    A \arrow[r,"f"] & B
\end{tikzcd}

$R$ has an algebra structure $\rho$ since $G^\T$ creates limits.\\
Now
\begin{tikzcd}
    R \arrow[r,shift left, "a"] \arrow[r, shift right, "b"'] & A \arrow[r,"f"] \arrow[l,bend left=40,"t"] & B \arrow[l,bend left=20,"s"]
\end{tikzcd}
, we can choose $s$ with $fs = 1_B$ and define $t$ to be the factorization of $(sf,1_A)$ through the pullback.\\
So $f$ is a coequalizer of $(R,\rho) \stackrel[b]{a}{\rightrightarrows} (A,\alpha)$ in $\mathbf{Set}^\T$.

(ii)

\includegraphics[scale=0.5]{image/Cat_08.png}

The above is anon-regular composite of two regular epimorphisms.

(iii) $\mathbf{DGph} \cong [M,\mathbf{Set}]$ where $M=\{1,d,c|d^2=cd=d,c^2=dc=c\}$, and $[M,\mathbf{Set}] \xrightarrow{U} \mathbf{Set}$ is monadic.\\
$G:\mathbf{Cat} \to \mathbf{DGph}$ has a left adjoint: the free category on a digraph $\mathcal{G}$ has the same objects as $\mathcal{G}$, and morphisms are composable strings $\cdot \to \cdot \to \cdot \to ... \to \cdot$, subject to cancellation of identities, and the adjunction is \emph{straight-forward} to verify, so \emph{that's easy}; and $\varepsilon:FG\mathcal{C} \to \mathcal{C}$ is bijective on objects.

Suppose
\begin{tikzcd}
    \mathcal{G} \arrow[r,shift left, "f"] \arrow[r,shift right, "g"] & \mathcal{H} \arrow[r,"h"] \arrow[l,"r"] & \mathcal{K}
\end{tikzcd}
is a reflexive coequalizer in $\mathbf{DGph}$ where $f$ and $g$ are bijective on objects. Then $h$ is bijcetive on objects, and the morphisms of $\mathcal{K}$ are equivalence classes of morphisms of $\mathcal{H}$.\\
So if $\mathcal{G}$ and $\mathcal{H}$ are categories and $f$ and $g$ are functors, $\mathcal{K}$ inherits a category structure making $h$ a coequalizer in $\mathbf{Cat}$ (lecturer: I'm a bit hand-waving on this, the actual verification is a bit long to write down but I hope it's obvious).\\
This is enough to make the proof of the reflexive monadicity theorem work.

\subsection{Question 7}
(i)

\begin{tikzcd}
    1 \arrow[r,"0"] & \N & \N \arrow[l,"s"']
\end{tikzcd}
is a coproduct and
\begin{tikzcd}
    \N \arrow[r,shift left, "s"] \arrow[r,shift right, "1_\N"'] & \N \arrow[r] & 1
\end{tikzcd}
is a coequalizer.\\
Given $A$, $1 \xrightarrow{a} A$ and $A \xrightarrow{t} A$ with corresponding diagrams, we define $f: \N to A$ recursively by $f(0)=a$ and $f(n+1) = tf(a)$.\\
The coproduct diagram ensures that $f$ is injective.\\
If it's not surjective, define $h:A \to \{0,1\}$ by $h(a) = 0$ if $a \in \im f$ and $h(a)=1$ otherwise. Then $h=ht$, contradicting the coequalizer diagram.\\
So if $F:\mathbf{Set} \to \mathbf{Set}$ preserves finite limits and colimits, it preserves $\N$. Hence it preserves countable coproducts, since we have pullbacks

\begin{tikzcd}
    F(\coprod_{n \in \N} A_n) \arrow[d] & FA_n \arrow[l] \arrow[d] \\
    F\N \arrow[d,no head,"\cong"] & F1 \arrow[l,"Fn"'] \arrow[d,no head,"\cong"]\\
    \N & 1 \arrow[l,"n"']
\end{tikzcd}

(ii) Suppose $F:\mathbf{Set} \to \mathbf{Set}$ preserves finite limits and countable coproducts (Note that $F$ preserves all epimorphisms, and hence preserves images).\\
$F$ preserves coequalizers of equivalence relations $R \subseteq A \times A$ by the hint in question 6.\\
Given a parallel pair $A \stackrel[g]{f}{\rightrightarrows} B$, we construct the equivalence relation on $B$ generated by all pairs $(fx,gx)$ as follows:\\
First form the image $I \rightarrowtail B \times B$ of $A \xrightarrow{(f,g)} B \times B$. Then form the image $S \rightarrowtail B \times B$ of $I \coprod B \coprod I^{op} \to B \times B$ to get a reflexive and symmetric relation. Now form the powers $S^n \rightarrowtail B \times B$ using finite limits and images, and then form $R = \im(\coprod_{n \in \N} S^n \to B \times B)$.\\
All of these is preserved by $F$.

(iii) Suppose $F:\mathbf{Set} \to \mathbf{Set}$ preserves finite limits and colimits. We have $\alpha:1_{\mathbf{Set}} \cong \mathbf{Set}(1,-) \to F$ corresponding to the unique element of $F1$.\\
Note $F(1 \coprod 1) \cong 1 \coprod 1$, whence $\alpha_2$ is bijective, whence $\alpha_A$ is injective for all $A$.\\
Suppose $\kappa$ is the least cardinal $(>\omega)$ s.t. $\alpha$ isn't surjective on (sets of cardinality) $\kappa$. Pick $x \in F(\kappa) \setminus \im \alpha_\kappa$; say $A \subseteq \kappa$ is \emph{large} if $x \in \im(FA \to F\kappa)$.\\
We can say several things about those large sets: if $A$ is large, $A \subseteq A'$ then $A'$ is large; if $A,A'$ are large then $A \cap A'$ is large since $F$ preserves pullbacks.\\
For every $A$, either $A$ or $\kappa \setminus A$ is large since $F$ preserves binary coproducts, but not both of them, since $F$ preserves $\phi$.\\
This means that the collection $\mathcal{U}$ of large sets is an \href{https://en.wikipedia.org/wiki/Ultrafilter}{ultrafilter}.\\
All finite sets are small; countable unions of small sets are small (since $F$ preserves countable coproducts), so countable intersections of large sets are large.\\
Hence $\kappa$ is a \href{https://en.wikipedia.org/wiki/Measurable_cardinal}{measurable cardinal}: if we are working in a model where no measurable cardinals exist, then no such $F$ can exist.\\
Given a countably complete non-principal ultrafilter $\mathcal{U}$ on $\kappa$, we can define $\pi_\mathcal{U}: \mathbf{Set} \to \mathbf{Set}$ by $\pi_\mathcal{U} (A) = A^\kappa / \sim_\mathcal{U}$, where $f,g: \kappa \rightrightarrows A$ are identified iff they agree on a set in $\mathcal{U}$.

\newpage

\section{Example Class 4}

\subsection{Question 1}
Suppose $A$ is strict. Then $\pi_1:A \times B \to A$ is an isomorphism. So there exists $\pi_2\pi_1^{-1} : A \to A \times B \to B$.\\
For uniqueness, if $f,g : A \rightrightarrows{B}$, then $\pi_1(1,f) = \pi_1(1,g):A \to A \times B \to A$, so $(1,f) = (1,g)$, so $f=g$.

For the second part, $\mathcal{C}$ is Cartesian closed, so $A \times B$ is initial, so $A \times B \xrightarrow{\pi_1} A$ is an isomorphism. Given $B \xrightarrow{f} A$, $B \xrightarrow{(f,1)} A \times B \xrightarrow{\pi_2} B$ is the identity, and $A \times B \xrightarrow{\pi_2} B \xrightarrow{(f,1)} A \times B = 1_{A \times B}$ since $A \times B$ is initial. So $f=\pi_1(f,1)$ is an isomorphism.

\subsection{Question 2}
(i) If $f:X_1 \to X_2, g:Y_1 \to Y_2$ are distance decreasing, then $f \times g: X_1 \times Y_1 \to X_2 \times Y_2$ is also distance decreasing for all the three metrics.

(ii) $\pi_1,\pi_2$ are distance decreasing for all of the metrics; but $X \xrightarrow{(1,1)} X \times X$ is only distance decreasing for the $d_\infty$ metric, so it's the only possible one. Then it's straight-forward to verify that it works: if $f:Z \to X$ and $g:Z \to Y$ are dd, then so is $f(f,g):Z \to X \times Y$ for $d_\infty$.

(iii) If $(-) \times X$ has a right adjoint $(-)^X$, then points of $Y^X$ must correspond to dd maps $1 \times X \cong X \to Y$.\\
We have a metric on this set given by $d(f,g)=\sup_{x \in X} d(f(x),g(x))$. Then, given a map $f:Z \times X \to Y$, $f$ is dd for $d_1$ iff $\bar{f}:Z \to Y^X$ is dd for this metric, since
\begin{equation*}
\begin{aligned}
d(f(z_1,x_1),f(z_2,x_2)) &\leq d(f(z_1,x_1),f(z_1,x_2)) + d(f(z_1,x_2),d(f(z_2,x_2)))\\
&\leq d(x_1,x_2)+d(\bar{f}(z_2))\\
&\leq d(x_1,x_2)+d(z_1,z_2)
\end{aligned}
\end{equation*}

The other two do not have right adjoints, but lecturer forgot how to prove that (he vaguely rememebered that it was some fancy combinatorial argument on a finite metric space). The important point is that we know the result, and hence we don't get a Cartesian closed category.

\subsection{Question 3}
(i)

\begin{tikzcd}
A_1 \times A_2 \arrow[rdd, "f_1 \times f_2", shift left] \arrow[rdd, "g_1 \times g_2"', shift right] & A_1 \times B_2 \arrow[dd,"f_1 \times 1"', shift right] \arrow[dd,"g_1 \times 1", shift left] \arrow[r, "1_{A_1} \times h_2"] & A_1 \times C_2 \arrow[dd, "f_1 \times 1"', shift right] \arrow[dd, "g_1 \times 1", shift left] &\\
& & &\\
B_1 \times A_2 \arrow[uu,"r_1 \times 1_{A_2}"] \arrow[r,"1 \times f_2", shift left] \arrow[r,"1 \times g_2"', shift right] & B_1 \times B_2 \arrow[r,"1 \times h_2"] \arrow[rd, "h_1 \times h_2"'] \arrow[rrdd, green, bend right=40, "x"'] & B_1 \times C_2 \arrow[d,"h_1 \times 1_{C_2}"] \arrow[rdd, green, bend left=40, "y"] &\\
& & C_1 \times C_2 \arrow[rd,green,"z"] &\\
& & & \textcolor{green}{Z}
\end{tikzcd}

Given $x:B_1 \times B_2 \to Z$ with $x(f_1 \times f_2) = x(g_1 \times g_2)$, we have $x(1 \times f_2) = x(1 \times g_2)$.\\
So we get $y:B_1 \times C_2 \to Z$ with $y(1 \times h_2) = x$.\\
Similarly, $x(f_1\times 1_{B_2}) = x(g_1 \times 1_{B_2})$, so $y(f_1 \times 1_{C_2})(1_{A_1} \times h_2) = y(g_1 \times 1)(1 \times h_2)$.\\
But $(1_{A_1} \times h_2)$ is epic, so $y$ factors as $z(h_1 \times 1_{C_2})$.

Suppose given a reflexive pair of monoid homomorphisms $A \stackrel[g]{f}{\rightrightarrows} B$ in $\mathbf{Mon}(\mathcal{C})$, with coequalizer $B \xrightarrow{h} C$ in $\mathcal{C}$. Then we have

\begin{tikzcd}
A \times A \arrow[r,"f \times f", shift left] \arrow[r, "g \times g"', shift right] \arrow[d, "m_A"] & B \times B \arrow[r,"h \times h"] \arrow[d,"m_B"] & C \times C \arrow[d,dashed, "m_C"]\\
A \arrow[r,shift left, "f"] \arrow[r, shift right, "g"'] & B \arrow[r,"h"] & C
\end{tikzcd}

and we get a unique $m_C:C \times C \to C$ s.t. $m_C(h \times h) = hm_B$ and we define $e_C:1 \to C$ to be $he_B$.\\
Associativity of $m$ asserts the equality of $C \times C \times C \stackrel[m(m \times 1)]{m(1 \times m)}{\rightrightarrows} C$, but these have equal composites $b^3 \stackrel{h^3}{\twoheadrightarrow} C^3$.\\
Similarly for the unit laws.\\
So $C$ is a monoid and $h$ is a monoid homomorphism, and it's a coequalizer in $\mathbf{Mon}(\mathcal{C})$.

(ii) Let $MA = \sum_{n \in \N} A^n$ (where $A^0 = 1, A^{n+1} = (A \times A^n)$).\\
Then $MA \times MA \cong \sum_{p,q \in \N} A^p \times A^q$ since $B \times (-)$ preserves coproducts.\\
Define $m:MA \times MA \to MA$ by

\begin{tikzcd}
A^p \times A^q \arrow[r,"\simeq"] \arrow[d,"\nu_{p,q}"] & A^{p+q} \arrow[d,"\nu_{p+q}"]\\
MA \times MA \arrow[r,"m"] & MA
\end{tikzcd}

for all $p,q$. Set $e = \nu_0:1 \to MA$. $m$ is associative, since the two isomorphisms

\begin{tikzcd}
A^p \times (A^q \times A^r) \arrow[r] \arrow[d,"\simeq"] & A^{p+q+r}\\
(A^p \times A^q) \times A^r \arrow[ur] &
\end{tikzcd}

are equal.\\
We take $\eta: A \to MA$ to be $A \cong A \times 1 \xrightarrow{\nu_1} MA$. If $B$ is the underlying object of a monoid, we get well-defined multiplications $B^p \to B$ for all $p$, and hence a map $MB \xrightarrow{\varepsilon_B} B$, ... (some more verifications)

\subsection{Question 4}
(i) It is sufficient to show that
$$colim_{\mathcal{C}}(F \times \triangle A) \to colim_{\mathcal{C}} F \times A$$
is iso. But $A \cong \sum_{a \in A} 1$, so $\triangle A \cong \sum_{a \in A} 1$ in $[\mathcal{C},\mathbf{Set}]$. So $F \times \triangle A \cong \sum_{a \in A} F$ since $[\mathcal{C},\mathbf{Set}]$ is cc.\\
So $colim_{\mathcal{C}}(F \times \triangle A) \cong \sum_{a \in A} colim_{\mathcal{C}} (F) \cong colim_{\mathcal{C}} (F) \times A$.

(ii) We have
\begin{equation*}
\begin{aligned}
\mathcal{C}(-,B)^{\mathcal{C}(-,A)} (C) &\cong [\mathcal{C}^{op}, \mathbf{Set}](\mathcal{C}(-,C) \times \mathcal{C}(-,A),\mathcal{C}(-,B))\\
&\cong [\mathcal{C}^{op},\mathbf{Set}](\mathcal{C}(-,C \times A),\mathcal{C}(-,B))\\
&\cong \mathcal{C}(C \times A,B) \text{ by Yoneda}\\
&\cong \mathcal{C}(C,B^A)\\
&=\mathcal{C}(-,B^A)(C)
\end{aligned}
\end{equation*}

So $\mathcal{C}(-,B)^{\mathcal{C}(-,A)} \cong \mathcal{C}(-,B^A)$.

\subsection{Question 5}
(i) Suppose $(-) \times (A \times B) \cong (- \times A) \times B$, we have $(-)^{A \times} \cong ((-)^B)^A$. So $A,B$ tiny $\implies A \times B$ tiny, and $(-)^1 \cong 1_\mathcal{C}$, so $1$ is tiny.

(ii) Given $F:\mathcal{C}^{op} \to \mathbf{Set}$
\begin{equation*}
\begin{aligned}
F^{\mathcal{C}(-,A)}(B) &\cong [\mathcal{C}^{op},\mathbf{Set}](\mathcal{C}(-,B) \times \mathcal{C}(-,A),F)\\
&\cong [\mathcal{C}^{op},\mathbf{Set}](\mathcal{C}(-,B \times A), F) \cong F(B \times A)
\end{aligned}
\end{equation*}
So $F^{\mathcal{C}(-,A)} \cong F(- \times A)$, so $(-)^{\mathcal{C}(-,A)} \cong (- \times A)^*: [\mathcal{C}^{op},\mathbf{Set}] \to [\mathcal{C}^{op},\mathbf{Set}]$.\\
By Sheet 2 q9(ii) we know it has a right adjoint.

(iii) First show $f$ is irreducible projective iff $[\mathcal{C}^{op},\mathbf{Set}](F,-)$ preserves both coproducts and epimorphisms (in fact, all colimits, but those are enough).\\
$[\mathcal{C}^{op},\mathbf{Set}](F,-)$ preserves coproducts iff every $F \to \sum_{i \in I} G$ factors through just one $G_j \xrightarrow{\nu_j} \sum_{i \in I} G_i$.\\
If this holds and $f$ is projective, and we're given $\sum_{i \in I} G_i \stackrel{e}{\twoheadrightarrow} F$, we have a splitting which factors through some $\nu_j$, so $e\nu_j$ is epic.

Conversely, if $f$ is irreducible, and we're given $F \xrightarrow{f} \sum_{i \in I} G_i$, form the pullbacks

\begin{tikzcd}
F_j \arrow[r] \arrow[d,tail] & G_j \arrow[d,tail,"\nu_j"]\\
F \arrow[r,"f"] & \sum_{i \in I} G_i
\end{tikzcd}

Then $\sum_{j \in J} F_j \to F$ is iso, so some $F_j \to F$ is iso, so $f$ factors through some $\nu_j$.

But $[\mathcal{C}^{op},\mathbf{Set}](F,-)$ is the composite

\begin{tikzcd}
{[\mathcal{C}^{op},\mathbf{Set}]} \arrow[r,"(-)^F"] & {[\mathcal{C}^{op},\mathbf{Set}]} \arrow[rr,"{[\mathcal{C}^{op},\mathbf{Set}](1,-)}"] & & \mathbf{Set}
\end{tikzcd}

and $F$ tiny, $1$ representable imply both factors preserve coproducts and epimorphisms.

Now we know

$F$ representable $\implies$($\mathcal{C}$ has products) $F$ tiny $\implies$ ($\mathcal{C}$ has terminal objects) $F$ irreducible projective $\implies$ ($\mathcal{C}$ Cauchy complete) $F$ representable.

Hence if $\mathcal{C}$ has all the three properties, then $[\mathcal{C}^{op},\mathbf{Set}]_t \simeq \{$ representable functors $\mathcal{C}^{op} \to \mathbf{Set}\} \simeq \mathcal{C}$.

Note that $A^{(-)}$ is a functor $\mathcal{E}^{op} \to \mathcal{E}$ in any ccc $\mathcal{E}$: given $B_1 \xrightarrow{g} B_2$, we get $A^{B_2} \to A^{B_1}$ as the transpose of $A^{B_2} \times B_1 \xrightarrow{1 \times g} A^{B_2} \times B_2 \xrightarrow{ev} A$.

Similarly, if we write $(-)_B$ for the right adjoint of $(-)^B$, $A_{(-)}$ becomes a functor $\mathcal{E}_t \to \mathcal{E}$. So if $B$ is tiny and $e:B \to B$ is idempotent with splitting $B \to x \to B$, we get $(-)^C$ as the splitting of $(-)^B \to (-)^B$, and $(-)_C$ as the splitting of $(-)_B \to (-)_B$.

\subsection{Question 6}
 Suppose given
\begin{tikzcd}
G \arrow[d,"\alpha"]\\
F
\end{tikzcd}
in $[\mathcal{C},\mathbf{Set}]/F$. Define $\Phi(G):\mathcal{F} \to \mathbf{Set}$ by $\Phi(G)(A,x) = \alpha_A^{-1} (x) \subseteq GA$, and $\Phi(G)((A,x) \xrightarrow{f} (B,y)) = Gf|_{\alpha_A^{-1}(x)}$.

$\Phi$ is functorial: given

\begin{tikzcd}
G \arrow[rr, "\gamma"] \arrow[rd, "\alpha"'] & & H \arrow[ld, "\beta"]\\
& F &
\end{tikzcd}
, $\Phi(r)_(A,x) = \gamma_A |_{\alpha_A^{-1}(x)}$.

Given $H:\mathcal{F} \to \mathbf{Set}$, define $\Psi(H):\mathcal{C} \to \mathbf{Set}$ by $\Psi(H)(A) = \coprod_{x \in FA} H(A,x)$ equipped with $\pi:\coprod_{x \in FA} H(A,x) \to FA$.\\
Similarly show $\Psi$ is a functor $[\mathcal{F},\mathbf{Set}] \to [\mathcal{C},\mathbf{Set}]/F$, and $\Phi\Psi,\Psi\Phi$ are both isomorphic to identity.

\subsection{Question 7}
(i) Suppose given $\Omega \stackrel{f}{\rightarrowtail} \Omega$ in a topos. Form the pullback
\begin{tikzcd}
U \arrow[r,tail] \arrow[d,tail,"g"] & 1 \arrow[d,tail,"\top"]\\
\Omega \arrow[r,tail,"f"] & \Omega
\end{tikzcd}
and
\begin{tikzcd}
V \arrow[r] \arrow[d,tail] & 1 \arrow[d,"\top"]\\
U \arrow[r,"g"] & \Omega
\end{tikzcd}
, and consider

\begin{tikzcd}
V \arrow[r,"1"] \arrow[d] & V \arrow[r] \arrow[d] & U \arrow[r,"u"] \arrow[d,"g"] & 1 \arrow[d,"\top"]\\
U \arrow[r,"u"] & 1 \arrow[r,"\top"] &\Omega \arrow[r,"f"] & \Omega
\end{tikzcd}

This is a pullback, so $f\top u = g$ and hence $ff\top u = fg = \top u$.

Now
\begin{tikzcd}
U \arrow[r] \arrow[d,"g",tail] & U \arrow[r] \arrow[d,"g",tail] & 1 \arrow[d,"\top"]\\
\Omega \arrow[r,"ff"] & \Omega \arrow[r,"f"] & \Omega
\end{tikzcd}

($ffg=f\top u = g$). The left square is a pullback since $ff$ is monic, so $fff=f$, so $ff=1_\Omega$.

(ii) In $[\N, \mathbf{Set}]$, $\Omega$ looks like

\begin{tikzcd}
\Omega(0) \arrow[r] & \Omega(1) \arrow[r] & \Omega(2) \arrow[r] & ...\\
0 \arrow[r] & 1 \arrow[r] & 2 & \\
1 \arrow[ru] & 2 \arrow[ru] & 3 & \\
2 \arrow[ru] & 3 \arrow[ru] & &\\
3 \arrow[ru] & & &\\
... & & &\\
\phi \arrow[r] & \phi \arrow[r] & \phi \arrow[r] & ...
\end{tikzcd}

The map $n \to \max\{n-1,m\}$, $\phi \to \phi$, $\Omega(m) \to \Omega(m)$ defines an epimorphism $\Omega \twoheadrightarrow \Omega$ which isn't mono.

\subsection{Question 8}

Given a $G$-set $A$, consider $A_C = \{a \in A | stab_G (a)$ is open $\}$.

This is a union of $G$-orbits, since $\exists$ is closed under conjugation, and so a continuous $G$-set.

Given $f:B \to A$ in $[G,\mathbf{Set}]$, we have $stab_G(b) \subseteq stab_G(f(b))$ for any $b \in B$. So if $B$ is continuous then $f$ takes values in $A_C$.

Given $A$ and $B$, $stab_G((a,b)) = stab_G(a) \cap stab_G(b)$, so $A,B$ continuous $\to$ $A \times B$ continuous; and any sub-$G$-set of a continuous $G$-set is continuous, so $\mathbf{Cont}(G)$ is closed under equalizers.

Given continuous $G$-sets $A,B,C$, morphisms $C \times A \to B$ in $\mathbf{Cont}(G)$ corresponds to morphisms $C \to B^A$ in $[G,\mathbf{Set}]$, and hence to morphisms $C \to (B^A)_C$ in $\mathbf{Cont}(G)$.

The $\Omega$ of $[t,\mathbf{Set}]$ has continuous $G$-action, and it is a subobject classifier in $\mathbf{Cont}(G)$.

If $A,B$ are uniform continuous $G$-sets, then $A \times B$ and $B^A$ are both aced on trivially by $H \cap K$, where $H$ acts trivially on $A$ and $K$ on $B$.

Also, arbitrary subobjects of uniform continuous $G$-sets are uniform continuous, and $\Omega$ is uniform continuous.

$Unif(\Z)$ consists of $\Z$-sets acted on trivially by $n\Z$ for some $n$.\\
Let $c_n$ be a single $\Z$-orbit of size $n$.\\
For any $n$, there exists a family of morphisms $\{C_m \to C_n \sqcup 1 | m \in \N\}$ whose $n$th member is injective, so if $\sum_{m \in \N} C_m$ existed, each $\nu_n:C_n \to \sum C_n$ need to be injective. Hence $\sum_{m \in \N} C_m$ can't be uniform continuous.

\subsection{Question 9}
(i) $\implies$ (ii),(iii),(iv) since $\mathcal{E}/B \xrightarrow{\Sigma_B} \mathcal{E}$ is faithful and preserves connected limits (somewhere on sheet 2).\\
(iv) $\implies$ (iii) by Sheet 2 q5(iii).\\
(iii) $\implies$ (ii) We have bijections $Sub_{\mathcal{F}}(A) \cong \mathcal{F}(A,\Omega_F) \cong \mathcal{E}(LA,\Omega_\mathcal{E}) \cong Sub_\mathcal{E}(LA)$, since

\begin{tikzcd}
LA' \arrow[r] \arrow[tail,d] & LF1 \arrow[r,"\varepsilon"] \arrow[d,"LF(T)"] & 1 \arrow[d,"\top"]\\
LA \arrow[r] & LF\Omega \arrow[r,"\varepsilon"] & \Omega
\end{tikzcd}

commutes, $LA'$ is contained in the subobject corresponding to $A'$ under this bijection.\\
So $A' \rightarrowtail A$ proper $\implies$ $LA' \rightarrowtail LA$ proper.

Hence if $A \stackrel[g]{f}{\rightrightarrows} B$ satisfies $f \neq g$, we get $Lf \neq Lg$.

(ii) $\implies$ (i) We can factor $L$ as $\mathcal{F} \xrightarrow{\hat{L}} \mathcal{E}/L1 \xrightarrow{\Sigma_{L1}} \mathcal{E}$.\\
$\hat{L}$ has a right adjoint $\hat{F}$ sending
\begin{tikzcd}
A \arrow[d,"g"]\\
L1
\end{tikzcd}
to the pullback
\begin{tikzcd}
\hat{F}g \arrow[r] \arrow[d] & FA \arrow[d,"Fg"]\\
1 \arrow[r,"\eta_1"] & FL1
\end{tikzcd}

$\hat{F}$ is the composite
\begin{tikzcd}
\mathcal{E}/L1 \arrow[r,"F/L1"] & \mathcal{F}/FL1 \arrow[r,"\eta_1^*"] & \mathcal{F}
\end{tikzcd}
, so it's logical.\\
$\hat{L}$ is faithful since $L$ is, and it preserves $1$.\\
So by Frobenius reciprocity,

\begin{tikzcd}
\hat{L}(\hat{F}A \times 1) \arrow[r] \arrow[d,"\cong"] & A \times \hat{L} 1 \arrow[d,"\cong"]\\
\hat{L}\hat{F} A \arrow[r,"\varepsilon_A"] & A
\end{tikzcd}
is iso, i.e. the counit of $(\hat{L}+\hat{F})$ is iso.\\
$\hat{L}$ reflects isos since $\mathcal{F}$ is balanced, and
\begin{tikzcd}
\hat{L} \arrow[r,"\hat{L}\eta"] \arrow[rd,"1"'] & \hat{L}\hat{F}\hat{L} \arrow[d,"\varepsilon_{\hat{L}}"]\\
& L
\end{tikzcd}
commutes, so $\hat{L} \eta$ is iso, so $\eta$ is iso.

\subsection{Question 10}
Lecturer does not have time to go through this, but it's not that difficult, and it's quite an important result in sheaf theory.

\end{document}