140 lines
No EOL
7.3 KiB
TeX
140 lines
No EOL
7.3 KiB
TeX
\chapter{Constructions}
|
|
\section{CPO}
|
|
Recall that $FI \iso I$ for the initial F-algebra $I$, our goal is to construct initial F-algebras as least fixpoints.
|
|
Consider for example the faculty function which is defined by the recursive equation
|
|
\[fac\;n := \mathrm{if}\; n=0\; \mathrm{then}\; 1 \;\mathrm{else}\; n \cdot fac(n-1).\]
|
|
$fac : \mathbb{N} \to \mathbb{N}$ is the \emph{solution} of the previous equation or equivalently the fixpoint of the function $\varphi : \Par(\mathbb{N},\mathbb{N}) \to \Par(\mathbb{N},\mathbb{N})$ defined by
|
|
\[\varphi\;f\;n := \mathrm{if}\; n=0\; \mathrm{then}\; 1 \;\mathrm{else}\; n \cdot f(n-1).\]
|
|
Thus, $fac$ should satisfy $fac = \varphi(fac)$, which is obtained by iteration of $\varphi$:
|
|
\begin{center}
|
|
\begin{tabular}{l l l l l}
|
|
& 0 & 1 & 2 & \ldots \\\midrule
|
|
$\bot$ & & & & \\
|
|
$\varphi(\bot)$ & 1 & & & \\
|
|
$\varphi(\varphi(\bot))$ & 1 & 1 & & \\
|
|
$\varphi(\varphi(\varphi(\bot)))$ & 1 & 1 & 2 & \\
|
|
$\ldots$ & & & &
|
|
\end{tabular}
|
|
\end{center}
|
|
|
|
Since $\Par(\mathbb{N},\mathbb{N})$ admits a poset structure where $f \sqsubseteq g$ iff $\dom f \subseteq \dom g$ and $\forall x \in \dom f. fx = gx$, we can view $fac$ as the supremum of the ascending chain
|
|
\[\bot \sqsubseteq \phi(\bot) \sqsubseteq \phi(\phi(\bot)) \sqsubseteq \ldots.\]
|
|
|
|
\begin{definition}[Complete Partial Order]
|
|
A \emph{complete partial order} (\emph{CPO}) is a poset $(X, \sqsubseteq)$ with
|
|
\begin{enumerate}
|
|
\item the smallest element $\bot$,
|
|
\item suprema for infinite chains:
|
|
\[x_0 \sqsubseteq x_1 \sqsubseteq x_2 \sqsubseteq \ldots.\]
|
|
\end{enumerate}
|
|
We denote the supremum of such chains as $\bigsqcup_i x_i$.
|
|
\end{definition}
|
|
|
|
\begin{example} Examples of CPOs include:
|
|
\begin{enumerate}
|
|
\item Every set $X$ yields a CPO $(\PSet X, \subseteq)$, where the smallest element is $\emptyset$ and the supremum of chains is the big union.
|
|
\item For any $X,Y$ we get a CPO $(\Par(X,Y), \sqsubseteq)$, defined as above. The supremum of a chain $(f_i)$ is defined by
|
|
\[ \dom (\bigsqcup_i f_i) = \bigcup_i \dom f_i; \qquad (\bigsqcup_i f_i)(x) = f_i(x), \text{ for a suitable (big enough) } i. \]
|
|
\item Every set $X$ yields a CPO $(X_\bot, \sqsubseteq)$, where $X_\bot = X \cup \{ \bot \}$ and $x \sqsubseteq y$ iff $x=y$ or $x = \bot$. This is called the \emph{flat CPO}.
|
|
\end{enumerate}
|
|
\end{example}
|
|
|
|
\begin{definition}[Continuous Function]
|
|
A function $\phi : (X, \sqsubseteq) \to (X', \sqsubseteq')$ is called \emph{continuous} if
|
|
\begin{itemize}
|
|
\item $\phi$ is monotonous, i.e.\ $x \sqsubseteq y \Rightarrow \phi(x) \sqsubseteq' \phi(y)$,
|
|
\item $\phi$ preserves suprema of chains, i.e.\ $\phi(\bigsqcup x_i) = \bigsqcup' \phi(x_i)$.
|
|
\end{itemize}
|
|
\end{definition}
|
|
\begin{example}
|
|
The aforementioned $\phi : \Par(\mathbb{N}, \mathbb{N})$ with $\phi\;f\;n = \ite{n=0}{1}{n \cdot f(n-1)}$ is continuous.
|
|
% TODO proof
|
|
\end{example}
|
|
|
|
\begin{theorem}[Kleene's Fixpoint Theorem]
|
|
Let $(X, \sqsubseteq)$ be a CPO and let $\phi : X \to X$ be continuous.
|
|
The least fixpoint of $\phi$ is
|
|
\[\mu\phi = \bigsqcup_i\phi^i(\bot).\]
|
|
\end{theorem}
|
|
\begin{proof}
|
|
$\mu\phi$ is a fixpoint, since
|
|
\[\phi(\mu\phi) = \phi (\bigsqcup_i \phi^i(\bot)) = \bigsqcup_i \phi^{i+1}(\bot) = \bigsqcup_i \phi^i(\bot) = \mu\phi.\]
|
|
To show that it is the least fixpoint, consider another fixpoint $\phi(x) = x$. To show that $\mu\phi \sqsubseteq x$ it suffices to show that $\phi^i(\bot) \sqsubseteq x$ for all $i \in \mathbb{N}$, which indeed follows by induction:
|
|
\begin{mycase}
|
|
\case{} $i=0$
|
|
\[\
|
|
\phi^0(\bot) = \bot \sqsubseteq x\]
|
|
\case{} $i = n+1$\\
|
|
The induction hypothesis $\phi^n \sqsubseteq x$ directly implies \[\phi^{n+1}(\bot) \sqsubseteq \phi(x) = x\] by monotonicity of $\phi$.
|
|
|
|
\end{mycase}
|
|
\end{proof}
|
|
|
|
In the next section we will generalize this result categorically to obtain a construction for initial F-algebras.
|
|
|
|
\section{Initial Algebra Construction}
|
|
Consider a cocomplete category $\CC$, $\CC$ has similarities to a CPO, since it has
|
|
\begin{itemize}
|
|
\item an initial object $0 \overset{\cobang_A}{\longrightarrow} A$,
|
|
\item colimits of every $\omega$-chain of morphisms (i.e.\ diagrams $D : (\mathbb{N}, \leq) \to \CC$):
|
|
% https://q.uiver.app/#q=WzAsNSxbMCwwLCJBXzAiXSxbMiwwLCJBXzEiXSxbNCwwLCJBXzIiXSxbNiwwLCJcXGxkb3RzIl0sWzIsMiwiQyJdLFswLDQsIlxcaW90YV8wIiwyLHsiY3VydmUiOjJ9XSxbMSw0LCJcXGlvdGFfMSJdLFsyLDQsIlxcaW90YV8yIiwwLHsiY3VydmUiOi0yfV0sWzMsNCwiXFxsZG90cyIsMCx7ImN1cnZlIjotM31dLFswLDEsImFfezAsMX0iXSxbMSwyLCJhX3sxLDJ9Il0sWzIsMywiXFxsZG90cyJdXQ==
|
|
\[\begin{tikzcd}
|
|
{A_0} && {A_1} && {A_2} && \ldots \\
|
|
\\
|
|
&& C
|
|
\arrow["{\iota_0}"', curve={height=12pt}, from=1-1, to=3-3]
|
|
\arrow["{\iota_1}", from=1-3, to=3-3]
|
|
\arrow["{\iota_2}", curve={height=-12pt}, from=1-5, to=3-3]
|
|
\arrow["\ldots", curve={height=-18pt}, from=1-7, to=3-3]
|
|
\arrow["{a_{0,1}}", from=1-1, to=1-3]
|
|
\arrow["{a_{1,2}}", from=1-3, to=1-5]
|
|
\arrow["\ldots", from=1-5, to=1-7]
|
|
\end{tikzcd}\]
|
|
\end{itemize}
|
|
|
|
\begin{definition}[$\omega$-cocontinuity]
|
|
A functor $F : \CC \to \CC$ is called \emph{$\omega$-cocontinuous} if $F$ preserves colimits of $\omega$-chains, i.e.\ if for every diagram $D: (\mathbb{N},\leq) \to \CC$:
|
|
\[F(\oname{colim} D) \iso \oname{colim}(FD).\]
|
|
More concretely, if for every colimit $(C, \iota)$ of $D$, the cone $(FC, F\iota)$ is the colimit of $FD$.
|
|
\end{definition}
|
|
|
|
\begin{definition}[Finitary Functor]
|
|
A functor $F : \Set \to \Set$ is called \emph{finitary} if for every $X$ and $x \in FX$ there exists a finite surjective map $m : Y \to X$ and $y \in FY$ such that $x = F\;m\;y$.
|
|
\end{definition}
|
|
|
|
\begin{theorem}
|
|
Finitary functors are $\omega$-cocontinuous.
|
|
\end{theorem}
|
|
|
|
\begin{lemma}\label{lem:finclosed}
|
|
Finitary functors are closed under
|
|
\begin{enumerate}
|
|
\item finite products,
|
|
\item coproducts,
|
|
\item and composition.
|
|
\end{enumerate}
|
|
\end{lemma}
|
|
|
|
A consequence of \autoref{lem:finclosed} is that for any signature $\Sigma$, the functor
|
|
\[F_\Sigma X = \coprod_{\sigma \in \Sigma} X^{ar(\sigma)}\]
|
|
is finitary.
|
|
|
|
\begin{theorem}
|
|
Let $\CC$ be cocomplete and $F : \CC \to \CC$ $\sigma$-cocontinuous. Then $F$ has the initial algebra $I = \oname{colim}_{n\in\mathbb{N}} F^n 0$.
|
|
More concretely $I$ is the colimit of the $\omega$-chain:
|
|
% https://q.uiver.app/#q=WzAsNSxbMCwwLCIwIl0sWzIsMCwiRjAiXSxbNCwwLCJGRjAiXSxbNiwwLCJcXGxkb3RzIl0sWzIsMiwiXFxtdSBGIl0sWzAsMSwiaSJdLFsxLDIsIkZpIl0sWzIsMywiXFxsZG90cyJdLFswLDQsIlxcaW90YV8wIiwyLHsiY3VydmUiOjJ9XSxbMSw0LCJcXGlvdGFfMSIsMl0sWzIsNCwiXFxpb3RhXzIiLDIseyJjdXJ2ZSI6LTN9XSxbMyw0LCJcXGxkb3RzIiwwLHsiY3VydmUiOi0zfV1d
|
|
\[\begin{tikzcd}
|
|
0 && F0 && FF0 && \ldots \\
|
|
\\
|
|
&& {I}
|
|
\arrow["i", from=1-1, to=1-3]
|
|
\arrow["Fi", from=1-3, to=1-5]
|
|
\arrow["\ldots", from=1-5, to=1-7]
|
|
\arrow["{\iota_0}"', curve={height=12pt}, from=1-1, to=3-3]
|
|
\arrow["{\iota_1}"', from=1-3, to=3-3]
|
|
\arrow["{\iota_2}"', curve={height=-18pt}, from=1-5, to=3-3]
|
|
\arrow["\ldots", curve={height=-18pt}, from=1-7, to=3-3]
|
|
\end{tikzcd}\]
|
|
\end{theorem}
|
|
|
|
\section{Terminal Coalgebra Construction} |