%! TEX root = CT.tex
% vim: tw=50
% 20/11/2024 09AM

\newpage
\section{Filtered Colimits}

\begin{fcdefn}[Filtered]
  \label{defn:6.1}
  \glsadjdefn{filted}{filtered}{\gls{cat}}%
  % Definition 6.1
  We say a \gls{cat} $\mathcal{C}$ is
  \emph{filtered} if every finite \gls{diag} $D :
  J \to \mathcal{C}$ has a \gls{cone} under it.
\end{fcdefn}

\begin{lemma}[]
  \label{lemma:6.2}
  % Lemma 6.2
  \cloze{$\mathcal{C}$ is \gls{filted}} if and only if:
  \begin{cenum}[(i)]
    \item $\mathcal{C}$ is nonempty.
    \item Given $A, B \in \ob \mathcal{C}$, there
      exists a \gls{cospan} $A \to C \leftarrow
      B$.
    \item Given $A \twofuncs fg B$ in
      $\mathcal{C}$, there exists $B
      \stackrel{h}{\to} C$ with $hf = hg$.
  \end{cenum}
\end{lemma}

\begin{iffproof}
  \rightimpl
  Since each of (i) - (iii) is a special case of
  \cref{defn:6.1}.
  \leftimpl
  (i) deals with the empty \gls{diag}.

  Given $D : J \to \mathcal{C}$ with $J$ finite
  and non-empty, by repeated use of (ii) we can
  find $A$ with morphisms $D(j) \to A$ for all
  $j$. Then by repeated use of (ii) we can find $A
  \to B$ \glsref[coequaler]{coequalising}
  \begin{picmath}
    \begin{tikzcd}
      & D(j') \ar[dr] \\
      D(j) \ar[ur, "D(\alpha)"] \ar[rr]
      &
      & A
    \end{tikzcd}
  \end{picmath}
  for each $\alpha \in \mor J$.
\end{iffproof}

\glsadjdefn{dired}{directed}{preorder}%
For preorders, we say \emph{directed} instead of
\gls{filted}.

\begin{fcdefn}[Has filtered colimits]
  \glsadjdefn{hfc}{has filtered
  colimits}{\gls{cat}}%
  \label{defn:6.3}
  % Definition 6.3
  We say \emph{$\mathcal{C}$ has filtered
  colimits} if every $D : J \to \mathcal{C}$,
  where $J$ is \gls{small} and \gls{filted}, has a
  colimit.
\end{fcdefn}

Note that \glspl{dirlim} as in \cref{eg:4.3}(g)
are \gls{dired} \glspl{colim}.

\begin{fclemma}[]
  \label{lemma:6.4}
  % Lemma 6.4
  Assuming:
  - $\mathcal{C}$ has finite \glspl{colim}
  - $\mathcal{C}$ has \gls{dired} \glspl{colim}
  Then:
  $\mathcal{C}$ has all \gls{small} \glspl{colim}.
\end{fclemma}

\begin{proof}
  By \cref{prop:4.4}(i), enough to show
  $\mathcal{C}$ has all \gls{small} \glspl{coprod}.

  Given a set-indexeud family $(A_j \mid j \in J)$
  of objects, the finite \glspl{coprod} $\sum_{j
  \in F} A_j$, for $F \subseteq J$ finite, form
  the vertices of a diagram of shape $P_f J = \{F
  \subseteq J \mid F \text{finite}\}$ whose edges
  are coprojections. $P_f J$ is \gls{dired}, and a
  \gls{colim} for this \gls{diag} has the
  universal property of a \gls{coprod} $\sum_{j
  \in J} A_j$.
\end{proof}

Suppose given a $D : I \times J \to \mathcal{C}$,
where $\mathcal{C}$ has \glspl{lim} of shape $I$
and \glspl{colim} of shape $J$.
\begin{picmath}
  \begin{tikzcd}
    L(j) \ar[dd] \ar[ddd, bend right=45]
    \ar[r, "L(\beta)"]
    & L(j') \ar[dd] \ar[ddd, bend left=45]
    \ar[r]
    & \colim_J L \ar[rd] \\
    &
    &
    & \lim_I M \ar[d] \ar[dd, bend left=30]
    \\
    D(i, j) \ar[r, "D(i{,} \beta)"]
    \ar[d, "D(\alpha{,} j)"]
    \ar[rrr, bend left=30]
    & D(i, j') \ar[d, "D(\alpha{,} j')", swap]
    \ar[rr]
    &
    & M(i) \ar[d, "M(\alpha)", swap] \\
    D(i', j) \ar[r, "D(i'{,} \beta)"]
    \ar[rrr, bend right=30]
    & D(i', j') \ar[rr]
    &
    & M(i')
  \end{tikzcd}
\end{picmath}
We can form $L(j) = \lim_I (D(\bullet, j) : I \to
\mathcal{C})$, by \cref{eg:4.7}(e) these are the
\glspl{vert} of a \gls{diag} $L : J \to
\mathcal{C}$, and we can form $\colim_J L$.

\glsadjdefn{lcomm}{commute}{\glspl{lim}}%
Similarly, the \glspl{colim} $M(i) = \colim_J D(i,
\bullet)$ form a \gls{diag} of shape $I$, and we can
form $\lim_I M$. We get an induced morphism
$\colim_J L \to \lim_I M$; if this is an
isomorphism for all $D : I \times J \to
\mathcal{C}$, we say \glspl{colim} of shape $J$
\emph{commute with} \glspl{lim} of shape $I$ in
$\mathcal{C}$.

Equivalently, $\colim_J : \funccat[J, \mathcal{C}]
\to \mathcal{C}$ \gls{preses} \glspl{lim} of shape
$I$, or $\lim_I : \funccat[I, \mathcal{C}] \to
\mathcal{C}$ \gls{preses} \glspl{colim} of shape
$J$.

In \cref{remark:5.13}(d) we saw that \gls{pprefl}
\glspl{coequaler} commute with finite products in
$\Set$.

\begin{fcthm}[]
  \label{thm:6.5}
  % Theorem 6.5
  Assuming:
  - $J$ a \gls{small} \gls{cat}
  Then:
  \begin{iffc}
    \lhs
    \glspl{colim} of shape $J$ \gls{lcomm} with
    all finite \glspl{lim} in $\Set$
    \rhs
    $J$ is \gls{filted}.
  \end{iffc}
\end{fcthm}

\begin{iffproof}
  \rightimpl
  Let $D : I \to J$ be a \gls{diag} with $I$
  finite. We have a \gls{diag} $E : I^\op \times J
  \to \Set$ defined by $E(i, j) = J(D(i), j)$.

  For each $i$, $(\colim_J E)(i)$ is a singleton
  since every $D(i) \to j$ is identified with
  $\identity{D(i)}$ in the \gls{colim}, so $\lim_I
  \colim_J E$ is a singleton.

  But elements of $\lim_I E(\bullet, j)$ are
  \glspl{cone} under $D$ with apex $j$, so if
  $\colim_J \lim_I E$ is nonempty there must be
  such a \gls{cone} for some $j$.

  \leftimpl
  Suppose given $D : I \times J \to \Set$ where
  $I$ is finite and $J$ is \gls{filted}. In
  general, the \gls{colim}of $E : J \to \Set$ is
  the quotient of $\coprod_{j \in \ob J} E(j)$ by
  the smallest equivalence relation identifying $x
  \in E(j)$ with $D(\alpha)(x) \in E(j')$ for all
  $\alpha : j \to j'$ in $J$. For \gls{filted}
  $J$, this identifies $x \in E(j)$ with $x' \in
  E(j')$ if and only if there exists $j
  \stackrel{\alpha}{\to} j''
  \stackrel{\alpha'}{\leftarrow} j'$ with
  $E(\alpha)(x) = E(\alpha')(x')$, and moreover if
  $j = j'$ we may assume $\alpha = \alpha'$.

  Now, given an element $x$ of $\lim_I \colim_J
  D$, we can write it as $(x_i \mid i \in \ob I)$
  where $x_i \in \colim_J D(i, \bullet)$ is an
  equivalence class of elements $x_{ij} \in D(i,
  j)$.
  If $\alpha : i \to i'$ in $I$, then $D(\alpha,
  j)(x_ij)$ and $x_{i'j'}$ represent the same
  element of $\colim_J D(i', \bullet)$ so by
  repeated use of \cref{lemma:6.2}(ii) we can
  choose representatives in $D(i, j_0)$ for some
  fixed $j_0$, and by repeated use of
  \cref{lemma:6.2}(iii) we can assume that these
  representatives define an element of $\lim_I
  D(\bullet, j_0)$.
  This defines an element of $\colim_J \lim_I D$
  mapping to the given element of $\lim_I \colim_J
  D$.

  The proof of injectivity is similar: if two
  elements $x, y$ of $\colim_J \lim_I D$ have the
  same image in $\lim_I \colim_J D$ we can choose
  representatives $x_j, y_j$ in $\lim_I D(\bullet,
  j)$ and then find $j \to j'$ so that each of the
  components $x_{ij}$ and $y_{ij}$ map to the same
  element of $D(i, j')$ under $j \to j'$. So $x =
  y$ in $\colim_J \lim_I D$.
\end{iffproof}

% \begin{corollary}
%   \label{coro:6.6}
%   % Corollary 6.6
%   If $\mathcal{C}$ is a \gls{cat} of finitary
%   algebras as in \cref{eg:5.14}(a), then
%   \begin{enumerate}[(i)]
%     \item The forgetful \gls{func} $\mathcal{C}
%       \to \Set$ \gls{creates} \gls{filted}
%       \glspl{colim}.
%     \item \glsref[filted]{Filtered} \glspl{colim}
%       \gls{lcomm} with finite \glspl{lim} in
%       $\mathcal{C}$.
%   \end{enumerate}
% \end{corollary}
