mirror of
https://git8.cs.fau.de/theses/bsc-leon-vatthauer.git
synced 2024-05-31 07:28:34 +02:00
Finish proofs in chapter 4 and apply some chktex hints
This commit is contained in:
parent
75a6789d18
commit
5e3600d29c
9 changed files with 1085 additions and 1126 deletions
2
thesis/.chktexrc
Normal file
2
thesis/.chktexrc
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
# Exclude these environments from syntax checking
|
||||||
|
VerbEnvir { tikzcd }
|
|
@ -4,9 +4,9 @@ imgpdf = $(wildcard img/*.pdf)
|
||||||
|
|
||||||
.PHONY: all clean
|
.PHONY: all clean
|
||||||
|
|
||||||
all: $(pdf) $(imgpdf)
|
all: \((pdf) \)(imgpdf)
|
||||||
|
|
||||||
%.pdf: %.tex $(wildcard src/*.tex) $(wildcard *.bib) $(imgpdf)
|
%.pdf: %.tex \((wildcard src/*.tex) \)(wildcard *.bib) $(imgpdf)
|
||||||
latexmk -pdf -xelatex -shell-escape -file-line-error -synctex=1 -halt-on-error -shell-escape $<
|
latexmk -pdf -xelatex -shell-escape -file-line-error -synctex=1 -halt-on-error -shell-escape $<
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
|
|
|
@ -165,19 +165,19 @@
|
||||||
\input{src/titlepage}%
|
\input{src/titlepage}%
|
||||||
\chapter*{Disclaimer}
|
\chapter*{Disclaimer}
|
||||||
\begin{german}
|
\begin{german}
|
||||||
Ich versichere, dass ich die Arbeit ohne fremde Hilfe und ohne Benutzung anderer als der angegebenen Quellen angefertigt habe und dass die Arbeit in gleicher oder ähnlicher Form noch keiner anderen Prüfungsbehörde vorgelegen hat und von dieser als Teil einer Prüfungsleistung angenommen wurde.
|
Ich versichere, dass ich die Arbeit ohne fremde Hilfe und ohne Benutzung anderer als der angegebenen Quellen angefertigt habe und dass die Arbeit in gleicher oder ähnlicher Form noch keiner anderen Prüfungsbehörde vorgelegen hat und von dieser als Teil einer Prüfungsleistung angenommen wurde.
|
||||||
Alle Ausführungen, die wörtlich oder sinngemäß übernommen wurden, sind als solche gekennzeichnet.
|
Alle Ausführungen, die wörtlich oder sinngemäß übernommen wurden, sind als solche gekennzeichnet.
|
||||||
|
|
||||||
\vspace{5em}
|
\vspace{5em}
|
||||||
Erlangen, \today{} \rule{7cm}{1pt}\\
|
Erlangen, \today{} \rule{7cm}{1pt}\\
|
||||||
\phantom{Erlangen, \today{}} \theauthor{}
|
\phantom{Erlangen, \today{}} \theauthor{}
|
||||||
\end{german}
|
\end{german}
|
||||||
|
|
||||||
\chapter*{Licensing}
|
\chapter*{Licensing}
|
||||||
\doclicenseThis{}
|
\doclicenseThis{}
|
||||||
\tableofcontents
|
\tableofcontents
|
||||||
|
|
||||||
\listoftodos
|
\listoftodos\
|
||||||
|
|
||||||
\newcommandx{\unsure}[2][1=]{\todo[inline,linecolor=red,backgroundcolor=red!25,bordercolor=red,#1]{#2}}
|
\newcommandx{\unsure}[2][1=]{\todo[inline,linecolor=red,backgroundcolor=red!25,bordercolor=red,#1]{#2}}
|
||||||
\newcommandx{\change}[2][1=]{\todo[linecolor=blue,backgroundcolor=blue!25,bordercolor=blue,#1]{#2}}
|
\newcommandx{\change}[2][1=]{\todo[linecolor=blue,backgroundcolor=blue!25,bordercolor=blue,#1]{#2}}
|
||||||
|
@ -219,5 +219,3 @@ Erlangen, \today{} \rule{7cm}{1pt}\\
|
||||||
\renewcommand*{\listtheoremname}{List of Definitions}
|
\renewcommand*{\listtheoremname}{List of Definitions}
|
||||||
\listoftheorems[ignoreall,show={definition}]
|
\listoftheorems[ignoreall,show={definition}]
|
||||||
\end{document}
|
\end{document}
|
||||||
|
|
||||||
% vim: tw=80 nospell spelllang=en nocul
|
|
||||||
|
|
|
@ -1,16 +1,17 @@
|
||||||
\chapter{Preliminaries}
|
\chapter{Preliminaries}
|
||||||
|
|
||||||
We assume familiarity with basic categorical notions, in particular: categories, functors, functor algebras and natural transformations, as well as special objects like (co-)products, terminal and initial objects and special morphisms like isos, epis and monos.
|
We assume familiarity with basic categorical notions, in particular: categories, functors, functor algebras and natural transformations, as well as special objects like (co-) products, terminal and initial objects and special morphisms like isos, epis and monos.
|
||||||
In this chapter we will introduce notation that will be used throughout the thesis and also introduce some notions that are crucial to this thesis in more detail.
|
In this chapter we will introduce notation that will be used throughout the thesis and also introduce some notions that are crucial to this thesis in more detail.
|
||||||
We write $\obj{C}$ for the objects of a category $\C$, $id_X$ for the identity morphism on $X$, $(-) \circ (-)$ for the composition of morphisms and $\C(X,Y)$ for the set of morphisms between $X$ and $Y$.
|
We write \(\obj{C}\) for the objects of a category \( \C \), \(id_X\) for the identity morphism on \(X\), \((-) \circ (-)\) for the composition of morphisms and \(\C(X,Y)\) for the set of morphisms between \(X\) and \(Y\).
|
||||||
We will also sometimes omit indices of the identity and of natural transformations in favor of readability.
|
We will also sometimes omit indices of the identity and of natural transformations in favor of readability.
|
||||||
|
|
||||||
\section{Distributive and Cartesian Closed Categories}
|
\section{Distributive and Cartesian Closed Categories}
|
||||||
Let us first introduce notation for binary (co-) products by giving their usual diagrams:
|
Let us first introduce notation for binary (co-) products by giving their usual diagrams:
|
||||||
|
|
||||||
\begin{figure}[ht]
|
\begin{figure}[ht]
|
||||||
% https://q.uiver.app/#q=WzAsOCxbMiwwLCJBIFxcdGltZXMgQiJdLFswLDAsIkEiXSxbNCwwLCJCIl0sWzIsMiwiQyJdLFs4LDAsIkEgKyBCIl0sWzYsMCwiQSJdLFsxMCwwLCJCIl0sWzgsMiwiQyJdLFswLDEsIlxccGlfMSIsMl0sWzAsMiwiXFxwaV8yIl0sWzMsMiwiZyIsMl0sWzMsMSwiZiJdLFszLDAsIlxcZXhpc3RzISBcXGxhbmdsZSBmICwgZyBcXHJhbmdsZSIsMix7InN0eWxlIjp7ImJvZHkiOnsibmFtZSI6ImRhc2hlZCJ9fX1dLFs1LDQsImlfMSJdLFs2LDQsImlfMiIsMl0sWzUsNywiZiIsMl0sWzYsNywiZyJdLFs0LDcsIlxcZXhpc3RzICEgW2YgLCBnXSIsMV1d
|
% https://q.uiver.app/#q=WzAsOCxbMiwwLCJBIFxcdGltZXMgQiJdLFswLDAsIkEiXSxbNCwwLCJCIl0sWzIsMiwiQyJdLFs4LDAsIkEgKyBCIl0sWzYsMCwiQSJdLFsxMCwwLCJCIl0sWzgsMiwiQyJdLFswLDEsIlxccGlfMSIsMl0sWzAsMiwiXFxwaV8yIl0sWzMsMiwiZyIsMl0sWzMsMSwiZiJdLFszLDAsIlxcZXhpc3RzISBcXGxhbmdsZSBmICwgZyBcXHJhbmdsZSIsMix7InN0eWxlIjp7ImJvZHkiOnsibmFtZSI6ImRhc2hlZCJ9fX1dLFs1LDQsImlfMSJdLFs2LDQsImlfMiIsMl0sWzUsNywiZiIsMl0sWzYsNywiZyJdLFs0LDcsIlxcZXhpc3RzICEgW2YgLCBnXSIsMV1d
|
||||||
\[\begin{tikzcd}
|
\[
|
||||||
|
\begin{tikzcd}
|
||||||
A && {A \times B} && B && A && {A + B} && B \\
|
A && {A \times B} && B && A && {A + B} && B \\
|
||||||
\\
|
\\
|
||||||
&& C &&&&&& C
|
&& C &&&&&& C
|
||||||
|
@ -24,47 +25,53 @@ Let us first introduce notation for binary (co-) products by giving their usual
|
||||||
\arrow["f"', from=1-7, to=3-9]
|
\arrow["f"', from=1-7, to=3-9]
|
||||||
\arrow["g", from=1-11, to=3-9]
|
\arrow["g", from=1-11, to=3-9]
|
||||||
\arrow["{\exists ! [f , g]}", dashed, from=1-9, to=3-9]
|
\arrow["{\exists ! [f , g]}", dashed, from=1-9, to=3-9]
|
||||||
\end{tikzcd}\]
|
\end{tikzcd}
|
||||||
\caption{The defining diagrams of products and coproducts}
|
\]
|
||||||
|
\caption{The defining diagrams of products and coproducts}
|
||||||
\end{figure}
|
\end{figure}
|
||||||
|
|
||||||
We will furthermore overload this notation and write $f \times g := \langle f \circ \pi_1 , g \circ \pi_2 \rangle$ and $f + g := \lbrack i_1 \circ f , i_2 \circ g \rbrack$ on morphisms. To avoid parentheses we will use the convention that products bind stronger than coproducts.
|
We will furthermore overload this notation and write \(f \times g := \langle f \circ \pi_1 , g \circ \pi_2 \rangle \) and \(f + g := \lbrack i_1 \circ f , i_2 \circ g \rbrack \) on morphisms. To avoid parentheses we will use the convention that products bind stronger than coproducts.
|
||||||
|
|
||||||
We write $1$ for the terminal object together with the unique morphism $! : A \rightarrow 1$ and $0$ for the initial object with the unique morphism $\text{!`} : A \rightarrow 0$.
|
We write \(1\) for the terminal object together with the unique morphism \(! : A \rightarrow 1\) and \(0\) for the initial object with the unique morphism \(¡ : A \rightarrow 0\).
|
||||||
|
|
||||||
Categories with finite products (i.e.\ binary products and a terminal object) are also called cartesian and categories with finite coproducts (i.e. binary coproducts and an initial object) are called cocartesian.
|
Categories with finite products (i.e.\ binary products and a terminal object) are also called cartesian and categories with finite coproducts (i.e.\ binary coproducts and an initial object) are called cocartesian.
|
||||||
|
|
||||||
\begin{definition}[Distributive Category]~\label{def:distributive}
|
\begin{definition}[Distributive Category]~\label{def:distributive}
|
||||||
A cartesian and cocartesian category $\C$ is called distributive if the canonical (left) distributivity morphism $dstl^{-1}$ is an iso:
|
A cartesian and cocartesian category \(\C \) is called distributive if the canonical (left) distributivity morphism \(dstl^{-1}\) is an iso:
|
||||||
% https://q.uiver.app/#q=WzAsMixbMCwwLCJYIFxcdGltZXMgWSArIFggXFx0aW1lcyBaIl0sWzMsMCwiWCBcXHRpbWVzIChZICsgWikiXSxbMCwxLCJkc3RsXnstMX0gOj0ge1xcbGJyYWNrIGlkIFxcdGltZXMgaV8xICwgaWQgXFx0aW1lcyBpXzIgXFxyYnJhY2t9IiwwLHsiY3VydmUiOi0zfV0sWzEsMCwiZHN0bCIsMCx7ImN1cnZlIjotM31dXQ==
|
% https://q.uiver.app/#q=WzAsMixbMCwwLCJYIFxcdGltZXMgWSArIFggXFx0aW1lcyBaIl0sWzMsMCwiWCBcXHRpbWVzIChZICsgWikiXSxbMCwxLCJkc3RsXnstMX0gOj0ge1xcbGJyYWNrIGlkIFxcdGltZXMgaV8xICwgaWQgXFx0aW1lcyBpXzIgXFxyYnJhY2t9IiwwLHsiY3VydmUiOi0zfV0sWzEsMCwiZHN0bCIsMCx7ImN1cnZlIjotM31dXQ==
|
||||||
\[\begin{tikzcd}
|
\[
|
||||||
|
\begin{tikzcd}
|
||||||
{X \times Y + X \times Z} &&& {X \times (Y + Z)}
|
{X \times Y + X \times Z} &&& {X \times (Y + Z)}
|
||||||
\arrow["{dstl^{-1} := {\lbrack id \times i_1 , id \times i_2 \rbrack}}", curve={height=-18pt}, from=1-1, to=1-4]
|
\arrow["{dstl^{-1} := {\lbrack id \times i_1 , id \times i_2 \rbrack}}", curve={height=-18pt}, from=1-1, to=1-4]
|
||||||
\arrow["dstl", curve={height=-18pt}, from=1-4, to=1-1]
|
\arrow["dstl", curve={height=-18pt}, from=1-4, to=1-1]
|
||||||
\end{tikzcd}\]
|
\end{tikzcd}
|
||||||
|
\]
|
||||||
|
|
||||||
\end{definition}
|
\end{definition}
|
||||||
|
|
||||||
\begin{remark}
|
\begin{remark}
|
||||||
Definition~\ref{def:distributive} can equivalently be expressed by requiring that the canonical (right) distributivity morphism is an iso, giving these inverse morphisms:
|
Definition~\ref{def:distributive} can equivalently be expressed by requiring that the canonical (right) distributivity morphism is an iso, giving these inverse morphisms:
|
||||||
% https://q.uiver.app/#q=WzAsMixbMCwwLCJZIFxcdGltZXMgWCArIFpcXHRpbWVzIFgiXSxbMywwLCIoWSArIFopIFxcdGltZXMgWCJdLFswLDEsImRzdHJeey0xfSA6PSBbIGlfMSBcXHRpbWVzIGlkICwgaV8yIFxcdGltZXMgaWQgXSIsMCx7ImN1cnZlIjotM31dLFsxLDAsImRzdHIiLDAseyJjdXJ2ZSI6LTN9XV0=
|
% https://q.uiver.app/#q=WzAsMixbMCwwLCJZIFxcdGltZXMgWCArIFpcXHRpbWVzIFgiXSxbMywwLCIoWSArIFopIFxcdGltZXMgWCJdLFswLDEsImRzdHJeey0xfSA6PSBbIGlfMSBcXHRpbWVzIGlkICwgaV8yIFxcdGltZXMgaWQgXSIsMCx7ImN1cnZlIjotM31dLFsxLDAsImRzdHIiLDAseyJjdXJ2ZSI6LTN9XV0=
|
||||||
\[\begin{tikzcd}
|
\[
|
||||||
|
\begin{tikzcd}
|
||||||
{Y \times X + Z\times X} &&& {(Y + Z) \times X}
|
{Y \times X + Z\times X} &&& {(Y + Z) \times X}
|
||||||
\arrow["{dstr^{-1} := [ i_1 \times id , i_2 \times id ]}", curve={height=-18pt}, from=1-1, to=1-4]
|
\arrow["{dstr^{-1} := [ i_1 \times id , i_2 \times id ]}", curve={height=-18pt}, from=1-1, to=1-4]
|
||||||
\arrow["dstr", curve={height=-18pt}, from=1-4, to=1-1]
|
\arrow["dstr", curve={height=-18pt}, from=1-4, to=1-1]
|
||||||
\end{tikzcd}\]
|
\end{tikzcd}
|
||||||
|
\]
|
||||||
|
|
||||||
These two can be derived from each other by taking either
|
These two can be derived from each other by taking either
|
||||||
\[dstr := (swap + swap) \circ dstl \circ swap \]
|
\[dstr := (swap + swap) \circ dstl \circ swap \]
|
||||||
or
|
or
|
||||||
\[dstl := (swap + swap) \circ dstr \circ swap \]
|
\[dstl := (swap + swap) \circ dstr \circ swap \]
|
||||||
where $swap := \langle \pi_2 , \pi_1 \rangle : A \times B \rightarrow B \times A$.
|
where \(swap := \langle \pi_2 , \pi_1 \rangle : A \times B \rightarrow B \times A\).
|
||||||
\end{remark}
|
\end{remark}
|
||||||
|
|
||||||
\begin{proposition}
|
\begin{proposition}
|
||||||
The distribution morphisms can be viewed as natural transformations i.e.\ they satisfy the following diagrams:
|
The distribution morphisms can be viewed as natural transformations i.e.\ they satisfy the following diagrams:
|
||||||
% https://q.uiver.app/#q=WzAsOCxbMCwwLCJYIFxcdGltZXMgKFkgK1opIl0sWzIsMCwiQSBcXHRpbWVzIChCICsgQykiXSxbMCwxLCJYIFxcdGltZXMgWSArIFggXFx0aW1lcyBaIl0sWzIsMSwiQSBcXHRpbWVzIEIgKyBBIFxcdGltZXMgQyJdLFszLDAsIihZICsgWikgXFx0aW1lcyBYIl0sWzUsMCwiKEIgKyBDKSBcXHRpbWVzIEEiXSxbMywxLCJZIFxcdGltZXMgWCArIFogXFx0aW1lcyBYIl0sWzUsMSwiQiBcXHRpbWVzIEEgKyBDIFxcdGltZXMgQSJdLFswLDEsImYgXFx0aW1lcyAoZyArIGgpIl0sWzIsMywiZiBcXHRpbWVzIGcgKyBmIFxcdGltZXMgaCJdLFswLDIsImRzdGwiXSxbMSwzLCJkc3RsIl0sWzQsNSwiKGcgKyBoKSBcXHRpbWVzIGYiXSxbNCw2LCJkc3RyIiwyXSxbNSw3LCJkc3RyIl0sWzYsNywiZyBcXHRpbWVzIGYgKyBoIFxcdGltZXMgZiJdXQ==
|
% https://q.uiver.app/#q=WzAsOCxbMCwwLCJYIFxcdGltZXMgKFkgK1opIl0sWzIsMCwiQSBcXHRpbWVzIChCICsgQykiXSxbMCwxLCJYIFxcdGltZXMgWSArIFggXFx0aW1lcyBaIl0sWzIsMSwiQSBcXHRpbWVzIEIgKyBBIFxcdGltZXMgQyJdLFszLDAsIihZICsgWikgXFx0aW1lcyBYIl0sWzUsMCwiKEIgKyBDKSBcXHRpbWVzIEEiXSxbMywxLCJZIFxcdGltZXMgWCArIFogXFx0aW1lcyBYIl0sWzUsMSwiQiBcXHRpbWVzIEEgKyBDIFxcdGltZXMgQSJdLFswLDEsImYgXFx0aW1lcyAoZyArIGgpIl0sWzIsMywiZiBcXHRpbWVzIGcgKyBmIFxcdGltZXMgaCJdLFswLDIsImRzdGwiXSxbMSwzLCJkc3RsIl0sWzQsNSwiKGcgKyBoKSBcXHRpbWVzIGYiXSxbNCw2LCJkc3RyIiwyXSxbNSw3LCJkc3RyIl0sWzYsNywiZyBcXHRpbWVzIGYgKyBoIFxcdGltZXMgZiJdXQ==
|
||||||
\[\begin{tikzcd}[column sep=4ex]
|
\[
|
||||||
|
\begin{tikzcd}[column sep=4ex]
|
||||||
{X \times (Y +Z)} && {A \times (B + C)} & {(Y + Z) \times X} && {(B + C) \times A} \\
|
{X \times (Y +Z)} && {A \times (B + C)} & {(Y + Z) \times X} && {(B + C) \times A} \\
|
||||||
{X \times Y + X \times Z} && {A \times B + A \times C} & {Y \times X + Z \times X} && {B \times A + C \times A}
|
{X \times Y + X \times Z} && {A \times B + A \times C} & {Y \times X + Z \times X} && {B \times A + C \times A}
|
||||||
\arrow["{f \times (g + h)}", from=1-1, to=1-3]
|
\arrow["{f \times (g + h)}", from=1-1, to=1-3]
|
||||||
|
@ -75,20 +82,21 @@ Categories with finite products (i.e.\ binary products and a terminal object) ar
|
||||||
\arrow["dstr"', from=1-4, to=2-4]
|
\arrow["dstr"', from=1-4, to=2-4]
|
||||||
\arrow["dstr", from=1-6, to=2-6]
|
\arrow["dstr", from=1-6, to=2-6]
|
||||||
\arrow["{g \times f + h \times f}", from=2-4, to=2-6]
|
\arrow["{g \times f + h \times f}", from=2-4, to=2-6]
|
||||||
\end{tikzcd}\]
|
\end{tikzcd}
|
||||||
|
\]
|
||||||
\end{proposition}
|
\end{proposition}
|
||||||
\begin{proof}
|
\begin{proof}
|
||||||
We will prove naturality of $dstl$, naturality for $dstr$ is symmetric. We use the fact that $dstl^{-1}$ is an iso and therefore also an epi.
|
We will prove naturality of \(dstl\), naturality for \(dstr\) is symmetric. We use the fact that \(dstl^{-1}\) is an iso and therefore also an epi.
|
||||||
|
|
||||||
\begin{alignat*}{1}
|
\begin{alignat*}{1}
|
||||||
&dstl \circ (f \times (g + h)) \circ dstl^{-1}\\
|
& dstl \circ (f \times (g + h)) \circ dstl^{-1} \\
|
||||||
=\;&dstl \circ (f \times (g + h)) \circ \lbrack id \times i_1 , id \times i_2 \rbrack\\
|
=\; & dstl \circ (f \times (g + h)) \circ \lbrack id \times i_1 , id \times i_2 \rbrack \\
|
||||||
=\;&dstl \circ \lbrack f \times ((g + h) \circ i_1) , f \times ((g + h) \circ i_2) \rbrack\\
|
=\; & dstl \circ \lbrack f \times ((g + h) \circ i_1) , f \times ((g + h) \circ i_2) \rbrack \\
|
||||||
=\;&dstl \circ \lbrack f \times (i_1 \circ g) , f \times (i_2 \circ h) \rbrack\\
|
=\; & dstl \circ \lbrack f \times (i_1 \circ g) , f \times (i_2 \circ h) \rbrack \\
|
||||||
=\;&dstl \circ \lbrack id \times i_1 , id \times i_2 \rbrack \circ (f \times g + f \times h)\\
|
=\; & dstl \circ \lbrack id \times i_1 , id \times i_2 \rbrack \circ (f \times g + f \times h) \\
|
||||||
=\;&dstl \circ dstl^{-1} \circ (f \times g + f \times h)\\
|
=\; & dstl \circ dstl^{-1} \circ (f \times g + f \times h) \\
|
||||||
=\;&(f \times g + f \times h)\\
|
=\; & (f \times g + f \times h) \\
|
||||||
=\;&(f \times g + f \times h) \circ dstl \circ dstl^{-1}
|
=\; & (f \times g + f \times h) \circ dstl \circ dstl^{-1}
|
||||||
\end{alignat*}
|
\end{alignat*}
|
||||||
\end{proof}
|
\end{proof}
|
||||||
|
|
||||||
|
@ -96,56 +104,56 @@ Categories with finite products (i.e.\ binary products and a terminal object) ar
|
||||||
The distribution morphisms satisfy the following properties:
|
The distribution morphisms satisfy the following properties:
|
||||||
|
|
||||||
\begin{enumerate}
|
\begin{enumerate}
|
||||||
\item $dstl \circ (id \times i_1) = i_1$
|
\item \(dstl \circ (id \times i_1) = i_1\)
|
||||||
\item $dstl \circ (id \times i_2) = i_2$
|
\item \(dstl \circ (id \times i_2) = i_2\)
|
||||||
\item $[ \pi_1 , \pi_1 ] \circ dstl = \pi_1$
|
\item \([ \pi_1 , \pi_1 ] \circ dstl = \pi_1\)
|
||||||
\item $( \pi_2 + \pi_2 ) \circ dstl = \pi_2$
|
\item \(( \pi_2 + \pi_2 ) \circ dstl = \pi_2\)
|
||||||
\item $dstl \circ swap = (swap + swap) \circ dstr$
|
\item \(dstl \circ swap = (swap + swap) \circ dstr\)
|
||||||
\item $dstr \circ (i_1 \times id) = i_1$
|
\item \(dstr \circ (i_1 \times id) = i_1\)
|
||||||
\item $dstr \circ (i_2 \times id) = i_2$
|
\item \(dstr \circ (i_2 \times id) = i_2\)
|
||||||
\item $(\pi_1 + \pi_1) \circ dstr = \pi_1$
|
\item \((\pi_1 + \pi_1) \circ dstr = \pi_1\)
|
||||||
\item $[ \pi_2 , \pi_2 ] \circ dstr = \pi_2$
|
\item \([ \pi_2 , \pi_2 ] \circ dstr = \pi_2\)
|
||||||
\item $dstr \circ swap = (swap + swap) \circ dstl$
|
\item \(dstr \circ swap = (swap + swap) \circ dstl\)
|
||||||
\end{enumerate}
|
\end{enumerate}
|
||||||
\end{proposition}
|
\end{proposition}
|
||||||
\begin{proof}
|
\begin{proof}
|
||||||
Let us verify the five properties concerning $dstl$, the ones concerning $dstr$ follow symmetrically:
|
Let us verify the five properties concerning \(dstl\), the ones concerning \(dstr\) follow symmetrically:
|
||||||
|
|
||||||
\begin{enumerate}
|
\begin{enumerate}
|
||||||
\item
|
\item
|
||||||
\begin{alignat*}{1}
|
\begin{alignat*}{1}
|
||||||
&dstl \circ (id \times i_1)
|
& dstl \circ (id \times i_1)
|
||||||
\\=\;&dstl \circ [ id \times i_1 , id \times i_2 ] \circ i_1
|
\\=\;&dstl \circ [ id \times i_1 , id \times i_2 ] \circ i_1
|
||||||
\\=\;&dstl \circ dstl^{-1} \circ i_1
|
\\=\;&dstl \circ dstl^{-1} \circ i_1
|
||||||
\\=\;&i_1
|
\\=\;&i_1
|
||||||
\end{alignat*}
|
\end{alignat*}
|
||||||
\item
|
\item
|
||||||
\begin{alignat*}{1}
|
\begin{alignat*}{1}
|
||||||
&dstl \circ (id \times i_2)
|
& dstl \circ (id \times i_2)
|
||||||
\\=\;&dstl \circ [ id \times i_1 , id \times i_2 ] \circ i_2
|
\\=\;&dstl \circ [ id \times i_1 , id \times i_2 ] \circ i_2
|
||||||
\\=\;&dstl \circ dstl^{-1} \circ i_2
|
\\=\;&dstl \circ dstl^{-1} \circ i_2
|
||||||
\\=\;&i_2
|
\\=\;&i_2
|
||||||
\end{alignat*}
|
\end{alignat*}
|
||||||
\item
|
\item
|
||||||
\begin{alignat*}{1}
|
\begin{alignat*}{1}
|
||||||
&\pi_1
|
& \pi_1
|
||||||
\\=\;&\pi_1 \circ dstl^{-1} \circ dstl
|
\\=\;&\pi_1 \circ dstl^{-1} \circ dstl
|
||||||
\\=\;&[ \pi_1 \circ (id \times i_1) , \pi_1 \circ (id \times i_2) ] \circ dstl
|
\\=\;&[ \pi_1 \circ (id \times i_1) , \pi_1 \circ (id \times i_2) ] \circ dstl
|
||||||
\\=\;&[ \pi_1 , \pi_1 ] \circ dstl
|
\\=\;&[ \pi_1 , \pi_1 ] \circ dstl
|
||||||
\end{alignat*}
|
\end{alignat*}
|
||||||
\item
|
\item
|
||||||
\begin{alignat*}{1}
|
\begin{alignat*}{1}
|
||||||
&\pi_2
|
& \pi_2
|
||||||
\\=\;&\pi_2 \circ dstl^{-1} \circ dstl
|
\\=\;&\pi_2 \circ dstl^{-1} \circ dstl
|
||||||
\\=\;&[ \pi_2 \circ (id \times i_1) , \pi_2 \circ (id \times i_2) ] \circ dstl
|
\\=\;&[ \pi_2 \circ (id \times i_1) , \pi_2 \circ (id \times i_2) ] \circ dstl
|
||||||
\\=\;&(\pi_2 + \pi_2) \circ dstl
|
\\=\;&(\pi_2 + \pi_2) \circ dstl
|
||||||
\end{alignat*}
|
\end{alignat*}
|
||||||
\item
|
\item
|
||||||
\begin{alignat*}{1}
|
\begin{alignat*}{1}
|
||||||
&dstl \circ swap
|
& dstl \circ swap
|
||||||
\\=\;&dstl \circ swap \circ dstr^{-1} \circ dstr
|
\\=\;&dstl \circ swap \circ dstr^{-1} \circ dstr
|
||||||
\\=\;&dstl \circ [ swap \circ (i_1 \times id) , swap \circ (i_2 \times id) ] \circ dstr
|
\\=\;&dstl \circ [ swap \circ (i_1 \times id) , swap \circ (i_2 \times id) ] \circ dstr
|
||||||
\\=\;&dstl \circ [ (id \times i_1) \circ swap , (id \times i_2) \circ swap) ] \circ dstr
|
\\=\;&dstl \circ [ (id \times i_1) \circ swap , (id \times i_2) \circ swap ] \circ dstr
|
||||||
\\=\;&dstl \circ [ id \times i_1 , id \times i_2 ] \circ (swap + swap) \circ dstr
|
\\=\;&dstl \circ [ id \times i_1 , id \times i_2 ] \circ (swap + swap) \circ dstr
|
||||||
\\=\;&dstl \circ dstl^{-1} \circ (swap + swap) \circ dstr
|
\\=\;&dstl \circ dstl^{-1} \circ (swap + swap) \circ dstr
|
||||||
\\=\;&(swap + swap) \circ dstr
|
\\=\;&(swap + swap) \circ dstr
|
||||||
|
@ -154,33 +162,38 @@ Categories with finite products (i.e.\ binary products and a terminal object) ar
|
||||||
\end{proof}
|
\end{proof}
|
||||||
|
|
||||||
\begin{definition}[Exponential Object]
|
\begin{definition}[Exponential Object]
|
||||||
Let $\C$ be a cartesian category and $X , Y \in \vert \C \vert$.
|
Let \(\C \) be a cartesian category and \(X , Y \in \vert \C \vert \).
|
||||||
An object $X^Y$ is called an exponential object (of $X$ and $Y$) if there exists an evaluation morphism $eval : X^Y \times Y \rightarrow X$ and for any $f : X \times Y \rightarrow Z$ there exists a morphism $curry\; f : X \rightarrow Z^Y$ that is unique with respect to the following diagram:
|
An object \(X^Y\) is called an exponential object (of \(X\) and \(Y\)) if there exists an evaluation morphism \(eval : X^Y \times Y \rightarrow X\) and for any \(f : X \times Y \rightarrow Z\) there exists a morphism \(curry\; f : X \rightarrow Z^Y\) that is unique with respect to the following diagram:
|
||||||
% https://q.uiver.app/#q=WzAsMyxbMCwwLCJaIFxcdGltZXMgWSJdLFsyLDAsIlheWSBcXHRpbWVzIFkiXSxbMiwyLCJYIl0sWzEsMiwiZXZhbCJdLFswLDEsImN1cnJ5XFw7ZiBcXHRpbWVzIGlkIl0sWzAsMiwiZiIsMl1d
|
% https://q.uiver.app/#q=WzAsMyxbMCwwLCJaIFxcdGltZXMgWSJdLFsyLDAsIlheWSBcXHRpbWVzIFkiXSxbMiwyLCJYIl0sWzEsMiwiZXZhbCJdLFswLDEsImN1cnJ5XFw7ZiBcXHRpbWVzIGlkIl0sWzAsMiwiZiIsMl1d
|
||||||
\[\begin{tikzcd}
|
\[
|
||||||
|
\begin{tikzcd}
|
||||||
{Z \times Y} && {X^Y \times Y} \\
|
{Z \times Y} && {X^Y \times Y} \\
|
||||||
\\
|
\\
|
||||||
&& X
|
&& X
|
||||||
\arrow["eval", from=1-3, to=3-3]
|
\arrow["eval", from=1-3, to=3-3]
|
||||||
\arrow["{curry\;f \times id}", from=1-1, to=1-3]
|
\arrow["{curry\;f \times id}", from=1-1, to=1-3]
|
||||||
\arrow["f"', from=1-1, to=3-3]
|
\arrow["f"', from=1-1, to=3-3]
|
||||||
\end{tikzcd}\]
|
\end{tikzcd}
|
||||||
|
\]
|
||||||
\end{definition}
|
\end{definition}
|
||||||
|
|
||||||
A cartesian closed category is a cartesian category $\C$ that also has an exponential object $X^Y$ for any $X, Y \in \C$.
|
\todo[inline]{Properties of exponentials, \(\beta, \eta, \ldots \)}
|
||||||
The internal logic of cartesian closed categories is the simply typed $\lambda$-calculus, which makes them a suitable target for interpreting programming languages. For the rest of this thesis we will work in an ambient distributive category that however does not have to be cartesian closed as to be more general.
|
|
||||||
|
A cartesian closed category is a cartesian category \(\C \) that also has an exponential object \(X^Y\) for any \(X, Y \in \C \).
|
||||||
|
The internal logic of cartesian closed categories is the simply typed \(\lambda \)-calculus, which makes them a suitable target for interpreting programming languages. For the rest of this thesis we will work in an ambient distributive category that however does not have to be cartesian closed as to be more general.
|
||||||
|
|
||||||
\section{F-Coalgebras}
|
\section{F-Coalgebras}
|
||||||
Let $F : \C \rightarrow \C$ be an endofunctor. Recall that F-algebras are tuples $(X, \alpha : FX \rightarrow X)$ consisting of an object of $\C$ and a morphism out of the functor. Initial F-algebras have been studied extensively as a means of modelling inductive data types together with induction and recursion principles~\cite{inductive}. For this thesis we will be more interested in the dual concept namely terminal coalgebras; let us formally introduce them now.
|
Let \(F : \C \rightarrow \C \) be an endofunctor. Recall that F-algebras are tuples \((X, \alpha : FX \rightarrow X)\) consisting of an object of \(\C \) and a morphism out of the functor. Initial F-algebras have been studied extensively as a means of modelling inductive data types together with induction and recursion principles~\cite{inductive}. For this thesis we will be more interested in the dual concept namely terminal coalgebras; let us formally introduce them now.
|
||||||
|
|
||||||
\begin{definition}[F-Coalgebra]
|
\begin{definition}[F-Coalgebra]
|
||||||
A tuple $(X \in \obj{\C}, \alpha : X \rightarrow FX)$ is called an F-coalgebra.
|
A tuple \((X \in \obj{\C}, \alpha : X \rightarrow FX)\) is called an F-coalgebra.
|
||||||
\end{definition}
|
\end{definition}
|
||||||
|
|
||||||
\begin{definition}[Morphisms between Coalgebras]\label{def:coalgmorph}
|
\begin{definition}[Morphisms between Coalgebras]\label{def:coalgmorph}
|
||||||
Let $(X \in \obj{\C} , \alpha : X \rightarrow FX)$ and $(Y \in \obj{\C} , \beta : Y \rightarrow FY)$ be two F-coalgebras. A morphism between these coalgebras is a morphism $f : X \rightarrow Y$ such that the following diagram commutes:
|
Let \((X \in \obj{\C} , \alpha : X \rightarrow FX)\) and \((Y \in \obj{\C} , \beta : Y \rightarrow FY)\) be two F-coalgebras. A morphism between these coalgebras is a morphism \(f : X \rightarrow Y\) such that the following diagram commutes:
|
||||||
% https://q.uiver.app/#q=WzAsNCxbMCwwLCJYIl0sWzAsMiwiWSJdLFsyLDAsIkZYIl0sWzIsMiwiRlkiXSxbMSwzLCJcXGJldGEiXSxbMCwyLCJcXGFscGhhIl0sWzAsMSwiZiIsMl0sWzIsMywiRmYiXV0=
|
% https://q.uiver.app/#q=WzAsNCxbMCwwLCJYIl0sWzAsMiwiWSJdLFsyLDAsIkZYIl0sWzIsMiwiRlkiXSxbMSwzLCJcXGJldGEiXSxbMCwyLCJcXGFscGhhIl0sWzAsMSwiZiIsMl0sWzIsMywiRmYiXV0=
|
||||||
\[\begin{tikzcd}[ampersand replacement=\&]
|
\[
|
||||||
|
\begin{tikzcd}[ampersand replacement=\&]
|
||||||
X \&\& FX \\
|
X \&\& FX \\
|
||||||
\\
|
\\
|
||||||
Y \&\& FY
|
Y \&\& FY
|
||||||
|
@ -188,35 +201,37 @@ Let $F : \C \rightarrow \C$ be an endofunctor. Recall that F-algebras are tuples
|
||||||
\arrow["\alpha", from=1-1, to=1-3]
|
\arrow["\alpha", from=1-1, to=1-3]
|
||||||
\arrow["f"', from=1-1, to=3-1]
|
\arrow["f"', from=1-1, to=3-1]
|
||||||
\arrow["Ff", from=1-3, to=3-3]
|
\arrow["Ff", from=1-3, to=3-3]
|
||||||
\end{tikzcd}\]
|
\end{tikzcd}
|
||||||
|
\]
|
||||||
|
|
||||||
\end{definition}
|
\end{definition}
|
||||||
|
|
||||||
\todo[inline]{Adopt text, lemma style}
|
\todo[inline]{Adopt text, lemma style}
|
||||||
|
|
||||||
\begin{proposition}
|
\begin{proposition}
|
||||||
F-coalgebras together with their morphisms form a category that we call $Coalg(F)$.
|
F-coalgebras together with their morphisms form a category that we call \(Coalg(F)\).
|
||||||
\end{proposition}
|
\end{proposition}
|
||||||
\begin{proof}
|
\begin{proof}
|
||||||
Let $(X , \alpha : X \rightarrow FX)$ be an F-coalgebra. The identity morphism on $(X , \alpha)$ is the identity morphism of $\C$ that trivially satisfies $\alpha \circ id = Fid \circ \alpha$.
|
Let \((X , \alpha : X \rightarrow FX)\) be an F-coalgebra. The identity morphism on \((X , \alpha)\) is the identity morphism of \(\C \) that trivially satisfies \(\alpha \circ id = Fid \circ \alpha \).
|
||||||
|
|
||||||
Let $(X , \alpha : X \rightarrow FX), (Y, \beta : Y \rightarrow FY)$ and $(Z , \gamma : Z \rightarrow FZ)$ be F-coalgebras.
|
Let \((X , \alpha : X \rightarrow FX), (Y, \beta : Y \rightarrow FY)\) and \((Z , \gamma : Z \rightarrow FZ)\) be F-coalgebras.
|
||||||
Composition of $f : (X, \alpha) \rightarrow (Y, \beta)$ and $g : (Y, \beta) \rightarrow (Z, \gamma)$ is composition of the underlying morphisms in $\C$ where:
|
Composition of \(f : (X, \alpha) \rightarrow (Y, \beta)\) and \(g : (Y, \beta) \rightarrow (Z, \gamma)\) is composition of the underlying morphisms in \(\C \) where:
|
||||||
\begin{alignat*}{1}
|
\begin{alignat*}{1}
|
||||||
&\gamma \circ g \circ f\\
|
& \gamma \circ g \circ f \\
|
||||||
=\;&Fg \circ \beta \circ f\\
|
=\; & Fg \circ \beta \circ f \\
|
||||||
=\;&Fg \circ Ff \circ \alpha\\
|
=\; & Fg \circ Ff \circ \alpha \\
|
||||||
=\;&F(g \circ f) \circ \alpha
|
=\; & F(g \circ f) \circ \alpha
|
||||||
\end{alignat*}
|
\end{alignat*}
|
||||||
\end{proof}
|
\end{proof}
|
||||||
|
|
||||||
The terminal object of $Coalg(F)$ is sometimes called \textit{final F-coalgebra} and can now similarly to initial F-algebras be used for modelling the semantics of coinductive data types where terminality of the coalgebra yields corecursion as a definitional principle and coinduction as a proof principle. Let us make the universal property of terminal F-coalgebras concrete:
|
The terminal object of \(Coalg(F)\) is sometimes called \textit{final F-coalgebra} and can now similarly to initial F-algebras be used for modelling the semantics of coinductive data types where terminality of the coalgebra yields corecursion as a definitional principle and coinduction as a proof principle. Let us make the universal property of terminal F-coalgebras concrete:
|
||||||
|
|
||||||
\begin{definition}[Terminal F-Coalgebra]
|
\begin{definition}[Terminal F-Coalgebra]
|
||||||
An F-coalgebra $(T, t : T \rightarrow FT)$ is called a terminal F-coalgebra if for any other F-coalgebra $(X, \alpha : X \rightarrow FX)$ there exists a unique morphism $\coalg{\alpha} : X \rightarrow T$ satisfying:
|
An F-coalgebra \((T, t : T \rightarrow FT)\) is called a terminal F-coalgebra if for any other F-coalgebra \((X, \alpha : X \rightarrow FX)\) there exists a unique morphism \(\coalg{\alpha} : X \rightarrow T\) satisfying:
|
||||||
|
|
||||||
% https://q.uiver.app/#q=WzAsNCxbMCwwLCJYIl0sWzIsMCwiRlgiXSxbMCwyLCJUIl0sWzIsMiwiRlQiXSxbMCwxLCJcXGFscGhhIl0sWzIsMywidCJdLFswLDIsIlxcbGxicmFja2V0IFxcYWxwaGEgXFxycmJyYWNrZXQiLDIseyJzdHlsZSI6eyJib2R5Ijp7Im5hbWUiOiJkYXNoZWQifX19XSxbMSwzLCJGXFxsbGJyYWNrZXQgXFxhbHBoYSBcXHJyYnJhY2tldCJdXQ==
|
% https://q.uiver.app/#q=WzAsNCxbMCwwLCJYIl0sWzIsMCwiRlgiXSxbMCwyLCJUIl0sWzIsMiwiRlQiXSxbMCwxLCJcXGFscGhhIl0sWzIsMywidCJdLFswLDIsIlxcbGxicmFja2V0IFxcYWxwaGEgXFxycmJyYWNrZXQiLDIseyJzdHlsZSI6eyJib2R5Ijp7Im5hbWUiOiJkYXNoZWQifX19XSxbMSwzLCJGXFxsbGJyYWNrZXQgXFxhbHBoYSBcXHJyYnJhY2tldCJdXQ==
|
||||||
\[\begin{tikzcd}[ampersand replacement=\&]
|
\[
|
||||||
|
\begin{tikzcd}[ampersand replacement=\&]
|
||||||
X \&\& FX \\
|
X \&\& FX \\
|
||||||
\\
|
\\
|
||||||
T \&\& FT
|
T \&\& FT
|
||||||
|
@ -224,16 +239,18 @@ The terminal object of $Coalg(F)$ is sometimes called \textit{final F-coalgebra}
|
||||||
\arrow["t", from=3-1, to=3-3]
|
\arrow["t", from=3-1, to=3-3]
|
||||||
\arrow["{\coalg{\alpha}}"', dashed, from=1-1, to=3-1]
|
\arrow["{\coalg{\alpha}}"', dashed, from=1-1, to=3-1]
|
||||||
\arrow["{F\coalg{\alpha}}", from=1-3, to=3-3]
|
\arrow["{F\coalg{\alpha}}", from=1-3, to=3-3]
|
||||||
\end{tikzcd}\]
|
\end{tikzcd}
|
||||||
|
\]
|
||||||
\end{definition}
|
\end{definition}
|
||||||
|
|
||||||
\begin{lemma}[Lambek's Lemma~\cite{lambek}]
|
\begin{lemma}[Lambek's Lemma~\cite{lambek}]
|
||||||
Let $(T, t : T \rightarrow FT)$ be a terminal F-coalgebra. Then $t$ is an isomorphism.
|
Let \((T, t : T \rightarrow FT)\) be a terminal F-coalgebra. Then \(t\) is an isomorphism.
|
||||||
\end{lemma}
|
\end{lemma}
|
||||||
\begin{proof}
|
\begin{proof}
|
||||||
First note that $(FT, Ft : FT \rightarrow FFT)$ is also an F-coalgebra. This yields the unique morphism $\coalg{Ft} : FT \rightarrow T$ satisfying:
|
First note that \((FT, Ft : FT \rightarrow FFT)\) is also an F-coalgebra. This yields the unique morphism \(\coalg{Ft} : FT \rightarrow T\) satisfying:
|
||||||
% https://q.uiver.app/#q=WzAsNCxbMCwwLCJGVCJdLFsyLDAsIkZGVCJdLFswLDIsIlQiXSxbMiwyLCJGVCJdLFswLDEsIkZ0Il0sWzIsMywidCJdLFswLDIsIlxcbGxicmFja2V0IEZ0IFxccnJicmFja2V0IiwyLHsic3R5bGUiOnsiYm9keSI6eyJuYW1lIjoiZGFzaGVkIn19fV0sWzEsMywiRlxcbGxicmFja2V0IEZ0IFxccnJicmFja2V0Il1d
|
% https://q.uiver.app/#q=WzAsNCxbMCwwLCJGVCJdLFsyLDAsIkZGVCJdLFswLDIsIlQiXSxbMiwyLCJGVCJdLFswLDEsIkZ0Il0sWzIsMywidCJdLFswLDIsIlxcbGxicmFja2V0IEZ0IFxccnJicmFja2V0IiwyLHsic3R5bGUiOnsiYm9keSI6eyJuYW1lIjoiZGFzaGVkIn19fV0sWzEsMywiRlxcbGxicmFja2V0IEZ0IFxccnJicmFja2V0Il1d
|
||||||
\[\begin{tikzcd}[ampersand replacement=\&]
|
\[
|
||||||
|
\begin{tikzcd}[ampersand replacement=\&]
|
||||||
FT \&\& FFT \\
|
FT \&\& FFT \\
|
||||||
\\
|
\\
|
||||||
T \&\& FT
|
T \&\& FT
|
||||||
|
@ -241,27 +258,28 @@ The terminal object of $Coalg(F)$ is sometimes called \textit{final F-coalgebra}
|
||||||
\arrow["t", from=3-1, to=3-3]
|
\arrow["t", from=3-1, to=3-3]
|
||||||
\arrow["{\coalg{Ft}}"', dashed, from=1-1, to=3-1]
|
\arrow["{\coalg{Ft}}"', dashed, from=1-1, to=3-1]
|
||||||
\arrow["{F\coalg{Ft}}", from=1-3, to=3-3]
|
\arrow["{F\coalg{Ft}}", from=1-3, to=3-3]
|
||||||
\end{tikzcd}\]
|
\end{tikzcd}
|
||||||
|
\]
|
||||||
|
|
||||||
$\coalg{Ft}$ is inverse to $t$:
|
\(\coalg{Ft}\) is inverse to \(t\):
|
||||||
|
|
||||||
\begin{enumerate}
|
\begin{enumerate}
|
||||||
\item $\coalg{Ft} \circ t : (T, t) \rightarrow (T, t)$ is a morphism between F-coalgebras since
|
\item \(\coalg{Ft} \circ t : (T, t) \rightarrow (T, t)\) is a morphism between F-coalgebras since
|
||||||
\begin{alignat*}{1}
|
\begin{alignat*}{1}
|
||||||
&F(\coalg{Ft} \circ t) \circ t\\
|
& F(\coalg{Ft} \circ t) \circ t \\
|
||||||
=\;&F \coalg{Ft} \circ t \circ t\\
|
=\; & F \coalg{Ft} \circ t \circ t \\
|
||||||
=\;&F \coalg{Ft} \circ Ft \circ t\\
|
=\; & F \coalg{Ft} \circ Ft \circ t \\
|
||||||
=\;&t \circ \coalg{Ft} \circ t
|
=\; & t \circ \coalg{Ft} \circ t
|
||||||
\end{alignat*}
|
\end{alignat*}
|
||||||
By uniqueness of the identity on $(T, t)$ we follow that $\coalg{Ft} \circ t = id$.
|
By uniqueness of the identity on \((T, t)\) we follow that \(\coalg{Ft} \circ t = id\).
|
||||||
|
|
||||||
\item $t \circ \coalg{Ft} = id : (FT, Ft) \rightarrow (FT, Ft)$ follows by:
|
\item \(t \circ \coalg{Ft} = id : (FT, Ft) \rightarrow (FT, Ft)\) follows by:
|
||||||
\begin{alignat*}{1}
|
\begin{alignat*}{1}
|
||||||
&t \circ \coalg{Ft}\\
|
& t \circ \coalg{Ft} \\
|
||||||
=\;&F\coalg{Ft} \circ Ft\\
|
=\; & F\coalg{Ft} \circ Ft \\
|
||||||
=\;&F(\coalg{Ft} \circ t)\\
|
=\; & F(\coalg{Ft} \circ t) \\
|
||||||
=\;&F(id)\\
|
=\; & F(id) \\
|
||||||
=\;&id
|
=\; & id
|
||||||
\end{alignat*}
|
\end{alignat*}
|
||||||
\end{enumerate}
|
\end{enumerate}
|
||||||
\end{proof}
|
\end{proof}
|
||||||
|
@ -270,17 +288,18 @@ The terminal object of $Coalg(F)$ is sometimes called \textit{final F-coalgebra}
|
||||||
Monads are widely known among programmers as a way of modelling effects in pure languages and are also central to this thesis. Let us recall the basic definitions\cite{Lane1971}\cite{moggi}.
|
Monads are widely known among programmers as a way of modelling effects in pure languages and are also central to this thesis. Let us recall the basic definitions\cite{Lane1971}\cite{moggi}.
|
||||||
|
|
||||||
\begin{definition}[Monad]
|
\begin{definition}[Monad]
|
||||||
A monad $\mathbf{T}$ on a category $\C$ is a triple $(T, \eta, \mu)$, where $T : \C \rightarrow \C$ is an endofunctor and $\eta : Id \rightarrow T, \mu : TT \rightarrow T$ are natural transformations, satisfying the following laws:
|
A monad \(\mathbf{T}\) on a category \(\C \) is a triple \((T, \eta, \mu)\), where \(T : \C \rightarrow \C \) is an endofunctor and \(\eta : Id \rightarrow T, \mu : TT \rightarrow T\) are natural transformations, satisfying the following laws:
|
||||||
\begin{alignat*}{2}
|
\begin{alignat*}{2}
|
||||||
&\mu_X \circ \mu_{TX} &&= \mu_X \circ T\mu_X \tag*{(M1)}\label{M1}\\
|
& \mu_X \circ \mu_{TX} & & = \mu_X \circ T\mu_X \tag*{(M1)}\label{M1} \\
|
||||||
&\mu_X \circ \eta_{TX} &&= id_{TX} \tag*{(M2)}\label{M2}\\
|
& \mu_X \circ \eta_{TX} & & = id_{TX} \tag*{(M2)}\label{M2} \\
|
||||||
&\mu_X \circ T\eta_X &&= id_{TX} \tag*{(M3)}\label{M3}
|
& \mu_X \circ T\eta_X & & = id_{TX} \tag*{(M3)}\label{M3}
|
||||||
\end{alignat*}
|
\end{alignat*}
|
||||||
|
|
||||||
These laws are expressed by the following diagrams:
|
These laws are expressed by the following diagrams:
|
||||||
% with indices: % https://q.uiver.app/#q=WzAsOCxbMCwwLCJUVFRYIl0sWzIsMCwiVFRYIl0sWzAsMiwiVFRYIl0sWzIsMiwiVFgiXSxbNCwwLCJUWCJdLFs2LDAsIlRUWCJdLFs4LDAsIlRYIl0sWzYsMiwiVFgiXSxbMCwxLCJcXG11X3tUWH0iXSxbMCwyLCJUXFxtdV9YIiwyXSxbMSwzLCJcXG11X1giXSxbNSw3LCJcXG11X1giXSxbNCw1LCJcXGV0YV97VFh9Il0sWzYsNSwiVFxcZXRhX1giXSxbNCw3LCJpZF97VFh9IiwyXSxbNiw3LCJpZF97VFh9IiwyXSxbMiwzLCJcXG11X1giLDJdXQ==
|
% with indices: % https://q.uiver.app/#q=WzAsOCxbMCwwLCJUVFRYIl0sWzIsMCwiVFRYIl0sWzAsMiwiVFRYIl0sWzIsMiwiVFgiXSxbNCwwLCJUWCJdLFs2LDAsIlRUWCJdLFs4LDAsIlRYIl0sWzYsMiwiVFgiXSxbMCwxLCJcXG11X3tUWH0iXSxbMCwyLCJUXFxtdV9YIiwyXSxbMSwzLCJcXG11X1giXSxbNSw3LCJcXG11X1giXSxbNCw1LCJcXGV0YV97VFh9Il0sWzYsNSwiVFxcZXRhX1giXSxbNCw3LCJpZF97VFh9IiwyXSxbNiw3LCJpZF97VFh9IiwyXSxbMiwzLCJcXG11X1giLDJdXQ==
|
||||||
% https://q.uiver.app/#q=WzAsOCxbMCwwLCJUVFRYIl0sWzIsMCwiVFRYIl0sWzAsMiwiVFRYIl0sWzIsMiwiVFgiXSxbNCwwLCJUWCJdLFs2LDAsIlRUWCJdLFs4LDAsIlRYIl0sWzYsMiwiVFgiXSxbMCwxLCJcXG11Il0sWzAsMiwiVFxcbXUiLDJdLFsxLDMsIlxcbXUiXSxbNSw3LCJcXG11Il0sWzQsNSwiXFxldGEiXSxbNiw1LCJUIl0sWzQsNywiaWQiLDJdLFs2LDcsImlkIiwyXSxbMiwzLCJcXG11IiwyXV0=
|
% https://q.uiver.app/#q=WzAsOCxbMCwwLCJUVFRYIl0sWzIsMCwiVFRYIl0sWzAsMiwiVFRYIl0sWzIsMiwiVFgiXSxbNCwwLCJUWCJdLFs2LDAsIlRUWCJdLFs4LDAsIlRYIl0sWzYsMiwiVFgiXSxbMCwxLCJcXG11Il0sWzAsMiwiVFxcbXUiLDJdLFsxLDMsIlxcbXUiXSxbNSw3LCJcXG11Il0sWzQsNSwiXFxldGEiXSxbNiw1LCJUIl0sWzQsNywiaWQiLDJdLFs2LDcsImlkIiwyXSxbMiwzLCJcXG11IiwyXV0=
|
||||||
\[\begin{tikzcd}
|
\[
|
||||||
|
\begin{tikzcd}
|
||||||
TTTX && TTX && TX && TTX && TX \\
|
TTTX && TTX && TX && TTX && TX \\
|
||||||
\\
|
\\
|
||||||
TTX && TX &&&& TX
|
TTX && TX &&&& TX
|
||||||
|
@ -293,17 +312,19 @@ Monads are widely known among programmers as a way of modelling effects in pure
|
||||||
\arrow["id"', from=1-5, to=3-7]
|
\arrow["id"', from=1-5, to=3-7]
|
||||||
\arrow["id"', from=1-9, to=3-7]
|
\arrow["id"', from=1-9, to=3-7]
|
||||||
\arrow["\mu"', from=3-1, to=3-3]
|
\arrow["\mu"', from=3-1, to=3-3]
|
||||||
\end{tikzcd}\]
|
\end{tikzcd}
|
||||||
|
\]
|
||||||
\end{definition}
|
\end{definition}
|
||||||
|
|
||||||
As with many categorical concepts we may consider the category of monads:
|
As with many categorical concepts we may consider the category of monads:
|
||||||
|
|
||||||
\todo[inline]{Use text => lemma style}
|
\todo[inline]{Use text => lemma style}
|
||||||
\begin{definition}[The Category of Monads]~\label{def:monads}
|
\begin{definition}[The Category of Monads]~\label{def:monads}
|
||||||
Let $\C$ be a category.
|
Let \(\C \) be a category.
|
||||||
A morphism between monads $(S : \C \rightarrow \C, \eta^S, \mu^S)$ and $(T : \C \rightarrow \C, \eta^T, \mu^T)$ is a natural transformation $\alpha : S \rightarrow T$ between the underlying functors satisfying:
|
A morphism between monads \((S : \C \rightarrow \C, \eta^S, \mu^S)\) and \((T : \C \rightarrow \C, \eta^T, \mu^T)\) is a natural transformation \(\alpha : S \rightarrow T\) between the underlying functors satisfying:
|
||||||
% https://q.uiver.app/#q=WzAsOCxbMCwwLCJYIl0sWzIsMCwiU1giXSxbMiwxLCJUWCJdLFszLDAsIlNTWCJdLFs1LDAsIlNUWCJdLFszLDEsIlNYIl0sWzcsMCwiVFRYIl0sWzcsMSwiVFgiXSxbMCwxLCJcXGV0YV5TIl0sWzEsMiwiXFxhbHBoYSJdLFswLDIsIlxcZXRhXlQiLDJdLFszLDQsIlNcXGFscGhhIl0sWzMsNSwiXFxtdV5TIiwyXSxbNCw2LCJcXGFscGhhIl0sWzUsNywiXFxhbHBoYSIsMl0sWzYsNywiXFxtdV5UIl1d
|
% https://q.uiver.app/#q=WzAsOCxbMCwwLCJYIl0sWzIsMCwiU1giXSxbMiwxLCJUWCJdLFszLDAsIlNTWCJdLFs1LDAsIlNUWCJdLFszLDEsIlNYIl0sWzcsMCwiVFRYIl0sWzcsMSwiVFgiXSxbMCwxLCJcXGV0YV5TIl0sWzEsMiwiXFxhbHBoYSJdLFswLDIsIlxcZXRhXlQiLDJdLFszLDQsIlNcXGFscGhhIl0sWzMsNSwiXFxtdV5TIiwyXSxbNCw2LCJcXGFscGhhIl0sWzUsNywiXFxhbHBoYSIsMl0sWzYsNywiXFxtdV5UIl1d
|
||||||
\[\begin{tikzcd}[ampersand replacement=\&]
|
\[
|
||||||
|
\begin{tikzcd}[ampersand replacement=\&]
|
||||||
X \&\& SX \& SSX \&\& STX \&\& TTX \\
|
X \&\& SX \& SSX \&\& STX \&\& TTX \\
|
||||||
\&\& TX \& SX \&\&\&\& TX
|
\&\& TX \& SX \&\&\&\& TX
|
||||||
\arrow["{\eta^S}", from=1-1, to=1-3]
|
\arrow["{\eta^S}", from=1-1, to=1-3]
|
||||||
|
@ -314,37 +335,38 @@ As with many categorical concepts we may consider the category of monads:
|
||||||
\arrow["\alpha", from=1-6, to=1-8]
|
\arrow["\alpha", from=1-6, to=1-8]
|
||||||
\arrow["\alpha"', from=2-4, to=2-8]
|
\arrow["\alpha"', from=2-4, to=2-8]
|
||||||
\arrow["{\mu^T}", from=1-8, to=2-8]
|
\arrow["{\mu^T}", from=1-8, to=2-8]
|
||||||
\end{tikzcd}\]
|
\end{tikzcd}
|
||||||
|
\]
|
||||||
|
|
||||||
This yields the category of monads on $\C$ which we call $\monads{\C}$. The identity morphism of $\monads{\C}$ is the identity natural transformation $Id : F \rightarrow F$ which trivially respects the monad unit and multiplication. Composition of monad morphisms is composition of the underlying natural transformation, the diagrams then also follow easily.
|
This yields the category of monads on \(\C \) which we call \(\monads{\C}\). The identity morphism of \(\monads{\C}\) is the identity natural transformation \(Id : F \rightarrow F\) which trivially respects the monad unit and multiplication. Composition of monad morphisms is composition of the underlying natural transformation, the diagrams then also follow easily.
|
||||||
\end{definition}
|
\end{definition}
|
||||||
|
|
||||||
Monads can also be specified in a second equivalent way that is better suited to describe computation.
|
Monads can also be specified in a second equivalent way that is better suited to describe computation.
|
||||||
|
|
||||||
\begin{definition}[Kleisli Triple]
|
\begin{definition}[Kleisli Triple]
|
||||||
A Kleisli triple on a category $\C$ is a triple $(F, \eta, (-)^*)$, where $F : \obj{C} \rightarrow \obj{C}$ is a mapping on objects, $(\eta_X : X \rightarrow FX)_{X\in\obj{C}}$ is a family of morphisms and for every morphism $f : X \rightarrow FY$ there exists a morphism $f^* : FX \rightarrow FY$ called the Kleisli lifting, where the following laws hold:
|
A Kleisli triple on a category \(\C \) is a triple \((F, \eta, {(-)}^*)\), where \(F : \obj{C} \rightarrow \obj{C}\) is a mapping on objects, \({(\eta_X : X \rightarrow FX)}_{X\in\obj{C}}\) is a family of morphisms and for every morphism \(f : X \rightarrow FY\) there exists a morphism \(f^* : FX \rightarrow FY\) called the Kleisli lifting, where the following laws hold:
|
||||||
\begin{alignat*}{3}
|
\begin{alignat*}{3}
|
||||||
&\eta_X^* &&= id_{FX} \tag*{(K1)}\label{K1}\\
|
& \eta_X^* & & = id_{FX} \tag*{(K1)}\label{K1} \\
|
||||||
&f^* \circ \eta_X &&= f &&\text{ for any } f : X \rightarrow FY \tag*{(K2)}\label{K2}\\
|
& f^* \circ \eta_X & & = f & & \text{ for any } f : X \rightarrow FY \tag*{(K2)}\label{K2} \\
|
||||||
&f^* \circ g* &&= (f^* \circ g)^* &&\text{ for any } f : Y \rightarrow FZ, g : X \rightarrow FY \tag*{(K3)}\label{K3}
|
& f^* \circ g* & & = {(f^* \circ g)}^* & & \text{ for any } f : Y \rightarrow FZ, g : X \rightarrow FY \tag*{(K3)}\label{K3}
|
||||||
\end{alignat*}
|
\end{alignat*}
|
||||||
\end{definition}
|
\end{definition}
|
||||||
|
|
||||||
Let $f : X \rightarrow TY, g : Y \rightarrow TZ$ be two programs, where $T$ is a Kleisli triple. These programs can be composed by taking: $f^* \circ g : X \rightarrow TZ$, which is called Kleisli composition. Haskell's do-notation is a useful tool for writing Kleisli composition in a legible way. $f^* \circ g$ can equivalently be expressed as:
|
Let \(f : X \rightarrow TY, g : Y \rightarrow TZ\) be two programs, where \(T\) is a Kleisli triple. These programs can be composed by taking: \(f^* \circ g : X \rightarrow TZ\), which is called Kleisli composition. Haskell's do-notation is a useful tool for writing Kleisli composition in a legible way. We will sometimes express \((f^* \circ g) x\) equivalently as
|
||||||
\begin{minted}{haskell}
|
\begin{minted}{haskell}
|
||||||
do y <- f x
|
do y <- g x
|
||||||
g y
|
f y
|
||||||
\end{minted}
|
\end{minted}
|
||||||
|
|
||||||
The possibility of Kleisli composition enables us to define the category of programs for any Kleisli triple $T$.
|
The possibility of Kleisli composition enables us to define the category of programs for any Kleisli triple \(T\).
|
||||||
|
|
||||||
\begin{definition}[Kleisli Category]
|
\begin{definition}[Kleisli Category]
|
||||||
Given a monad $T$ on a category $\C$, the Kleisli category $\C^T$ is defined as:
|
Given a monad \(T\) on a category \(\C \), the Kleisli category \(\C^T\) is defined as:
|
||||||
\begin{itemize}
|
\begin{itemize}
|
||||||
\item $\vert \C^T \vert = \obj{C}$
|
\item \(\vert \C^T \vert = \obj{C}\)
|
||||||
\item $\mathcal{C^T}(X, Y) = \C(X, TY)$
|
\item \(\mathcal{C^T}(X, Y) = \C(X, TY)\)
|
||||||
\item Composition of programs is Kleisli composition.
|
\item Composition of programs is Kleisli composition.
|
||||||
\item The identity morphisms are the unit morphisms of $T$, $id_X = \eta_X : X \rightarrow TX$
|
\item The identity morphisms are the unit morphisms of \(T\), \(id_X = \eta_X : X \rightarrow TX\)
|
||||||
\end{itemize}
|
\end{itemize}
|
||||||
The laws of categories then follow from the Kleisli triple laws.
|
The laws of categories then follow from the Kleisli triple laws.
|
||||||
\end{definition}
|
\end{definition}
|
||||||
|
@ -352,24 +374,24 @@ The possibility of Kleisli composition enables us to define the category of prog
|
||||||
\begin{theorem}[\cite{manes}] The notions of Kleisli triple and monad are equivalent.
|
\begin{theorem}[\cite{manes}] The notions of Kleisli triple and monad are equivalent.
|
||||||
\end{theorem}
|
\end{theorem}
|
||||||
\begin{proof}
|
\begin{proof}
|
||||||
The crux of this proof is defining the triples, the proofs of the corresponding laws (functoriality, naturality, monad and Kleisli triple laws) are left out.
|
The crux of this proof is defining the triples, the proofs of the corresponding laws (functoriality, naturality, monad and Kleisli triple laws) are left out.
|
||||||
|
|
||||||
``$\Rightarrow$'':
|
``\(\Rightarrow \)'':
|
||||||
Given a Kleisli triple $(F, \eta, (-)^*)$,
|
Given a Kleisli triple \((F, \eta, {(-)}^*)\),
|
||||||
we get a monad $(F, \eta, \mu)$ where $F$ is the object mapping of the Kleisli triple together with the functor action $F(f : X \rightarrow Y) = (\eta_Y \circ f)^*$,
|
we get a monad \((F, \eta, \mu)\) where \(F\) is the object mapping of the Kleisli triple together with the functor action \(F(f : X \rightarrow Y) = {(\eta_Y \circ f)}^*\),
|
||||||
$\eta$ is the morphism family of the Kleisli triple where naturality is easy to show and $\mu$ is a natural transformation defined as $\mu_X = id_{FX}^*$
|
\(\eta \) is the morphism family of the Kleisli triple where naturality is easy to show and \(\mu \) is a natural transformation defined as \(\mu_X = id_{FX}^*\)
|
||||||
|
|
||||||
|
|
||||||
``$\Leftarrow$'': \\
|
``\(\Leftarrow \)'': \\
|
||||||
Given a monad $(F, \eta, \mu)$,
|
Given a monad \((F, \eta, \mu)\),
|
||||||
we get a Kleisli triple $(F, \eta, (-)^*)$ by restricting the functor $F$ on objects,
|
we get a Kleisli triple \((F, \eta, {(-)}^*)\) by restricting the functor \(F\) on objects,
|
||||||
taking the underlying mapping of $\eta$ and defining $f^* = \mu_Y \circ Ff$ for any $f : X \rightarrow FY$.
|
taking the underlying mapping of \(\eta \) and defining \(f^* = \mu_Y \circ Ff\) for any \(f : X \rightarrow FY\).
|
||||||
\end{proof}
|
\end{proof}
|
||||||
|
|
||||||
For the rest of this thesis we will use both equivalent notions interchangeably to make definitions easier.
|
For the rest of this thesis we will use both equivalent notions interchangeably to make definitions easier.
|
||||||
|
|
||||||
\section{Strong and Commutative Monads}
|
\section{Strong and Commutative Monads}
|
||||||
When modelling partiality with a monad, one would expect the following two programs to be equivalent:
|
When modelling partiality with a monad, one would expect the following two programs to be equivalent
|
||||||
\begin{multicols}{2}
|
\begin{multicols}{2}
|
||||||
\begin{minted}{haskell}
|
\begin{minted}{haskell}
|
||||||
do x <- p
|
do x <- p
|
||||||
|
@ -383,26 +405,27 @@ When modelling partiality with a monad, one would expect the following two progr
|
||||||
return (x, y)
|
return (x, y)
|
||||||
\end{minted}
|
\end{minted}
|
||||||
\end{multicols}
|
\end{multicols}
|
||||||
where p and q are (partial) computations. This condition can be expressed categorically, but first we need another definition:
|
Where p and q are (partial) computations. This condition can be expressed categorically, but first we need another definition:
|
||||||
|
|
||||||
\change[inline]{Find Motivation for strong monads}
|
\change[inline]{Find Motivation for strong monads}
|
||||||
|
|
||||||
\begin{definition}[Strong Monad] A monad $(T, \eta, \mu)$ on a cartesian category $\C$ is called strong if there exists a natural transformation $\tau_{X,Y} : X \times TY \rightarrow T(X \times Y)$ that satisfies the following conditions:
|
\begin{definition}[Strong Monad] A monad \((T, \eta, \mu)\) on a cartesian category \(\C \) is called strong if there exists a natural transformation \(\tau_{X,Y} : X \times TY \rightarrow T(X \times Y)\) that satisfies the following conditions:
|
||||||
\begin{alignat*}{2}
|
\begin{alignat*}{2}
|
||||||
&T\pi_2 \circ \tau_{1,X} &&= \pi_2 \tag*{(S1)}\label{S1}\\
|
& T\pi_2 \circ \tau_{1,X} & & = \pi_2 \tag*{(S1)}\label{S1} \\
|
||||||
&\tau_{X,Y} \circ (id_X \times \eta_Y) &&= \eta_{X\times Y} \tag*{(S2)}\label{S2}\\
|
& \tau_{X,Y} \circ (id_X \times \eta_Y) & & = \eta_{X\times Y} \tag*{(S2)}\label{S2} \\
|
||||||
&\tau_{X,Y} \circ (id_X \times \mu_Y) &&= \mu_{X\times Y} \circ T\tau_{X,Y} \circ \tau_{X,TY} \tag*{(S3)}\label{S3}\\
|
& \tau_{X,Y} \circ (id_X \times \mu_Y) & & = \mu_{X\times Y} \circ T\tau_{X,Y} \circ \tau_{X,TY} \tag*{(S3)}\label{S3} \\
|
||||||
&M \alpha_{X,Y,Z} \circ \tau_{X \times Y, Z} &&= \tau_{X, Y\times Z} \circ (id_X \times \tau_{Y, Z}) \circ \alpha_{X,Y,TZ} \tag*{(S4)}\label{S4}
|
& M \alpha_{X,Y,Z} \circ \tau_{X \times Y, Z} & & = \tau_{X, Y\times Z} \circ (id_X \times \tau_{Y, Z}) \circ \alpha_{X,Y,TZ} \tag*{(S4)}\label{S4}
|
||||||
\end{alignat*}
|
\end{alignat*}
|
||||||
where $\alpha_{X,Y,Z} = \langle \langle \pi_1 , \pi_1 \circ \pi_2 \rangle , \pi_2 \circ \pi_2 \rangle : X \times (Y \times Z) \rightarrow (X \times Y) \times Z$ is the associativity morphism on products.
|
where \(\alpha_{X,Y,Z} = \langle \langle \pi_1 , \pi_1 \circ \pi_2 \rangle , \pi_2 \circ \pi_2 \rangle : X \times (Y \times Z) \rightarrow (X \times Y) \times Z\) is the associativity morphism on products.
|
||||||
\end{definition}
|
\end{definition}
|
||||||
|
|
||||||
\todo[inline]{Use text => lemma style}
|
\todo[inline]{Use text => lemma style}
|
||||||
As with monads we can now consider the category of strong monads:
|
As with monads we can now consider the category of strong monads:
|
||||||
\begin{definition}[The Category of Strong Monads]\label{def:strongmonads}
|
\begin{definition}[The Category of Strong Monads]\label{def:strongmonads}
|
||||||
Let $\C$ be a category. A morphism between two strong monads $(S : \C \rightarrow \C, \eta^S, \mu^S, \tau^S)$ and $(T : \C \rightarrow \C, \eta^T, \mu^T, \tau^T)$ is a morphism between monads as in \autoref{def:monads} that additionally satisfies:
|
Let \(\C \) be a category. A morphism between two strong monads \((S : \C \rightarrow \C, \eta^S, \mu^S, \tau^S)\) and \((T : \C \rightarrow \C, \eta^T, \mu^T, \tau^T)\) is a morphism between monads as in \autoref{def:monads} that additionally satisfies:
|
||||||
% https://q.uiver.app/#q=WzAsNCxbMCwwLCJYIFxcdGltZXMgU1kiXSxbMCwyLCJTKFggXFx0aW1lcyBZKSJdLFsyLDIsIlQoWCBcXHRpbWVzIFkpIl0sWzIsMCwiWCBcXHRpbWVzIFRZIl0sWzAsMSwiXFx0YXVeUyJdLFsxLDIsIlxcYWxwaGEiXSxbMCwzLCJpZCBcXHRpbWVzIFxcYWxwaGEiXSxbMywyLCJcXHRhdV5UIiwyXV0=
|
% https://q.uiver.app/#q=WzAsNCxbMCwwLCJYIFxcdGltZXMgU1kiXSxbMCwyLCJTKFggXFx0aW1lcyBZKSJdLFsyLDIsIlQoWCBcXHRpbWVzIFkpIl0sWzIsMCwiWCBcXHRpbWVzIFRZIl0sWzAsMSwiXFx0YXVeUyJdLFsxLDIsIlxcYWxwaGEiXSxbMCwzLCJpZCBcXHRpbWVzIFxcYWxwaGEiXSxbMywyLCJcXHRhdV5UIiwyXV0=
|
||||||
\[\begin{tikzcd}[ampersand replacement=\&]
|
\[
|
||||||
|
\begin{tikzcd}[ampersand replacement=\&]
|
||||||
{X \times SY} \&\& {X \times TY} \\
|
{X \times SY} \&\& {X \times TY} \\
|
||||||
\\
|
\\
|
||||||
{S(X \times Y)} \&\& {T(X \times Y)}
|
{S(X \times Y)} \&\& {T(X \times Y)}
|
||||||
|
@ -410,18 +433,20 @@ As with monads we can now consider the category of strong monads:
|
||||||
\arrow["\alpha", from=3-1, to=3-3]
|
\arrow["\alpha", from=3-1, to=3-3]
|
||||||
\arrow["{id \times \alpha}", from=1-1, to=1-3]
|
\arrow["{id \times \alpha}", from=1-1, to=1-3]
|
||||||
\arrow["{\tau^T}"', from=1-3, to=3-3]
|
\arrow["{\tau^T}"', from=1-3, to=3-3]
|
||||||
\end{tikzcd}\]
|
\end{tikzcd}
|
||||||
This yields the category $\strongmonads{\C}$ of strong monads over $\C$.
|
\]
|
||||||
|
This yields the category \(\strongmonads{\C}\) of strong monads over \(\C \).
|
||||||
\end{definition}
|
\end{definition}
|
||||||
|
|
||||||
Now we can express the above condition:
|
Now we can express the above condition:
|
||||||
\begin{definition}[Commutative Monad]
|
\begin{definition}[Commutative Monad]
|
||||||
A strong monad $\mathbf{T}$ is called commutative if the (right) strength $\tau$ commutes with the induced left strength
|
A strong monad \(\mathbf{T}\) is called commutative if the (right) strength \(\tau \) commutes with the induced left strength
|
||||||
\[\sigma_{X,Y} = Tswap \circ \tau_{Y,X} \circ swap : TX \times Y \rightarrow T(X \times Y)\]
|
\[\sigma_{X,Y} = Tswap \circ \tau_{Y,X} \circ swap : TX \times Y \rightarrow T(X \times Y)\]
|
||||||
that satisfies symmetrical conditions to the ones $\tau$ satisfies.
|
that satisfies symmetrical conditions to the ones \(\tau \) satisfies.
|
||||||
Concretely, $\mathbf{T}$ is called commutative if the following diagram commutes:
|
Concretely, \(\mathbf{T}\) is called commutative if the following diagram commutes:
|
||||||
% https://q.uiver.app/#q=WzAsNCxbMCwyLCJUKFggXFx0aW1lcyBUWSkiXSxbMiwwLCJUKFRYIFxcdGltZXMgWSkiXSxbMiwyLCJUKFggXFx0aW1lcyBZKSJdLFswLDAsIlRYIFxcdGltZXMgVFkiXSxbMywxLCJcXHRhdSJdLFszLDAsIlxcc2lnbWEiLDJdLFswLDIsIlxcdGF1XioiLDJdLFsxLDIsIlxcc2lnbWFeKiJdXQ==
|
% https://q.uiver.app/#q=WzAsNCxbMCwyLCJUKFggXFx0aW1lcyBUWSkiXSxbMiwwLCJUKFRYIFxcdGltZXMgWSkiXSxbMiwyLCJUKFggXFx0aW1lcyBZKSJdLFswLDAsIlRYIFxcdGltZXMgVFkiXSxbMywxLCJcXHRhdSJdLFszLDAsIlxcc2lnbWEiLDJdLFswLDIsIlxcdGF1XioiLDJdLFsxLDIsIlxcc2lnbWFeKiJdXQ==
|
||||||
\[\begin{tikzcd}
|
\[
|
||||||
|
\begin{tikzcd}
|
||||||
{TX \times TY} && {T(TX \times Y)} \\
|
{TX \times TY} && {T(TX \times Y)} \\
|
||||||
\\
|
\\
|
||||||
{T(X \times TY)} && {T(X \times Y)}
|
{T(X \times TY)} && {T(X \times Y)}
|
||||||
|
@ -429,7 +454,8 @@ Now we can express the above condition:
|
||||||
\arrow["\sigma"', from=1-1, to=3-1]
|
\arrow["\sigma"', from=1-1, to=3-1]
|
||||||
\arrow["{\tau^*}"', from=3-1, to=3-3]
|
\arrow["{\tau^*}"', from=3-1, to=3-3]
|
||||||
\arrow["{\sigma^*}", from=1-3, to=3-3]
|
\arrow["{\sigma^*}", from=1-3, to=3-3]
|
||||||
\end{tikzcd}\]
|
\end{tikzcd}
|
||||||
|
\]
|
||||||
\end{definition}
|
\end{definition}
|
||||||
|
|
||||||
\section{Free Objects}
|
\section{Free Objects}
|
||||||
|
@ -438,33 +464,35 @@ on free structures in \autoref{chp:iteration} to define a monad in a general set
|
||||||
to establish some notation and then describe how to obtain a monad via existence of free objects.
|
to establish some notation and then describe how to obtain a monad via existence of free objects.
|
||||||
|
|
||||||
\begin{definition}[Free Object]\label{def:free}
|
\begin{definition}[Free Object]\label{def:free}
|
||||||
Let $\C, \D$ be categories and $U : \C \rightarrow \D$ be a forgetful functor (whose construction usually is obvious). A free object on some object $X \in \obj{\D}$ is an object $FX \in \obj{\C}$ together with a morphism $\eta : X \rightarrow UFX$ such that for any $Y \in \obj{\C}$ and $f : X \rightarrow UY$ there exists a unique morphism $\free{f} : UFX \rightarrow UY$ satisfying:
|
Let \(\C, \D \) be categories and \(U : \C \rightarrow \D \) be a forgetful functor (whose construction usually is obvious). A free object on some object \(X \in \obj{\D}\) is an object \(FX \in \obj{\C}\) together with a morphism \(\eta : X \rightarrow UFX\) such that for any \(Y \in \obj{\C}\) and \(f : X \rightarrow UY\) there exists a unique morphism \(\free{f} : UFX \rightarrow UY\) satisfying:
|
||||||
% https://q.uiver.app/#q=WzAsMyxbMCwwLCJYIl0sWzEsMCwiVVkiXSxbMCwxLCJVRlgiXSxbMCwxLCJmIl0sWzAsMiwiXFxldGEiLDJdLFsyLDEsIlxcZnJlZXtmfSIsMix7InN0eWxlIjp7ImJvZHkiOnsibmFtZSI6ImRhc2hlZCJ9fX1dXQ==
|
% https://q.uiver.app/#q=WzAsMyxbMCwwLCJYIl0sWzEsMCwiVVkiXSxbMCwxLCJVRlgiXSxbMCwxLCJmIl0sWzAsMiwiXFxldGEiLDJdLFsyLDEsIlxcZnJlZXtmfSIsMix7InN0eWxlIjp7ImJvZHkiOnsibmFtZSI6ImRhc2hlZCJ9fX1dXQ==
|
||||||
\[\begin{tikzcd}[ampersand replacement=\&]
|
\[
|
||||||
|
\begin{tikzcd}[ampersand replacement=\&]
|
||||||
X \& UY \\
|
X \& UY \\
|
||||||
UFX
|
UFX
|
||||||
\arrow["f", from=1-1, to=1-2]
|
\arrow["f", from=1-1, to=1-2]
|
||||||
\arrow["\eta"', from=1-1, to=2-1]
|
\arrow["\eta"', from=1-1, to=2-1]
|
||||||
\arrow["{\free{f}}"', dashed, from=2-1, to=1-2]
|
\arrow["{\free{f}}"', dashed, from=2-1, to=1-2]
|
||||||
\end{tikzcd}\]
|
\end{tikzcd}
|
||||||
|
\]
|
||||||
\end{definition}
|
\end{definition}
|
||||||
|
|
||||||
\begin{theorem}\label{thm:freemonad}
|
\begin{theorem}\label{thm:freemonad}
|
||||||
Let $U : \C \rightarrow \D$ be a forgetful functor.
|
Let \(U : \C \rightarrow \D \) be a forgetful functor.
|
||||||
If for every $X \in \obj{\D}$ a free object $FX \in \obj{C}$ exists then $(X \mapsto UFX, \eta : X \rightarrow UFX, \free{(f : X \rightarrow UFY)} : UFX \rightarrow UFY)$ is a Kleisli triple on $\D$.
|
If for every \(X \in \obj{\D}\) a free object \(FX \in \obj{C}\) exists then \((X \mapsto UFX, \eta : X \rightarrow UFX, \free{(f : X \rightarrow UFY)} : UFX \rightarrow UFY)\) is a Kleisli triple on \(\D \).
|
||||||
\end{theorem}
|
\end{theorem}
|
||||||
\begin{proof}
|
\begin{proof}
|
||||||
We are left to check the laws of Kleisli triples.
|
We are left to check the laws of Kleisli triples.
|
||||||
|
|
||||||
\begin{itemize}
|
\begin{itemize}
|
||||||
\item[\ref{K1}] $\free{\eta} = id$
|
\item[\ref{K1}] \(\free{\eta} = id\)
|
||||||
|
|
||||||
By uniqueness of $\free{\eta}$ it suffices to show that $id \circ \eta = \eta$ which holds trivially.
|
By uniqueness of \(\free{\eta}\) it suffices to show that \(id \circ \eta = \eta \) which holds trivially.
|
||||||
\item[\ref{K2}] $\free{f} \circ \eta = f$ for any $f : X \rightarrow UFY$
|
\item[\ref{K2}] \(\free{f} \circ \eta = f\) for any \(f : X \rightarrow UFY\)
|
||||||
|
|
||||||
This is the universal property concerning $\free{f}$.
|
This is the universal property concerning \(\free{f}\).
|
||||||
\item[\ref{K3}] $\free{f} \circ \free{g} = \free{\freee{f} \circ g}$ for any $f : Y \rightarrow UFZ, g : X \rightarrow UFY$
|
\item[\ref{K3}] \(\free{f} \circ \free{g} = \free{\freee{f} \circ g}\) for any \(f : Y \rightarrow UFZ, g : X \rightarrow UFY\)
|
||||||
|
|
||||||
By uniqueness of $\free{\freee{f} \circ g}$ we are left to show $\free{f} \circ \free{g} \circ \eta = \free{f} \circ g$ which again follows directly by the universal property of $\free{g}$.
|
By uniqueness of \(\free{\freee{f} \circ g}\) we are left to show \(\free{f} \circ \free{g} \circ \eta = \free{f} \circ g\) which again follows directly by the universal property of \(\free{g}\).
|
||||||
\end{itemize}
|
\end{itemize}
|
||||||
\end{proof}
|
\end{proof}
|
|
@ -8,18 +8,18 @@ This chapter shall serve as a quick introduction to the library and the formaliz
|
||||||
\section{Setoid Enriched Categories}
|
\section{Setoid Enriched Categories}
|
||||||
The usual textbook definition of a category glosses over some design decisions that have to be made when implementing it in type theory. One would usually see something like this:
|
The usual textbook definition of a category glosses over some design decisions that have to be made when implementing it in type theory. One would usually see something like this:
|
||||||
\begin{definition}[Category]
|
\begin{definition}[Category]
|
||||||
A category consists of
|
A category consists of
|
||||||
\begin{itemize}
|
\begin{itemize}
|
||||||
\item A collection of objects
|
\item A collection of objects
|
||||||
\item A collection of morphisms between objects
|
\item A collection of morphisms between objects
|
||||||
\item For every two morphisms $f : X \rightarrow Y, g : Y \rightarrow Z$ another morphism $g \circ f : X \rightarrow Z$ called the composition
|
\item For every two morphisms \(f : X \rightarrow Y, g : Y \rightarrow Z\) another morphism \(g \circ f : X \rightarrow Z\) called the composition
|
||||||
\item For every object $X$ a morphism $id_X : X \rightarrow X$ called the identity
|
\item For every object \(X\) a morphism \(id_X : X \rightarrow X\) called the identity
|
||||||
\end{itemize}
|
\end{itemize}
|
||||||
where the composition is associative, and the identity morphisms are identities with respect to the composition.
|
where the composition is associative, and the identity morphisms are identities with respect to the composition.
|
||||||
\end{definition}
|
\end{definition}
|
||||||
|
|
||||||
Here \textit{collection} refers to something that behaves set-like, which is not a set and is needed to prevent size issues (there is no set of all sets, otherwise we would obtain Russel's paradox, but there is a collection of all sets), it is not immediately clear how to translate this to type theory.
|
Here \textit{collection} refers to something that behaves set-like, which is not a set and is needed to prevent size issues (there is no set of all sets, otherwise we would obtain Russel's paradox, but there is a collection of all sets), it is not immediately clear how to translate this to type theory.
|
||||||
Furthermore, in mathematical textbooks equality between morphisms is usually taken for granted, i.e. there is some global notion of equality that is clear to everyone. In type theory we need to be more thorough as there is no global notion of equality, eligible for all purposes, e.g. the standard notion of propositional equality has issues when dealing with functions in that it requires extra axioms like functional extensionality.
|
Furthermore, in mathematical textbooks equality between morphisms is usually taken for granted, i.e.\ there is some global notion of equality that is clear to everyone. In type theory we need to be more thorough as there is no global notion of equality, eligible for all purposes, e.g.\ the standard notion of propositional equality has issues when dealing with functions in that it requires extra axioms like functional extensionality.
|
||||||
|
|
||||||
The definition of category that we will work with can be seen in listing~\ref{lst:category} (unnecessary information has been stripped).
|
The definition of category that we will work with can be seen in listing~\ref{lst:category} (unnecessary information has been stripped).
|
||||||
The key differences to the definition above are firstly that instead of talking about collections, Agda's infinite \Verb{Set} hierarchy is utilized to prevent size issues.
|
The key differences to the definition above are firstly that instead of talking about collections, Agda's infinite \Verb{Set} hierarchy is utilized to prevent size issues.
|
||||||
|
@ -64,6 +64,6 @@ From this it should be clear how other basic notions like functors or natural tr
|
||||||
|
|
||||||
\improvement{Explain more}
|
\improvement{Explain more}
|
||||||
|
|
||||||
The Agda formalization of this thesis is structured similar to the agda-categories library, e.g. key concepts like monads and categories correspond to separate top-level folders, which contain the core definitions as well as folders for sub-concepts and their properties, and possibly folders 'Instances' for specific instances, and 'Construction' for blueprints for constructing this concept (e.g. the Kleisli category of a monad would be in 'Category.Construction.Kleisli').
|
The Agda formalization of this thesis is structured similar to the agda-categories library, e.g.\ key concepts like monads and categories correspond to separate top-level folders, which contain the core definitions as well as folders for sub-concepts and their properties, and possibly folders `Instances' for specific instances, and `Construction' for blueprints for constructing this concept (e.g.\ the Kleisli category of a monad would be in `Category.Construction.Kleisli').
|
||||||
|
|
||||||
The source code of the formalization can be found \href{https://git8.cs.fau.de/theses/bsc-leon-vatthauer}{here} (internal) or as clickable HTML \href{https://wwwcip.cs.fau.de/~hy84coky/bsc-thesis/}{here} (public).
|
The source code of the formalization can be found \href{https://git8.cs.fau.de/theses/bsc-leon-vatthauer}{here} (internal) or as clickable HTML \href{https://wwwcip.cs.fau.de/~hy84coky/bsc-thesis/}{here} (public).
|
|
@ -1,5 +1,5 @@
|
||||||
\chapter{Partiality Monads}\label{chp:partiality}
|
\chapter{Partiality Monads}\label{chp:partiality}
|
||||||
Moggi's categorical semantics~\cite{moggi} describe a way to interpret an effectful programming language in a category. For this one needs a (strong) monad $T$ capturing the desired effects, then we can take the elements of $TA$ as denotations for programs of type $A$. The Kleisli category of $T$ can be viewed as the category of programs, which gives us a way of composing programs (Kleisli composition).
|
Moggi's categorical semantics~\cite{moggi} describe a way to interpret an effectful programming language in a category. For this one needs a (strong) monad \(T\) capturing the desired effects, then we can take the elements of \(TA\) as denotations for programs of type \(A\). The Kleisli category of \(T\) can be viewed as the category of programs, which gives us a way of composing programs (Kleisli composition).
|
||||||
|
|
||||||
For this thesis we will restrict ourselves to monads for modelling partiality, the goal of this chapter is to capture what it means to be a partiality monad and look at two common examples.
|
For this thesis we will restrict ourselves to monads for modelling partiality, the goal of this chapter is to capture what it means to be a partiality monad and look at two common examples.
|
||||||
|
|
||||||
|
@ -19,25 +19,25 @@ To ensure that programs are partial, we recall the following notion by Cockett a
|
||||||
|
|
||||||
\newcommand{\tdom}{\text{dom}\;}
|
\newcommand{\tdom}{\text{dom}\;}
|
||||||
\begin{definition}[Restriction Structure]
|
\begin{definition}[Restriction Structure]
|
||||||
A restriction structure on a category $\mathcal{C}$ is a mapping $dom : \mathcal{C}(X, Y) \rightarrow \mathcal{C}(X , X)$ with the following properties:
|
A restriction structure on a category \(\mathcal{C}\) is a mapping \(dom : \mathcal{C}(X, Y) \rightarrow \mathcal{C}(X , X)\) with the following properties:
|
||||||
\begin{alignat*}{1}
|
\begin{alignat*}{1}
|
||||||
f \circ (\tdom f) & = f\tag*{(R1)}\label{R1} \\
|
f \circ (\tdom f) & = f\tag*{(R1)}\label{R1} \\
|
||||||
(\tdom f) \circ (\tdom g) & = (\tdom g) \circ (\tdom f)\tag*{(R2)}\label{R2} \\
|
(\tdom f) \circ (\tdom g) & = (\tdom g) \circ (\tdom f)\tag*{(R2)}\label{R2} \\
|
||||||
\tdom(g \circ (\tdom f)) & = (\tdom g) \circ (\tdom f)\tag*{(R3)}\label{R3} \\
|
\tdom(g \circ (\tdom f)) & = (\tdom g) \circ (\tdom f)\tag*{(R3)}\label{R3} \\
|
||||||
(\tdom h) \circ f & = f \circ \tdom (h \circ f)\tag*{(R4)}\label{R4}
|
(\tdom h) \circ f & = f \circ \tdom (h \circ f)\tag*{(R4)}\label{R4}
|
||||||
\end{alignat*}
|
\end{alignat*}
|
||||||
for any $X, Y, Z \in \vert\mathcal{C}\vert, f : X \rightarrow Y, g : X \rightarrow Z, h: Y \rightarrow Z$.
|
for any \(X, Y, Z \in \vert\mathcal{C}\vert, f : X \rightarrow Y, g : X \rightarrow Z, h: Y \rightarrow Z\).
|
||||||
\end{definition}
|
\end{definition}
|
||||||
|
|
||||||
\begin{lemma}
|
\begin{lemma}
|
||||||
For any $f : X \rightarrow Y$ the restriction morphism $\tdom f$ is idempotent.
|
For any \(f : X \rightarrow Y\) the restriction morphism \(\tdom f\) is idempotent.
|
||||||
\end{lemma}
|
\end{lemma}
|
||||||
\begin{proof}
|
\begin{proof}
|
||||||
This follows by \ref{R3} and \ref{R1}:
|
This follows by~\ref{R3} and~\ref{R1}:
|
||||||
\[\tdom f \circ \tdom f = \tdom (f \circ \tdom f) = \tdom f\]
|
\[\tdom f \circ \tdom f = \tdom (f \circ \tdom f) = \tdom f\]
|
||||||
\end{proof}
|
\end{proof}
|
||||||
|
|
||||||
The idempotent morphism $\tdom f : X \rightarrow X$ represents the domain of definiteness of $f : X \rightarrow Y$. In the category of partial functions this takes the following form:
|
The idempotent morphism \(\tdom f : X \rightarrow X\) represents the domain of definiteness of \(f : X \rightarrow Y\). In the category of partial functions this takes the following form:
|
||||||
|
|
||||||
\[
|
\[
|
||||||
(\tdom f)(x) = \begin{cases}
|
(\tdom f)(x) = \begin{cases}
|
||||||
|
@ -46,30 +46,31 @@ The idempotent morphism $\tdom f : X \rightarrow X$ represents the domain of def
|
||||||
\end{cases}
|
\end{cases}
|
||||||
\]
|
\]
|
||||||
|
|
||||||
That is, $\tdom f$ is only defined on values where $f$ is defined and for those values it behaves like the identity function.
|
That is, \(\tdom f\) is only defined on values where \(f\) is defined and for those values it behaves like the identity function.
|
||||||
|
|
||||||
\begin{definition}[Restriction Category]
|
\begin{definition}[Restriction Category]
|
||||||
Every category has a trivial restriction structure by taking $dom (f : X \rightarrow Y) = id_X$.
|
Every category has a trivial restriction structure by taking \(dom (f : X \rightarrow Y) = id_X\).
|
||||||
We call categories with a non-trivial restriction structure \textit{restriction categories}.
|
We call categories with a non-trivial restriction structure \textit{restriction categories}.
|
||||||
\end{definition}
|
\end{definition}
|
||||||
|
|
||||||
For a suitable defined partiality monad $T$ the Kleisli category $\C^T$ should be a restriction category.
|
For a suitable defined partiality monad \(T\) the Kleisli category \(\C^T\) should be a restriction category.
|
||||||
|
|
||||||
Lastly we also recall the following notion by Bucalo et al.~\cite{eqlm} which captures what it means for a monad to have no other side effect besides some sort of non-termination:
|
Lastly we also recall the following notion by Bucalo et al.~\cite{eqlm} which captures what it means for a monad to have no other side effect besides some sort of non-termination:
|
||||||
|
|
||||||
\begin{definition}[Equational Lifting Monad]
|
\begin{definition}[Equational Lifting Monad]\label{def:eqlm}
|
||||||
\label{def:eqlm}
|
A commutative monad \(T\) is called an \textit{equational lifting monad} if the following diagram commutes:
|
||||||
A commutative monad $T$ is called an \textit{equational lifting monad} if the following diagram commutes:
|
|
||||||
% https://q.uiver.app/#q=WzAsMyxbMCwwLCJUWCJdLFsyLDAsIlRYIFxcdGltZXMgVFgiXSxbMiwyLCJUKFRYIFxcdGltZXMgWCkiXSxbMCwxLCJcXERlbHRhIl0sWzEsMiwiXFx0YXUiXSxbMCwyLCJUIFxcbGFuZ2xlIFxcZXRhICwgaWQgXFxyYW5nbGUiLDJdXQ==
|
% https://q.uiver.app/#q=WzAsMyxbMCwwLCJUWCJdLFsyLDAsIlRYIFxcdGltZXMgVFgiXSxbMiwyLCJUKFRYIFxcdGltZXMgWCkiXSxbMCwxLCJcXERlbHRhIl0sWzEsMiwiXFx0YXUiXSxbMCwyLCJUIFxcbGFuZ2xlIFxcZXRhICwgaWQgXFxyYW5nbGUiLDJdXQ==
|
||||||
\[\begin{tikzcd}
|
\[
|
||||||
|
\begin{tikzcd}
|
||||||
TX && {TX \times TX} \\
|
TX && {TX \times TX} \\
|
||||||
\\
|
\\
|
||||||
&& {T(TX \times X)}
|
&& {T(TX \times X)}
|
||||||
\arrow["\Delta", from=1-1, to=1-3]
|
\arrow["\Delta", from=1-1, to=1-3]
|
||||||
\arrow["\tau", from=1-3, to=3-3]
|
\arrow["\tau", from=1-3, to=3-3]
|
||||||
\arrow["{T \langle \eta , id \rangle}"', from=1-1, to=3-3]
|
\arrow["{T \langle \eta , id \rangle}"', from=1-1, to=3-3]
|
||||||
\end{tikzcd}\]
|
\end{tikzcd}
|
||||||
where $\Delta : X \rightarrow X \times X$ is the diagonal morphism.
|
\]
|
||||||
|
where \(\Delta : X \rightarrow X \times X\) is the diagonal morphism.
|
||||||
\end{definition}
|
\end{definition}
|
||||||
|
|
||||||
To make the equational lifting property more comprehensible we can alternatively state it using do-notation. The equational lifting property states that the following programs must be equal:
|
To make the equational lifting property more comprehensible we can alternatively state it using do-notation. The equational lifting property states that the following programs must be equal:
|
||||||
|
@ -86,16 +87,16 @@ To make the equational lifting property more comprehensible we can alternatively
|
||||||
\end{minted}
|
\end{minted}
|
||||||
\end{multicols}
|
\end{multicols}
|
||||||
|
|
||||||
That is, if some computation $p : TX$ terminates with the result $x : X$, then $p = return\;x$ must hold. This of course implies that running $p$ multiple times yields the same result as running $p$ once.
|
That is, if some computation \(p : TX\) terminates with the result \(x : X\), then \(p = return\;x\) must hold. This of course implies that running \(p\) multiple times yields the same result as running \(p\) once.
|
||||||
|
|
||||||
\begin{theorem}[\cite{eqlm}]
|
\begin{theorem}[\cite{eqlm}]
|
||||||
If $T$ is an equational lifting monad the Kleisli category $\mathcal{C}^T$ is a restriction category.
|
If \(T\) is an equational lifting monad the Kleisli category \(\mathcal{C}^T\) is a restriction category.
|
||||||
\end{theorem}
|
\end{theorem}
|
||||||
|
|
||||||
Definition~\ref{def:eqlm} combines all three properties stated above, so when studying partiality monads in this thesis, we ideally expect them to be equational lifting monads. For the rest of this chapter we will use these definitions to compare two monads that are commonly used to model partiality.
|
Definition~\ref{def:eqlm} combines all three properties stated above, so when studying partiality monads in this thesis, we ideally expect them to be equational lifting monads. For the rest of this chapter we will use these definitions to compare two monads that are commonly used to model partiality.
|
||||||
|
|
||||||
\section{The Maybe Monad}
|
\section{The Maybe Monad}
|
||||||
The endofunctor $MX = X + 1$ extends to a monad by taking $\eta_X = i_1 : X \rightarrow X + 1$ and $\mu_X = [ id , i_2 ] : (X + 1) + 1 \rightarrow X + 1$. The monad laws follow easily. This is generally known as the maybe monad and can be viewed as the canonical example of an equational lifting monad:
|
The endofunctor \(MX = X + 1\) extends to a monad by taking \(\eta_X = i_1 : X \rightarrow X + 1\) and \(\mu_X = [ id , i_2 ] : (X + 1) + 1 \rightarrow X + 1\). The monad laws follow easily. This is generally known as the maybe monad and can be viewed as the canonical example of an equational lifting monad:
|
||||||
|
|
||||||
\begin{theorem} M is an equational lifting monad.
|
\begin{theorem} M is an equational lifting monad.
|
||||||
\end{theorem}
|
\end{theorem}
|
||||||
|
@ -103,7 +104,7 @@ The endofunctor $MX = X + 1$ extends to a monad by taking $\eta_X = i_1 : X \rig
|
||||||
We define strength as:
|
We define strength as:
|
||||||
\[ \tau_{X,Y} := X \times (Y + 1) \overset{dstl}{\longrightarrow} (X \times Y) + (X \times 1) \overset{id+!}{\longrightarrow} (X \times Y) + 1 \]
|
\[ \tau_{X,Y} := X \times (Y + 1) \overset{dstl}{\longrightarrow} (X \times Y) + (X \times 1) \overset{id+!}{\longrightarrow} (X \times Y) + 1 \]
|
||||||
|
|
||||||
Naturality of $\tau$ follows by naturality of $dstl$:
|
Naturality of \(\tau \) follows by naturality of \(dstl\):
|
||||||
|
|
||||||
\begin{alignat*}{1}
|
\begin{alignat*}{1}
|
||||||
& (id + !) \circ dstl \circ (id \times (f + id)) \\
|
& (id + !) \circ dstl \circ (id \times (f + id)) \\
|
||||||
|
@ -116,7 +117,8 @@ The endofunctor $MX = X + 1$ extends to a monad by taking $\eta_X = i_1 : X \rig
|
||||||
|
|
||||||
We are left to check the equational lifting law:
|
We are left to check the equational lifting law:
|
||||||
% https://q.uiver.app/#q=WzAsNCxbMCwwLCJYKzEiXSxbMywwLCIoWCsxKVxcdGltZXMoWCsxKSJdLFszLDIsIigoWCsxKVxcdGltZXMgWCkgKygoWCsxKVxcdGltZXMgMSkiXSxbMyw0LCIoKFgrMSlcXHRpbWVzIFgpKzEiXSxbMCwxLCJcXERlbHRhIl0sWzEsMiwiZHN0bCJdLFsyLDMsImlkK1xcOyEiXSxbMCwzLCJcXGxhbmdsZSBpXzEsaWRcXHJhbmdsZSArIFxcOyEiLDJdXQ==
|
% https://q.uiver.app/#q=WzAsNCxbMCwwLCJYKzEiXSxbMywwLCIoWCsxKVxcdGltZXMoWCsxKSJdLFszLDIsIigoWCsxKVxcdGltZXMgWCkgKygoWCsxKVxcdGltZXMgMSkiXSxbMyw0LCIoKFgrMSlcXHRpbWVzIFgpKzEiXSxbMCwxLCJcXERlbHRhIl0sWzEsMiwiZHN0bCJdLFsyLDMsImlkK1xcOyEiXSxbMCwzLCJcXGxhbmdsZSBpXzEsaWRcXHJhbmdsZSArIFxcOyEiLDJdXQ==
|
||||||
\[\begin{tikzcd}
|
\[
|
||||||
|
\begin{tikzcd}
|
||||||
{X+1} &&& {(X+1)\times(X+1)} \\
|
{X+1} &&& {(X+1)\times(X+1)} \\
|
||||||
\\
|
\\
|
||||||
&&& {((X+1)\times X) +((X+1)\times 1)} \\
|
&&& {((X+1)\times X) +((X+1)\times 1)} \\
|
||||||
|
@ -126,22 +128,23 @@ The endofunctor $MX = X + 1$ extends to a monad by taking $\eta_X = i_1 : X \rig
|
||||||
\arrow["dstl", from=1-4, to=3-4]
|
\arrow["dstl", from=1-4, to=3-4]
|
||||||
\arrow["{id+\;!}", from=3-4, to=5-4]
|
\arrow["{id+\;!}", from=3-4, to=5-4]
|
||||||
\arrow["{\langle i_1,id\rangle + \;!}"', from=1-1, to=5-4]
|
\arrow["{\langle i_1,id\rangle + \;!}"', from=1-1, to=5-4]
|
||||||
\end{tikzcd}\]
|
\end{tikzcd}
|
||||||
|
\]
|
||||||
|
|
||||||
This is easily proven by pre-composing with $i_1$ and $i_2$:
|
This is easily proven by pre-composing with \(i_1\) and \(i_2\):
|
||||||
\begin{alignat*}{1}
|
\begin{alignat*}{1}
|
||||||
&(id\;+\;!) \circ dstl \circ \langle i_1 , i_1 \rangle
|
& (id\;+\;!) \circ dstl \circ \langle i_1 , i_1 \rangle
|
||||||
\\=\;&(id\;+\;!) \circ dstl \circ (id \times i_1) \circ \langle i_1 , id \rangle
|
\\=\;&(id\;+\;!) \circ dstl \circ (id \times i_1) \circ \langle i_1 , id \rangle
|
||||||
\\=\;&(id\;+\;!) \circ i_1 \circ \langle i_1 , id \rangle
|
\\=\;&(id\;+\;!) \circ i_1 \circ \langle i_1 , id \rangle
|
||||||
\\=\;&i_1 \circ \langle i_1 , id \rangle
|
\\=\;&i_1 \circ \langle i_1 , id \rangle
|
||||||
\end{alignat*}
|
\end{alignat*}
|
||||||
|
|
||||||
\begin{alignat*}{1}
|
\begin{alignat*}{1}
|
||||||
&(id\;+\;!) \circ dstl \circ \langle i_2 , i_2 \rangle
|
& (id\;+\;!) \circ dstl \circ \langle i_2 , i_2 \rangle
|
||||||
\\=\;&(id\;+\;!) \circ dstl \circ (id \times i_2) \circ \langle i_2 , id \rangle
|
\\=\;&(id\;+\;!) \circ dstl \circ (id \times i_2) \circ \langle i_2 , id \rangle
|
||||||
\\=\;&(id\;+\;!) \circ i_2 \circ \langle i_2 , id \rangle
|
\\=\;&(id\;+\;!) \circ i_2 \circ \langle i_2 , id \rangle
|
||||||
\\=\;&i_2 \;\circ\; ! \circ \langle i_2 , id \rangle
|
\\=\;&i_2 \;\circ \; ! \circ \langle i_2 , id \rangle
|
||||||
\\=\;&i_2 \;\circ\; !
|
\\=\;&i_2 \;\circ \; !
|
||||||
\end{alignat*}
|
\end{alignat*}
|
||||||
\end{proof}
|
\end{proof}
|
||||||
|
|
||||||
|
@ -150,26 +153,26 @@ In the setting of classical mathematics this monad is therefore sufficient for m
|
||||||
\section{The Delay Monad}
|
\section{The Delay Monad}
|
||||||
\todo[inline]{Take introduction from setoids chapter and put it here!}
|
\todo[inline]{Take introduction from setoids chapter and put it here!}
|
||||||
Capretta's delay monad~\cite{delay} is a coinductive datatype whose inhabitants can be viewed as suspended computations.
|
Capretta's delay monad~\cite{delay} is a coinductive datatype whose inhabitants can be viewed as suspended computations.
|
||||||
This monad is usually defined by the two coinductive constructors $now$ and $later$, where $now$ is for lifting a value to a computation and $later$ intuitively delays a computation by one time unit:
|
This monad is usually defined by the two coinductive constructors \(now\) and \(later\), where \(now\) is for lifting a value to a computation and \(later\) intuitively delays a computation by one time unit:
|
||||||
|
|
||||||
\todo[inline]{Explain convention of double lines vs single lines ==> remove double lines here!!}
|
\todo[inline]{Explain convention of double lines vs single lines ==> remove double lines here!!}
|
||||||
|
|
||||||
\[\mprset{fraction={===}}
|
\[\mprset{fraction={===}}
|
||||||
\inferrule {x : X} {now\; x : DX}\hskip 2cm
|
\inferrule {x : X} {now\; x : DX}\qquad
|
||||||
\inferrule {c : DX} {later\; c : DX}\]
|
\inferrule {c : DX} {later\; c : DX}\]
|
||||||
|
|
||||||
Categorically we obtain this monad by the final coalgebras $DX = \nu A. X + A$, which we assume to exist. In this section we will show that $\mathbf{D}$ is a strong and commutative monad.
|
Categorically we obtain this monad by the final coalgebras \(DX = \nu A. X + A\), which we assume to exist. In this section we will show that \(\mathbf{D}\) is a strong and commutative monad.
|
||||||
|
|
||||||
Since $DX$ is defined as a final coalgebra, we can define morphisms via corecursion and prove theorems by coinduction. By Lambek's lemma the coalgebra structure $out : DX \rightarrow X + DX$ is an isomorphism, whose inverse can be decomposed into the two constructors mentioned before: $out^{-1} = [ now , later ] : X + DX \rightarrow DX$.
|
Since \(DX\) is defined as a final coalgebra, we can define morphisms via corecursion and prove theorems by coinduction. By Lambek's lemma the coalgebra structure \(out : DX \rightarrow X + DX\) is an isomorphism, whose inverse can be decomposed into the two constructors mentioned before: \(out^{-1} = [ now , later ] : X + DX \rightarrow DX\).
|
||||||
|
|
||||||
\begin{lemma}~\label{lem:delay}
|
\begin{lemma}~\label{lem:delay}
|
||||||
The following conditions hold:
|
The following conditions hold:
|
||||||
\begin{itemize}
|
\begin{itemize}
|
||||||
\item $now : X \rightarrow DX$ and $later : DX \rightarrow DX$ satisfy:
|
\item \(now : X \rightarrow DX\) and \(later : DX \rightarrow DX\) satisfy:
|
||||||
\begin{equation*}
|
\begin{equation*}
|
||||||
out \circ now = i_1 \qquad\qquad\qquad out \circ later = i_2 \tag*{(D1)}\label{D1}
|
out \circ now = i_1 \qquad\qquad\qquad out \circ later = i_2 \tag*{(D1)}\label{D1}
|
||||||
\end{equation*}
|
\end{equation*}
|
||||||
\item For any $f : X \rightarrow DY$ there exists a unique morphism $f^* : DX \rightarrow DY$ satisfying:
|
\item For any \(f : X \rightarrow DY\) there exists a unique morphism \(f^* : DX \rightarrow DY\) satisfying:
|
||||||
\begin{equation*}
|
\begin{equation*}
|
||||||
% https://q.uiver.app/#q=WzAsNCxbMCwwLCJEWCJdLFszLDAsIlggKyBEWCJdLFswLDEsIkRZIl0sWzMsMSwiWSArIERZIl0sWzAsMSwib3V0Il0sWzAsMiwiZl4qIiwwLHsic3R5bGUiOnsiYm9keSI6eyJuYW1lIjoiZGFzaGVkIn19fV0sWzIsMywib3V0Il0sWzEsMywiWyBvdXQgXFxjaXJjIGYgLCBpXzIgXFxjaXJjIGZeKiBdIl1d
|
% https://q.uiver.app/#q=WzAsNCxbMCwwLCJEWCJdLFszLDAsIlggKyBEWCJdLFswLDEsIkRZIl0sWzMsMSwiWSArIERZIl0sWzAsMSwib3V0Il0sWzAsMiwiZl4qIiwwLHsic3R5bGUiOnsiYm9keSI6eyJuYW1lIjoiZGFzaGVkIn19fV0sWzIsMywib3V0Il0sWzEsMywiWyBvdXQgXFxjaXJjIGYgLCBpXzIgXFxjaXJjIGZeKiBdIl1d
|
||||||
\begin{tikzcd}
|
\begin{tikzcd}
|
||||||
|
@ -179,9 +182,10 @@ Since $DX$ is defined as a final coalgebra, we can define morphisms via corecurs
|
||||||
\arrow["{f^*}", dashed, from=1-1, to=2-1]
|
\arrow["{f^*}", dashed, from=1-1, to=2-1]
|
||||||
\arrow["out", from=2-1, to=2-4]
|
\arrow["out", from=2-1, to=2-4]
|
||||||
\arrow["{[ out \circ f , i_2 \circ f^* ]}", from=1-4, to=2-4]
|
\arrow["{[ out \circ f , i_2 \circ f^* ]}", from=1-4, to=2-4]
|
||||||
\end{tikzcd}\tag*{(D2)}\label{D2}
|
\end{tikzcd}
|
||||||
|
\tag*{(D2)}\label{D2}
|
||||||
\end{equation*}
|
\end{equation*}
|
||||||
\item There exists a unique morphism $\tau : X \times DY \rightarrow D(X \times Y)$ satisfying:
|
\item There exists a unique morphism \(\tau : X \times DY \rightarrow D(X \times Y)\) satisfying:
|
||||||
\begin{equation*}
|
\begin{equation*}
|
||||||
% https://q.uiver.app/#q=WzAsNSxbMCwwLCJYIFxcdGltZXMgRFkiXSxbMCwxLCJEKFggXFx0aW1lcyBZKSJdLFsyLDAsIlggXFx0aW1lcyAoWSArIERZKSJdLFs0LDAsIlggXFx0aW1lcyBZICsgWCBcXHRpbWVzIERZIl0sWzQsMSwiWCBcXHRpbWVzIFkgKyBEKFggXFx0aW1lcyBZKSJdLFswLDEsIlxcdGF1IiwwLHsic3R5bGUiOnsiYm9keSI6eyJuYW1lIjoiZGFzaGVkIn19fV0sWzAsMiwiaWQgXFx0aW1lcyBvdXQiXSxbMiwzLCJkc3RsIl0sWzMsNCwiaWQgK1xcdGF1IiwyXSxbMSw0LCJvdXQiXV0=
|
% https://q.uiver.app/#q=WzAsNSxbMCwwLCJYIFxcdGltZXMgRFkiXSxbMCwxLCJEKFggXFx0aW1lcyBZKSJdLFsyLDAsIlggXFx0aW1lcyAoWSArIERZKSJdLFs0LDAsIlggXFx0aW1lcyBZICsgWCBcXHRpbWVzIERZIl0sWzQsMSwiWCBcXHRpbWVzIFkgKyBEKFggXFx0aW1lcyBZKSJdLFswLDEsIlxcdGF1IiwwLHsic3R5bGUiOnsiYm9keSI6eyJuYW1lIjoiZGFzaGVkIn19fV0sWzAsMiwiaWQgXFx0aW1lcyBvdXQiXSxbMiwzLCJkc3RsIl0sWzMsNCwiaWQgK1xcdGF1IiwyXSxbMSw0LCJvdXQiXV0=
|
||||||
\begin{tikzcd}[ampersand replacement=\&]
|
\begin{tikzcd}[ampersand replacement=\&]
|
||||||
|
@ -192,22 +196,24 @@ Since $DX$ is defined as a final coalgebra, we can define morphisms via corecurs
|
||||||
\arrow["dstl", from=1-3, to=1-5]
|
\arrow["dstl", from=1-3, to=1-5]
|
||||||
\arrow["{id +\tau}"', from=1-5, to=2-5]
|
\arrow["{id +\tau}"', from=1-5, to=2-5]
|
||||||
\arrow["out", from=2-1, to=2-5]
|
\arrow["out", from=2-1, to=2-5]
|
||||||
\end{tikzcd}\tag*{(D3)}\label{D3}
|
\end{tikzcd}
|
||||||
|
\tag*{(D3)}\label{D3}
|
||||||
\end{equation*}
|
\end{equation*}
|
||||||
\end{itemize}
|
\end{itemize}
|
||||||
\end{lemma}
|
\end{lemma}
|
||||||
\begin{proof}
|
\begin{proof}
|
||||||
We will make use of the fact that every $DX$ is a final coalgebra:
|
We will make use of the fact that every \(DX\) is a final coalgebra:
|
||||||
\begin{itemize}
|
\begin{itemize}
|
||||||
\item[\ref{D1}] These follow by definition:
|
\item[\ref{D1}] These follow by definition:
|
||||||
\begin{alignat*}{3}
|
\begin{alignat*}{3}
|
||||||
&out \circ now &&= out \circ out^{-1} \circ i_1 &= i_1
|
& out \circ now & & = out \circ out^{-1} \circ i_1 & = i_1
|
||||||
\\&out \circ later &&= out \circ out^{-1} \circ i_2 &= i_2
|
\\&out \circ later &&= out \circ out^{-1} \circ i_2 &= i_2
|
||||||
\end{alignat*}
|
\end{alignat*}
|
||||||
\item[\ref{D2}] We define $f^* = \;\coalg{\alpha} \circ i_1$, where $\coalg{\alpha}$ is the unique coalgebra morphism in this diagram:
|
\item[\ref{D2}] We define \(f^* = \;\coalg{\alpha} \circ i_1\), where \(\coalg{\alpha}\) is the unique coalgebra morphism in this diagram:
|
||||||
|
|
||||||
% https://q.uiver.app/#q=WzAsNSxbMCwxLCJEWCArIERZIl0sWzcsMSwiWSArIChEWCArIERZKSJdLFswLDAsIkRYIl0sWzAsMiwiRFkiXSxbNywyLCJZICsgRFkiXSxbMCwxLCJcXGFscGhhIDo9IFsgWyBbIGlfMSAsIGlfMiBcXGNpcmMgaV8yIF0gXFxjaXJjIChvdXQgXFxjaXJjIGYpICwgaV8yIFxcY2lyYyBpXzEgXSBcXGNpcmMgb3V0ICwgKGlkICsgaV8yKSBcXGNpcmMgb3V0IF0iXSxbMiwwLCJpXzEiXSxbMCwzLCJcXGNvYWxne1xcYWxwaGF9IiwwLHsic3R5bGUiOnsiYm9keSI6eyJuYW1lIjoiZGFzaGVkIn19fV0sWzMsNCwib3V0Il0sWzEsNCwiaWQgKyBcXGNvYWxne1xcYWxwaGF9IiwwLHsic3R5bGUiOnsiYm9keSI6eyJuYW1lIjoiZGFzaGVkIn19fV1d
|
% https://q.uiver.app/#q=WzAsNSxbMCwxLCJEWCArIERZIl0sWzcsMSwiWSArIChEWCArIERZKSJdLFswLDAsIkRYIl0sWzAsMiwiRFkiXSxbNywyLCJZICsgRFkiXSxbMCwxLCJcXGFscGhhIDo9IFsgWyBbIGlfMSAsIGlfMiBcXGNpcmMgaV8yIF0gXFxjaXJjIChvdXQgXFxjaXJjIGYpICwgaV8yIFxcY2lyYyBpXzEgXSBcXGNpcmMgb3V0ICwgKGlkICsgaV8yKSBcXGNpcmMgb3V0IF0iXSxbMiwwLCJpXzEiXSxbMCwzLCJcXGNvYWxne1xcYWxwaGF9IiwwLHsic3R5bGUiOnsiYm9keSI6eyJuYW1lIjoiZGFzaGVkIn19fV0sWzMsNCwib3V0Il0sWzEsNCwiaWQgKyBcXGNvYWxne1xcYWxwaGF9IiwwLHsic3R5bGUiOnsiYm9keSI6eyJuYW1lIjoiZGFzaGVkIn19fV1d
|
||||||
\[\begin{tikzcd}[ampersand replacement=\&]
|
\[
|
||||||
|
\begin{tikzcd}[ampersand replacement=\&]
|
||||||
DX \\
|
DX \\
|
||||||
{DX + DY} \&\&\&\&\&\&\& {Y + (DX + DY)} \\
|
{DX + DY} \&\&\&\&\&\&\& {Y + (DX + DY)} \\
|
||||||
DY \&\&\&\&\&\&\& {Y + DY}
|
DY \&\&\&\&\&\&\& {Y + DY}
|
||||||
|
@ -216,19 +222,20 @@ Since $DX$ is defined as a final coalgebra, we can define morphisms via corecurs
|
||||||
\arrow["{\coalg{\alpha}}", dashed, from=2-1, to=3-1]
|
\arrow["{\coalg{\alpha}}", dashed, from=2-1, to=3-1]
|
||||||
\arrow["out", from=3-1, to=3-8]
|
\arrow["out", from=3-1, to=3-8]
|
||||||
\arrow["{id + \coalg{\alpha}}", dashed, from=2-8, to=3-8]
|
\arrow["{id + \coalg{\alpha}}", dashed, from=2-8, to=3-8]
|
||||||
\end{tikzcd}\]
|
\end{tikzcd}
|
||||||
|
\]
|
||||||
|
|
||||||
Note that $\coalg{\alpha} \circ i_2 = id : (DY, out) \rightarrow (DY, out)$, by uniqueness of the identity morphism and the fact that $\coalg{\alpha} \circ i_2$ is a coalgebra morphism:
|
Note that \(\coalg{\alpha} \circ i_2 = id : (DY, out) \rightarrow (DY, out)\), by uniqueness of the identity morphism and the fact that \(\coalg{\alpha} \circ i_2\) is a coalgebra morphism:
|
||||||
\begin{alignat*}{1}
|
\begin{alignat*}{1}
|
||||||
&out \circ \coalg{\alpha} \circ i_2
|
& out \circ \coalg{\alpha} \circ i_2
|
||||||
\\=\;&(id+\coalg{\alpha}) \circ \alpha \circ i_2
|
\\=\;&(id+\coalg{\alpha}) \circ \alpha \circ i_2
|
||||||
\\=\;&(id + \coalg{\alpha}) \circ (id + i_2) \circ out
|
\\=\;&(id + \coalg{\alpha}) \circ (id + i_2) \circ out
|
||||||
\\=\;&(id + \coalg{\alpha} \circ i_2) \circ out
|
\\=\;&(id + \coalg{\alpha} \circ i_2) \circ out
|
||||||
\end{alignat*}
|
\end{alignat*}
|
||||||
Let us verify that $f^*$ indeed satisfies the requisite property:
|
Let us verify that \(f^*\) indeed satisfies the requisite property:
|
||||||
|
|
||||||
\begin{alignat*}{1}
|
\begin{alignat*}{1}
|
||||||
&out \circ \coalg{\alpha} \circ i_1
|
& out \circ \coalg{\alpha} \circ i_1
|
||||||
\\=\;&(id + \coalg{\alpha}) \circ \alpha \circ i_1
|
\\=\;&(id + \coalg{\alpha}) \circ \alpha \circ i_1
|
||||||
\\=\;&(id + \coalg{\alpha}) \circ [ [ i_1 , i_2 \circ i_2 ] \circ out \circ f , i_2 \circ i_1 ] \circ out
|
\\=\;&(id + \coalg{\alpha}) \circ [ [ i_1 , i_2 \circ i_2 ] \circ out \circ f , i_2 \circ i_1 ] \circ out
|
||||||
\\=\;&[ [ (id + \coalg{\alpha}) \circ i_1 , (id + \coalg{\alpha}) \circ i_2 \circ i_2 ] \circ out \circ f , (id + \coalg{\alpha}) \circ i_2 \circ i_1 ] \circ out
|
\\=\;&[ [ (id + \coalg{\alpha}) \circ i_1 , (id + \coalg{\alpha}) \circ i_2 \circ i_2 ] \circ out \circ f , (id + \coalg{\alpha}) \circ i_2 \circ i_1 ] \circ out
|
||||||
|
@ -236,53 +243,53 @@ Since $DX$ is defined as a final coalgebra, we can define morphisms via corecurs
|
||||||
\\=\;&[ out \circ f , i_2 \circ f^* ] \circ out
|
\\=\;&[ out \circ f , i_2 \circ f^* ] \circ out
|
||||||
\end{alignat*}
|
\end{alignat*}
|
||||||
|
|
||||||
We are left to check uniqueness of $f^*$. Let $g : DX \rightarrow DY$ and $out \circ g = [ out \circ f , i_2 \circ g ] \circ out$.
|
We are left to check uniqueness of \(f^*\). Let \(g : DX \rightarrow DY\) and \(out \circ g = [ out \circ f , i_2 \circ g ] \circ out\).
|
||||||
Note that $[ g , id ] : DX + DY \rightarrow DY$ is a coalgebra morphism:
|
Note that \([ g , id ] : DX + DY \rightarrow DY\) is a coalgebra morphism:
|
||||||
\begin{alignat*}{1}
|
\begin{alignat*}{1}
|
||||||
&out \circ [ g , id ]
|
& out \circ [ g , id ]
|
||||||
\\=\;&[ out \circ g , out ]
|
\\=\;&[ out \circ g , out ]
|
||||||
\\=\;&[ [ out \circ f , i_2 \circ g ] \circ out , out]
|
\\=\;&[ [ out \circ f , i_2 \circ g ] \circ out , out]
|
||||||
\\=\;&[ [ [ i_1 , i_2 ] \circ out \circ f , i_2 \circ g ] \circ out , (id + id) \circ out ]
|
\\=\;&[ [ [ i_1 , i_2 ] \circ out \circ f , i_2 \circ g ] \circ out , (id + id) \circ out ]
|
||||||
\\=\;&[ [ [ i_1 , i_2 \circ [g , id] \circ i_2 ] \circ out \circ f , i_2 \circ [g , id] \circ i_1 ] \circ out , (id + [g , id] \circ i_2) \circ out ]
|
\\=\;&[ [ [ i_1 , i_2 \circ [g , id] \circ i_2 ] \circ out \circ f , i_2 \circ [g , id] \circ i_1 ] \circ out , (id + [g , id] \circ i_2) \circ out ]
|
||||||
\\=\;&[ [ [ (id + [g , id]) \circ i_1 , (id + [g , id]) \circ i_2 \circ i_2 ] \circ out \circ f , (id + [g , id]) \circ i_2 \circ i_1 ] \circ out
|
\\=\;&[ [ [ (id + [g , id]) \circ i_1 , (id + [g , id]) \circ i_2 \circ i_2 ] \circ out \circ f , (id + [g , id]) \circ i_2 \circ i_1 ] \circ out
|
||||||
\\\;&, (id + [g , id]) \circ (id + i_2) \circ out ]
|
\\ \;&, (id + [g , id]) \circ (id + i_2) \circ out ]
|
||||||
\\=\;&(id + [g , id]) \circ [ [ [ i_1 , i_2 \circ i_2 ] \circ out \circ f , i_2 \circ i_1 ] \circ out , (id + i_2) \circ out ]
|
\\=\;&(id + [g , id]) \circ [ [ [ i_1 , i_2 \circ i_2 ] \circ out \circ f , i_2 \circ i_1 ] \circ out , (id + i_2) \circ out ]
|
||||||
\end{alignat*}
|
\end{alignat*}
|
||||||
|
|
||||||
Thus, $[ g , id ] = \coalg{\alpha}$ by uniqueness of $\coalg{\alpha}$.
|
Thus, \([ g , id ] = \coalg{\alpha}\) by uniqueness of \(\coalg{\alpha}\).
|
||||||
It follows: \[g = [ g , id ] \circ i_1 =\;\coalg{\alpha} \circ i_1 = f^*\]
|
It follows: \[g = [ g , id ] \circ i_1 =\;\coalg{\alpha} \circ i_1 = f^*\]
|
||||||
\item[\ref{D3}] This follows immediately since $\tau$ is the unique coalgebra morphism from $(X \times DY, dstl \circ (id \times out))$ into the terminal coalgebra $(D(X \times Y) , out)$.
|
\item[\ref{D3}] This follows immediately since \(\tau \) is the unique coalgebra morphism from \((X \times DY, dstl \circ (id \times out))\) into the terminal coalgebra \((D(X \times Y) , out)\).
|
||||||
\end{itemize}
|
\end{itemize}
|
||||||
\end{proof}
|
\end{proof}
|
||||||
|
|
||||||
\begin{lemma}
|
\begin{lemma}
|
||||||
The following properties follow from \autoref{lem:delay}:
|
The following properties follow from \autoref{lem:delay}:
|
||||||
\begin{enumerate}
|
\begin{enumerate}
|
||||||
\item $out \circ Df = (f + Df) \circ out$
|
\item \(out \circ Df = (f + Df) \circ out\)
|
||||||
\item $f^* = [ f , {(later \circ f)}^* ] \circ out$
|
\item \(f^* = [ f , {(later \circ f)}^* ] \circ out\)
|
||||||
\item $later \circ f^* = {(later \circ f)}^* = f^* \circ later$
|
\item \(later \circ f^* = {(later \circ f)}^* = f^* \circ later\)
|
||||||
\end{enumerate}
|
\end{enumerate}
|
||||||
\end{lemma}
|
\end{lemma}
|
||||||
\begin{proof}
|
\begin{proof}
|
||||||
\begin{itemize}
|
\begin{itemize}
|
||||||
\item[1.] Note that definitionally: $Df = {(now \circ f)}^*$ for any $f : X \rightarrow TY$. The statement is then simply a consequence of~\ref{D1} and~\ref{D2}:
|
\item[1.] Note that definitionally: \(Df = {(now \circ f)}^*\) for any \(f : X \rightarrow TY\). The statement is then simply a consequence of~\ref{D1} and~\ref{D2}:
|
||||||
\begin{alignat*}{1}
|
\begin{alignat*}{1}
|
||||||
&out \circ Df
|
& out \circ Df
|
||||||
\\=\;&out \circ {(now \circ f)}^*
|
\\=\;&out \circ {(now \circ f)}^*
|
||||||
\\=\;&[ out \circ now \circ f , i_2 \circ {(now \circ f)}^* ] \circ out\tag*{\ref{D2}}
|
\\=\;&[ out \circ now \circ f , i_2 \circ {(now \circ f)}^* ] \circ out\tag*{\ref{D2}}
|
||||||
\\=\;&(f + Df) \circ out\tag*{\ref{D1}}
|
\\=\;&(f + Df) \circ out\tag*{\ref{D1}}
|
||||||
\end{alignat*}
|
\end{alignat*}
|
||||||
\item[2.] By uniqueness of $f^*$ it suffices to show:
|
\item[2.] By uniqueness of \(f^*\) it suffices to show:
|
||||||
\begin{alignat*}{1}
|
\begin{alignat*}{1}
|
||||||
&out \circ [ f , {(later \circ f)}^* ] \circ out
|
& out \circ [ f , {(later \circ f)}^* ] \circ out
|
||||||
\\=\;&[ out \circ f , out \circ {(later \circ f)}^* ] \circ out
|
\\=\;&[ out \circ f , out \circ {(later \circ f)}^* ] \circ out
|
||||||
\\=\;&[out \circ f , [ out \circ later \circ f , i_2 \circ {(later \circ f)}^* ] \circ out ] \circ out\tag*{\ref{D2}}
|
\\=\;&[out \circ f , [ out \circ later \circ f , i_2 \circ {(later \circ f)}^* ] \circ out ] \circ out\tag*{\ref{D2}}
|
||||||
\\=\;&[out \circ f , i_2 \circ [ f , {(later \circ f)}^* ] \circ out ] \circ out\tag*{\ref{D1}}
|
\\=\;&[out \circ f , i_2 \circ [ f , {(later \circ f)}^* ] \circ out ] \circ out\tag*{\ref{D1}}
|
||||||
\end{alignat*}
|
\end{alignat*}
|
||||||
\item[3.]
|
\item[3.]
|
||||||
These equations follow by monicity of $out$:
|
These equations follow by monicity of \(out\):
|
||||||
\begin{alignat*}{1}
|
\begin{alignat*}{1}
|
||||||
&out \circ {(later \circ f)}^*
|
& out \circ {(later \circ f)}^*
|
||||||
\\=\;&[ out \circ later \circ f , i_2 \circ {(later \circ f)}^*] \circ out\tag*{\ref{D2}}
|
\\=\;&[ out \circ later \circ f , i_2 \circ {(later \circ f)}^*] \circ out\tag*{\ref{D2}}
|
||||||
\\=\;&i_2 \circ [ f , {(later \circ f)}^*] \circ out\tag*{\ref{D1}}
|
\\=\;&i_2 \circ [ f , {(later \circ f)}^*] \circ out\tag*{\ref{D1}}
|
||||||
\\=\;&i_2 \circ f^*
|
\\=\;&i_2 \circ f^*
|
||||||
|
@ -296,23 +303,23 @@ Since $DX$ is defined as a final coalgebra, we can define morphisms via corecurs
|
||||||
\end{proof}
|
\end{proof}
|
||||||
|
|
||||||
\begin{theorem}
|
\begin{theorem}
|
||||||
$\mathbf{D} = (D, now, (-)^*)$ is a Kleisli triple.
|
\(\mathbf{D} = (D, now, {(-)}^*)\) is a Kleisli triple.
|
||||||
\end{theorem}
|
\end{theorem}
|
||||||
\begin{proof}
|
\begin{proof}
|
||||||
We will now use the properties proven in Corollary~\ref{lem:delay} to prove the Kleisli triple laws:
|
We will now use the properties proven in Corollary~\ref{lem:delay} to prove the Kleisli triple laws:
|
||||||
\begin{itemize}
|
\begin{itemize}
|
||||||
\item[\ref{K1}]
|
\item[\ref{K1}]
|
||||||
By uniqueness of $now^*$ it suffices to show that $out \circ id = [ out \circ now , i_2 \circ id ] \circ out$ which instantly follows by \ref{D1}.
|
By uniqueness of \(now^*\) it suffices to show that \(out \circ id = [ out \circ now , i_2 \circ id ] \circ out\) which instantly follows by~\ref{D1}.
|
||||||
\item[\ref{K2}] Let $f : X \rightarrow DY$. We proceed by monicity of $out$:
|
\item[\ref{K2}] Let \(f : X \rightarrow DY\). We proceed by monicity of \(out\):
|
||||||
\begin{alignat*}{1}
|
\begin{alignat*}{1}
|
||||||
&out \circ f^* \circ now
|
& out \circ f^* \circ now
|
||||||
\\=\;&[ out \circ f , i_2 \circ f^* ] \circ out \circ now\tag*{\ref{D2}}
|
\\=\;&[ out \circ f , i_2 \circ f^* ] \circ out \circ now\tag*{\ref{D2}}
|
||||||
\\=\;&[ out \circ f , i_2 \circ f^* ] \circ i_1\tag*{\ref{D1}}
|
\\=\;&[ out \circ f , i_2 \circ f^* ] \circ i_1\tag*{\ref{D1}}
|
||||||
\\=\;&out \circ f
|
\\=\;&out \circ f
|
||||||
\end{alignat*}
|
\end{alignat*}
|
||||||
\item[\ref{K3}] Let $f : Y \rightarrow Z, g : X \rightarrow Z$ to show $f^* \circ g^* = (f^* \circ g)^*$ by uniqueness of $(f^* \circ g)^*$ it suffices to show:
|
\item[\ref{K3}] Let \(f : Y \rightarrow Z, g : X \rightarrow Z\) to show \(f^* \circ g^* = {(f^* \circ g)}^*\) by uniqueness of \({(f^* \circ g)}^*\) it suffices to show:
|
||||||
\begin{alignat*}{1}
|
\begin{alignat*}{1}
|
||||||
&out \circ f^* \circ g^*
|
& out \circ f^* \circ g^*
|
||||||
\\=\;&[ out \circ f , i_2 \circ f^* ] \circ out \circ g^*\tag*{\ref{D2}}
|
\\=\;&[ out \circ f , i_2 \circ f^* ] \circ out \circ g^*\tag*{\ref{D2}}
|
||||||
\\=\;&[ out \circ f , i_2 \circ f^* ] \circ [ out \circ g , i_2 \circ g^* ] \circ out\tag*{\ref{D2}}
|
\\=\;&[ out \circ f , i_2 \circ f^* ] \circ [ out \circ g , i_2 \circ g^* ] \circ out\tag*{\ref{D2}}
|
||||||
\\=\;&[ [ out \circ f , i_2 \circ f^* ] \circ out \circ g , i_2 \circ f^* \circ g^* ] \circ out
|
\\=\;&[ [ out \circ f , i_2 \circ f^* ] \circ out \circ g , i_2 \circ f^* \circ g^* ] \circ out
|
||||||
|
@ -321,11 +328,12 @@ Since $DX$ is defined as a final coalgebra, we can define morphisms via corecurs
|
||||||
\end{itemize}
|
\end{itemize}
|
||||||
\end{proof}
|
\end{proof}
|
||||||
|
|
||||||
Finality of the coalgebras $(DX, out : DX \rightarrow X + DX)_{X \in \obj{\C}}$ yields the following proof principle:
|
Finality of the coalgebras \({(DX, out : DX \rightarrow X + DX)}_{X \in \obj{\C}}\) yields the following proof principle:
|
||||||
\begin{remark}[Proof by coinduction]~\label{rem:coinduction}
|
\begin{remark}[Proof by coinduction]~\label{rem:coinduction}
|
||||||
Given two morphisms $f, g : X \rightarrow DY$. To show that $f = g$ it suffices to show that there exists a coalgebra structure $\alpha : X \rightarrow Y + X$ such that the following diagrams commute:
|
Given two morphisms \(f, g : X \rightarrow DY\). To show that \(f = g\) it suffices to show that there exists a coalgebra structure \(\alpha : X \rightarrow Y + X\) such that the following diagrams commute:
|
||||||
% https://q.uiver.app/#q=WzAsOCxbMCwwLCJYIl0sWzAsMSwiRFkiXSxbMiwxLCJZICsgRFkiXSxbMiwwLCJZICsgWCJdLFs0LDAsIlgiXSxbNCwxLCJEWSJdLFs2LDAsIlkgKyBYIl0sWzYsMSwiWSArIERZIl0sWzEsMiwib3V0Il0sWzAsMywiXFxhbHBoYSJdLFswLDEsImYiXSxbMywyLCJpZCArIGYiXSxbNCw2LCJcXGFscGhhIl0sWzQsNSwiZyJdLFs2LDcsImlkICsgZyJdLFs1LDcsIm91dCJdXQ==
|
% https://q.uiver.app/#q=WzAsOCxbMCwwLCJYIl0sWzAsMSwiRFkiXSxbMiwxLCJZICsgRFkiXSxbMiwwLCJZICsgWCJdLFs0LDAsIlgiXSxbNCwxLCJEWSJdLFs2LDAsIlkgKyBYIl0sWzYsMSwiWSArIERZIl0sWzEsMiwib3V0Il0sWzAsMywiXFxhbHBoYSJdLFswLDEsImYiXSxbMywyLCJpZCArIGYiXSxbNCw2LCJcXGFscGhhIl0sWzQsNSwiZyJdLFs2LDcsImlkICsgZyJdLFs1LDcsIm91dCJdXQ==
|
||||||
\[\begin{tikzcd}[ampersand replacement=\&]
|
\[
|
||||||
|
\begin{tikzcd}[ampersand replacement=\&]
|
||||||
X \&\& {Y + X} \&\& X \&\& {Y + X} \\
|
X \&\& {Y + X} \&\& X \&\& {Y + X} \\
|
||||||
DY \&\& {Y + DY} \&\& DY \&\& {Y + DY}
|
DY \&\& {Y + DY} \&\& DY \&\& {Y + DY}
|
||||||
\arrow["out", from=2-1, to=2-3]
|
\arrow["out", from=2-1, to=2-3]
|
||||||
|
@ -336,21 +344,23 @@ Finality of the coalgebras $(DX, out : DX \rightarrow X + DX)_{X \in \obj{\C}}$
|
||||||
\arrow["g", from=1-5, to=2-5]
|
\arrow["g", from=1-5, to=2-5]
|
||||||
\arrow["{id + g}", from=1-7, to=2-7]
|
\arrow["{id + g}", from=1-7, to=2-7]
|
||||||
\arrow["out", from=2-5, to=2-7]
|
\arrow["out", from=2-5, to=2-7]
|
||||||
\end{tikzcd}\]
|
\end{tikzcd}
|
||||||
Uniqueness of the coalgebra morphism $\coalg{\alpha} : (X, \alpha) \rightarrow (DY, out)$ then results in $f = g$.
|
\]
|
||||||
|
Uniqueness of the coalgebra morphism \(\coalg{\alpha} : (X, \alpha) \rightarrow (DY, out)\) then results in \(f = g\).
|
||||||
\end{remark}
|
\end{remark}
|
||||||
|
|
||||||
\begin{theorem}
|
\begin{theorem}
|
||||||
$\mathbf{D}$ is a strong monad.
|
\(\mathbf{D}\) is a strong monad.
|
||||||
\end{theorem}
|
\end{theorem}
|
||||||
\begin{proof}
|
\begin{proof}
|
||||||
Most of the following proofs are done via coinduction (Remark~\ref{rem:coinduction}). We will only give the requisite coalgebra structure. The proofs that the diagrams commute can be looked up in the Agda formalization.
|
Most of the following proofs are done via coinduction (Remark~\ref{rem:coinduction}). We will only give the requisite coalgebra structure. The proofs that the diagrams commute can be looked up in the Agda formalization.
|
||||||
|
|
||||||
First we need to show naturality of $\tau$, i.e. we need to show that
|
First we need to show naturality of \(\tau \), i.e.\ we need to show that
|
||||||
\[\tau \circ (f \times (now \circ g)^*) = (now \circ (f \times g))^* \circ \tau\]
|
\[\tau \circ (f \times {(now \circ g)}^*) = {(now \circ (f \times g))}^* \circ \tau \]
|
||||||
The coalgebra for coinduction is:
|
The coalgebra for coinduction is:
|
||||||
% https://q.uiver.app/#q=WzAsNixbMCwwLCJYIFxcdGltZXMgRFkiXSxbMCwyLCJEKEFcXHRpbWVzIEIpIl0sWzQsMiwiQVxcdGltZXMgQiArIEQoQSBcXHRpbWVzIEIpIl0sWzEsMCwiWCBcXHRpbWVzIChZICsgRFkpIl0sWzIsMCwiWCBcXHRpbWVzIFkgKyBYIFxcdGltZXMgRFkiXSxbNCwwLCJBIFxcdGltZXMgQiArIFggXFx0aW1lcyBEWSJdLFsxLDIsIm91dCJdLFswLDMsImlkIFxcdGltZXMgb3V0Il0sWzMsNCwiZHN0bCJdLFswLDEsIlxcY29hbGd7LX0iLDAseyJzdHlsZSI6eyJib2R5Ijp7Im5hbWUiOiJkYXNoZWQifX19XSxbNCw1LCJmIFxcdGltZXMgZyArIGlkIl0sWzUsMiwiaWQgKyBcXGNvYWxney19IiwwLHsic3R5bGUiOnsiYm9keSI6eyJuYW1lIjoiZGFzaGVkIn19fV1d
|
% https://q.uiver.app/#q=WzAsNixbMCwwLCJYIFxcdGltZXMgRFkiXSxbMCwyLCJEKEFcXHRpbWVzIEIpIl0sWzQsMiwiQVxcdGltZXMgQiArIEQoQSBcXHRpbWVzIEIpIl0sWzEsMCwiWCBcXHRpbWVzIChZICsgRFkpIl0sWzIsMCwiWCBcXHRpbWVzIFkgKyBYIFxcdGltZXMgRFkiXSxbNCwwLCJBIFxcdGltZXMgQiArIFggXFx0aW1lcyBEWSJdLFsxLDIsIm91dCJdLFswLDMsImlkIFxcdGltZXMgb3V0Il0sWzMsNCwiZHN0bCJdLFswLDEsIlxcY29hbGd7LX0iLDAseyJzdHlsZSI6eyJib2R5Ijp7Im5hbWUiOiJkYXNoZWQifX19XSxbNCw1LCJmIFxcdGltZXMgZyArIGlkIl0sWzUsMiwiaWQgKyBcXGNvYWxney19IiwwLHsic3R5bGUiOnsiYm9keSI6eyJuYW1lIjoiZGFzaGVkIn19fV1d
|
||||||
\[\begin{tikzcd}[ampersand replacement=\&]
|
\[
|
||||||
|
\begin{tikzcd}[ampersand replacement=\&]
|
||||||
{X \times DY} \& {X \times (Y + DY)} \& {X \times Y + X \times DY} \&\& {A \times B + X \times DY} \\
|
{X \times DY} \& {X \times (Y + DY)} \& {X \times Y + X \times DY} \&\& {A \times B + X \times DY} \\
|
||||||
\\
|
\\
|
||||||
{D(A\times B)} \&\&\&\& {A\times B + D(A \times B)}
|
{D(A\times B)} \&\&\&\& {A\times B + D(A \times B)}
|
||||||
|
@ -360,15 +370,17 @@ Finality of the coalgebras $(DX, out : DX \rightarrow X + DX)_{X \in \obj{\C}}$
|
||||||
\arrow["{\coalg{\text{-}}}", dashed, from=1-1, to=3-1]
|
\arrow["{\coalg{\text{-}}}", dashed, from=1-1, to=3-1]
|
||||||
\arrow["{f \times g + id}", from=1-3, to=1-5]
|
\arrow["{f \times g + id}", from=1-3, to=1-5]
|
||||||
\arrow["{id + \coalg{\text{-}}}", dashed, from=1-5, to=3-5]
|
\arrow["{id + \coalg{\text{-}}}", dashed, from=1-5, to=3-5]
|
||||||
\end{tikzcd}\]
|
\end{tikzcd}
|
||||||
We write $\coalg{\text{-}}$ to abbreviate the used coalgebra, i.e.\ in the previous diagram
|
\]
|
||||||
|
We write \(\coalg{\text{-}}\) to abbreviate the used coalgebra, i.e.\ in the previous diagram
|
||||||
\[\coalg{\text{-}} = \coalg{(f\times g + id) \circ dstl \circ (id \times out)}.\]
|
\[\coalg{\text{-}} = \coalg{(f\times g + id) \circ dstl \circ (id \times out)}.\]
|
||||||
|
|
||||||
Next we check the strength laws:
|
Next we check the strength laws:
|
||||||
\begin{itemize}
|
\begin{itemize}
|
||||||
\item[\ref{S1}] To show that $(now \circ \pi_2)^* \circ \tau = \pi_2$ we do coinduction using the following coalgebra:
|
\item[\ref{S1}] To show that \({(now \circ \pi_2)}^* \circ \tau = \pi_2\) we do coinduction using the following coalgebra:
|
||||||
% https://q.uiver.app/#q=WzAsNixbMCwwLCIxIFxcdGltZXMgRFgiXSxbMCwxLCJEWCJdLFszLDAsIlggKyAxIFxcdGltZXMgRFgiXSxbMywxLCJYICsgRFgiXSxbMSwwLCIxIFxcdGltZXMgWCArIERYIl0sWzIsMCwiMSBcXHRpbWVzIFggKyAxIFxcdGltZXMgRFgiXSxbMSwzLCJvdXQiXSxbMCwxLCJcXGNvYWxney19IiwwLHsic3R5bGUiOnsiYm9keSI6eyJuYW1lIjoiZGFzaGVkIn19fV0sWzIsMywiaWQgKyBcXGNvYWxney19Il0sWzAsNCwiaWQgXFx0aW1lcyBvdXQiXSxbNCw1LCJkc3RsIl0sWzUsMiwiXFxwaV8yICsgaWQiXV0=
|
% https://q.uiver.app/#q=WzAsNixbMCwwLCIxIFxcdGltZXMgRFgiXSxbMCwxLCJEWCJdLFszLDAsIlggKyAxIFxcdGltZXMgRFgiXSxbMywxLCJYICsgRFgiXSxbMSwwLCIxIFxcdGltZXMgWCArIERYIl0sWzIsMCwiMSBcXHRpbWVzIFggKyAxIFxcdGltZXMgRFgiXSxbMSwzLCJvdXQiXSxbMCwxLCJcXGNvYWxney19IiwwLHsic3R5bGUiOnsiYm9keSI6eyJuYW1lIjoiZGFzaGVkIn19fV0sWzIsMywiaWQgKyBcXGNvYWxney19Il0sWzAsNCwiaWQgXFx0aW1lcyBvdXQiXSxbNCw1LCJkc3RsIl0sWzUsMiwiXFxwaV8yICsgaWQiXV0=
|
||||||
\[\begin{tikzcd}[ampersand replacement=\&]
|
\[
|
||||||
|
\begin{tikzcd}[ampersand replacement=\&]
|
||||||
{1 \times DX} \& {1 \times X + DX} \& {1 \times X + 1 \times DX} \& {X + 1 \times DX} \\
|
{1 \times DX} \& {1 \times X + DX} \& {1 \times X + 1 \times DX} \& {X + 1 \times DX} \\
|
||||||
DX \&\&\& {X + DX}
|
DX \&\&\& {X + DX}
|
||||||
\arrow["out", from=2-1, to=2-4]
|
\arrow["out", from=2-1, to=2-4]
|
||||||
|
@ -377,12 +389,13 @@ Finality of the coalgebras $(DX, out : DX \rightarrow X + DX)_{X \in \obj{\C}}$
|
||||||
\arrow["{id \times out}", from=1-1, to=1-2]
|
\arrow["{id \times out}", from=1-1, to=1-2]
|
||||||
\arrow["dstl", from=1-2, to=1-3]
|
\arrow["dstl", from=1-2, to=1-3]
|
||||||
\arrow["{\pi_2 + id}", from=1-3, to=1-4]
|
\arrow["{\pi_2 + id}", from=1-3, to=1-4]
|
||||||
\end{tikzcd}\]
|
\end{tikzcd}
|
||||||
\item[\ref{S2}] We don't need coinduction to show $\tau \circ (id \times now) = now$, but we need a small helper lemma:
|
\]
|
||||||
|
\item[\ref{S2}] We don't need coinduction to show \(\tau \circ (id \times now) = now\), but we need a small helper lemma:
|
||||||
\begin{equation*}
|
\begin{equation*}
|
||||||
\tau \circ (id \times out^{-1}) = out^{-1} \circ (id + \tau) \circ dstl \tag*{($\ast$)}\label{helper}
|
\tau \circ (id \times out^{-1}) = out^{-1} \circ (id + \tau) \circ dstl \tag*{(\(\ast \))}\label{helper}
|
||||||
\end{equation*}
|
\end{equation*}
|
||||||
which is a direct consequence of \ref{D3}.
|
which is a direct consequence of~\ref{D3}.
|
||||||
With this the proof is straightforward:
|
With this the proof is straightforward:
|
||||||
\begin{alignat*}{1}
|
\begin{alignat*}{1}
|
||||||
& \tau \circ (id \times now) \\
|
& \tau \circ (id \times now) \\
|
||||||
|
@ -390,10 +403,11 @@ Finality of the coalgebras $(DX, out : DX \rightarrow X + DX)_{X \in \obj{\C}}$
|
||||||
=\; & out^{-1} \circ (id + \tau) \circ dstl \circ (id \times i_1)\tag*{\ref*{helper}} \\
|
=\; & out^{-1} \circ (id + \tau) \circ dstl \circ (id \times i_1)\tag*{\ref*{helper}} \\
|
||||||
=\; & now
|
=\; & now
|
||||||
\end{alignat*}
|
\end{alignat*}
|
||||||
where the last step follows by $dstl \circ (id \times i_1) = i_1$.
|
where the last step follows by \(dstl \circ (id \times i_1) = i_1\).
|
||||||
\item[\ref{S3}] We need to check $\tau^* \circ \tau = \tau \circ (id \times id^*)$, the coalgebra for coinduction is:
|
\item[\ref{S3}] We need to check \(\tau^* \circ \tau = \tau \circ (id \times id^*)\), the coalgebra for coinduction is:
|
||||||
% https://q.uiver.app/#q=WzAsNixbMCwwLCJYIFxcdGltZXMgRERZIl0sWzAsMiwiRChYXFx0aW1lcyBZKSJdLFsxLDAsIlggXFx0aW1lcyAoRFkgKyBERFkpIl0sWzIsMCwiWCBcXHRpbWVzIERZICsgWCBcXHRpbWVzIEREWSJdLFsyLDIsIlggXFx0aW1lcyBZICsgRChYIFxcdGltZXMgWSkiXSxbMiwxLCJYIFxcdGltZXMgWSArIFggXFx0aW1lcyBERFkiXSxbMCwxLCJcXGNvYWxney19IiwwLHsic3R5bGUiOnsiYm9keSI6eyJuYW1lIjoiZGFzaGVkIn19fV0sWzAsMiwiaWQgXFx0aW1lcyBvdXQiXSxbMiwzLCJkc3RsIl0sWzEsNCwib3V0Il0sWzUsNCwiaWQgKyBcXGNvYWxney19IiwyXSxbMyw1LCJbIChpZCArIChpZCBcXHRpbWVzIG5vdykpIFxcY2lyYyBkc3RsIFxcY2lyYyAoaWQgXFx0aW1lcyBvdXQpICwgaV8yIF0iLDJdXQ==
|
% https://q.uiver.app/#q=WzAsNixbMCwwLCJYIFxcdGltZXMgRERZIl0sWzAsMiwiRChYXFx0aW1lcyBZKSJdLFsxLDAsIlggXFx0aW1lcyAoRFkgKyBERFkpIl0sWzIsMCwiWCBcXHRpbWVzIERZICsgWCBcXHRpbWVzIEREWSJdLFsyLDIsIlggXFx0aW1lcyBZICsgRChYIFxcdGltZXMgWSkiXSxbMiwxLCJYIFxcdGltZXMgWSArIFggXFx0aW1lcyBERFkiXSxbMCwxLCJcXGNvYWxney19IiwwLHsic3R5bGUiOnsiYm9keSI6eyJuYW1lIjoiZGFzaGVkIn19fV0sWzAsMiwiaWQgXFx0aW1lcyBvdXQiXSxbMiwzLCJkc3RsIl0sWzEsNCwib3V0Il0sWzUsNCwiaWQgKyBcXGNvYWxney19IiwyXSxbMyw1LCJbIChpZCArIChpZCBcXHRpbWVzIG5vdykpIFxcY2lyYyBkc3RsIFxcY2lyYyAoaWQgXFx0aW1lcyBvdXQpICwgaV8yIF0iLDJdXQ==
|
||||||
\[\begin{tikzcd}[ampersand replacement=\&]
|
\[
|
||||||
|
\begin{tikzcd}[ampersand replacement=\&]
|
||||||
{X \times DDY} \& {X \times (DY + DDY)} \& {X \times DY + X \times DDY} \\
|
{X \times DDY} \& {X \times (DY + DDY)} \& {X \times DY + X \times DDY} \\
|
||||||
\&\& {X \times Y + X \times DDY} \\
|
\&\& {X \times Y + X \times DDY} \\
|
||||||
{D(X\times Y)} \&\& {X \times Y + D(X \times Y)}
|
{D(X\times Y)} \&\& {X \times Y + D(X \times Y)}
|
||||||
|
@ -403,10 +417,12 @@ Finality of the coalgebras $(DX, out : DX \rightarrow X + DX)_{X \in \obj{\C}}$
|
||||||
\arrow["out", from=3-1, to=3-3]
|
\arrow["out", from=3-1, to=3-3]
|
||||||
\arrow["{id + \coalg{\text{-}}}"', from=2-3, to=3-3]
|
\arrow["{id + \coalg{\text{-}}}"', from=2-3, to=3-3]
|
||||||
\arrow["{[ (id + (id \times now)) \circ dstl \circ (id \times out) , i_2 ]}"', from=1-3, to=2-3]
|
\arrow["{[ (id + (id \times now)) \circ dstl \circ (id \times out) , i_2 ]}"', from=1-3, to=2-3]
|
||||||
\end{tikzcd}\]
|
\end{tikzcd}
|
||||||
\item[\ref{S4}] To show $D\alpha \circ \tau = \tau \circ (id \times \tau) \circ \alpha$ by coinduction we take the coalgebra:
|
\]
|
||||||
|
\item[\ref{S4}] To show \(D\alpha \circ \tau = \tau \circ (id \times \tau) \circ \alpha \) by coinduction we take the coalgebra:
|
||||||
% https://q.uiver.app/#q=WzAsNixbMCwwLCIoWCBcXHRpbWVzIFkpIFxcdGltZXMgRFoiXSxbMCwyLCJEKFggXFx0aW1lcyBZIFxcdGltZXMgWikiXSxbMiwyLCJYIFxcdGltZXMgWSBcXHRpbWVzIFogKyBEKFggXFx0aW1lcyBZIFxcdGltZXMgWikiXSxbMiwxLCJYIFxcdGltZXMgWSAgXFx0aW1lcyBaICsgKFggXFx0aW1lcyBZKSBcXHRpbWVzIERaIl0sWzEsMCwiKFggXFx0aW1lcyBZKSBcXHRpbWVzIChaKyBEWikiXSxbMiwwLCIoWFxcdGltZXMgWSkgXFx0aW1lcyBaICsgKFggXFx0aW1lcyBZKSBcXHRpbWVzIERaIl0sWzAsMSwiXFxjb2FsZ3stfSIsMCx7InN0eWxlIjp7ImJvZHkiOnsibmFtZSI6ImRhc2hlZCJ9fX1dLFsxLDIsIm91dCJdLFszLDIsImlkICtcXGNvYWxney19IiwyXSxbMCw0LCJpZCBcXHRpbWVzIG91dCJdLFs0LDUsImRzdGwiXSxbNSwzLCJcXGxhbmdsZSBcXHBpXzEgXFxjaXJjIFxccGlfMSAsIFxcbGFuZ2xlIFxccGlfMiBcXGNpcmMgXFxwaV8xICwgXFxwaV8yIFxccmFuZ2xlIFxccmFuZ2xlICsgaWQiLDJdXQ==
|
% https://q.uiver.app/#q=WzAsNixbMCwwLCIoWCBcXHRpbWVzIFkpIFxcdGltZXMgRFoiXSxbMCwyLCJEKFggXFx0aW1lcyBZIFxcdGltZXMgWikiXSxbMiwyLCJYIFxcdGltZXMgWSBcXHRpbWVzIFogKyBEKFggXFx0aW1lcyBZIFxcdGltZXMgWikiXSxbMiwxLCJYIFxcdGltZXMgWSAgXFx0aW1lcyBaICsgKFggXFx0aW1lcyBZKSBcXHRpbWVzIERaIl0sWzEsMCwiKFggXFx0aW1lcyBZKSBcXHRpbWVzIChaKyBEWikiXSxbMiwwLCIoWFxcdGltZXMgWSkgXFx0aW1lcyBaICsgKFggXFx0aW1lcyBZKSBcXHRpbWVzIERaIl0sWzAsMSwiXFxjb2FsZ3stfSIsMCx7InN0eWxlIjp7ImJvZHkiOnsibmFtZSI6ImRhc2hlZCJ9fX1dLFsxLDIsIm91dCJdLFszLDIsImlkICtcXGNvYWxney19IiwyXSxbMCw0LCJpZCBcXHRpbWVzIG91dCJdLFs0LDUsImRzdGwiXSxbNSwzLCJcXGxhbmdsZSBcXHBpXzEgXFxjaXJjIFxccGlfMSAsIFxcbGFuZ2xlIFxccGlfMiBcXGNpcmMgXFxwaV8xICwgXFxwaV8yIFxccmFuZ2xlIFxccmFuZ2xlICsgaWQiLDJdXQ==
|
||||||
\[\begin{tikzcd}[ampersand replacement=\&]
|
\[
|
||||||
|
\begin{tikzcd}[ampersand replacement=\&]
|
||||||
{(X \times Y) \times DZ} \& {(X \times Y) \times (Z+ DZ)} \& {(X\times Y) \times Z + (X \times Y) \times DZ} \\
|
{(X \times Y) \times DZ} \& {(X \times Y) \times (Z+ DZ)} \& {(X\times Y) \times Z + (X \times Y) \times DZ} \\
|
||||||
\&\& {X \times Y \times Z + (X \times Y) \times DZ} \\
|
\&\& {X \times Y \times Z + (X \times Y) \times DZ} \\
|
||||||
{D(X \times Y \times Z)} \&\& {X \times Y \times Z + D(X \times Y \times Z)}
|
{D(X \times Y \times Z)} \&\& {X \times Y \times Z + D(X \times Y \times Z)}
|
||||||
|
@ -416,37 +432,40 @@ Finality of the coalgebras $(DX, out : DX \rightarrow X + DX)_{X \in \obj{\C}}$
|
||||||
\arrow["{id \times out}", from=1-1, to=1-2]
|
\arrow["{id \times out}", from=1-1, to=1-2]
|
||||||
\arrow["dstl", from=1-2, to=1-3]
|
\arrow["dstl", from=1-2, to=1-3]
|
||||||
\arrow["{\langle \pi_1 \circ \pi_1 , \langle \pi_2 \circ \pi_1 , \pi_2 \rangle \rangle + id}"', from=1-3, to=2-3]
|
\arrow["{\langle \pi_1 \circ \pi_1 , \langle \pi_2 \circ \pi_1 , \pi_2 \rangle \rangle + id}"', from=1-3, to=2-3]
|
||||||
\end{tikzcd}\]
|
\end{tikzcd}
|
||||||
|
\]
|
||||||
\end{itemize}
|
\end{itemize}
|
||||||
\end{proof}
|
\end{proof}
|
||||||
|
|
||||||
To prove that $\mathbf{D}$ is commutative we will use another proof principle previously called the \textit{Solution Theorem}~\cite{sol-thm} or \textit{Parametric Corecursion}~\cite{param-corec}. In our setting this takes the following form:
|
To prove that \(\mathbf{D}\) is commutative we will use another proof principle previously called the \textit{Solution Theorem}~\cite{sol-thm} or \textit{Parametric Corecursion}~\cite{param-corec}. In our setting this takes the following form:
|
||||||
|
|
||||||
\begin{definition}
|
\begin{definition}
|
||||||
We call a morphism $g : X \rightarrow D (Y + X)$ \textit{guarded} if there exists an $h : X \rightarrow Y + D(Y+X)$ such that the following diagram commutes:
|
We call a morphism \(g : X \rightarrow D (Y + X)\) \textit{guarded} if there exists an \(h : X \rightarrow Y + D(Y+X)\) such that the following diagram commutes:
|
||||||
% https://q.uiver.app/#q=WzAsNCxbMCwwLCJYIl0sWzMsMCwiRCAoWSArWCkiXSxbMywxLCIoWSArIFgpICsgRChZICsgWCkiXSxbMCwxLCJZICsgRChZK1gpIl0sWzAsMSwiZyJdLFsxLDIsIm91dCJdLFszLDIsImlfMSArIGlkIiwyXSxbMCwzLCJoIiwyXV0=
|
% https://q.uiver.app/#q=WzAsNCxbMCwwLCJYIl0sWzMsMCwiRCAoWSArWCkiXSxbMywxLCIoWSArIFgpICsgRChZICsgWCkiXSxbMCwxLCJZICsgRChZK1gpIl0sWzAsMSwiZyJdLFsxLDIsIm91dCJdLFszLDIsImlfMSArIGlkIiwyXSxbMCwzLCJoIiwyXV0=
|
||||||
\[\begin{tikzcd}[ampersand replacement=\&]
|
\[
|
||||||
|
\begin{tikzcd}[ampersand replacement=\&]
|
||||||
X \&\&\& {D (Y +X)} \\
|
X \&\&\& {D (Y +X)} \\
|
||||||
{Y + D(Y+X)} \&\&\& {(Y + X) + D(Y + X)}
|
{Y + D(Y+X)} \&\&\& {(Y + X) + D(Y + X)}
|
||||||
\arrow["g", from=1-1, to=1-4]
|
\arrow["g", from=1-1, to=1-4]
|
||||||
\arrow["out", from=1-4, to=2-4]
|
\arrow["out", from=1-4, to=2-4]
|
||||||
\arrow["{i_1 + id}"', from=2-1, to=2-4]
|
\arrow["{i_1 + id}"', from=2-1, to=2-4]
|
||||||
\arrow["h"', from=1-1, to=2-1]
|
\arrow["h"', from=1-1, to=2-1]
|
||||||
\end{tikzcd}\]
|
\end{tikzcd}
|
||||||
|
\]
|
||||||
\end{definition}
|
\end{definition}
|
||||||
|
|
||||||
\begin{corollary}[Solution Theorem]
|
\begin{corollary}[Solution Theorem]\label{cor:solution}
|
||||||
\label{cor:solution}
|
Let \(g : X \rightarrow D(Y + X)\) be guarded.\ \textit{Solutions} of g are unique, i.e.\ given two morphisms \(f, i : X \rightarrow DY\) then
|
||||||
Let $g : X \rightarrow D(Y + X)$ be guarded. \textit{Solutions} of g are unique, i.e. given two morphisms $f, i : X \rightarrow DY$ then
|
\(f = {[ now , f ]}^* \circ g\) and \(i = {[ now , i ]}^* \circ g\) already implies \(f = i\).
|
||||||
$f = [ now , f ]^* \circ g$ and $i = [ now , i ]^* \circ g$ already implies $f = i$.
|
|
||||||
\end{corollary}
|
\end{corollary}
|
||||||
\begin{proof}
|
\begin{proof}
|
||||||
Let $g : X \rightarrow D(Y + X)$ be guarded by $h : X \rightarrow Y + D(Y+X)$ and $f, i : X \rightarrow DY$ be solutions of g.
|
Let \(g : X \rightarrow D(Y + X)\) be guarded by \(h : X \rightarrow Y + D(Y+X)\) and \(f, i : X \rightarrow DY\) be solutions of g.
|
||||||
It suffices to show $[ now , f ]^* = [ now , i ]^*$, because then follows:
|
It suffices to show \({[ now , f ]}^* = {[ now , i ]}^*\), because then follows:
|
||||||
\[f = [ now , f ]^* \circ g = [ now , i ]^* \circ g = i\]
|
\[f = {[ now , f ]}^* \circ g = {[ now , i ]}^* \circ g = i\]
|
||||||
We prove this by coinduction using:
|
We prove this by coinduction using:
|
||||||
% https://q.uiver.app/#q=WzAsNSxbMCwxLCJEWSJdLFszLDEsIlkgKyBEWSJdLFswLDAsIkQoWSArIFgpIl0sWzEsMCwiKFkgKyBYKSArIEQoWStYKSJdLFszLDAsIlkgKyBEKFkrWCkiXSxbMCwxLCJvdXQiXSxbMiwzLCJvdXQiXSxbMyw0LCJbIFsgaV8xICwgaCBdICwgaV8yIF0iXSxbNCwxLCJpZCArIFxcY29hbGd7LX0iXSxbMiwwLCJcXGNvYWxney19IiwwLHsic3R5bGUiOnsiYm9keSI6eyJuYW1lIjoiZGFzaGVkIn19fV1d
|
% https://q.uiver.app/#q=WzAsNSxbMCwxLCJEWSJdLFszLDEsIlkgKyBEWSJdLFswLDAsIkQoWSArIFgpIl0sWzEsMCwiKFkgKyBYKSArIEQoWStYKSJdLFszLDAsIlkgKyBEKFkrWCkiXSxbMCwxLCJvdXQiXSxbMiwzLCJvdXQiXSxbMyw0LCJbIFsgaV8xICwgaCBdICwgaV8yIF0iXSxbNCwxLCJpZCArIFxcY29hbGd7LX0iXSxbMiwwLCJcXGNvYWxney19IiwwLHsic3R5bGUiOnsiYm9keSI6eyJuYW1lIjoiZGFzaGVkIn19fV1d
|
||||||
\[\begin{tikzcd}[ampersand replacement=\&]
|
\[
|
||||||
|
\begin{tikzcd}[ampersand replacement=\&]
|
||||||
{D(Y + X)} \& {(Y + X) + D(Y+X)} \&\& {Y + D(Y+X)} \\
|
{D(Y + X)} \& {(Y + X) + D(Y+X)} \&\& {Y + D(Y+X)} \\
|
||||||
DY \&\&\& {Y + DY}
|
DY \&\&\& {Y + DY}
|
||||||
\arrow["out", from=2-1, to=2-4]
|
\arrow["out", from=2-1, to=2-4]
|
||||||
|
@ -454,18 +473,19 @@ To prove that $\mathbf{D}$ is commutative we will use another proof principle pr
|
||||||
\arrow["{[ [ i_1 , h ] , i_2 ]}", from=1-2, to=1-4]
|
\arrow["{[ [ i_1 , h ] , i_2 ]}", from=1-2, to=1-4]
|
||||||
\arrow["{id + \coalg{\text{-}}}", from=1-4, to=2-4]
|
\arrow["{id + \coalg{\text{-}}}", from=1-4, to=2-4]
|
||||||
\arrow["{\coalg{\text{-}}}", dashed, from=1-1, to=2-1]
|
\arrow["{\coalg{\text{-}}}", dashed, from=1-1, to=2-1]
|
||||||
\end{tikzcd}\]
|
\end{tikzcd}
|
||||||
|
\]
|
||||||
\end{proof}
|
\end{proof}
|
||||||
|
|
||||||
Let us record some facts that we will use to prove commutativity of $\mathbf{D}$:
|
Let us record some facts that we will use to prove commutativity of \(\mathbf{D}\):
|
||||||
|
|
||||||
\begin{corollary}
|
\begin{corollary}
|
||||||
These properties of $\tau$ and $\sigma$ hold:
|
These properties of \(\tau \) and \(\sigma \) hold:
|
||||||
\begin{alignat*}{2}
|
\begin{alignat*}{2}
|
||||||
& out \circ \tau & & = (id + \tau) \circ dstl \circ (id \times out)\tag*{($\tau_1$)}\label{tau1}
|
& out \circ \tau & & = (id + \tau) \circ dstl \circ (id \times out)\tag*{(\(\tau_1\))}\label{tau1}
|
||||||
\\&out \circ \sigma &&= (id + \sigma) \circ dstr \circ (out \times id)\tag*{($\sigma_1$)}\label{sigma1}
|
\\&out \circ \sigma &&= (id + \sigma) \circ dstr \circ (out \times id)\tag*{(\(\sigma_1\))}\label{sigma1}
|
||||||
\\&\tau \circ (id \times out^{-1}) &&= out^{-1} \circ (id + \tau) \circ dstl\tag*{($\tau_2$)}\label{tau2}
|
\\&\tau \circ (id \times out^{-1}) &&= out^{-1} \circ (id + \tau) \circ dstl\tag*{(\(\tau_2\))}\label{tau2}
|
||||||
\\& \sigma \circ (out^{-1} \times id) &&= out^{-1} \circ (id + \sigma) \circ dstr\tag*{($\sigma_2$)}\label{sigma2}
|
\\& \sigma \circ (out^{-1} \times id) &&= out^{-1} \circ (id + \sigma) \circ dstr\tag*{(\(\sigma_2\))}\label{sigma2}
|
||||||
\end{alignat*}
|
\end{alignat*}
|
||||||
\end{corollary}
|
\end{corollary}
|
||||||
|
|
||||||
|
@ -474,7 +494,7 @@ Let us record some facts that we will use to prove commutativity of $\mathbf{D}$
|
||||||
\item[\ref{tau1}] This is just~\ref{D3} restated.
|
\item[\ref{tau1}] This is just~\ref{D3} restated.
|
||||||
\item[\ref{sigma1}]
|
\item[\ref{sigma1}]
|
||||||
\begin{alignat*}{1}
|
\begin{alignat*}{1}
|
||||||
&out \circ \sigma
|
& out \circ \sigma
|
||||||
\\=\;&out \circ Dswap \circ \tau \circ swap
|
\\=\;&out \circ Dswap \circ \tau \circ swap
|
||||||
\\=\;&(swap + Dswap) \circ out \circ \tau \circ swap
|
\\=\;&(swap + Dswap) \circ out \circ \tau \circ swap
|
||||||
\\=\;&(swap + Dswap) \circ (id + \tau) \circ dstl \circ (id \times out) \circ swap \tag*{\ref{tau1}}
|
\\=\;&(swap + Dswap) \circ (id + \tau) \circ dstl \circ (id \times out) \circ swap \tag*{\ref{tau1}}
|
||||||
|
@ -482,15 +502,15 @@ Let us record some facts that we will use to prove commutativity of $\mathbf{D}$
|
||||||
\\=\;&(swap + Dswap) \circ (id + \tau) \circ (swap + swap) \circ dstr \circ (out \times id)
|
\\=\;&(swap + Dswap) \circ (id + \tau) \circ (swap + swap) \circ dstr \circ (out \times id)
|
||||||
\\=\;&(id + \sigma) \circ dstr \circ (out \times id)
|
\\=\;&(id + \sigma) \circ dstr \circ (out \times id)
|
||||||
\end{alignat*}
|
\end{alignat*}
|
||||||
\item[\ref{tau2}] By monicity of $out$:
|
\item[\ref{tau2}] By monicity of \(out\):
|
||||||
\begin{alignat*}{1}
|
\begin{alignat*}{1}
|
||||||
&out \circ \tau \circ (id \times out^{-1})
|
& out \circ \tau \circ (id \times out^{-1})
|
||||||
\\=\;&(id + \tau) \circ dstl \circ (id \times out) \circ (id \times out^{-1})\tag*{\ref{tau1}}
|
\\=\;&(id + \tau) \circ dstl \circ (id \times out) \circ (id \times out^{-1})\tag*{\ref{tau1}}
|
||||||
\\=\;&(id + \tau) \circ dstl
|
\\=\;&(id + \tau) \circ dstl
|
||||||
\end{alignat*}
|
\end{alignat*}
|
||||||
\item[\ref{sigma2}] By monicity of $out$:
|
\item[\ref{sigma2}] By monicity of \(out\):
|
||||||
\begin{alignat*}{1}
|
\begin{alignat*}{1}
|
||||||
&out \circ \sigma \circ (out^{-1} \times id)
|
& out \circ \sigma \circ (out^{-1} \times id)
|
||||||
\\=\;&(id + \sigma) \circ dstr \circ (out \times id) \circ (out^{-1} \times id)\tag*{\ref{sigma1}}
|
\\=\;&(id + \sigma) \circ dstr \circ (out \times id) \circ (out^{-1} \times id)\tag*{\ref{sigma1}}
|
||||||
\\=\;&(id + \sigma) \circ dstr
|
\\=\;&(id + \sigma) \circ dstr
|
||||||
\end{alignat*}
|
\end{alignat*}
|
||||||
|
@ -498,21 +518,21 @@ Let us record some facts that we will use to prove commutativity of $\mathbf{D}$
|
||||||
\end{proof}
|
\end{proof}
|
||||||
|
|
||||||
\begin{theorem}
|
\begin{theorem}
|
||||||
$\mathbf{D}$ is commutative.
|
\(\mathbf{D}\) is commutative.
|
||||||
\end{theorem}
|
\end{theorem}
|
||||||
\begin{proof}
|
\begin{proof}
|
||||||
Using \autoref{cor:solution} it suffices to show that both $\tau^* \circ \sigma$ and $\sigma^* \circ \tau$ are solutions of some guarded morphism $g$.
|
Using \autoref{cor:solution} it suffices to show that both \(\tau^* \circ \sigma \) and \(\sigma^* \circ \tau \) are solutions of some guarded morphism \(g\).
|
||||||
|
|
||||||
Let $w = (dstr + dstr) \circ dstl \circ (out \times out)$ and take
|
Let \(w = (dstr + dstr) \circ dstl \circ (out \times out)\) and take
|
||||||
\[g = out^{-1} \circ [ i_1 + D i_1 \circ \sigma , i_2 \circ [ D i_1 \circ \tau , later \circ now \circ i_2 ] ] \circ w\]
|
\[g = out^{-1} \circ [ i_1 + D i_1 \circ \sigma , i_2 \circ [ D i_1 \circ \tau , later \circ now \circ i_2 ] ] \circ w\]
|
||||||
$g$ is trivially guarded by $[ id + D i_1 \circ \sigma , i_2 \circ [ D i_1 \circ \tau , later \circ now \circ i_2 ] ] \circ w$.
|
\(g\) is trivially guarded by \([ id + D i_1 \circ \sigma , i_2 \circ [ D i_1 \circ \tau , later \circ now \circ i_2 ] ] \circ w\).
|
||||||
|
|
||||||
We are left to show that both $\tau^* \circ \sigma$ and $\sigma^* \circ \tau$ are solutions of $g$. Consider:
|
We are left to show that both \(\tau^* \circ \sigma \) and \(\sigma^* \circ \tau \) are solutions of \(g\). Consider:
|
||||||
|
|
||||||
\[\tau^* \circ \sigma = out^{-1} \circ [ id + \sigma , i_2 \circ [ \tau , later \circ \tau^* \circ \sigma ] ] \circ w = [ now , \tau^* \circ \sigma]^* \circ g \]
|
\[\tau^* \circ \sigma = out^{-1} \circ [ id + \sigma , i_2 \circ [ \tau , later \circ \tau^* \circ \sigma ] ] \circ w = {[ now , \tau^* \circ \sigma]}^* \circ g \]
|
||||||
\[\sigma^* \circ \tau = out^{-1} \circ [ id + \sigma , i_2 \circ [ \tau , later \circ \sigma^* \circ \tau ] ] \circ w = [ now , \sigma^* \circ \tau]^* \circ g \]
|
\[\sigma^* \circ \tau = out^{-1} \circ [ id + \sigma , i_2 \circ [ \tau , later \circ \sigma^* \circ \tau ] ] \circ w = {[ now , \sigma^* \circ \tau]}^* \circ g \]
|
||||||
|
|
||||||
The last step in both equations can be proven generally for any $f : DX \times DY \rightarrow D(X \times Y)$ using monicity of $out$:
|
The last step in both equations can be proven generally for any \(f : DX \times DY \rightarrow D(X \times Y)\) using monicity of \(out\):
|
||||||
\begin{alignat*}{1}
|
\begin{alignat*}{1}
|
||||||
& out \circ {[ now , f ]}^* \circ out^{-1} \circ [ i_1 + D i_1 \circ \sigma , i_2 \circ [ D i_1 \circ \tau , later \circ now \circ i_2 ] ] \circ w
|
& out \circ {[ now , f ]}^* \circ out^{-1} \circ [ i_1 + D i_1 \circ \sigma , i_2 \circ [ D i_1 \circ \tau , later \circ now \circ i_2 ] ] \circ w
|
||||||
\\=\; & [ out \circ [ now , f ] , i_2 \circ {[ now , f ]}^* ] \circ [ i_1 + D i_1 \circ \sigma , i_2 \circ [ D i_1 \circ \tau , later \circ now \circ i_2 ] ] \circ w\tag*{\ref{D2}}
|
\\=\; & [ out \circ [ now , f ] , i_2 \circ {[ now , f ]}^* ] \circ [ i_1 + D i_1 \circ \sigma , i_2 \circ [ D i_1 \circ \tau , later \circ now \circ i_2 ] ] \circ w\tag*{\ref{D2}}
|
||||||
|
@ -522,9 +542,9 @@ Let us record some facts that we will use to prove commutativity of $\mathbf{D}$
|
||||||
\\=\; & [ id + \sigma , i_2 \circ [ \tau , later \circ f ] ] \circ w
|
\\=\; & [ id + \sigma , i_2 \circ [ \tau , later \circ f ] ] \circ w
|
||||||
\end{alignat*}
|
\end{alignat*}
|
||||||
|
|
||||||
Let us now check the first step in the equation for $\sigma^* \circ \tau$, the same step for $\tau^* \circ \sigma$ is then symmetric.
|
Let us now check the first step in the equation for \(\sigma^* \circ \tau \), the same step for \(\tau^* \circ \sigma \) is then symmetric.
|
||||||
|
|
||||||
Again we proceed by monicity of $out$:
|
Again we proceed by monicity of \(out\):
|
||||||
\begin{alignat*}{1}
|
\begin{alignat*}{1}
|
||||||
& out \circ \sigma^* \circ \tau
|
& out \circ \sigma^* \circ \tau
|
||||||
\\=\;&[ out \circ \sigma , i_2 \circ \sigma^* ] \circ out \circ \tau\tag*{\ref{D2}}
|
\\=\;&[ out \circ \sigma , i_2 \circ \sigma^* ] \circ out \circ \tau\tag*{\ref{D2}}
|
||||||
|
@ -533,19 +553,19 @@ Let us record some facts that we will use to prove commutativity of $\mathbf{D}$
|
||||||
\\=\;&[ (id + \sigma) \circ dstr \circ (out \times id) , i_2 \circ \sigma^* \circ \tau ] \circ ((out^{-1} \times id) + (out^{-1} \times id)) \circ dstl \circ (out \times out)
|
\\=\;&[ (id + \sigma) \circ dstr \circ (out \times id) , i_2 \circ \sigma^* \circ \tau ] \circ ((out^{-1} \times id) + (out^{-1} \times id)) \circ dstl \circ (out \times out)
|
||||||
\\=\;&[ (id + \sigma) \circ dstr, i_2 \circ \sigma^* \circ \tau \circ (out^{-1} \times id)] \circ dstl \circ (out \times out)
|
\\=\;&[ (id + \sigma) \circ dstr, i_2 \circ \sigma^* \circ \tau \circ (out^{-1} \times id)] \circ dstl \circ (out \times out)
|
||||||
\\=\;&[ (id + \sigma) \circ dstr, i_2 \circ \sigma^* \circ D(out^{-1} \times id) \circ \tau] \circ dstl \circ (out \times out)
|
\\=\;&[ (id + \sigma) \circ dstr, i_2 \circ \sigma^* \circ D(out^{-1} \times id) \circ \tau] \circ dstl \circ (out \times out)
|
||||||
\\=\;&[ (id + \sigma) \circ dstr, i_2 \circ (\sigma \times (out^{-1} \times id))^* \circ \tau] \circ dstl \circ (out \times out)
|
\\=\;&[ (id + \sigma) \circ dstr, i_2 \circ {(\sigma \times (out^{-1} \times id))}^* \circ \tau] \circ dstl \circ (out \times out)
|
||||||
\\=\;&[ (id + \sigma) \circ dstr, i_2 \circ (out^{-1} \circ (id + \sigma) \circ dstr)^* \circ \tau] \circ dstl \circ (out \times out)\tag*{\ref{sigma2}}
|
\\=\;&[ (id + \sigma) \circ dstr, i_2 \circ {(out^{-1} \circ (id + \sigma) \circ dstr)}^* \circ \tau] \circ dstl \circ (out \times out)\tag*{\ref{sigma2}}
|
||||||
\\=\;&[ (id + \sigma) \circ dstr, i_2 \circ (out^{-1} \circ (id + \sigma))^* \circ Ddstr \circ \tau] \circ dstl \circ (out \times out)
|
\\=\;&[ (id + \sigma) \circ dstr, i_2 \circ {(out^{-1} \circ (id + \sigma))}^* \circ Ddstr \circ \tau] \circ dstl \circ (out \times out)
|
||||||
\\=\;&[ (id + \sigma) \circ dstr, i_2 \circ (out^{-1} \circ (id + \sigma))^* \circ [D i_1 \circ \tau , D i_2 \circ \tau] \circ dstr] \circ dstl \circ (out \times out)\tag*{\ref{Dcomm-helper}}
|
\\=\;&[ (id + \sigma) \circ dstr, i_2 \circ {(out^{-1} \circ (id + \sigma))}^* \circ [D i_1 \circ \tau , D i_2 \circ \tau] \circ dstr] \circ dstl \circ (out \times out)\tag*{\ref{Dcomm-helper}}
|
||||||
\\=\;&[ (id + \sigma), i_2 \circ (out^{-1} \circ (id + \sigma))^* \circ [D i_1 \circ \tau , D i_2 \circ \tau]] \circ (dstr + dstr) \circ dstl \circ (out \times out)
|
\\=\;&[ (id + \sigma), i_2 \circ {(out^{-1} \circ (id + \sigma))}^* \circ [D i_1 \circ \tau , D i_2 \circ \tau]] \circ (dstr + dstr) \circ dstl \circ (out \times out)
|
||||||
\\=\;&[ (id + \sigma), i_2 \circ [(out^{-1} \circ i_1)^* \circ \tau , (out^{-1} \circ i_2 \circ \sigma)^* \circ \tau]] \circ w
|
\\=\;&[ (id + \sigma), i_2 \circ [{(out^{-1} \circ i_1)}^* \circ \tau , {(out^{-1} \circ i_2 \circ \sigma)}^* \circ \tau]] \circ w
|
||||||
\\=\;&[ (id + \sigma), i_2 \circ [ \tau , (later \circ \sigma)^* \circ \tau]] \circ w \tag*{\ref{K1}}
|
\\=\;&[ (id + \sigma), i_2 \circ [ \tau , {(later \circ \sigma)}^* \circ \tau]] \circ w \tag*{\ref{K1}}
|
||||||
\\=\;&[ (id + \sigma), i_2 \circ [ \tau , later \circ \sigma^* \circ \tau]] \circ w
|
\\=\;&[ (id + \sigma), i_2 \circ [ \tau , later \circ \sigma^* \circ \tau]] \circ w
|
||||||
\end{alignat*}
|
\end{alignat*}
|
||||||
|
|
||||||
where
|
where
|
||||||
\[Ddstr \circ \tau = [ Di_1 \circ \tau , Di_2 \circ \tau ] \circ dstr \tag*{(*)}\label{Dcomm-helper}\]
|
\[Ddstr \circ \tau = [ Di_1 \circ \tau , Di_2 \circ \tau ] \circ dstr \tag*{(*)}\label{Dcomm-helper}\]
|
||||||
is proven using epicness of $dstr^{-1}$:
|
is proven using epicness of \(dstr^{-1}\):
|
||||||
|
|
||||||
\begin{alignat*}{1}
|
\begin{alignat*}{1}
|
||||||
& Ddstr \circ \tau \circ dstr^{-1}
|
& Ddstr \circ \tau \circ dstr^{-1}
|
||||||
|
@ -556,6 +576,6 @@ Let us record some facts that we will use to prove commutativity of $\mathbf{D}$
|
||||||
\end{proof}
|
\end{proof}
|
||||||
|
|
||||||
\improvement[inline]{Elaborate more?}
|
\improvement[inline]{Elaborate more?}
|
||||||
We have now seen that $\mathbf{D}$ is strong and commutative, however it is not an equational lifting monad, since besides modelling non-termination, the delay monad also counts the execution time of a computation. This is a result of the too intensional notion of equality that this monad comes with.
|
We have now seen that \(\mathbf{D}\) is strong and commutative, however it is not an equational lifting monad, since besides modelling non-termination, the delay monad also counts the execution time of a computation. This is a result of the too intensional notion of equality that this monad comes with.
|
||||||
|
|
||||||
In chapter~\ref{chp:setoids} we will see a way to remedy this: taking the quotient of the delay monad where execution time is ignored. This will then yield an equational lifting monad on the category of setoids. However, in a general setting it is generally believed to be impossible to define a monad structure on this quotient. Chapman et al. have identified the axiom of countable choice (which crucially holds in the category of setoids) as a sufficient requirement for defining a monad structure on the quotient of $\mathbf{D}$.
|
In \autoref{chp:setoids} we will see a way to remedy this: taking the quotient of the delay monad where execution time is ignored. This will then yield an equational lifting monad on the category of setoids. However, in a general setting it is generally believed to be impossible to define a monad structure on this quotient. Chapman et al.\ have identified the axiom of countable choice (which crucially holds in the category of setoids) as a sufficient requirement for defining a monad structure on the quotient of \(\mathbf{D}\).
|
|
@ -13,28 +13,28 @@ In this chapter we will draw on the inherent connection between partiality and i
|
||||||
A (unguarded) Elgot Algebra~\cite{uniformelgot} consists of:
|
A (unguarded) Elgot Algebra~\cite{uniformelgot} consists of:
|
||||||
\begin{itemize}
|
\begin{itemize}
|
||||||
\item An object A
|
\item An object A
|
||||||
\item for every $f : X \rightarrow A + X$ the iteration $f^\# : X \rightarrow A$, satisfying:
|
\item for every \(f : X \rightarrow A + X\) the iteration \(f^\# : X \rightarrow A\), satisfying:
|
||||||
\begin{itemize}
|
\begin{itemize}
|
||||||
\item \customlabel{law:fixpoint}{\textbf{Fixpoint}}: $f^\# = [ id , f ^\# ] \circ f$
|
\item \customlabel{law:fixpoint}{\textbf{Fixpoint}}: \(f^\# = [ id , f ^\# ] \circ f\)
|
||||||
\\ for $f : X \rightarrow A + X$
|
\\ for \(f : X \rightarrow A + X\)
|
||||||
\item \customlabel{law:uniformity}{\textbf{Uniformity}}: $(id + h) \circ f = g \circ h \Rightarrow f ^\# = g^\# \circ h$
|
\item \customlabel{law:uniformity}{\textbf{Uniformity}}: \((id + h) \circ f = g \circ h \Rightarrow f ^\# = g^\# \circ h\)
|
||||||
\\ for $f : X \rightarrow A + X,\; g : Y \rightarrow A + Y,\; h : X \rightarrow Y$
|
\\ for \(f : X \rightarrow A + X,\; g : Y \rightarrow A + Y,\; h : X \rightarrow Y\)
|
||||||
\item \customlabel{law:folding}{\textbf{Folding}}: $((f^\# + id) \circ h)^\# = [ (id + inl) \circ f , inr \circ h ] ^\#$
|
\item \customlabel{law:folding}{\textbf{Folding}}: \(((f^\# + id) \circ h)^\# = [ (id + inl) \circ f , inr \circ h ]^\# \)
|
||||||
\\ for $f : X \rightarrow A + X,\; h : Y \rightarrow X + Y$
|
\\ for \(f : X \rightarrow A + X,\; h : Y \rightarrow X + Y\)
|
||||||
\end{itemize}
|
\end{itemize}
|
||||||
\end{itemize}
|
\end{itemize}
|
||||||
\end{definition}
|
\end{definition}
|
||||||
|
|
||||||
\begin{lemma}
|
\begin{lemma}
|
||||||
Every Elgot algebra $(A , (-)^\#)$ satisfies the following additional laws
|
Every Elgot algebra \((A , (-)^\#)\) satisfies the following additional laws
|
||||||
|
|
||||||
\begin{itemize}
|
\begin{itemize}
|
||||||
\item \customlabel{law:stutter}{\textbf{Stutter}}: $(([ h , h ] + id) \circ f)^\# = (i_1 \circ h , [ h + i_1 , i_2 \circ i_2 ] )^\# \circ inr$
|
\item \customlabel{law:stutter}{\textbf{Stutter}}: \({(([ h , h ] + id) \circ f)}^\# = {(i_1 \circ h , [ h + i_1 , i_2 \circ i_2 ] )}^\# \circ inr\)
|
||||||
\\ for $f : X \rightarrow (Y + Y) + X, h : Y \rightarrow A$
|
\\ for \(f : X \rightarrow (Y + Y) + X, h : Y \rightarrow A\)
|
||||||
\item \customlabel{law:diamond}{\textbf{Diamond}}: $((id + \Delta) \circ f)^\# = ([ i_1 , ((id + \Delta) \circ f)^\# + id] \circ f)^\#$
|
\item \customlabel{law:diamond}{\textbf{Diamond}}: \({((id + \Delta) \circ f)}^\# = {([ i_1 , ((id + \Delta) \circ f)^\# + id] \circ f)}^\# \)
|
||||||
\\ for $f : X \rightarrow A + (X + X)$
|
\\ for \(f : X \rightarrow A + (X + X)\)
|
||||||
\item \customlabel{law:compositionality}{\textbf{Compositionality}}: $((f^\# + id) \circ h)^\# = ([ (id + i_1) \circ f , i_2 \circ i_2 ] \circ [ i_1 , h ])^\# \circ i_2$
|
\item \customlabel{law:compositionality}{\textbf{Compositionality}}: \({((f^\# + id) \circ h)}^\# = {([ (id + i_1) \circ f , i_2 \circ i_2 ] \circ [ i_1 , h ])}^\# \circ i_2\)
|
||||||
\\ for $f : X \rightarrow A + X, h : Y \rightarrow X + Y$
|
\\ for \(f : X \rightarrow A + X, h : Y \rightarrow X + Y\)
|
||||||
\end{itemize}
|
\end{itemize}
|
||||||
\end{lemma}
|
\end{lemma}
|
||||||
\begin{proof}
|
\begin{proof}
|
||||||
|
@ -45,129 +45,129 @@ In this chapter we will draw on the inherent connection between partiality and i
|
||||||
|
|
||||||
Morphisms between Elgot algebras that are coherent with respect to the iteration operator are of special interest to us, the following definition classifies them.
|
Morphisms between Elgot algebras that are coherent with respect to the iteration operator are of special interest to us, the following definition classifies them.
|
||||||
|
|
||||||
\begin{definition}
|
\begin{definition}[Iteration Preserving Morphisms]
|
||||||
Let $(A, (-)^{\#_a}), (B, (-)^{\#_b})$ be two Elgot algebras.
|
Let \((A, {(-)}^{\#_a}), (B, {(-)}^{\#_b})\) be two Elgot algebras.
|
||||||
|
|
||||||
A morphism $f : X \times A \rightarrow B$ is called \textit{right iteration preserving} if
|
A morphism \(f : X \times A \rightarrow B\) is called \textit{right iteration preserving} if
|
||||||
\[f \circ (id \times h^{\#_a}) = ((f + id) \circ dstl \circ (id \times h))^{\#_b}\]
|
\[f \circ (id \times h^{\#_a}) = ((f + id) \circ dstl \circ (id \times h))^{\#_b}\]
|
||||||
for any $h : Y \rightarrow A + Y$.
|
for any \(h : Y \rightarrow A + Y\).
|
||||||
|
|
||||||
Symmetrically a morphism $g : A \times X \rightarrow B$ is called \textit{left iteration preserving} if
|
Symmetrically a morphism \(g : A \times X \rightarrow B\) is called \textit{left iteration preserving} if
|
||||||
\[f \circ (h^{\#_a} \times id) = ((f + id) \circ dstr \circ (h \times id))^{\#_b}\]
|
\[f \circ (h^{\#_a} \times id) = ((f + id) \circ dstr \circ (h \times id))^{\#_b}\]
|
||||||
for any $h : Y \rightarrow A + Y$.
|
for any \(h : Y \rightarrow A + Y\).
|
||||||
|
|
||||||
Let us also consider the special case where $X = 1$.
|
Let us also consider the special case where \(X = 1\).
|
||||||
A morphism $f : A \rightarrow B$ is called \textit{iteration preserving} if
|
A morphism \(f : A \rightarrow B\) is called \textit{iteration preserving} if
|
||||||
\[f \circ h^{\#_a} = ((f + id) \circ h)^{\#_b}\]
|
\[f \circ h^{\#_a} = {((f + id) \circ h)}^{\#_b}\]
|
||||||
for any $h : Y \rightarrow A + Y$.
|
for any \(h : Y \rightarrow A + Y\).
|
||||||
\end{definition}
|
\end{definition}
|
||||||
|
|
||||||
The previous definition yields the category of Elgot algebras over a category $\C$ and iteration preserving morphisms between these algebras. We call this category $\elgotalgs{\C}$.
|
The previous definition yields the category of Elgot algebras over a category \(\C \) and iteration preserving morphisms between these algebras. We call this category \(\elgotalgs{\C}\).
|
||||||
|
|
||||||
\begin{lemma}
|
\begin{lemma}
|
||||||
$\elgotalgs{\C}$ is a category.
|
\(\elgotalgs{\C}\) is a category.
|
||||||
\end{lemma}
|
\end{lemma}
|
||||||
\begin{proof}
|
\begin{proof}
|
||||||
It suffices to show that the identity morphism in $\C$ is iteration preserving and the composite of two iteration preserving morphisms is also iteration preserving.
|
It suffices to show that the identity morphism in \(\C \) is iteration preserving and the composite of two iteration preserving morphisms is also iteration preserving.
|
||||||
|
|
||||||
Let $(A , (-)^{\#_a}), (B , (-)^{\#_b}), (C , (-)^{\#_c})$ be Elgot algebras.
|
Let \((A , {(-)}^{\#_a}), (B , {(-)}^{\#_b}), (C , {(-)}^{\#_c})\) be Elgot algebras.
|
||||||
The identity trivially satisfies
|
The identity trivially satisfies
|
||||||
\[id \circ f^{\#_a} = f^{\#_a} = ((id + id) \circ f)^{\#_a}\]
|
\[id \circ f^{\#_a} = f^{\#_a} = {((id + id) \circ f)}^{\#_a}\]
|
||||||
for any $f : X \rightarrow A + X$.
|
for any \(f : X \rightarrow A + X\).
|
||||||
Given two iteration preserving morphisms $f : B \rightarrow C, g : A \rightarrow B$, the composite is iteration preserving since
|
Given two iteration preserving morphisms \(f : B \rightarrow C, g : A \rightarrow B\), the composite is iteration preserving since
|
||||||
\begin{alignat*}{1}
|
\begin{alignat*}{1}
|
||||||
&f \circ g \circ h^{\#_a}
|
& f \circ g \circ h^{\#_a}
|
||||||
\\=\;& f \circ ((g + id) \circ h)^{\#_b}
|
\\=\;& f \circ {((g + id) \circ h)}^{\#_b}
|
||||||
\\=\;&((f + id) \circ (g + id) \circ h)^{\#_c}
|
\\=\;&{((f + id) \circ (g + id) \circ h)}^{\#_c}
|
||||||
\\=\;&(((f \circ g) + id) \circ h)^{\#_c}
|
\\=\;&{(((f \circ g) + id) \circ h)}^{\#_c}
|
||||||
\end{alignat*}
|
\end{alignat*}
|
||||||
for any $h : X \rightarrow A + X$.
|
for any \(h : X \rightarrow A + X\).
|
||||||
\end{proof}
|
\end{proof}
|
||||||
|
|
||||||
Products and exponentials of Elgot algebras can be formed in a canonical way.
|
Products and exponentials of Elgot algebras can be formed in a canonical way.
|
||||||
|
|
||||||
\begin{lemma}\label{lem:elgotalgscat}
|
\begin{lemma}\label{lem:elgotalgscat}
|
||||||
If $\C$ is a cartesian category, so is $\elgotalgs{\C}$.
|
If \(\C\) is a cartesian category, so is \(\elgotalgs{\C}\).
|
||||||
\end{lemma}
|
\end{lemma}
|
||||||
|
|
||||||
\begin{proof}
|
\begin{proof}
|
||||||
Let $1$ be the terminal object of $\C$. Given $f : X \rightarrow 1 + X$ we define the iteration $f^\# =\;! : X \rightarrow 1$ as the unique morphism into the terminal object. The Elgot algebra laws follow instantly by uniqueness of $!$. $(1 , !)$ is the terminal Elgot algebra since for every Elgot algebra $A$ the morphism $! : A \rightarrow 1$ extends to a morphism between Elgot algebras by uniqueness.
|
Let \(1\) be the terminal object of \(\C \). Given \(f : X \rightarrow 1 + X\) we define the iteration \(f^\# =\;! : X \rightarrow 1\) as the unique morphism into the terminal object. The Elgot algebra laws follow instantly by uniqueness of \(!\). \((1 , !)\) is the terminal Elgot algebra since for every Elgot algebra \(A\) the morphism \(! : A \rightarrow 1\) extends to a morphism between Elgot algebras by uniqueness.
|
||||||
|
|
||||||
Let $(A, (-)^{\#_a}) , (B, (-)^{\#_b}) \in \vert\elgotalgs{\C}\vert$ and $A \times B$ be the product of $A$ and $B$ in $\C$. Given $f : X \rightarrow (A \times B) + X$ we define the iteration as:
|
Let \((A, {(-)}^{\#_a}) , (B, {(-)}^{\#_b}) \in \vert\elgotalgs{\C}\vert \) and \(A \times B\) be the product of \(A\) and \(B\) in \(\C \). Given \(f : X \rightarrow (A \times B) + X\) we define the iteration as:
|
||||||
\[f^\# = \langle ((\pi_1 + id) \circ f)^{\#_a} , ((\pi_2 + id) \circ f)^{\#_b} \rangle : X \rightarrow A \times B\]
|
\[f^\# = \langle ((\pi_1 + id) \circ f)^{\#_a} , {((\pi_2 + id) \circ f)}^{\#_b} \rangle : X \rightarrow A \times B\]
|
||||||
Next we show that $(A \times B, (-)^\#)$ is indeed an Elgot algebra:
|
Next we show that \((A \times B, {(-)}^\#)\) is indeed an Elgot algebra:
|
||||||
\begin{itemize}
|
\begin{itemize}
|
||||||
\item \textbf{Fixpoint}: Let $f : X \rightarrow (A \times B) + X$. The requisite equation follows by the fixpoint identities of $((\pi_1 + id) \circ f)^{\#_a}$ and $((\pi_2 + id) \circ f)^{\#_b}$:
|
\item \textbf{Fixpoint}: Let \(f : X \rightarrow (A \times B) + X\). The requisite equation follows by the fixpoint identities of \(((\pi_1 + id) \circ f)^{\#_a}\) and \({((\pi_2 + id) \circ f)}^{\#_b}\):
|
||||||
\begin{alignat*}{1}
|
\begin{alignat*}{1}
|
||||||
&\langle ((\pi_1 + id) \circ f)^{\#_a} , ((\pi_2 + id) \circ f)^{\#_b} \rangle
|
& \langle {((\pi_1 + id) \circ f)}^{\#_a} , {((\pi_2 + id) \circ f)}^{\#_b} \rangle
|
||||||
\\=\;&\langle [ id , ((\pi_1 + id) \circ f)^{\#_a} ] \circ (\pi_1 + id) \circ f
|
\\=\;&\langle [ id , {((\pi_1 + id) \circ f)}^{\#_a} ] \circ (\pi_1 + id) \circ f
|
||||||
\\ &, [ id , ((\pi_2 + id) \circ f)^{\#_b} ] \circ (\pi_2 + id) \circ f \rangle \tag{\ref{law:fixpoint}}
|
\\ &, [ id , ((\pi_2 + id) \circ f)^{\#_b} ] \circ (\pi_2 + id) \circ f \rangle \tag{\ref{law:fixpoint}}
|
||||||
\\=\;&\langle [ \pi_1 , ((\pi_1 + id) \circ f)^{\#_a} ] \circ f , [ \pi_2 , ((\pi_2 + id) \circ f)^{\#_b} ] \circ f \rangle
|
\\=\;&\langle [ \pi_1 , {((\pi_1 + id) \circ f)}^{\#_a} ] \circ f , [ \pi_2 , {((\pi_2 + id) \circ f)}^{\#_b} ] \circ f \rangle
|
||||||
\\=\;&\langle [ \pi_1 , ((\pi_1 + id) \circ f)^{\#_a} ] , [ \pi_2 , ((\pi_2 + id) \circ f)^{\#_b} ] \rangle \circ f
|
\\=\;&\langle [ \pi_1 , {((\pi_1 + id) \circ f)}^{\#_a} ] , [ \pi_2 , {((\pi_2 + id) \circ f)}^{\#_b} ] \rangle \circ f
|
||||||
\\=\;&[ \langle \pi_1 , \pi_2 \rangle , \langle ((\pi_1 + id) \circ f)^{\#_a} , ((\pi_2 + id) \circ f)^{\#_b} \rangle ] \circ f
|
\\=\;&[ \langle \pi_1 , \pi_2 \rangle , \langle {((\pi_1 + id) \circ f)}^{\#_a} , {((\pi_2 + id) \circ f)}^{\#_b} \rangle ] \circ f
|
||||||
\\=\;&[ id , \langle ((\pi_1 + id) \circ f)^{\#_a} , ((\pi_2 + id) \circ f)^{\#_b} \rangle ] \circ f
|
\\=\;&[ id , \langle {((\pi_1 + id) \circ f)}^{\#_a} , {((\pi_2 + id) \circ f)}^{\#_b} \rangle ] \circ f
|
||||||
\end{alignat*}
|
\end{alignat*}
|
||||||
\item \textbf{Uniformity}: Let $f : X \rightarrow (A \times B) + X, g : Y \rightarrow (A \times B) + Y, h : X \rightarrow Y$ and $(id + h) \circ f = g \circ h$.
|
\item \textbf{Uniformity}: Let \(f : X \rightarrow (A \times B) + X, g : Y \rightarrow (A \times B) + Y, h : X \rightarrow Y\) and \((id + h) \circ f = g \circ h\).
|
||||||
Note that this implies:
|
Note that this implies:
|
||||||
\begin{alignat*}{2}
|
\begin{alignat*}{2}
|
||||||
&(id + h) \circ (\pi_1 + id) \circ f &&= (\pi_1 + id) \circ g \circ h
|
& (id + h) \circ (\pi_1 + id) \circ f & & = (\pi_1 + id) \circ g \circ h
|
||||||
\\&(id + h) \circ (\pi_2 + id) \circ f &&= (\pi_2 + id) \circ g \circ h
|
\\&(id + h) \circ (\pi_2 + id) \circ f &&= (\pi_2 + id) \circ g \circ h
|
||||||
\end{alignat*}
|
\end{alignat*}
|
||||||
|
|
||||||
\ref{law:uniformity} of $(-)^{\#_a}$ and $(-)^{\#_b}$ with the previous two equations yields:
|
Then,~\ref{law:uniformity} of \({(-)}^{\#_a}\) and \({(-)}^{\#_b}\) with the previous two equations yields:
|
||||||
\begin{alignat*}{2}
|
\begin{alignat*}{2}
|
||||||
&\langle ((\pi_1 + id) \circ f)^{\#_a} , ((\pi_1 + id) \circ f)^{\#_a} \rangle &&= ((\pi_1 + id) \circ g)^{\#_a} \circ h
|
& \langle {((\pi_1 + id) \circ f)}^{\#_a} , {((\pi_1 + id) \circ f)}^{\#_a} \rangle & & = {((\pi_1 + id) \circ g})^{\#_a} \circ h
|
||||||
\\&\langle ((\pi_2 + id) \circ f)^{\#_b} , ((\pi_2 + id) \circ f)^{\#_b} \rangle &&= ((\pi_2 + id) \circ g)^{\#_b} \circ h
|
\\&\langle {((\pi_2 + id) \circ f)}^{\#_b} , {((\pi_2 + id) \circ f)}^{\#_b} \rangle &&= {((\pi_2 + id) \circ g)}^{\#_b} \circ h
|
||||||
\end{alignat*}
|
\end{alignat*}
|
||||||
|
|
||||||
This concludes the proof of:
|
This concludes the proof of:
|
||||||
\[ \langle ((\pi_1 + id) \circ f)^{\#_a} , ((\pi_2 + id) \circ f)^{\#_b} \rangle = \langle ((\pi_1 + id) \circ g)^{\#_a} , ((\pi_2 + id) \circ g)^{\#_b} \rangle \circ h \]
|
\[ \langle {((\pi_1 + id) \circ f)}^{\#_a} , ((\pi_2 + id) \circ f)^{\#_b} \rangle = \langle {((\pi_1 + id) \circ g)}^{\#_a} , {((\pi_2 + id) \circ g)}^{\#_b} \rangle \circ h \]
|
||||||
\item \textbf{Folding}: Let $f : X \rightarrow (A \times B) + X, h : Y \rightarrow X + Y$. We need to show:
|
\item \textbf{Folding}: Let \(f : X \rightarrow (A \times B) + X, h : Y \rightarrow X + Y\). We need to show:
|
||||||
\begin{alignat*}{1}
|
\begin{alignat*}{1}
|
||||||
&\langle ((\pi_1 + id) \circ (\langle ((\pi_1 + id) \circ f)^{\#_a} , ((\pi_2 + id) \circ f)^{\#_b} \rangle + h)))^{\#_a}
|
& \langle {((\pi_1 + id) \circ (\langle {((\pi_1 + id) \circ f)}^{\#_a} , {((\pi_2 + id) \circ f)}^{\#_b} \rangle + h))}^{\#_a}
|
||||||
\\&,((\pi_2 + id) \circ (\langle ((\pi_1 + id) \circ f)^{\#_a} , ((\pi_2 + id) \circ f)^{\#_b} \rangle + h)))^{\#_b} \rangle
|
\\&,{((\pi_2 + id) \circ (\langle {((\pi_1 + id) \circ f)}^{\#_a} , {((\pi_2 + id) \circ f)}^{\#_b} \rangle + h))}^{\#_b} \rangle
|
||||||
\\=\;&\langle (\pi_1 + id) \circ [ (id + i_1) \circ f , i_2 \circ h ]^{\#_a} , (\pi_2 + id) \circ [ (id + i_1) \circ f , i_2 \circ h ]^{\#_b} \rangle
|
\\=\;&\langle (\pi_1 + id) \circ {[ (id + i_1) \circ f , i_2 \circ h ]}^{\#_a} , (\pi_2 + id) \circ {[ (id + i_1) \circ f , i_2 \circ h ]}^{\#_b} \rangle
|
||||||
\end{alignat*}
|
\end{alignat*}
|
||||||
|
|
||||||
Indeed, the folding laws for $(-)^{\#_a}$ and $(-)^{\#_b}$ imply
|
Indeed, the folding laws for \({(-)}^{\#_a}\) and \({(-)}^{\#_b}\) imply
|
||||||
\begin{alignat*}{1}
|
\begin{alignat*}{1}
|
||||||
&((\pi_1 + id) \circ (\langle ((\pi_1 + id) \circ f)^{\#_a} , ((\pi_2 + id) \circ f)^{\#_b} \rangle + h)))^{\#_a}
|
& {((\pi_1 + id) \circ (\langle {((\pi_1 + id) \circ f)}^{\#_a} , {((\pi_2 + id) \circ f)}^{\#_b} \rangle + h))}^{\#_a}
|
||||||
\\=\;&(((\pi_1 + id) \circ f)^{\#_a} + h)^{\#_a}
|
\\=\;&{({((\pi_1 + id) \circ f)}^{\#_a} + h)}^{\#_a}
|
||||||
\\=\;&[ (id + i_1) \circ (\pi_1 + id) \circ f , i_2 \circ h ]^{\#_a}\tag{\ref{law:folding}}
|
\\=\;&{[ (id + i_1) \circ (\pi_1 + id) \circ f , i_2 \circ h ]}^{\#_a}\tag{\ref{law:folding}}
|
||||||
\\=\;&(\pi_1 + id) \circ [ (id + i_1) \circ f , i_2 \circ h ]^{\#_a}
|
\\=\;&(\pi_1 + id) \circ {[ (id + i_1) \circ f , i_2 \circ h ]}^{\#_a}
|
||||||
\end{alignat*}
|
\end{alignat*}
|
||||||
and
|
and
|
||||||
\begin{alignat*}{1}
|
\begin{alignat*}{1}
|
||||||
&((\pi_2 + id) \circ (\langle ((\pi_1 + id) \circ f)^{\#_a} , ((\pi_2 + id) \circ f)^{\#_b} \rangle + h)))^{\#_b}
|
& {((\pi_2 + id) \circ (\langle {((\pi_1 + id) \circ f)}^{\#_a} , {((\pi_2 + id) \circ f)}^{\#_b} \rangle + h))}^{\#_b}
|
||||||
\\=\;&(((\pi_2 + id) \circ f)^{\#_b} + h)^{\#_b}
|
\\=\;&{(((\pi_2 + id) \circ f)^{\#_b} + h)}^{\#_b}
|
||||||
\\=\;&[ (id + i_1) \circ (\pi_2 + id) \circ f , i_2 \circ h ]^{\#_b}\tag{\ref{law:folding}}
|
\\=\;&{[ (id + i_1) \circ (\pi_2 + id) \circ f , i_2 \circ h ]}^{\#_b}\tag{\ref{law:folding}}
|
||||||
\\=\;&(\pi_2 + id) \circ [ (id + i_1) \circ f , i_2 \circ h ]^{\#_b}
|
\\=\;&(\pi_2 + id) \circ {[ (id + i_1) \circ f , i_2 \circ h ]}^{\#_b}
|
||||||
\end{alignat*}
|
\end{alignat*}
|
||||||
which concludes the proof of the folding law.
|
which concludes the proof of the folding law.
|
||||||
\end{itemize}
|
\end{itemize}
|
||||||
|
|
||||||
The product diagram of $A \times B$ in $\C$ then also holds in $\elgotalgs{\C}$, we just have to check that the projections are iteration preserving, which follows instantly, and that the unique morphism $\langle f , g \rangle$ is iteration preserving for any $f : (Z, (-)^{\#_z}) \rightarrow (X, (-)^{\#_x}), g : (Z, (-)^{\#_z}) \rightarrow (Y, (-)^{\#_y})$:
|
The product diagram of \(A \times B\) in \(\C\) then also holds in \(\elgotalgs{\C}\), we just have to check that the projections are iteration preserving, which follows instantly, and that the unique morphism \(\langle f , g \rangle\) is iteration preserving for any \(f : (Z, (-)^{\#_z}) \rightarrow (X, (-)^{\#_x}), g : (Z, (-)^{\#_z}) \rightarrow (Y, (-)^{\#_y})\):
|
||||||
|
|
||||||
Let $h : X \rightarrow E + X$ where $E \in \obj{\elgotalgs{\C}}$. We use the fact that $f, g$ are iteration preserving to show:
|
Let \(h : X \rightarrow E + X\) where \(E \in \obj{\elgotalgs{\C}}\). We use the fact that \(f, g\) are iteration preserving to show:
|
||||||
\begin{alignat*}{1}
|
\begin{alignat*}{1}
|
||||||
&\langle f , g \rangle \circ (h^{\#_e})
|
& \langle f , g \rangle \circ (h^{\#_e})
|
||||||
\\=\;&\langle f \circ (h^{\#_e}) , g \circ (h^{\#_e}) \rangle
|
\\=\;&\langle f \circ (h^{\#_e}) , g \circ (h^{\#_e}) \rangle
|
||||||
\\=\;&\langle ((f + id) \circ h)^{\#_a} , ((g + id) \circ h)^{\#_b} \rangle
|
\\=\;&\langle ((f + id) \circ h)^{\#_a} , ((g + id) \circ h)^{\#_b} \rangle
|
||||||
\\=\;&\langle ((\pi_1 + id) \circ (\langle f , g \rangle + id) \circ h)^{\#_a} , ((\pi_1 + id) \circ (\langle f , g \rangle + id) \circ h)^{\#_b} \rangle
|
\\=\;&\langle ((\pi_1 + id) \circ (\langle f , g \rangle + id) \circ h)^{\#_a} , ((\pi_1 + id) \circ (\langle f , g \rangle + id) \circ h)^{\#_b} \rangle
|
||||||
\end{alignat*}
|
\end{alignat*}
|
||||||
Which confirms that $\langle f , g \rangle$ is indeed iteration preserving. Thus, we have shown that $\elgotalgs{\C}$ is cartesian if $\C$ is cartesian.
|
Which confirms that \(\langle f , g \rangle\) is indeed iteration preserving. Thus, we have shown that \(\elgotalgs{\C}\) is cartesian if \(\C \) is cartesian.
|
||||||
\end{proof}
|
\end{proof}
|
||||||
|
|
||||||
\begin{lemma}\label{lem:elgotexp}
|
\begin{lemma}\label{lem:elgotexp}
|
||||||
Given $X \in \obj{\C}$ and $(A, (-)^{\#_a}) \in \vert\elgotalgs{\C}\vert$. The exponential $X^A$ (if it exists) can be equipped with an Elgot algebra structure.
|
Given \(X \in \obj{\C}\) and \((A, (-)^{\#_a}) \in \vert\elgotalgs{\C}\vert \). The exponential \(X^A\) (if it exists) can be equipped with an Elgot algebra structure.
|
||||||
\end{lemma}
|
\end{lemma}
|
||||||
\begin{proof}
|
\begin{proof}
|
||||||
Take $f^\# = curry (((eval + id) \circ dstr \circ (f \times id))^{\#_a})$ as the iteration of some $f : Z \rightarrow A^X + Z$.
|
Take \(f^\# = curry (((eval + id) \circ dstr \circ (f \times id))^{\#_a})\) as the iteration of some \(f : Z \rightarrow A^X + Z\).
|
||||||
|
|
||||||
\begin{itemize}
|
\begin{itemize}
|
||||||
\item \textbf{Fixpoint}: Let $f : Y \rightarrow X^A + Y$ with $Y \in \obj{C}$. By uniqueness of $f^\# = curry\;(((eval + id) \circ dstr \circ (f \times id))^{\#_a})$ it suffices to show:
|
\item \textbf{Fixpoint}: Let \(f : Y \rightarrow X^A + Y\) with \(Y \in \obj{C}\). By uniqueness of \(f^\# = curry\;(((eval + id) \circ dstr \circ (f \times id))^{\#_a})\) it suffices to show:
|
||||||
\begin{alignat*}{1}
|
\begin{alignat*}{1}
|
||||||
&eval \circ ([ id , curry (((eval + id) \circ dstr \circ (f \times id))^{\#_a}) ] \circ f] \times id)
|
& eval \circ ([ id , curry (((eval + id) \circ dstr \circ (f \times id))^{\#_a}) ] \circ f] \times id)
|
||||||
\\=\;&eval \circ [ id , curry (((eval + id) \circ dstr \circ (f \times id))^{\#_a}) \times id ] \circ dstr \circ (f \times id)\tag*{\ref{hlp:elgot_exp_fixpoint}}
|
\\=\;&eval \circ [ id , curry (((eval + id) \circ dstr \circ (f \times id))^{\#_a}) \times id ] \circ dstr \circ (f \times id)\tag*{\ref{hlp:elgot_exp_fixpoint}}
|
||||||
\\=\;&[ eval , eval \circ curry (((eval + id) \circ dstr \circ (f \times id))^{\#_a}) \times id ] \circ dstr \circ (f \times id)
|
\\=\;&[ eval , eval \circ curry (((eval + id) \circ dstr \circ (f \times id))^{\#_a}) \times id ] \circ dstr \circ (f \times id)
|
||||||
\\=\;&[ eval , ((eval + id) \circ dstr \circ (f \times id))^{\#_a} ] \circ dstr \circ (f \times id)
|
\\=\;&[ eval , ((eval + id) \circ dstr \circ (f \times id))^{\#_a} ] \circ dstr \circ (f \times id)
|
||||||
|
@ -176,13 +176,13 @@ Products and exponentials of Elgot algebras can be formed in a canonical way.
|
||||||
\end{alignat*}
|
\end{alignat*}
|
||||||
Where
|
Where
|
||||||
\begin{alignat*}{1}
|
\begin{alignat*}{1}
|
||||||
&[ id , curry(((eval + id) \circ dstr \circ (f \times id))^{\#_a}) ] \times id
|
& [ id , curry(((eval + id) \circ dstr \circ (f \times id))^{\#_a}) ] \times id
|
||||||
\\= \;&[ id , curry(((eval + id) \circ dstr \circ (f \times id))^{\#_a}) \times id ] \circ dstr \tag*{(*)}\label{hlp:elgot_exp_fixpoint}
|
\\= \;&[ id , curry(((eval + id) \circ dstr \circ (f \times id))^{\#_a}) \times id ] \circ dstr \tag*{(*)}\label{hlp:elgot_exp_fixpoint}
|
||||||
\end{alignat*}
|
\end{alignat*}
|
||||||
follows by post-composing with $\pi_1$ and $\pi_2$:
|
follows by post-composing with \(\pi_1\) and \(\pi_2\):
|
||||||
|
|
||||||
\begin{alignat*}{1}
|
\begin{alignat*}{1}
|
||||||
&\pi_1 \circ [ id , curry(((eval + id) \circ dstr \circ (f \times id))^{\#_a}) \times id ] \circ dstr
|
& \pi_1 \circ [ id , curry(((eval + id) \circ dstr \circ (f \times id))^{\#_a}) \times id ] \circ dstr
|
||||||
\\=\;&[ \pi_1 , \pi_1 \circ curry(((eval + id) \circ dstr \circ (f \times id))^{\#_a}) \times id ] \circ dstr
|
\\=\;&[ \pi_1 , \pi_1 \circ curry(((eval + id) \circ dstr \circ (f \times id))^{\#_a}) \times id ] \circ dstr
|
||||||
\\=\;&[ \pi_1 , curry(((eval + id) \circ dstr \circ (f \times id))^{\#_a}) \circ \pi_1 ] \circ dstr
|
\\=\;&[ \pi_1 , curry(((eval + id) \circ dstr \circ (f \times id))^{\#_a}) \circ \pi_1 ] \circ dstr
|
||||||
\\=\;&[ id , curry(((eval + id) \circ dstr \circ (f \times id))^{\#_a}) ] \circ (\pi_1 + \pi_1) \circ dstr
|
\\=\;&[ id , curry(((eval + id) \circ dstr \circ (f \times id))^{\#_a}) ] \circ (\pi_1 + \pi_1) \circ dstr
|
||||||
|
@ -190,28 +190,28 @@ Products and exponentials of Elgot algebras can be formed in a canonical way.
|
||||||
\end{alignat*}
|
\end{alignat*}
|
||||||
|
|
||||||
\begin{alignat*}{1}
|
\begin{alignat*}{1}
|
||||||
&\pi_2 \circ [ id , curry(((eval + id) \circ dstr \circ (f \times id))^{\#_a}) \times id ] \circ dstr
|
& \pi_2 \circ [ id , curry(((eval + id) \circ dstr \circ (f \times id))^{\#_a}) \times id ] \circ dstr
|
||||||
\\=\;&[ \pi_2 , \pi_2 \circ curry(((eval + id) \circ dstr \circ (f \times id))^{\#_a}) \times id ] \circ dstr
|
\\=\;&[ \pi_2 , \pi_2 \circ curry(((eval + id) \circ dstr \circ (f \times id))^{\#_a}) \times id ] \circ dstr
|
||||||
\\=\;&[ \pi_2 , \pi_2 ] \circ dstr
|
\\=\;&[ \pi_2 , \pi_2 ] \circ dstr
|
||||||
\\=\;&\pi_2
|
\\=\;&\pi_2
|
||||||
\end{alignat*}
|
\end{alignat*}
|
||||||
\item \textbf{Uniformity}: Let $Y, Z \in \obj{C}, f : Y \rightarrow X^A + Y, g : Z \rightarrow X^A + Z, h : Y \rightarrow Z$ and $(id + h) \circ f = g \circ h$. By uniqueness of $f^\# = curry(((eval + id) \circ dstr \circ (f \times id))^{\#_a})$ it suffices to show:
|
\item \textbf{Uniformity}: Let \(Y, Z \in \obj{C}, f : Y \rightarrow X^A + Y, g : Z \rightarrow X^A + Z, h : Y \rightarrow Z\) and \((id + h) \circ f = g \circ h\). By uniqueness of \(f^\# = curry(((eval + id) \circ dstr \circ (f \times id))^{\#_a})\) it suffices to show:
|
||||||
\begin{alignat*}{1}
|
\begin{alignat*}{1}
|
||||||
&((eval + id) \circ dstr \circ (f \times id))^{\#_a}
|
& ((eval + id) \circ dstr \circ (f \times id))^{\#_a}
|
||||||
\\=\;&((eval + id) \circ dstr \circ (g \times id))^{\#_a} \circ (h \times id)\tag{\ref{law:uniformity}}
|
\\=\;&((eval + id) \circ dstr \circ (g \times id))^{\#_a} \circ (h \times id)\tag{\ref{law:uniformity}}
|
||||||
\\=\;&eval \circ (((eval + id) \circ dstr \circ (g \times id))^{\#_a} \times id) \circ (h \times id)
|
\\=\;&eval \circ (((eval + id) \circ dstr \circ (g \times id))^{\#_a} \times id) \circ (h \times id)
|
||||||
\\=\;&eval \circ (((eval + id) \circ dstr \circ (g \times id))^{\#_a} \circ h \times id)
|
\\=\;&eval \circ (((eval + id) \circ dstr \circ (g \times id))^{\#_a} \circ h \times id)
|
||||||
\end{alignat*}
|
\end{alignat*}
|
||||||
Note that the application of \ref{law:uniformity} requires:
|
Note that the application of \ref{law:uniformity} requires:
|
||||||
\begin{alignat*}{1}
|
\begin{alignat*}{1}
|
||||||
&(id + (h \times id)) \circ (eval + id) \circ dstr \circ (f \times id)
|
& (id + (h \times id)) \circ (eval + id) \circ dstr \circ (f \times id)
|
||||||
\\=\;&(eval + id) \circ (id + (h \times id)) \circ dstr \circ (f \times id)
|
\\=\;&(eval + id) \circ (id + (h \times id)) \circ dstr \circ (f \times id)
|
||||||
\\=\;&(eval + id) \circ dstr \circ (id \times h) \circ (id \times id) \circ (f \times id)
|
\\=\;&(eval + id) \circ dstr \circ (id \times h) \circ (id \times id) \circ (f \times id)
|
||||||
\\=\;&(eval + id) \circ dstr \circ (g \times id) \circ (h \times id)
|
\\=\;&(eval + id) \circ dstr \circ (g \times id) \circ (h \times id)
|
||||||
\end{alignat*}
|
\end{alignat*}
|
||||||
\item \textbf{Folding}: Let $Y, Z \in \obj{C}, f : Y \rightarrow X^A + Y, h : Y \rightarrow Z$.
|
\item \textbf{Folding}: Let \(Y, Z \in \obj{C}, f : Y \rightarrow X^A + Y, h : Y \rightarrow Z\).
|
||||||
\begin{alignat*}{1}
|
\begin{alignat*}{1}
|
||||||
&(f^\# + h)^\#
|
& (f^\# + h)^\#
|
||||||
\\=\;&curry(((eval + id) \circ dstr \circ ((curry(((eval + id) \circ dstr \circ (f \times id))^{\#_a}) + h) \times id))^{\#_a})
|
\\=\;&curry(((eval + id) \circ dstr \circ ((curry(((eval + id) \circ dstr \circ (f \times id))^{\#_a}) + h) \times id))^{\#_a})
|
||||||
\\=\;&curry(((eval + id) \circ ((curry(((eval + id) \circ dstr \circ (f \times id))^{\#_a}) \times id) + (h \times id)) \circ dstr)^{\#_a})
|
\\=\;&curry(((eval + id) \circ ((curry(((eval + id) \circ dstr \circ (f \times id))^{\#_a}) \times id) + (h \times id)) \circ dstr)^{\#_a})
|
||||||
\\=\;&curry(((eval \circ (curry(((eval + id) \circ dstr \circ (f \times id))^{\#_a}) \times id) + (h \times id)) \circ dstr)^{\#_a})
|
\\=\;&curry(((eval \circ (curry(((eval + id) \circ dstr \circ (f \times id))^{\#_a}) \times id) + (h \times id)) \circ dstr)^{\#_a})
|
||||||
|
@ -221,14 +221,10 @@ Products and exponentials of Elgot algebras can be formed in a canonical way.
|
||||||
\\=\;&curry(((eval + id) \circ dstr \circ ([ (id + i_1) \circ f , i_2 \circ h ] \times id))^{\#_a})\tag{\ref{law:uniformity}}
|
\\=\;&curry(((eval + id) \circ dstr \circ ([ (id + i_1) \circ f , i_2 \circ h ] \times id))^{\#_a})\tag{\ref{law:uniformity}}
|
||||||
\\=\;&[ (id + i_1) \circ f , i_2 \circ h ]^\#
|
\\=\;&[ (id + i_1) \circ f , i_2 \circ h ]^\#
|
||||||
\end{alignat*}
|
\end{alignat*}
|
||||||
% Where the first application of \ref{law:uniformity} is justified by:
|
\
|
||||||
% \begin{alignat*}{1}
|
The second application of~\ref{law:uniformity} is non-trivial, using epicness of \(dstr^{-1}\):
|
||||||
% &(id + dstr) \circ (((eval + id) \circ dstr \circ (f \times id))^{\#_a} + (h \times id)) \circ dstr
|
|
||||||
% \\=\;&(((eval + id) \circ dstr \circ (f \times id))^{\#_a} + (dstr \circ (h \times id))) \circ dstr
|
|
||||||
% \end{alignat*}
|
|
||||||
The second application of \ref{law:uniformity} is non-trivial, using epicness of $dstr^{-1}$:
|
|
||||||
\begin{alignat*}{1}
|
\begin{alignat*}{1}
|
||||||
&(id + dstr) \circ (eval + id) \circ dstr \circ ([ (id + i_1) \circ f , i_2 \circ h ] \times id) \circ dstr^{-1}
|
& (id + dstr) \circ (eval + id) \circ dstr \circ ([ (id + i_1) \circ f , i_2 \circ h ] \times id) \circ dstr^{-1}
|
||||||
\\=\;&[ (id + dstr) \circ (eval + id) \circ dstr \circ ([ (id + i_1) \circ f , i_2 \circ h ] \times id) \circ (i_1 \times id)
|
\\=\;&[ (id + dstr) \circ (eval + id) \circ dstr \circ ([ (id + i_1) \circ f , i_2 \circ h ] \times id) \circ (i_1 \times id)
|
||||||
\\&, (id + dstr) \circ (eval + id) \circ dstr \circ ([ (id + i_1) \circ f , i_2 \circ h ] \times id) \circ (i_2 \times id) ]
|
\\&, (id + dstr) \circ (eval + id) \circ dstr \circ ([ (id + i_1) \circ f , i_2 \circ h ] \times id) \circ (i_2 \times id) ]
|
||||||
\\=\;&[ (id + dstr) \circ (eval + id) \circ dstr \circ (((id + i_1) \circ f) \times id)
|
\\=\;&[ (id + dstr) \circ (eval + id) \circ dstr \circ (((id + i_1) \circ f) \times id)
|
||||||
|
@ -248,44 +244,36 @@ Products and exponentials of Elgot algebras can be formed in a canonical way.
|
||||||
\improvement{Add some text, explain Elgot monads and while loops}
|
\improvement{Add some text, explain Elgot monads and while loops}
|
||||||
|
|
||||||
\begin{definition}[(Strong) Pre-Elgot Monad]
|
\begin{definition}[(Strong) Pre-Elgot Monad]
|
||||||
A monad $\mathbf{T}$ is called pre-Elgot if every $TX$ extends to an Elgot algebra such that for every $f : X \rightarrow TY$ the Kleisli lifting $f^* : TX \rightarrow TY$ is iteration preserving.
|
A monad \(\mathbf{T}\) is called pre-Elgot if every \(TX\) extends to an Elgot algebra such that for every \(f : X \rightarrow TY\) the Kleisli lifting \(f^* : TX \rightarrow TY\) is iteration preserving.
|
||||||
|
|
||||||
If $\mathbf{T}$ is additionally strong and the strength $\tau$ is right iteration preserving we call it strong pre-Elgot.
|
If \(\mathbf{T}\) is additionally strong and the strength \(\tau \) is right iteration preserving we call it strong pre-Elgot.
|
||||||
\end{definition}
|
\end{definition}
|
||||||
|
|
||||||
(Strong) pre-Elgot monads form a subcategory of $\monads{\C}$ where objects are (strong) pre-Elgot monads and morphisms between pre-Elgot monads are natural transformations $\alpha$ as in \autoref{def:monads} such that additionally each $\alpha_X$ is iteration preserving. Similarly, morphisms between strong pre-Elgot monads are natural transformations $\alpha$ as in \autoref{def:strongmonads} such that each $\alpha_X$ is iteration preserving. We call these categories $\preelgot{\C}$ and $\strongpreelgot{\C}$ respectively.
|
(Strong) pre-Elgot monads form a subcategory of \(\monads{\C}\) where objects are (strong) pre-Elgot monads and morphisms between pre-Elgot monads are natural transformations \(\alpha \) as in \autoref{def:monads} such that additionally each \(\alpha_X\) is iteration preserving. Similarly, morphisms between strong pre-Elgot monads are natural transformations \(\alpha \) as in \autoref{def:strongmonads} such that each \(\alpha_X\) is iteration preserving. We call these categories \(\preelgot{\C}\) and \(\strongpreelgot{\C}\) respectively.
|
||||||
|
|
||||||
\begin{lemma}
|
\begin{lemma}
|
||||||
$\preelgot{\C}$ and $\strongpreelgot{\C}$ are categories.
|
\(\preelgot{\C}\) and \(\strongpreelgot{\C}\) are categories.
|
||||||
\end{lemma}
|
\end{lemma}
|
||||||
\begin{proof}
|
\begin{proof}
|
||||||
Using \autoref{def:monads} and \autoref{def:strongmonads} it suffices to show that the components of the identity natural transformation are iteration preserving and that the composition of two pre-Elgot monad morphisms is iteration preserving component wise. This has already been shown in \autoref{lem:elgotalgscat}.
|
Using \autoref{def:monads} and \autoref{def:strongmonads} it suffices to show that the components of the identity natural transformation are iteration preserving and that the composition of two pre-Elgot monad morphisms is iteration preserving component wise. This has already been shown in \autoref{lem:elgotalgscat}.
|
||||||
\end{proof}
|
\end{proof}
|
||||||
|
|
||||||
% Let us briefly introduce the category of (strong) pre-Elgot monads because the initial objects of these categories will be of special interest to us.
|
|
||||||
|
|
||||||
% \begin{definition}[The Category of (Strong) Pre-Elgot Monads]
|
|
||||||
% Let $\C$ be a category. We define the category $\preelgot{\C}$ where objects are pre-Elgot monads and morphisms between pre-Elgot monads are morphisms between monads as in \autoref{def:monads} and additionally every $\alpha_X$ is a morphism between Elgot algebras as in \autoref{def:elgotalgebras}.
|
|
||||||
|
|
||||||
% Similarly, morphisms between strong pre-Elgot Monads are morphisms between strong monads as in \autoref{def:strongmonads} and every $\alpha_X$ is a morphism between Elgot algebras. This describes the category of strong pre-Elgot monads that we call $\strongpreelgot{\C}$.
|
|
||||||
% \end{definition}
|
|
||||||
|
|
||||||
\todo[inline]{Initial pre-Elgot bridges gap to Elgot monads under countable choice\ldots}
|
\todo[inline]{Initial pre-Elgot bridges gap to Elgot monads under countable choice\ldots}
|
||||||
|
|
||||||
\section{The Initial Strong Pre-Elgot Monad}
|
\section{The Initial Strong Pre-Elgot Monad}
|
||||||
In this section we will study the monad that arises from existence of all free Elgot algebras. We will show that this is an equational lifting monad and also the initial strong pre-Elgot monad.
|
In this section we will study the monad that arises from existence of all free Elgot algebras. We will show that this is an equational lifting monad and also the initial strong pre-Elgot monad.
|
||||||
|
|
||||||
\begin{proposition}
|
\begin{proposition}
|
||||||
Existence of all free Elgot algebras yields a monad that we call $\mathbf{K}$.
|
Existence of all free Elgot algebras yields a monad that we call \(\mathbf{K}\).
|
||||||
\end{proposition}
|
\end{proposition}
|
||||||
\begin{proof}
|
\begin{proof}
|
||||||
This is a direct consequence of \autoref{thm:freemonad}.
|
This is a direct consequence of \autoref{thm:freemonad}.
|
||||||
\end{proof}
|
\end{proof}
|
||||||
|
|
||||||
We will need a notion of stability for $\mathbf{K}$ to make progress, since we do not assume $\C$ to be cartesian closed.
|
We will need a notion of stability for \(\mathbf{K}\) to make progress, since we do not assume \(\C \) to be cartesian closed.
|
||||||
|
|
||||||
\begin{definition}[Right-Stable Free Elgot Algebra]\label{def:rightstablefreeelgot}
|
\begin{definition}[Right-Stable Free Elgot Algebra]\label{def:rightstablefreeelgot}
|
||||||
Let $KY$ be a free Elgot algebra on $Y \in \obj{\C}$. We call $KY$ \textit{right-stable} if for every $A \in \elgotalgs{\C}, X \in \obj{\C}$, and $f : X \times Y \rightarrow A$ there exists a unique right iteration preserving $\rs{f} : X \times KY \rightarrow A$ such that
|
Let \(KY\) be a free Elgot algebra on \(Y \in \obj{\C}\). We call \(KY\) \textit{right-stable} if for every \(A \in \elgotalgs{\C}, X \in \obj{\C}\), and \(f : X \times Y \rightarrow A\) there exists a unique right iteration preserving \(\rs{f} : X \times KY \rightarrow A\) such that
|
||||||
% https://q.uiver.app/#q=WzAsMyxbMCwwLCJYIFxcdGltZXMgWSJdLFsyLDAsIkEiXSxbMCwyLCJYIFxcdGltZXMgS1kiXSxbMCwxLCJmIl0sWzAsMiwiaWRcXHRpbWVzXFxldGEiLDJdLFsyLDEsIlxccnN7Zn0iLDJdXQ==
|
% https://q.uiver.app/#q=WzAsMyxbMCwwLCJYIFxcdGltZXMgWSJdLFsyLDAsIkEiXSxbMCwyLCJYIFxcdGltZXMgS1kiXSxbMCwxLCJmIl0sWzAsMiwiaWRcXHRpbWVzXFxldGEiLDJdLFsyLDEsIlxccnN7Zn0iLDJdXQ==
|
||||||
\[\begin{tikzcd}[ampersand replacement=\&]
|
\[\begin{tikzcd}[ampersand replacement=\&]
|
||||||
{X \times Y} \&\& A \\
|
{X \times Y} \&\& A \\
|
||||||
|
@ -301,7 +289,7 @@ We will need a notion of stability for $\mathbf{K}$ to make progress, since we d
|
||||||
A symmetrical variant of the previous definition is sometimes useful.
|
A symmetrical variant of the previous definition is sometimes useful.
|
||||||
|
|
||||||
\begin{definition}[Left-Stable Free Elgot Algebra]\label{def:leftstablefreeelgot}
|
\begin{definition}[Left-Stable Free Elgot Algebra]\label{def:leftstablefreeelgot}
|
||||||
Let $KY$ be a free Elgot algebra on $Y \in \obj{\C}$. We call $KY$ \textit{left-stable} if for every $A \in \elgotalgs{\C}, X \in \obj{\C}$, and $f : Y \times X \rightarrow A$ there exists a unique left iteration preserving $\ls{f} : KY \times X \rightarrow A$ such that
|
Let \(KY\) be a free Elgot algebra on \(Y \in \obj{\C}\). We call \(KY\) \textit{left-stable} if for every \(A \in \elgotalgs{\C}, X \in \obj{\C}\), and \(f : Y \times X \rightarrow A\) there exists a unique left iteration preserving \(\ls{f} : KY \times X \rightarrow A\) such that
|
||||||
% https://q.uiver.app/#q=WzAsMyxbMCwwLCJYIFxcdGltZXMgWSJdLFsyLDAsIkEiXSxbMCwyLCJLWCBcXHRpbWVzIFkiXSxbMCwxLCJmIl0sWzAsMiwiXFxldGFcXHRpbWVzIGlkIiwyXSxbMiwxLCJcXGxze2Z9IiwyXV0=
|
% https://q.uiver.app/#q=WzAsMyxbMCwwLCJYIFxcdGltZXMgWSJdLFsyLDAsIkEiXSxbMCwyLCJLWCBcXHRpbWVzIFkiXSxbMCwxLCJmIl0sWzAsMiwiXFxldGFcXHRpbWVzIGlkIiwyXSxbMiwxLCJcXGxze2Z9IiwyXV0=
|
||||||
\[\begin{tikzcd}[ampersand replacement=\&]
|
\[\begin{tikzcd}[ampersand replacement=\&]
|
||||||
{X \times Y} \&\& A \\
|
{X \times Y} \&\& A \\
|
||||||
|
@ -315,20 +303,20 @@ A symmetrical variant of the previous definition is sometimes useful.
|
||||||
\end{definition}
|
\end{definition}
|
||||||
|
|
||||||
\begin{lemma}
|
\begin{lemma}
|
||||||
Definitions \ref{def:rightstablefreeelgot} and \ref{def:leftstablefreeelgot} are equivalent in the sense that they imply each other.
|
Definitions~\ref{def:rightstablefreeelgot} and~\ref{def:leftstablefreeelgot} are equivalent in the sense that they imply each other.
|
||||||
\end{lemma}
|
\end{lemma}
|
||||||
\begin{proof} Let $(KY, (-)^{\#_y})$ be a left stable free Elgot algebra on $Y \in \obj{\C}$. Furthermore, let $A \in \elgotalgs{\C}, X \in \obj{\C}, f : Y \times X \rightarrow A$.
|
\begin{proof} Let \((KY, (-)^{\#_y})\) be a left stable free Elgot algebra on \(Y \in \obj{\C}\). Furthermore, let \(A \in \elgotalgs{\C}, X \in \obj{\C}, f : Y \times X \rightarrow A\).
|
||||||
|
|
||||||
We take $\rs{f} := \ls{f \circ swap} \circ swap$, which is indeed right iteration preserving, since
|
We take \(\rs{f} := \ls{f \circ swap} \circ swap\), which is indeed right iteration preserving, since
|
||||||
\begin{alignat*}{1}
|
\begin{alignat*}{1}
|
||||||
&\rs{f} \circ (id \times h^{\#_y})
|
& \rs{f} \circ (id \times h^{\#_y})
|
||||||
\\=\;&\ls{f \circ swap} \circ swap \circ (id \times h^{\#_y})
|
\\=\;&\ls{f \circ swap} \circ swap \circ (id \times h^{\#_y})
|
||||||
\\=\;&\ls{f \circ swap} \circ (h^{\#_y} \times id) \circ swap
|
\\=\;&\ls{f \circ swap} \circ (h^{\#_y} \times id) \circ swap
|
||||||
\\=\;&((\ls{f \circ swap} + id) \circ dstr \circ (id \times h))^{\#_a} \circ swap
|
\\=\;&((\ls{f \circ swap} + id) \circ dstr \circ (id \times h))^{\#_a} \circ swap
|
||||||
\\=\;&(((\ls{f \circ swap} \circ swap) + id) \circ dstl \circ (id \times h))^{\#_a}\tag{\ref{law:uniformity}}
|
\\=\;&(((\ls{f \circ swap} \circ swap) + id) \circ dstl \circ (id \times h))^{\#_a}\tag{\ref{law:uniformity}}
|
||||||
\\=\;&(((\rs{f} + id) \circ dstl \circ (id \times h))^{\#_a},
|
\\=\;&(((\rs{f} + id) \circ dstl \circ (id \times h))^{\#_a},
|
||||||
\end{alignat*}
|
\end{alignat*}
|
||||||
for any $Z \in \obj{\C}, h : Z \rightarrow KY + Z$.
|
for any \(Z \in \obj{\C}, h : Z \rightarrow KY + Z\).
|
||||||
|
|
||||||
% Where the application of \ref{law:uniformity} is justified by
|
% Where the application of \ref{law:uniformity} is justified by
|
||||||
% \begin{alignat*}{1}
|
% \begin{alignat*}{1}
|
||||||
|
@ -341,29 +329,29 @@ A symmetrical variant of the previous definition is sometimes useful.
|
||||||
|
|
||||||
The requisite diagram commutes, since
|
The requisite diagram commutes, since
|
||||||
\begin{alignat*}{1}
|
\begin{alignat*}{1}
|
||||||
&\rs{f} \circ (id \times \eta)
|
& \rs{f} \circ (id \times \eta)
|
||||||
\\=\;&\ls{f \circ swap} \circ swap \circ (id \times \eta)
|
\\=\;&\ls{f \circ swap} \circ swap \circ (id \times \eta)
|
||||||
\\=\;&\ls{f \circ swap} \circ (\eta \times id) \circ swap
|
\\=\;&\ls{f \circ swap} \circ (\eta \times id) \circ swap
|
||||||
\\=\;&f \circ swap \circ swap
|
\\=\;&f \circ swap \circ swap
|
||||||
\\=\;&f.
|
\\=\;&f.
|
||||||
\end{alignat*}
|
\end{alignat*}
|
||||||
|
|
||||||
Finally, let us check uniqueness of $\rs{f} = \ls{f \circ swap} \circ swap$. Let $g : X \times KY \rightarrow A$ be right iteration preserving with $g \circ (id \times \eta) = f$. To show that $g = \ls{f \circ swap} \circ swap$, by uniqueness of $\ls{f \circ swap}$ it suffices to show that $g \circ swap$ satisfies $g \circ swap \circ (\eta \times id) = f \circ swap$ and is left iteration preserving.
|
Finally, let us check uniqueness of \(\rs{f} = \ls{f \circ swap} \circ swap\). Let \(g : X \times KY \rightarrow A\) be right iteration preserving with \(g \circ (id \times \eta) = f\). To show that \(g = \ls{f \circ swap} \circ swap\), by uniqueness of \(\ls{f \circ swap}\) it suffices to show that \(g \circ swap\) satisfies \(g \circ swap \circ (\eta \times id) = f \circ swap\) and is left iteration preserving.
|
||||||
|
|
||||||
Indeed,
|
Indeed,
|
||||||
\begin{alignat*}{1}
|
\begin{alignat*}{1}
|
||||||
&g \circ swap \circ (\eta \times id)
|
& g \circ swap \circ (\eta \times id)
|
||||||
\\=\;&g \circ (id \times \eta) \circ swap
|
\\=\;&g \circ (id \times \eta) \circ swap
|
||||||
\\=\;&f \circ swap,
|
\\=\;&f \circ swap,
|
||||||
\end{alignat*}
|
\end{alignat*}
|
||||||
and
|
and
|
||||||
\begin{alignat*}{1}
|
\begin{alignat*}{1}
|
||||||
&g \circ swap \circ (h^{\#_y} \times id)
|
& g \circ swap \circ (h^{\#_y} \times id)
|
||||||
\\=\;&g \circ (id \times h^{\#_y}) \circ swap
|
\\=\;&g \circ (id \times h^{\#_y}) \circ swap
|
||||||
\\=\;&((g + id) \circ dstl \circ (id \times h))^{\#_a} \circ swap
|
\\=\;&((g + id) \circ dstl \circ (id \times h))^{\#_a} \circ swap
|
||||||
\\=\;&(((g \circ swap) + id) \circ dstr \circ (h \times id))^{\#_a},\tag{\ref{law:uniformity}}
|
\\=\;&(((g \circ swap) + id) \circ dstr \circ (h \times id))^{\#_a},\tag{\ref{law:uniformity}}
|
||||||
\end{alignat*}
|
\end{alignat*}
|
||||||
for any $Z \in \obj{\C}, h : Z \rightarrow KY + Z$.
|
for any \(Z \in \obj{\C}, h : Z \rightarrow KY + Z\).
|
||||||
|
|
||||||
% The application of \ref{law:uniformity} is justified by
|
% The application of \ref{law:uniformity} is justified by
|
||||||
% \begin{alignat*}{1}
|
% \begin{alignat*}{1}
|
||||||
|
@ -384,19 +372,19 @@ In a less general setting stability indeed follows automatically.
|
||||||
In a cartesian closed category every free Elgot algebra is stable.
|
In a cartesian closed category every free Elgot algebra is stable.
|
||||||
\end{theorem}
|
\end{theorem}
|
||||||
\begin{proof}
|
\begin{proof}
|
||||||
Let $\C$ be cartesian closed and let $(KX, (-)^\#, \free{(-)})$ be a free Elgot algebra on some $X \in \obj{\C}$.
|
Let \(\C\) be cartesian closed and let \((KX, (-)^\#, \free{(-)})\) be a free Elgot algebra on some \(X \in \obj{\C}\).
|
||||||
|
|
||||||
To show left stability of $KX$ we define $\ls{f} := eval \circ (\free{curry\;f} \times id)$ for any $X \in \obj{\C}, A \in \vert\elgotalgs{\C}\vert$, and $f : Y \times X \rightarrow A$.
|
To show left stability of \(KX\) we define \(\ls{f} := eval \circ (\free{curry\;f} \times id)\) for any \(X \in \obj{\C}, A \in \vert\elgotalgs{\C}\vert\), and \(f : Y \times X \rightarrow A\).
|
||||||
We will now verify that this does indeed satisfy the requisite properties, i.e.
|
We will now verify that this does indeed satisfy the requisite properties, i.e.
|
||||||
\begin{alignat*}{1}
|
\begin{alignat*}{1}
|
||||||
&eval \circ (\free{curry\;f} \times id) \circ (\eta \times id)
|
& eval \circ (\free{curry\;f} \times id) \circ (\eta \times id)
|
||||||
\\=\;&eval \circ ((\free{curry\;f} \circ \eta) \times id)
|
\\=\;&eval \circ ((\free{curry\;f} \circ \eta) \times id)
|
||||||
\\=\;&eval \circ (curry\;f) \times id)
|
\\=\;&eval \circ (curry\;f) \times id)
|
||||||
\\=\;&f
|
\\=\;&f
|
||||||
\end{alignat*}
|
\end{alignat*}
|
||||||
and for any $Z \in \obj{\C}, h : Z \rightarrow KY + Z$:
|
and for any \(Z \in \obj{\C}, h : Z \rightarrow KY + Z\):
|
||||||
\begin{alignat*}{1}
|
\begin{alignat*}{1}
|
||||||
&eval \circ (\free{curry\;f} \times id) \circ (h^{\#_a} \times id)
|
& eval \circ (\free{curry\;f} \times id) \circ (h^{\#_a} \times id)
|
||||||
\\=\;&eval \circ ((\free{curry\;f} \circ h^{\#_a}) \times id)
|
\\=\;&eval \circ ((\free{curry\;f} \circ h^{\#_a}) \times id)
|
||||||
\\=\;&eval \circ (curry(((eval + id) \circ dstr \circ (((\free{curry\;f} + id) \circ h) \times id))^{\#_b})) \times id)
|
\\=\;&eval \circ (curry(((eval + id) \circ dstr \circ (((\free{curry\;f} + id) \circ h) \times id))^{\#_b})) \times id)
|
||||||
\\=\;&((eval + id) \circ dstr \circ (((\free{curry\;f} + id) \circ h) \times id))^{\#_b}
|
\\=\;&((eval + id) \circ dstr \circ (((\free{curry\;f} + id) \circ h) \times id))^{\#_b}
|
||||||
|
@ -407,20 +395,20 @@ In a less general setting stability indeed follows automatically.
|
||||||
|
|
||||||
\unsure[inline]{Maybe prove that curry is injective in preliminaries.}
|
\unsure[inline]{Maybe prove that curry is injective in preliminaries.}
|
||||||
|
|
||||||
Lastly, we need to check uniqueness of $\ls{f}$. Let us consider a left iteration preserving morphism $g : KY \times X \rightarrow A$ that satisfies $g \circ (\eta \times id) = f$. Since $curry$ is an injective mapping it suffices to show that
|
Lastly, we need to check uniqueness of \(\ls{f}\). Let us consider a left iteration preserving morphism \(g : KY \times X \rightarrow A\) that satisfies \(g \circ (\eta \times id) = f\). Since \(curry\) is an injective mapping it suffices to show that
|
||||||
\begin{alignat*}{1}
|
\begin{alignat*}{1}
|
||||||
&curry\;\ls{f}
|
& curry\;\ls{f}
|
||||||
\\=\;&curry(eval \circ (\free{curry\;f} \times id))
|
\\=\;&curry(eval \circ (\free{curry\;f} \times id))
|
||||||
\\=\;&\free{curry\;f}
|
\\=\;&\free{curry\;f}
|
||||||
\\=\;&curry\;g.
|
\\=\;&curry\;g.
|
||||||
\end{alignat*}
|
\end{alignat*}
|
||||||
Where the last step is the only non-trivial one. Since $\free{curry\;f}$ is a unique iteration preserving morphism satisfying $\free{curry\;f} \circ \eta = curry\;f$, we are left to show that $g$ is also iteration preserving and satisfies the same property.
|
Where the last step is the only non-trivial one. Since \(\free{curry\;f}\) is a unique iteration preserving morphism satisfying \(\free{curry\;f} \circ \eta = curry\;f\), we are left to show that \(g\) is also iteration preserving and satisfies the same property.
|
||||||
|
|
||||||
\unsure[inline]{Maybe prove helper lemmas about exponentials in preliminaries, like subst, beta and eta.}
|
\unsure[inline]{Maybe prove helper lemmas about exponentials in preliminaries, like subst, beta and eta.}
|
||||||
|
|
||||||
Indeed,
|
Indeed,
|
||||||
\begin{alignat*}{1}
|
\begin{alignat*}{1}
|
||||||
&curry\;g \circ h^{\#}
|
& curry\;g \circ h^{\#}
|
||||||
\\=\;&curry\;(g \circ (h^{\#} \times id))
|
\\=\;&curry\;(g \circ (h^{\#} \times id))
|
||||||
\\=\;&curry\;(((g + id) \circ dstr \circ (h \times id))^{\#_a})
|
\\=\;&curry\;(((g + id) \circ dstr \circ (h \times id))^{\#_a})
|
||||||
\\=\;&curry\;((((eval \circ (curry\; g \times id)) + id) \circ dstr \circ (h \times id))^{\#_a})
|
\\=\;&curry\;((((eval \circ (curry\; g \times id)) + id) \circ dstr \circ (h \times id))^{\#_a})
|
||||||
|
@ -428,9 +416,9 @@ In a less general setting stability indeed follows automatically.
|
||||||
\\=\;&curry\;(((eval + id) \circ dstr \circ ((curry\;g + id) \times id) \circ (h \times id))^{\#_a})
|
\\=\;&curry\;(((eval + id) \circ dstr \circ ((curry\;g + id) \times id) \circ (h \times id))^{\#_a})
|
||||||
\\=\;&curry\;(((eval + id) \circ dstr \circ (((curry\;g + id) \circ h) \times id))^{\#_a})
|
\\=\;&curry\;(((eval + id) \circ dstr \circ (((curry\;g + id) \circ h) \times id))^{\#_a})
|
||||||
\end{alignat*}
|
\end{alignat*}
|
||||||
for any $Z \in \obj{\C}, h : Z \rightarrow KY + Z$, and
|
for any \(Z \in \obj{\C}, h : Z \rightarrow KY + Z\), and
|
||||||
\begin{alignat*}{1}
|
\begin{alignat*}{1}
|
||||||
&curry\;g \circ \eta
|
& curry\;g \circ \eta
|
||||||
\\=\;&curry(g \circ (\eta \times id))
|
\\=\;&curry(g \circ (\eta \times id))
|
||||||
\\=\;&curry\;f
|
\\=\;&curry\;f
|
||||||
\end{alignat*}
|
\end{alignat*}
|
||||||
|
@ -438,11 +426,11 @@ In a less general setting stability indeed follows automatically.
|
||||||
This completes the proof.
|
This completes the proof.
|
||||||
\end{proof}
|
\end{proof}
|
||||||
|
|
||||||
For the rest of this chapter we will assume every $KX$ to exist and be stable. Under these assumptions we show that $\mathbf{K}$ is an equational lifting monad and in fact the initial strong pre-Elgot monad.
|
For the rest of this chapter we will assume every \(KX\) to exist and be stable. Under these assumptions we show that \(\mathbf{K}\) is an equational lifting monad and in fact the initial strong pre-Elgot monad.
|
||||||
|
|
||||||
Let us first introduce a proof principle similar to \autoref{rem:coinduction}.
|
Let us first introduce a proof principle similar to \autoref{rem:coinduction}.
|
||||||
\begin{remark}[Proof by right-stability]~\label{rem:proofbystability}
|
\begin{remark}[Proof by right-stability]~\label{rem:proofbystability}
|
||||||
Given two morphisms $g, h : X \times KY \rightarrow A$ where $X, Y \in \obj{\C}, A \in \obj{\elgotalgs{\C}}$. To show that $g = h$, it suffices to show that $g$ and $h$ are right iteration preserving and there exists a morphism $f : X \times Y \rightarrow A$ such that
|
Given two morphisms \(g, h : X \times KY \rightarrow A\) where \(X, Y \in \obj{\C}, A \in \obj{\elgotalgs{\C}}\). To show that \(g = h\), it suffices to show that \(g\) and \(h\) are right iteration preserving and there exists a morphism \(f : X \times Y \rightarrow A\) such that
|
||||||
% https://q.uiver.app/#q=WzAsMyxbMCwwLCJYIFxcdGltZXMgS1kiXSxbMiwwLCJBIl0sWzAsMiwiWCBcXHRpbWVzIFkiXSxbMCwxLCJnIiwwLHsib2Zmc2V0IjotMX1dLFswLDEsImgiLDIseyJvZmZzZXQiOjF9XSxbMiwxLCJmIiwyXSxbMiwwLCJpZCBcXHRpbWVzIFxcZXRhIl1d
|
% https://q.uiver.app/#q=WzAsMyxbMCwwLCJYIFxcdGltZXMgS1kiXSxbMiwwLCJBIl0sWzAsMiwiWCBcXHRpbWVzIFkiXSxbMCwxLCJnIiwwLHsib2Zmc2V0IjotMX1dLFswLDEsImgiLDIseyJvZmZzZXQiOjF9XSxbMiwxLCJmIiwyXSxbMiwwLCJpZCBcXHRpbWVzIFxcZXRhIl1d
|
||||||
\[\begin{tikzcd}[ampersand replacement=\&]
|
\[\begin{tikzcd}[ampersand replacement=\&]
|
||||||
{X \times KY} \&\& A \\
|
{X \times KY} \&\& A \\
|
||||||
|
@ -457,7 +445,7 @@ Let us first introduce a proof principle similar to \autoref{rem:coinduction}.
|
||||||
\end{remark}
|
\end{remark}
|
||||||
Of course there is also a symmetric version of this.
|
Of course there is also a symmetric version of this.
|
||||||
\begin{remark}[Proof by left-stability]~\label{rem:proofbyleftstability}
|
\begin{remark}[Proof by left-stability]~\label{rem:proofbyleftstability}
|
||||||
Given two morphisms $g, h : KX \times Y \rightarrow A$ where $X, Y \in \obj{\C}, A \in \obj{\elgotalgs{\C}}$. To show that $g = h$, it suffices to show that $g$ and $h$ are left iteration preserving and there exists a morphism $f : X \times Y \rightarrow A$ such that
|
Given two morphisms \(g, h : KX \times Y \rightarrow A\) where \(X, Y \in \obj{\C}, A \in \obj{\elgotalgs{\C}}\). To show that \(g = h\), it suffices to show that \(g\) and \(h\) are left iteration preserving and there exists a morphism \(f : X \times Y \rightarrow A\) such that
|
||||||
% https://q.uiver.app/#q=WzAsMyxbMCwwLCJLWCBcXHRpbWVzIFkiXSxbMiwwLCJBIl0sWzAsMiwiWCBcXHRpbWVzIFkiXSxbMCwxLCJnIiwwLHsib2Zmc2V0IjotMX1dLFswLDEsImgiLDIseyJvZmZzZXQiOjF9XSxbMiwxLCJmIiwyXSxbMiwwLCJcXGV0YSBcXHRpbWVzIGlkIl1d
|
% https://q.uiver.app/#q=WzAsMyxbMCwwLCJLWCBcXHRpbWVzIFkiXSxbMiwwLCJBIl0sWzAsMiwiWCBcXHRpbWVzIFkiXSxbMCwxLCJnIiwwLHsib2Zmc2V0IjotMX1dLFswLDEsImgiLDIseyJvZmZzZXQiOjF9XSxbMiwxLCJmIiwyXSxbMiwwLCJcXGV0YSBcXHRpbWVzIGlkIl1d
|
||||||
\[\begin{tikzcd}[ampersand replacement=\&]
|
\[\begin{tikzcd}[ampersand replacement=\&]
|
||||||
{KX \times Y} \&\& A \\
|
{KX \times Y} \&\& A \\
|
||||||
|
@ -471,15 +459,15 @@ Of course there is also a symmetric version of this.
|
||||||
commutes.
|
commutes.
|
||||||
\end{remark}
|
\end{remark}
|
||||||
|
|
||||||
\begin{theorem}
|
\begin{lemma}\label{lem:Kstrong}
|
||||||
$\mathbf{K}$ is a strong monad.
|
\(\mathbf{K}\) is a strong monad.
|
||||||
\end{theorem}
|
\end{lemma}
|
||||||
\begin{proof}
|
\begin{proof}
|
||||||
We define strength as $\tau = \rs{(\eta : X \times Y \rightarrow K(X \times Y))} : X \times KY \rightarrow K(X \times Y)$. Note that $\tau$ is right iteration preserving by definition and $\tau \circ (id \times \eta) = \eta$.
|
We define strength as \(\tau = \rs{(\eta : X \times Y \rightarrow K(X \times Y))} : X \times KY \rightarrow K(X \times Y)\). Note that \(\tau\) is right iteration preserving by definition and \(\tau \circ (id \times \eta) = \eta\).
|
||||||
|
|
||||||
Most of the requisite proofs will be done by right-stability, i.e.\ to prove an identity we need to give a unifying morphism such that the requisite diagram commutes, and we need to show that both sides of the identity are right iteration preserving. The proofs of commutativity follow by easy rewriting and are thus deferred to the formalization. The proofs of right iteration preservation follow in most cases instantly since the morphisms are composed of (right) iteration preserving morphisms but in non-trivial cases we will give the full proof.
|
Most of the requisite proofs will be done by right-stability, i.e.\ to prove an identity we need to give a unifying morphism such that the requisite diagram commutes, and we need to show that both sides of the identity are right iteration preserving. The proofs of commutativity follow by easy rewriting and are thus deferred to the formalization. The proofs of right iteration preservation follow in most cases instantly since the morphisms are composed of (right) iteration preserving morphisms but in non-trivial cases we will give the full proof.
|
||||||
|
|
||||||
Naturality of $\tau$ follows by:
|
Naturality of \(\tau \) follows by:
|
||||||
% https://q.uiver.app/#q=WzAsNSxbMSwwLCJBIFxcdGltZXMgS0IiXSxbMCwzLCJBIFxcdGltZXMgQiJdLFsxLDIsIksoQSBcXHRpbWVzIEIpIl0sWzMsMiwiSyhYIFxcdGltZXMgWSkiXSxbMywwLCJYIFxcdGltZXMgS1kiXSxbMSwwLCJpZCBcXHRpbWVzIFxcZXRhIiwwLHsiY3VydmUiOi0yfV0sWzAsMiwiXFx0YXUiLDJdLFsyLDMsIksoZlxcdGltZXMgZykiLDJdLFswLDQsImYgXFx0aW1lcyBLZyJdLFs0LDMsIlxcdGF1Il0sWzEsMywiXFxldGEgXFxjaXJjIChmIFxcdGltZXMgZykiLDIseyJjdXJ2ZSI6Mn1dXQ==
|
% https://q.uiver.app/#q=WzAsNSxbMSwwLCJBIFxcdGltZXMgS0IiXSxbMCwzLCJBIFxcdGltZXMgQiJdLFsxLDIsIksoQSBcXHRpbWVzIEIpIl0sWzMsMiwiSyhYIFxcdGltZXMgWSkiXSxbMywwLCJYIFxcdGltZXMgS1kiXSxbMSwwLCJpZCBcXHRpbWVzIFxcZXRhIiwwLHsiY3VydmUiOi0yfV0sWzAsMiwiXFx0YXUiLDJdLFsyLDMsIksoZlxcdGltZXMgZykiLDJdLFswLDQsImYgXFx0aW1lcyBLZyJdLFs0LDMsIlxcdGF1Il0sWzEsMywiXFxldGEgXFxjaXJjIChmIFxcdGltZXMgZykiLDIseyJjdXJ2ZSI6Mn1dXQ==
|
||||||
\[\begin{tikzcd}
|
\[\begin{tikzcd}
|
||||||
& {A \times KB} && {X \times KY} \\
|
& {A \times KB} && {X \times KY} \\
|
||||||
|
@ -494,9 +482,9 @@ Of course there is also a symmetric version of this.
|
||||||
\arrow["{\eta \circ (f \times g)}"', curve={height=12pt}, from=4-1, to=3-4]
|
\arrow["{\eta \circ (f \times g)}"', curve={height=12pt}, from=4-1, to=3-4]
|
||||||
\end{tikzcd}\]
|
\end{tikzcd}\]
|
||||||
|
|
||||||
Notably, $\tau \circ (f \times Kg)$ is right iteration preserving, since for any $Z : \obj{\C}$ and $h : Z \rightarrow KY + Z$:
|
Notably, \(\tau \circ (f \times Kg)\) is right iteration preserving, since for any \(Z : \obj{\C}\) and \(h : Z \rightarrow KY + Z\):
|
||||||
\begin{alignat*}{1}
|
\begin{alignat*}{1}
|
||||||
&\tau \circ (f \times Kg) \circ (id \times h^\#)
|
& \tau \circ (f \times Kg) \circ (id \times h^\#)
|
||||||
\\=\;&\tau \circ (f \times ((Kg + id) \circ h)^\#)
|
\\=\;&\tau \circ (f \times ((Kg + id) \circ h)^\#)
|
||||||
\\=\;&((\tau + id) \circ dstl \circ (id \times ((Kg + id) \circ h)))^\# \circ (f \times id)
|
\\=\;&((\tau + id) \circ dstl \circ (id \times ((Kg + id) \circ h)))^\# \circ (f \times id)
|
||||||
\\=\;&(((\tau \circ (f \times Kg)) + id) \circ dstl \circ (id \times h))^\#.\tag{\ref{law:uniformity}}
|
\\=\;&(((\tau \circ (f \times Kg)) + id) \circ dstl \circ (id \times h))^\#.\tag{\ref{law:uniformity}}
|
||||||
|
@ -508,7 +496,7 @@ Of course there is also a symmetric version of this.
|
||||||
% \\=\;&(\tau + id) \circ dstl \circ (id \times ((Kg + id) \circ h)) \circ (f \times id)
|
% \\=\;&(\tau + id) \circ dstl \circ (id \times ((Kg + id) \circ h)) \circ (f \times id)
|
||||||
% \end{alignat*}
|
% \end{alignat*}
|
||||||
|
|
||||||
% Both sides of the identity are right iteration preserving, since for any $Z \in \obj{\C}$ and $h : Z \rightarrow KY + Z$:
|
% Both sides of the identity are right iteration preserving, since for any \(Z \in \obj{\C}\) and \(h : Z \rightarrow KY + Z\):
|
||||||
% \begin{alignat*}{1}
|
% \begin{alignat*}{1}
|
||||||
% &K(f \times g) \circ \tau \circ (id \times h^\#)
|
% &K(f \times g) \circ \tau \circ (id \times h^\#)
|
||||||
% \\=\;&K(f \times g) \circ ((\tau + id) \circ dstl \circ (id \times h))^\#
|
% \\=\;&K(f \times g) \circ ((\tau + id) \circ dstl \circ (id \times h))^\#
|
||||||
|
@ -524,9 +512,10 @@ Of course there is also a symmetric version of this.
|
||||||
Let us now check the strength laws.
|
Let us now check the strength laws.
|
||||||
|
|
||||||
\begin{itemize}
|
\begin{itemize}
|
||||||
\item[\ref{S1}] Note that for $K\pi_2 \circ \tau = \pi_2$ holds more generally for any $X, Y \in \obj{\C}$, instead of just for $X = 1$:
|
\item[\ref{S1}] Note that for \(K\pi_2 \circ \tau = \pi_2\) holds more generally for any \(X, Y \in \obj{\C}\), instead of just for \(X = 1\):
|
||||||
% https://q.uiver.app/#q=WzAsNCxbMCwwLCJYIFxcdGltZXMgS1kiXSxbMiwwLCJLKFhcXHRpbWVzIFkpIl0sWzIsMiwiS1kiXSxbMCwyLCJYIFxcdGltZXMgWSJdLFswLDEsIlxcdGF1Il0sWzEsMiwiS1xccGlfMiJdLFswLDIsIlxccGlfMiIsMl0sWzMsMCwiaWQgXFx0aW1lcyBcXGV0YSIsMl0sWzMsMiwiXFxldGEgXFxjaXJjIFxccGlfMiIsMl1d
|
% https://q.uiver.app/#q=WzAsNCxbMCwwLCJYIFxcdGltZXMgS1kiXSxbMiwwLCJLKFhcXHRpbWVzIFkpIl0sWzIsMiwiS1kiXSxbMCwyLCJYIFxcdGltZXMgWSJdLFswLDEsIlxcdGF1Il0sWzEsMiwiS1xccGlfMiJdLFswLDIsIlxccGlfMiIsMl0sWzMsMCwiaWQgXFx0aW1lcyBcXGV0YSIsMl0sWzMsMiwiXFxldGEgXFxjaXJjIFxccGlfMiIsMl1d
|
||||||
\[\begin{tikzcd}
|
\[
|
||||||
|
\begin{tikzcd}
|
||||||
{X \times KY} && {K(X\times Y)} \\
|
{X \times KY} && {K(X\times Y)} \\
|
||||||
\\
|
\\
|
||||||
{X \times Y} && KY
|
{X \times Y} && KY
|
||||||
|
@ -535,12 +524,14 @@ Of course there is also a symmetric version of this.
|
||||||
\arrow["{\pi_2}"', from=1-1, to=3-3]
|
\arrow["{\pi_2}"', from=1-1, to=3-3]
|
||||||
\arrow["{id \times \eta}"', from=3-1, to=1-1]
|
\arrow["{id \times \eta}"', from=3-1, to=1-1]
|
||||||
\arrow["{\eta \circ \pi_2}"', from=3-1, to=3-3]
|
\arrow["{\eta \circ \pi_2}"', from=3-1, to=3-3]
|
||||||
\end{tikzcd}\]
|
\end{tikzcd}
|
||||||
|
\]
|
||||||
|
|
||||||
\item[\ref{S2}] As already mentioned, $\tau \circ (id \times \eta) = \eta$ follows by definition of $\tau$.
|
\item[\ref{S2}] As already mentioned, \(\tau \circ (id \times \eta) = \eta\) follows by definition of \(\tau\).
|
||||||
\item[\ref{S3}] To show that $\tau \circ (id \times \mu) = \tau^* \circ \tau$, consider:
|
\item[\ref{S3}] To show that \(\tau \circ (id \times \mu) = \tau^* \circ \tau\), consider:
|
||||||
% https://q.uiver.app/#q=WzAsNSxbMSwwLCJYIFxcdGltZXMgS0tZIl0sWzMsMCwiWCBcXHRpbWVzIEtZIl0sWzMsMiwiSyhYXFx0aW1lcyBZKSJdLFsxLDIsIksoWCBcXHRpbWVzIEtZKSJdLFswLDMsIlggXFx0aW1lcyBLWSJdLFswLDEsImlkIFxcdGltZXMgXFxtdSIsMl0sWzEsMiwiXFx0YXUiLDJdLFswLDMsIlxcdGF1Il0sWzMsMiwiXFx0YXVeKiJdLFs0LDAsImlkIFxcdGltZXMgXFxldGEiLDAseyJjdXJ2ZSI6LTJ9XSxbNCwyLCJcXHRhdSIsMCx7ImN1cnZlIjoyfV1d
|
% https://q.uiver.app/#q=WzAsNSxbMSwwLCJYIFxcdGltZXMgS0tZIl0sWzMsMCwiWCBcXHRpbWVzIEtZIl0sWzMsMiwiSyhYXFx0aW1lcyBZKSJdLFsxLDIsIksoWCBcXHRpbWVzIEtZKSJdLFswLDMsIlggXFx0aW1lcyBLWSJdLFswLDEsImlkIFxcdGltZXMgXFxtdSIsMl0sWzEsMiwiXFx0YXUiLDJdLFswLDMsIlxcdGF1Il0sWzMsMiwiXFx0YXVeKiJdLFs0LDAsImlkIFxcdGltZXMgXFxldGEiLDAseyJjdXJ2ZSI6LTJ9XSxbNCwyLCJcXHRhdSIsMCx7ImN1cnZlIjoyfV1d
|
||||||
\[\begin{tikzcd}
|
\[
|
||||||
|
\begin{tikzcd}
|
||||||
& {X \times KKY} && {X \times KY} \\
|
& {X \times KKY} && {X \times KY} \\
|
||||||
\\
|
\\
|
||||||
& {K(X \times KY)} && {K(X\times Y)} \\
|
& {K(X \times KY)} && {K(X\times Y)} \\
|
||||||
|
@ -551,10 +542,12 @@ Of course there is also a symmetric version of this.
|
||||||
\arrow["{\tau^*}", from=3-2, to=3-4]
|
\arrow["{\tau^*}", from=3-2, to=3-4]
|
||||||
\arrow["{id \times \eta}", curve={height=-12pt}, from=4-1, to=1-2]
|
\arrow["{id \times \eta}", curve={height=-12pt}, from=4-1, to=1-2]
|
||||||
\arrow["\tau", curve={height=12pt}, from=4-1, to=3-4]
|
\arrow["\tau", curve={height=12pt}, from=4-1, to=3-4]
|
||||||
\end{tikzcd}\]
|
\end{tikzcd}
|
||||||
|
\]
|
||||||
\item[\ref{S4}] Lastly, consider the following diagram:
|
\item[\ref{S4}] Lastly, consider the following diagram:
|
||||||
% https://q.uiver.app/#q=WzAsNixbMSwwLCIoWCBcXHRpbWVzIFkpIFxcdGltZXMgS1oiXSxbMSwyLCJYIFxcdGltZXMgWSBcXHRpbWVzIEtZIl0sWzMsMCwiSygoWCBcXHRpbWVzIFkpIFxcdGltZXMgWikiXSxbMywyLCJLKFggXFx0aW1lcyBZIFxcdGltZXMgWikiXSxbMiwyLCJYIFxcdGltZXMgSyhZIFxcdGltZXMgWikiXSxbMCwzLCIoWCBcXHRpbWVzIFkpIFxcdGltZXMgWiJdLFswLDEsIlxcYWxwaGEiXSxbMiwzLCJLXFxhbHBoYSJdLFswLDIsIlxcdGF1Il0sWzEsNCwiaWQgXFx0aW1lc1xcdGF1Il0sWzQsMywiXFx0YXUiXSxbNSwwLCJpZCBcXHRpbWVzIFxcZXRhIiwwLHsiY3VydmUiOi0yfV0sWzUsMywiXFxldGEgXFxjaXJjIFxcYWxwaGEiLDIseyJjdXJ2ZSI6Mn1dXQ==
|
% https://q.uiver.app/#q=WzAsNixbMSwwLCIoWCBcXHRpbWVzIFkpIFxcdGltZXMgS1oiXSxbMSwyLCJYIFxcdGltZXMgWSBcXHRpbWVzIEtZIl0sWzMsMCwiSygoWCBcXHRpbWVzIFkpIFxcdGltZXMgWikiXSxbMywyLCJLKFggXFx0aW1lcyBZIFxcdGltZXMgWikiXSxbMiwyLCJYIFxcdGltZXMgSyhZIFxcdGltZXMgWikiXSxbMCwzLCIoWCBcXHRpbWVzIFkpIFxcdGltZXMgWiJdLFswLDEsIlxcYWxwaGEiXSxbMiwzLCJLXFxhbHBoYSJdLFswLDIsIlxcdGF1Il0sWzEsNCwiaWQgXFx0aW1lc1xcdGF1Il0sWzQsMywiXFx0YXUiXSxbNSwwLCJpZCBcXHRpbWVzIFxcZXRhIiwwLHsiY3VydmUiOi0yfV0sWzUsMywiXFxldGEgXFxjaXJjIFxcYWxwaGEiLDIseyJjdXJ2ZSI6Mn1dXQ==
|
||||||
\[\begin{tikzcd}
|
\[
|
||||||
|
\begin{tikzcd}
|
||||||
& {(X \times Y) \times KZ} && {K((X \times Y) \times Z)} \\
|
& {(X \times Y) \times KZ} && {K((X \times Y) \times Z)} \\
|
||||||
\\
|
\\
|
||||||
& {X \times Y \times KY} & {X \times K(Y \times Z)} & {K(X \times Y \times Z)} \\
|
& {X \times Y \times KY} & {X \times K(Y \times Z)} & {K(X \times Y \times Z)} \\
|
||||||
|
@ -566,11 +559,12 @@ Of course there is also a symmetric version of this.
|
||||||
\arrow["\tau", from=3-3, to=3-4]
|
\arrow["\tau", from=3-3, to=3-4]
|
||||||
\arrow["{id \times \eta}", curve={height=-12pt}, from=4-1, to=1-2]
|
\arrow["{id \times \eta}", curve={height=-12pt}, from=4-1, to=1-2]
|
||||||
\arrow["{\eta \circ \alpha}"', curve={height=12pt}, from=4-1, to=3-4]
|
\arrow["{\eta \circ \alpha}"', curve={height=12pt}, from=4-1, to=3-4]
|
||||||
\end{tikzcd}\]
|
\end{tikzcd}
|
||||||
|
\]
|
||||||
|
|
||||||
where $\tau \circ (id \times \tau) \circ \alpha$ is right iteration preserving, since for any $Z : \obj{\C}$ and $h : Z \rightarrow KX + Z$:
|
where \(\tau \circ (id \times \tau) \circ \alpha \) is right iteration preserving, since for any \(Z : \obj{\C}\) and \(h : Z \rightarrow KX + Z\):
|
||||||
\begin{alignat*}{1}
|
\begin{alignat*}{1}
|
||||||
&\tau \circ (id \times \tau) \circ \alpha \circ (id \times h^\#)
|
& \tau \circ (id \times \tau) \circ \alpha \circ (id \times h^\#)
|
||||||
\\=\;&\tau \circ \langle \pi_1 \circ \pi_1 , \tau \circ \langle \pi_2 \circ \pi_1 , \pi_2 \rangle \rangle \circ (id \times h^\#)
|
\\=\;&\tau \circ \langle \pi_1 \circ \pi_1 , \tau \circ \langle \pi_2 \circ \pi_1 , \pi_2 \rangle \rangle \circ (id \times h^\#)
|
||||||
\\=\;&\tau \circ \langle \pi_1 \circ \pi_1 , \tau \circ \langle \pi_2 \circ \pi_1 , h^\# \circ \pi_2 \rangle \rangle
|
\\=\;&\tau \circ \langle \pi_1 \circ \pi_1 , \tau \circ \langle \pi_2 \circ \pi_1 , h^\# \circ \pi_2 \rangle \rangle
|
||||||
\\=\;&\tau \circ \langle \pi_1 \circ \pi_1 , \tau \circ (id \times h^\#) \circ \langle \pi_2 \circ \pi_1 , \pi_2 \rangle \rangle
|
\\=\;&\tau \circ \langle \pi_1 \circ \pi_1 , \tau \circ (id \times h^\#) \circ \langle \pi_2 \circ \pi_1 , \pi_2 \rangle \rangle
|
||||||
|
@ -582,28 +576,28 @@ Of course there is also a symmetric version of this.
|
||||||
\end{itemize}
|
\end{itemize}
|
||||||
\end{proof}
|
\end{proof}
|
||||||
|
|
||||||
As we did when proving commutativity of $\mathbf{D}$, let us record some facts about $\tau$ and the induced $\sigma$, before proving commutativity of $\mathbf{K}$.
|
As we did when proving commutativity of \(\mathbf{D}\), let us record some facts about \(\tau \) and the induced \(\sigma \), before proving commutativity of \(\mathbf{K}\).
|
||||||
|
|
||||||
\begin{corollary}
|
\begin{corollary}
|
||||||
$\sigma$ is left iteration preserving and satisfies $\sigma \circ (\eta \times id) = \eta$ and the following properties of $\tau$ and $\sigma$ hold.
|
\(\sigma \) is left iteration preserving and satisfies \(\sigma \circ (\eta \times id) = \eta \) and the following properties of \(\tau \) and \(\sigma \) hold.
|
||||||
\begin{alignat*}{2}
|
\begin{alignat*}{2}
|
||||||
&\tau \circ (f^* \times g^*) &&= (\tau \circ (id \times g))^* \circ \tau \circ (f^* \times id)\tag{$\tau_1$}\label{Ktau1}
|
& \tau \circ (f^* \times g^*) & & = (\tau \circ {(id \times g))}^* \circ \tau \circ (f^* \times id)\tag{\(\tau_1\)}\label{Ktau1}
|
||||||
\\&\sigma \circ (f^* \times g^*) &&= (\sigma \circ (f \times id))^* \circ \sigma \circ (id \times g^*)\tag{$\sigma_1$}\label{Ksigma1}
|
\\&\sigma \circ (f^* \times g^*) &&= (\sigma \circ {(f \times id))}^* \circ \sigma \circ (id \times g^*)\tag{\(\sigma_1\)}\label{Ksigma1}
|
||||||
\end{alignat*}
|
\end{alignat*}
|
||||||
\end{corollary}
|
\end{corollary}
|
||||||
\begin{proof}
|
\begin{proof}
|
||||||
Note that the first part of the proof amounts to showing that $\sigma = \ls{\eta}$ using uniqueness of $\ls{\eta}$. Indeed,
|
Note that the first part of the proof amounts to showing that \(\sigma = \ls{\eta}\) using uniqueness of \(\ls{\eta}\). Indeed,
|
||||||
\begin{alignat*}{1}
|
\begin{alignat*}{1}
|
||||||
&\sigma \circ (\eta \times id)
|
& \sigma \circ (\eta \times id)
|
||||||
\\=\;&Kswap \circ \tau \circ swap \circ (\eta \times id)
|
\\=\;&Kswap \circ \tau \circ swap \circ (\eta \times id)
|
||||||
\\=\;&Kswap \circ \tau \circ (id \times \eta) \circ swap
|
\\=\;&Kswap \circ \tau \circ (id \times \eta) \circ swap
|
||||||
\\=\;&Kswap \circ \eta \circ swap
|
\\=\;&Kswap \circ \eta \circ swap
|
||||||
\\=\;&\eta \circ swap \circ swap
|
\\=\;&\eta \circ swap \circ swap
|
||||||
\\=\;&\eta
|
\\=\;&\eta
|
||||||
\end{alignat*}
|
\end{alignat*}
|
||||||
and for any $h : Z \rightarrow KX + Z$
|
and for any \(h : Z \rightarrow KX + Z\)
|
||||||
\begin{alignat*}{1}
|
\begin{alignat*}{1}
|
||||||
&\sigma \circ (h^\# \times id)
|
& \sigma \circ (h^\# \times id)
|
||||||
\\=\;&Kswap \circ \tau \circ swap \circ (h^\# \times id)
|
\\=\;&Kswap \circ \tau \circ swap \circ (h^\# \times id)
|
||||||
\\=\;&Kswap \circ \tau \circ (id \times h^\#) \circ swap
|
\\=\;&Kswap \circ \tau \circ (id \times h^\#) \circ swap
|
||||||
\\=\;&Kswap \circ ((\tau + id) \circ dstl \circ (id \times h))^\# \circ swap
|
\\=\;&Kswap \circ ((\tau + id) \circ dstl \circ (id \times h))^\# \circ swap
|
||||||
|
@ -611,11 +605,11 @@ As we did when proving commutativity of $\mathbf{D}$, let us record some facts a
|
||||||
\\=\;&((\sigma + id) \circ dstr \circ (h \times id))^\#.\tag{\ref{law:uniformity}}
|
\\=\;&((\sigma + id) \circ dstr \circ (h \times id))^\#.\tag{\ref{law:uniformity}}
|
||||||
\end{alignat*}
|
\end{alignat*}
|
||||||
|
|
||||||
Let us now proceed with the properties of $\tau$ and $\sigma$.
|
Let us now proceed with the properties of \(\tau \) and \(\sigma \).
|
||||||
\begin{itemize}
|
\begin{itemize}
|
||||||
\item[(\ref{Ktau1})]
|
\item[(\ref{Ktau1})]
|
||||||
\begin{alignat*}{1}
|
\begin{alignat*}{1}
|
||||||
&(\tau \circ (id \times g))^* \circ \tau \circ (f^* \times id)
|
& (\tau \circ {(id \times g))}^* \circ \tau \circ (f^* \times id)
|
||||||
\\=\;&\tau^* \circ K(id \times g) \circ \tau \circ (f^* \times id)
|
\\=\;&\tau^* \circ K(id \times g) \circ \tau \circ (f^* \times id)
|
||||||
\\=\;&\tau^* \circ \tau \circ (id \times Kg) \circ (f^* \times id)
|
\\=\;&\tau^* \circ \tau \circ (id \times Kg) \circ (f^* \times id)
|
||||||
\\=\;&\tau \circ (id \times \mu) \circ (id \times Kg) \circ (f^* \times id)
|
\\=\;&\tau \circ (id \times \mu) \circ (id \times Kg) \circ (f^* \times id)
|
||||||
|
@ -625,7 +619,7 @@ As we did when proving commutativity of $\mathbf{D}$, let us record some facts a
|
||||||
|
|
||||||
\item[(\ref{Ksigma1})]
|
\item[(\ref{Ksigma1})]
|
||||||
\begin{alignat*}{1}
|
\begin{alignat*}{1}
|
||||||
&(\sigma \circ (f \times id))^* \circ \sigma \circ (id \times g^*)
|
& (\sigma \circ {(f \times id))}^* \circ \sigma \circ (id \times g^*)
|
||||||
\\=\;&\sigma^* \circ K(f \times id) \circ \sigma \circ (id \times g^*)
|
\\=\;&\sigma^* \circ K(f \times id) \circ \sigma \circ (id \times g^*)
|
||||||
\\=\;&\sigma^* \circ \sigma \circ (Kf \times id) \circ (id \times g^*)
|
\\=\;&\sigma^* \circ \sigma \circ (Kf \times id) \circ (id \times g^*)
|
||||||
\\=\;&\sigma \circ (\mu \times id) \circ (Kf \times id) \circ (id \times g^*)
|
\\=\;&\sigma \circ (\mu \times id) \circ (Kf \times id) \circ (id \times g^*)
|
||||||
|
@ -637,61 +631,61 @@ As we did when proving commutativity of $\mathbf{D}$, let us record some facts a
|
||||||
|
|
||||||
The following Lemma is central to the proof of commutativity.
|
The following Lemma is central to the proof of commutativity.
|
||||||
|
|
||||||
\begin{lemma}\label{lem:KCommKey} Given $f : X \rightarrow KY + Z, g : Z \rightarrow KA + Z$,
|
\begin{lemma}\label{lem:KCommKey} Given \(f : X \rightarrow KY + Z, g : Z \rightarrow KA + Z\),
|
||||||
\[\tau^* \circ \sigma \circ (((\eta + id) \circ f)^\# \times ((\eta + id) \circ g)^\#) = \sigma^* \circ \tau \circ (((\eta + id) \circ f)^\# \times ((\eta + id) \circ g)^\#).\]
|
\[\tau^* \circ \sigma \circ (((\eta + id) \circ f)^\# \times ((\eta + id) \circ g)^\#) = \sigma^* \circ \tau \circ (((\eta + id) \circ f)^\# \times ((\eta + id) \circ g)^\#).\]
|
||||||
\end{lemma}
|
\end{lemma}
|
||||||
\begin{proof}
|
\begin{proof}
|
||||||
Let us abbreviate $\hat{f} := (\eta + id) \circ f$ and $\hat{g} := (\eta + id) \circ g$. It suffices to find a $w : ?$ such that $\hat{f}^\# \circ \pi_1 = [ \hat{f}^\# \circ \pi_1 , \eta \circ \pi_1 ]^* \circ w^\#$ and $\hat{g}^\# \circ \pi_2 = [ \hat{g}^\# \circ \pi_2 , \eta \circ \pi_2 ]^* \circ w^\#$, then
|
Let us abbreviate \(\hat{f} := (\eta + id) \circ f\) and \(\hat{g} := (\eta + id) \circ g\). It suffices to find a \(w : ?\) such that \(\hat{f}^\# \circ \pi_1 = [ \hat{f}^\# \circ \pi_1 , \eta \circ \pi_1 ]^* \circ w^\#\) and \(\hat{g}^\# \circ \pi_2 = [ \hat{g}^\# \circ \pi_2 , \eta \circ \pi_2 ]^* \circ w^\# \), then
|
||||||
\begin{alignat*}{1}
|
\begin{alignat*}{1}
|
||||||
&\tau^* \circ \sigma \circ (\hat{f}^\# \times \hat{g}^\#)
|
& \tau^* \circ \sigma \circ (\hat{f}^\# \times \hat{g}^\#)
|
||||||
\\=\;&\tau^* \circ \sigma \circ ([ \hat{f}^\# \circ \pi_1 , \eta \circ \pi_1 ]^* \times [ \hat{g}^\# \circ \pi_2 , \eta \circ \pi_2 ]^*) \circ (w^\# \times w^\#)
|
\\=\;&\tau^* \circ \sigma \circ ([ \hat{f}^\# \circ \pi_1 , \eta \circ \pi_1 ]^* \times [ \hat{g}^\# \circ \pi_2 , \eta \circ \pi_2 ]^*) \circ (w^\# \times w^\#)
|
||||||
\\=\;&\tau^* \circ (\sigma \circ ([ \hat{f}^\# \circ \pi_1 , \eta \circ \pi_1 ] \times id))^* \circ \sigma \circ (id \times [ \hat{g}^\# \circ \pi_2 , \eta \circ \pi_2 ]^*) \circ (w^\# \times w^\#)
|
\\=\;&\tau^* \circ (\sigma \circ {([ \hat{f}^\# \circ \pi_1 , \eta \circ \pi_1 ] \times id))}^* \circ \sigma \circ (id \times [ \hat{g}^\# \circ \pi_2 , \eta \circ \pi_2 ]^*) \circ (w^\# \times w^\#)
|
||||||
\\=\;&\tau^* \circ (\sigma \circ ([ \hat{f}^\# \circ \pi_1 , \eta \circ \pi_1 ] \times id))^* \circ K(id \times [ \hat{g}^\# \circ \pi_2 , \eta \circ \pi_2 ]^*) \circ \sigma \circ (w^\# \times w^\#)
|
\\=\;&\tau^* \circ (\sigma \circ {([ \hat{f}^\# \circ \pi_1 , \eta \circ \pi_1 ] \times id))}^* \circ K(id \times [ \hat{g}^\# \circ \pi_2 , \eta \circ \pi_2 ]^*) \circ \sigma \circ (w^\# \times w^\#)
|
||||||
\\=\;&\tau^* \circ (\sigma \circ ([ \hat{f}^\# \circ \pi_1 , \eta \circ \pi_1 ] \times id))^* \circ K(id \times [ \hat{g}^\# \circ \pi_2 , \eta \circ \pi_2 ]^*) \circ Kswap \circ \tau \circ \Delta \circ w^\#
|
\\=\;&\tau^* \circ (\sigma \circ {([ \hat{f}^\# \circ \pi_1 , \eta \circ \pi_1 ] \times id))}^* \circ K(id \times [ \hat{g}^\# \circ \pi_2 , \eta \circ \pi_2 ]^*) \circ Kswap \circ \tau \circ \Delta \circ w^\#
|
||||||
\\=\;&\tau^* \circ (\sigma \circ ([ \hat{f}^\# \circ \pi_1 , \eta \circ \pi_1 ] \times id))^* \circ K(id \times [ \hat{g}^\# \circ \pi_2 , \eta \circ \pi_2 ]^*) \circ Kswap \circ K\langle \eta , id \rangle \circ w^\#\tag{\ref{thm:Klifting}}
|
\\=\;&\tau^* \circ (\sigma \circ {([ \hat{f}^\# \circ \pi_1 , \eta \circ \pi_1 ] \times id))}^* \circ K(id \times [ \hat{g}^\# \circ \pi_2 , \eta \circ \pi_2 ]^*) \circ Kswap \circ K\langle \eta , id \rangle \circ w^\#\tag{\ref{thm:Klifting}}
|
||||||
\\=\;&\tau^* \circ (\sigma \circ ([ \hat{f}^\# \circ \pi_1 , \eta \circ \pi_1 ] \times id))^* \circ K(id \times [ \hat{g}^\# \circ \pi_2 , \eta \circ \pi_2 ]^*) \circ K\langle id , \eta \rangle \circ w^\#
|
\\=\;&\tau^* \circ (\sigma \circ {([ \hat{f}^\# \circ \pi_1 , \eta \circ \pi_1 ] \times id))}^* \circ K(id \times [ \hat{g}^\# \circ \pi_2 , \eta \circ \pi_2 ]^*) \circ K\langle id , \eta \rangle \circ w^\#
|
||||||
\\=\;&\tau^* \circ (\sigma \circ ([ \hat{f}^\# \circ \pi_1 , \eta \circ \pi_1 ] \times id))^* \circ K\langle id , [ \hat{g}^\# \circ \pi_2 , \eta \circ \pi_2 ]\rangle \circ w^\#
|
\\=\;&\tau^* \circ (\sigma \circ {([ \hat{f}^\# \circ \pi_1 , \eta \circ \pi_1 ] \times id))}^* \circ K\langle id , [ \hat{g}^\# \circ \pi_2 , \eta \circ \pi_2 ]\rangle \circ w^\#
|
||||||
\\=\;&\tau^* \circ (\sigma \circ \langle[ \hat{f}^\# \circ \pi_1 , \eta \circ \pi_1 ] , [ \hat{g}^\# \circ \pi_2 , \eta \circ \pi_2 ]\rangle)^* \circ w^\#
|
\\=\;&\tau^* \circ {(\sigma \circ \langle[ \hat{f}^\# \circ \pi_1 , \eta \circ \pi_1 ] , [ \hat{g}^\# \circ \pi_2 , \eta \circ \pi_2 ]\rangle)}^* \circ w^\#
|
||||||
\\=\;&\tau^* \circ (\sigma \circ [\langle \hat{f}^\# \circ \pi_1 , \eta \circ \pi_2 \rangle , \langle \eta \circ \pi_1 , \hat{g}^\# \circ \pi_2 \rangle])^* \circ w^\#
|
\\=\;&\tau^* \circ {(\sigma \circ [\langle \hat{f}^\# \circ \pi_1 , \eta \circ \pi_2 \rangle , \langle \eta \circ \pi_1 , \hat{g}^\# \circ \pi_2 \rangle])}^* \circ w^\#
|
||||||
\\=\;&(\tau^* \circ \sigma \circ [\hat{f}^\# \times \eta , \eta \times \hat{g}^\#])^* \circ w^\#
|
\\=\;&{(\tau^* \circ \sigma \circ [\hat{f}^\# \times \eta , \eta \times \hat{g}^\#])}^* \circ w^\#
|
||||||
\\=\;&([\tau^* \circ \sigma \circ (\hat{f}^\# \times \eta) , \tau^* \circ \sigma \circ (\eta \times \hat{g}^\#)])^* \circ w^\#
|
\\=\;&([\tau^* \circ \sigma \circ (\hat{f}^\# \times \eta) , \tau^* \circ \sigma \circ {(\eta \times \hat{g}^\#)])}^* \circ w^\#
|
||||||
\\=\;&([\tau^* \circ K(id \times \eta) \circ \sigma \circ (\hat{f}^\# \times id) , \tau^* \circ \eta \circ (id \times \hat{g}^\#)])^* \circ w^\#
|
\\=\;&([\tau^* \circ K(id \times \eta) \circ \sigma \circ (\hat{f}^\# \times id) , \tau^* \circ \eta \circ {(id \times \hat{g}^\#)])}^* \circ w^\#
|
||||||
\\=\;&([\sigma \circ (\hat{f}^\# \times id) , \tau \circ (id \times \hat{g}^\#)])^* \circ w^\#,
|
\\=\;&([\sigma \circ (\hat{f}^\# \times id) , \tau \circ {(id \times \hat{g}^\#)])}^* \circ w^\#,
|
||||||
\end{alignat*}
|
\end{alignat*}
|
||||||
|
|
||||||
\todo[inline]{Full proofs or 'symmetric' enough?}
|
\todo[inline]{Full proofs or `symmetric' enough?}
|
||||||
and by a symmetric argument also
|
and by a symmetric argument also
|
||||||
\[\sigma^* \circ \tau \circ (\hat{f}^\# \times \hat{g}^\#) = ([\sigma \circ (\hat{f}^\# \times id) , \tau \circ (id \times \hat{g}^\#)])^* \circ w^\#.\]
|
\[\sigma^* \circ \tau \circ (\hat{f}^\# \times \hat{g}^\#) = ([\sigma \circ (\hat{f}^\# \times id) , \tau \circ {(id \times \hat{g}^\#)])}^* \circ w^\#.\]
|
||||||
% \begin{alignat*}{1}
|
% \begin{alignat*}{1}
|
||||||
% &\sigma^* \circ \tau \circ (\hat{f}^\# \times \hat{g}^\#)
|
% &\sigma^* \circ \tau \circ (\hat{f}^\# \times \hat{g}^\#)
|
||||||
% \\=\;&\sigma^* \circ \tau \circ ([ \hat{f}^\# \circ \pi_1 , \eta \circ \pi_1 ]^* \times [ \hat{g}^\# \circ \pi_2 , \eta \circ \pi_2 ]^*) \circ (w^\# \times w^\#)
|
% \\=\;&\sigma^* \circ \tau \circ ([ \hat{f}^\# \circ \pi_1 , \eta \circ \pi_1 ]^* \times [ \hat{g}^\# \circ \pi_2 , \eta \circ \pi_2 ]^*) \circ (w^\# \times w^\#)
|
||||||
% \\=\;&\sigma^* \circ (\tau \circ (id \times [ \hat{g}^\# \circ \pi_2 , \eta \circ \pi_2 ]))^* \circ \tau \circ ([ \hat{f}^\# \circ \pi_1 , \eta \circ \pi_1 ]^* \times id) \circ (w^\# \times w^\#)
|
% \\=\;&\sigma^* \circ (\tau \circ {(id \times [ \hat{g}^\# \circ \pi_2 , \eta \circ \pi_2 ]))}^* \circ \tau \circ ([ \hat{f}^\# \circ \pi_1 , \eta \circ \pi_1 ]^* \times id) \circ (w^\# \times w^\#)
|
||||||
% \\=\;&\sigma^* \circ (\tau \circ (id \times [ \hat{g}^\# \circ \pi_2 , \eta \circ \pi_2 ]))^* \circ K([ \hat{f}^\# \circ \pi_1 , \eta \circ \pi_1 ]^* \times id) \circ \tau \circ (w^\# \times w^\#)
|
% \\=\;&\sigma^* \circ (\tau \circ {(id \times [ \hat{g}^\# \circ \pi_2 , \eta \circ \pi_2 ]))}^* \circ K([ \hat{f}^\# \circ \pi_1 , \eta \circ \pi_1 ]^* \times id) \circ \tau \circ (w^\# \times w^\#)
|
||||||
% \\=\;&\sigma^* \circ (\tau \circ (id \times [ \hat{g}^\# \circ \pi_2 , \eta \circ \pi_2 ]))^* \circ K([ \hat{f}^\# \circ \pi_1 , \eta \circ \pi_1 ]^* \times id) \circ \tau \circ \Delta \circ w^\#\tag{\ref{thm:Klifting}}
|
% \\=\;&\sigma^* \circ (\tau \circ {(id \times [ \hat{g}^\# \circ \pi_2 , \eta \circ \pi_2 ]))}^* \circ K([ \hat{f}^\# \circ \pi_1 , \eta \circ \pi_1 ]^* \times id) \circ \tau \circ \Delta \circ w^\#\tag{\ref{thm:Klifting}}
|
||||||
% \\=\;&\sigma^* \circ (\tau \circ (id \times [ \hat{g}^\# \circ \pi_2 , \eta \circ \pi_2 ]))^* \circ K([ \hat{f}^\# \circ \pi_1 , \eta \circ \pi_1 ]^* \times id) \circ K\langle \eta , id \rangle \circ w^\#
|
% \\=\;&\sigma^* \circ (\tau \circ {(id \times [ \hat{g}^\# \circ \pi_2 , \eta \circ \pi_2 ]))}^* \circ K([ \hat{f}^\# \circ \pi_1 , \eta \circ \pi_1 ]^* \times id) \circ K\langle \eta , id \rangle \circ w^\#
|
||||||
% \\=\;&\sigma^* \circ (\tau \circ (id \times [ \hat{g}^\# \circ \pi_2 , \eta \circ \pi_2 ]))^* \circ K\langle[ \hat{f}^\# \circ \pi_1 , \eta \circ \pi_1 ] , id\rangle \circ w^\#
|
% \\=\;&\sigma^* \circ (\tau \circ {(id \times [ \hat{g}^\# \circ \pi_2 , \eta \circ \pi_2 ]))}^* \circ K\langle[ \hat{f}^\# \circ \pi_1 , \eta \circ \pi_1 ] , id\rangle \circ w^\#
|
||||||
% \\=\;&\sigma^* \circ (\tau \circ \langle [ \hat{f}^\# \circ \pi_1 , \eta \circ \pi_1 ] , [ \hat{g}^\# \circ \pi_2 , \eta \circ \pi_2 ]\rangle)^* \circ w^\#
|
% \\=\;&\sigma^* \circ {(\tau \circ \langle [ \hat{f}^\# \circ \pi_1 , \eta \circ \pi_1 ] , [ \hat{g}^\# \circ \pi_2 , \eta \circ \pi_2 ]\rangle)}^* \circ w^\#
|
||||||
% \\=\;&\sigma^* \circ (\tau \circ \langle [ \hat{f}^\# \circ \pi_1 , \eta \circ \pi_1 ] , [ \hat{g}^\# \circ \pi_2 , \eta \circ \pi_2 ]\rangle)^* \circ w^\#
|
% \\=\;&\sigma^* \circ {(\tau \circ \langle [ \hat{f}^\# \circ \pi_1 , \eta \circ \pi_1 ] , [ \hat{g}^\# \circ \pi_2 , \eta \circ \pi_2 ]\rangle)}^* \circ w^\#
|
||||||
% \\=\;&\sigma^* \circ (\tau \circ [ \hat{f}^\# \times \eta , \eta \times \hat{g}^\# ])^* \circ w^\#
|
% \\=\;&\sigma^* \circ {(\tau \circ [ \hat{f}^\# \times \eta , \eta \times \hat{g}^\# ])}^* \circ w^\#
|
||||||
% \\=\;&([ \sigma^* \circ \tau \circ (\hat{f}^\# \times \eta) , \sigma^* \circ \tau \circ (\eta \times \hat{g}^\#) ])^* \circ w^\#
|
% \\=\;&([ \sigma^* \circ \tau \circ (\hat{f}^\# \times \eta) , \sigma^* \circ \tau \circ {(\eta \times \hat{g}^\#) ])}^* \circ w^\#
|
||||||
% \\=\;&([ \sigma^* \circ \eta \circ (\hat{f}^\# \times id) , \sigma^* \circ K(\eta \times id) \circ \tau \circ (id \times \hat{g}^\#) ])^* \circ w^\#
|
% \\=\;&([ \sigma^* \circ \eta \circ (\hat{f}^\# \times id) , \sigma^* \circ K(\eta \times id) \circ \tau \circ {(id \times \hat{g}^\#) ])}^* \circ w^\#
|
||||||
% \\=\;&([ \sigma \circ (\hat{f}^\# \times id) , \tau \circ (id \times \hat{g}^\#) ])^* \circ w^\#.
|
% \\=\;&([ \sigma \circ (\hat{f}^\# \times id) , \tau \circ {(id \times \hat{g}^\#) ])}^* \circ w^\#.
|
||||||
% \end{alignat*}
|
% \end{alignat*}
|
||||||
|
|
||||||
Note that we are referencing \autoref{thm:Klifting} even though for a monad to be an equational lifting monad it has to be commutative first. However, we are merely referencing the equational law, which can (and does in this case) hold without depending on commutativity.
|
Note that we are referencing \autoref{thm:Klifting} even though for a monad to be an equational lifting monad it has to be commutative first. However, we are merely referencing the equational law, which can (and does in this case) hold without depending on commutativity.
|
||||||
|
|
||||||
We are thus left to find such a $w$, consider
|
We are thus left to find such a \(w\), consider
|
||||||
\[w := [ i_1 \circ K i_1 \circ \tau , ((K i_2 \circ \sigma) + id) \circ dstr \circ (\hat{f} \times id) ] \circ dstl \circ (id \times \hat{g}). \]
|
\[w := [ i_1 \circ K i_1 \circ \tau , ((K i_2 \circ \sigma) + id) \circ dstr \circ (\hat{f} \times id) ] \circ dstl \circ (id \times \hat{g}). \]
|
||||||
$w$ indeed satisfies the requisite properties, let us check the first property, the second one follows by a symmetric argument. We will show that
|
\(w\) indeed satisfies the requisite properties, let us check the first property, the second one follows by a symmetric argument. We will show that
|
||||||
\[[ \hat{f}^\# \circ \pi_1 , \eta \circ \pi_1 ]^* \circ w^\# = ([ i_1 \circ \pi_1 , (\hat{f}^\# \circ \pi_1 + id) \circ dstl ] \circ dstr \circ (\hat{f} \times g))^\# = \hat{f}^\# \circ \pi_1. \]
|
\[[ \hat{f}^\# \circ \pi_1 , \eta \circ \pi_1 ]^* \circ w^\# = ([ i_1 \circ \pi_1 , (\hat{f}^\# \circ \pi_1 + id) \circ dstl ] \circ dstr \circ (\hat{f} \times g))^\# = \hat{f}^\# \circ \pi_1. \]
|
||||||
Indeed,
|
Indeed,
|
||||||
\begin{alignat*}{1}
|
\begin{alignat*}{1}
|
||||||
&[ \hat{f}^\# \circ \pi_1 , \eta \circ \pi_1 ]^* \circ w^\#
|
& [ \hat{f}^\# \circ \pi_1 , \eta \circ \pi_1 ]^* \circ w^\#
|
||||||
\\=\;&(([ \hat{f}^\# \circ \pi_1 , \eta \circ \pi_1 ]^* + id) \circ w)^\#
|
\\=\;&(([ \hat{f}^\# \circ \pi_1 , \eta \circ \pi_1 ]^* + id) \circ w)^\#
|
||||||
\\=\;&([ i_1 \circ (\hat{f}^\# \circ \pi_1)^* \circ \tau , ((K\pi_1 \circ \sigma) + id) \circ dstr \circ (\hat{f} \times id) ] \circ dstl \circ (id \times \hat{g}))^\#
|
\\=\;&([ i_1 \circ {(\hat{f}^\# \circ \pi_1)}^* \circ \tau , ((K\pi_1 \circ \sigma) + id) \circ dstr \circ (\hat{f} \times id) ] \circ dstl \circ (id \times \hat{g}))^\#
|
||||||
\\=\;&([ i_1 \circ (\hat{f}^\# \circ \pi_1)^* \circ \tau , ((K\pi_1 \circ \sigma) + id) \circ dstr \circ (\hat{f} \times id) ] \circ dstl \circ (id \times (\eta + id)) \circ (id \times g))^\#
|
\\=\;&([ i_1 \circ {(\hat{f}^\# \circ \pi_1)}^* \circ \tau , ((K\pi_1 \circ \sigma) + id) \circ dstr \circ (\hat{f} \times id) ] \circ dstl \circ (id \times (\eta + id)) \circ (id \times g))^\#
|
||||||
\\=\;&([ i_1 \circ (\hat{f}^\# \circ \pi_1)^* \circ \tau , ((K\pi_1 \circ \sigma) + id) \circ dstr \circ (\hat{f} \times id) ] \circ ((id \times \eta) + id) \circ dstl \circ (id \times g))^\#
|
\\=\;&([ i_1 \circ {(\hat{f}^\# \circ \pi_1)}^* \circ \tau , ((K\pi_1 \circ \sigma) + id) \circ dstr \circ (\hat{f} \times id) ] \circ ((id \times \eta) + id) \circ dstl \circ (id \times g))^\#
|
||||||
\\=\;&([ i_1 \circ (\hat{f}^\# \circ \pi_1)^* \circ \tau \circ (id \times \eta) , ((K\pi_1 \circ \sigma) + id) \circ dstr \circ (\hat{f} \times id) ] \circ dstl \circ (id \times g))^\#
|
\\=\;&([ i_1 \circ {(\hat{f}^\# \circ \pi_1)}^* \circ \tau \circ (id \times \eta) , ((K\pi_1 \circ \sigma) + id) \circ dstr \circ (\hat{f} \times id) ] \circ dstl \circ (id \times g))^\#
|
||||||
\\=\;&([ i_1 \circ \hat{f}^\# \circ \pi_1 , ((K\pi_1 \circ \sigma) + id) \circ dstr \circ (\hat{f} \times id) ] \circ dstl \circ (id \times g))^\#
|
\\=\;&([ i_1 \circ \hat{f}^\# \circ \pi_1 , ((K\pi_1 \circ \sigma) + id) \circ dstr \circ (\hat{f} \times id) ] \circ dstl \circ (id \times g))^\#
|
||||||
\\=\;&([ i_1 \circ [id , \hat{f}^\#] \circ \hat{f} \circ \pi_1 , ((K\pi_1 \circ \sigma) + id) \circ dstr \circ (\hat{f} \times id) ] \circ dstl \circ (id \times g))^\#\tag{\ref{law:fixpoint}}
|
\\=\;&([ i_1 \circ [id , \hat{f}^\#] \circ \hat{f} \circ \pi_1 , ((K\pi_1 \circ \sigma) + id) \circ dstr \circ (\hat{f} \times id) ] \circ dstl \circ (id \times g))^\#\tag{\ref{law:fixpoint}}
|
||||||
\\=\;&([ i_1 \circ [id , \hat{f}^\#] \circ \pi_1 \circ (\hat{f} \times id) , ((K\pi_1 \circ \sigma) + id) \circ dstr \circ (\hat{f} \times id) ] \circ dstl \circ (id \times g))^\#
|
\\=\;&([ i_1 \circ [id , \hat{f}^\#] \circ \pi_1 \circ (\hat{f} \times id) , ((K\pi_1 \circ \sigma) + id) \circ dstr \circ (\hat{f} \times id) ] \circ dstl \circ (id \times g))^\#
|
||||||
|
@ -707,7 +701,7 @@ The following Lemma is central to the proof of commutativity.
|
||||||
\end{alignat*}
|
\end{alignat*}
|
||||||
and
|
and
|
||||||
\begin{alignat*}{1}
|
\begin{alignat*}{1}
|
||||||
&\hat{f}^\# \circ \pi_1
|
& \hat{f}^\# \circ \pi_1
|
||||||
\\=\;&((id + \Delta) \circ h)^\# \tag{\ref{law:uniformity}}
|
\\=\;&((id + \Delta) \circ h)^\# \tag{\ref{law:uniformity}}
|
||||||
\\=\;&([ i_1 , ((id + \Delta) \circ h)^\# + id] \circ h)^\# \tag{\ref{law:diamond}}
|
\\=\;&([ i_1 , ((id + \Delta) \circ h)^\# + id] \circ h)^\# \tag{\ref{law:diamond}}
|
||||||
\\=\;&([ i_1 , (\hat{f}^\# \circ \pi_1) + id ] \circ h)^\# \tag{\ref{law:uniformity}}
|
\\=\;&([ i_1 , (\hat{f}^\# \circ \pi_1) + id ] \circ h)^\# \tag{\ref{law:uniformity}}
|
||||||
|
@ -718,9 +712,9 @@ The following Lemma is central to the proof of commutativity.
|
||||||
\\=\;&([ i_1 \circ \pi_1 , ((\hat{f} \circ \pi_1) + id) \circ dstl ] \circ dstr \circ (\hat{f} \times g))^\#,
|
\\=\;&([ i_1 \circ \pi_1 , ((\hat{f} \circ \pi_1) + id) \circ dstl ] \circ dstr \circ (\hat{f} \times g))^\#,
|
||||||
\end{alignat*}
|
\end{alignat*}
|
||||||
|
|
||||||
where $h = (\pi_1 + ((\pi_1 + (\pi_1 \times id)) \circ dstl \circ \langle id , g \circ \pi_2 \rangle)) \circ dstr \circ (\hat{f} \times id)$ and the application of \ref{law:uniformity} is justified, since
|
where \(h = (\pi_1 + ((\pi_1 + (\pi_1 \times id)) \circ dstl \circ \langle id , g \circ \pi_2 \rangle)) \circ dstr \circ (\hat{f} \times id)\) and the application of \ref{law:uniformity} is justified, since
|
||||||
\begin{alignat*}{1}
|
\begin{alignat*}{1}
|
||||||
&(id + \pi_1) \circ (id + \Delta) \circ h
|
& (id + \pi_1) \circ (id + \Delta) \circ h
|
||||||
\\=\;&(\pi_1 + ((\pi_1 \circ [ \pi_1 , \pi_1 \times id ]) \circ dstl \circ \langle id , g \circ \pi_2 \rangle)) \circ dstr \circ (\hat{f} \times id)
|
\\=\;&(\pi_1 + ((\pi_1 \circ [ \pi_1 , \pi_1 \times id ]) \circ dstl \circ \langle id , g \circ \pi_2 \rangle)) \circ dstr \circ (\hat{f} \times id)
|
||||||
\\=\;&(\pi_1 + ([ \pi_1 \circ \pi_1 , \pi_1 \circ \pi_1 ] \circ dstl \circ \langle id , g \circ \pi_2 \rangle)) \circ dstr \circ (\hat{f} \times id)
|
\\=\;&(\pi_1 + ([ \pi_1 \circ \pi_1 , \pi_1 \circ \pi_1 ] \circ dstl \circ \langle id , g \circ \pi_2 \rangle)) \circ dstr \circ (\hat{f} \times id)
|
||||||
\\=\;&(\pi_1 + (\pi_1 \circ \pi_1 \circ \langle id , g \circ \pi_2 \rangle)) \circ dstr \circ (\hat{f} \times id)
|
\\=\;&(\pi_1 + (\pi_1 \circ \pi_1 \circ \langle id , g \circ \pi_2 \rangle)) \circ dstr \circ (\hat{f} \times id)
|
||||||
|
@ -733,9 +727,9 @@ The following Lemma is central to the proof of commutativity.
|
||||||
\end{proof}
|
\end{proof}
|
||||||
|
|
||||||
\begin{theorem}
|
\begin{theorem}
|
||||||
$\mathbf{K}$ is a commutative monad.
|
\(\mathbf{K}\) is a commutative monad.
|
||||||
\end{theorem}
|
\end{theorem}
|
||||||
\begin{proof} We need to show that $\tau^* \circ \sigma = \sigma^* \circ \tau : KX \times KY \rightarrow K(X \times Y)$.
|
\begin{proof} We need to show that \(\tau^* \circ \sigma = \sigma^* \circ \tau : KX \times KY \rightarrow K(X \times Y)\).
|
||||||
Let us proceed by right stability, consider the following diagram.
|
Let us proceed by right stability, consider the following diagram.
|
||||||
% https://q.uiver.app/#q=WzAsNSxbMSwwLCJLWCBcXHRpbWVzIEtZIl0sWzMsMCwiSyhLWCBcXHRpbWVzIFkpIl0sWzEsMiwiSyhYIFxcdGltZXMgS1kpIl0sWzMsMiwiSyhYIFxcdGltZXMgWSkiXSxbMCwzLCJLWCBcXHRpbWVzIFkiXSxbMCwxLCJcXHRhdSJdLFswLDIsIlxcaGF0e1xcdGF1fSIsMl0sWzEsMywiXFxoYXR7XFx0YXV9XioiXSxbMiwzLCJcXHRhdV4qIiwyXSxbNCwwLCJpZCBcXHRpbWVzIFxcZXRhIiwwLHsiY3VydmUiOi0yfV0sWzQsMywiXFxoYXR7XFx0YXV9IiwyLHsiY3VydmUiOjJ9XV0=
|
% https://q.uiver.app/#q=WzAsNSxbMSwwLCJLWCBcXHRpbWVzIEtZIl0sWzMsMCwiSyhLWCBcXHRpbWVzIFkpIl0sWzEsMiwiSyhYIFxcdGltZXMgS1kpIl0sWzMsMiwiSyhYIFxcdGltZXMgWSkiXSxbMCwzLCJLWCBcXHRpbWVzIFkiXSxbMCwxLCJcXHRhdSJdLFswLDIsIlxcaGF0e1xcdGF1fSIsMl0sWzEsMywiXFxoYXR7XFx0YXV9XioiXSxbMiwzLCJcXHRhdV4qIiwyXSxbNCwwLCJpZCBcXHRpbWVzIFxcZXRhIiwwLHsiY3VydmUiOi0yfV0sWzQsMywiXFxoYXR7XFx0YXV9IiwyLHsiY3VydmUiOjJ9XV0=
|
||||||
\[\begin{tikzcd}
|
\[\begin{tikzcd}
|
||||||
|
@ -752,14 +746,14 @@ The following Lemma is central to the proof of commutativity.
|
||||||
\end{tikzcd}\]
|
\end{tikzcd}\]
|
||||||
|
|
||||||
The diagram commutes since
|
The diagram commutes since
|
||||||
\[\sigma^* \circ \tau \circ (id \times \eta) = \sigma^* \circ \eta = \sigma\]
|
\[\sigma^* \circ \tau \circ (id \times \eta) = \sigma^* \circ \eta = \sigma \]
|
||||||
and
|
and
|
||||||
\[\tau^* \circ \sigma \circ (id \times \eta) = \tau^* \circ K(id \times \eta) \circ \sigma = (\tau \circ (id \times \eta))^* \circ \sigma = \sigma.\]
|
\[\tau^* \circ \sigma \circ (id \times \eta) = \tau^* \circ K(id \times \eta) \circ \sigma = (\tau \circ {(id \times \eta))}^* \circ \sigma = \sigma.\]
|
||||||
|
|
||||||
We are left to show that both $\sigma^* \circ \tau$ and $\tau^* \circ \sigma$ are right iteration preserving. Let $h : Z \rightarrow KY + Z$, indeed
|
We are left to show that both \(\sigma^* \circ \tau \) and \(\tau^* \circ \sigma \) are right iteration preserving. Let \(h : Z \rightarrow KY + Z\), indeed
|
||||||
\[\sigma^* \circ \tau \circ (id \times h^\#) = \sigma^* ((\tau + id) \circ dstl \circ (id \times h))^\# = (((\sigma^* \circ \tau) + id) \circ dstl \circ (id \times h))^\#. \]
|
\[\sigma^* \circ \tau \circ (id \times h^\#) = \sigma^* ((\tau + id) \circ dstl \circ (id \times h))^\# = (((\sigma^* \circ \tau) + id) \circ dstl \circ (id \times h))^\#. \]
|
||||||
|
|
||||||
Let $\psi := \tau^* \circ \sigma$ and let us proceed by left stability to show that $\psi$ is right iteration preserving, consider the following diagram
|
Let \(\psi := \tau^* \circ \sigma \) and let us proceed by left stability to show that \(\psi \) is right iteration preserving, consider the following diagram
|
||||||
% https://q.uiver.app/#q=WzAsNCxbNCwwLCJLWCBcXHRpbWVzIEtZIl0sWzQsMSwiSyhYIFxcdGltZXMgWSkiXSxbMCwxLCJLWCBcXHRpbWVzIFoiXSxbMCwzLCJYIFxcdGltZXMgWiJdLFswLDEsIlxccHNpIl0sWzIsMCwiaWQgXFx0aW1lcyBoXlxcIyJdLFsyLDEsIigoXFxwc2kgKyBpZCkgXFxjaXJjIGRzdGwgXFxjaXJjIChpZCBcXHRpbWVzIGgpKV5cXCMiLDJdLFszLDIsIlxcZXRhIFxcdGltZXMgaWQiXSxbMywxLCJcXHRhdSBcXGNpcmMgKGlkIFxcdGltZXMgaF5cXCMpIiwyXV0=
|
% https://q.uiver.app/#q=WzAsNCxbNCwwLCJLWCBcXHRpbWVzIEtZIl0sWzQsMSwiSyhYIFxcdGltZXMgWSkiXSxbMCwxLCJLWCBcXHRpbWVzIFoiXSxbMCwzLCJYIFxcdGltZXMgWiJdLFswLDEsIlxccHNpIl0sWzIsMCwiaWQgXFx0aW1lcyBoXlxcIyJdLFsyLDEsIigoXFxwc2kgKyBpZCkgXFxjaXJjIGRzdGwgXFxjaXJjIChpZCBcXHRpbWVzIGgpKV5cXCMiLDJdLFszLDIsIlxcZXRhIFxcdGltZXMgaWQiXSxbMywxLCJcXHRhdSBcXGNpcmMgKGlkIFxcdGltZXMgaF5cXCMpIiwyXV0=
|
||||||
\[\begin{tikzcd}
|
\[\begin{tikzcd}
|
||||||
&&&& {KX \times KY} \\
|
&&&& {KX \times KY} \\
|
||||||
|
@ -774,7 +768,7 @@ The following Lemma is central to the proof of commutativity.
|
||||||
\end{tikzcd}\]
|
\end{tikzcd}\]
|
||||||
which commutes, since
|
which commutes, since
|
||||||
\begin{alignat*}{1}
|
\begin{alignat*}{1}
|
||||||
&\psi \circ (id \times h^\#) \circ (\eta \times id)
|
& \psi \circ (id \times h^\#) \circ (\eta \times id)
|
||||||
\\=\;&\psi \circ (\eta \times id) \circ (id \times h^\#)
|
\\=\;&\psi \circ (\eta \times id) \circ (id \times h^\#)
|
||||||
\\=\;&\tau^* \circ \eta \circ (id \times h^\#)
|
\\=\;&\tau^* \circ \eta \circ (id \times h^\#)
|
||||||
\\=\;&\tau \circ (id \times h^\#)
|
\\=\;&\tau \circ (id \times h^\#)
|
||||||
|
@ -782,9 +776,9 @@ The following Lemma is central to the proof of commutativity.
|
||||||
\\=\;&((\psi + id) \circ dstl \circ (id \times h))^\# \circ (\eta \times id).\tag{\ref{law:uniformity}}
|
\\=\;&((\psi + id) \circ dstl \circ (id \times h))^\# \circ (\eta \times id).\tag{\ref{law:uniformity}}
|
||||||
\end{alignat*}
|
\end{alignat*}
|
||||||
|
|
||||||
We are left to show that both $\psi \circ (id \times h^\#)$ and $((\psi + id) \circ dstl \circ (id \times h))^\#$ are left iteration preserving. Let $g : A \rightarrow KX + A$, then $\psi \circ (id \times h^\#)$ is left iteration preserving, since
|
We are left to show that both \(\psi \circ (id \times h^\#)\) and \(((\psi + id) \circ dstl \circ (id \times h))^\# \) are left iteration preserving. Let \(g : A \rightarrow KX + A\), then \(\psi \circ (id \times h^\#)\) is left iteration preserving, since
|
||||||
\begin{alignat*}{1}
|
\begin{alignat*}{1}
|
||||||
&\psi \circ (id \times h^\#) \circ (g^\# \times id)
|
& \psi \circ (id \times h^\#) \circ (g^\# \times id)
|
||||||
\\=\;&\psi \circ (g^\# \times id) \circ (id \times h^\#)
|
\\=\;&\psi \circ (g^\# \times id) \circ (id \times h^\#)
|
||||||
\\=\;&\tau^* \circ ((\sigma + id) \circ dstr \circ (g \times id))^\# \circ (id \times h^\#)
|
\\=\;&\tau^* \circ ((\sigma + id) \circ dstr \circ (g \times id))^\# \circ (id \times h^\#)
|
||||||
\\=\;&((\psi + id) \circ dstr \circ (g \times id))^\# \circ (id \times h^\#)
|
\\=\;&((\psi + id) \circ dstr \circ (g \times id))^\# \circ (id \times h^\#)
|
||||||
|
@ -798,30 +792,30 @@ The following Lemma is central to the proof of commutativity.
|
||||||
|
|
||||||
Consider now, that
|
Consider now, that
|
||||||
\begin{alignat*}{1}
|
\begin{alignat*}{1}
|
||||||
&((((\psi + id) \circ dstl \circ (id \times h))^\# + id) \circ dstr \circ (g \times id))^\#
|
& ((((\psi + id) \circ dstl \circ (id \times h))^\# + id) \circ dstr \circ (g \times id))^\#
|
||||||
\\=\;&(((((\psi + id) \circ dstl \circ (id \times h))^\#)^* + id) \circ (\eta + id) \circ dstr \circ (g \times id))^\#
|
\\=\;&(((((\psi + id) \circ dstl \circ {(id \times h))^\#)}^* + id) \circ (\eta + id) \circ dstr \circ (g \times id))^\#
|
||||||
\\=\;&(((\psi + id) \circ dstl \circ (id \times h))^\#)^* \circ ((\eta + id) \circ dstr \circ (g \times id))^\#
|
\\=\;&(((\psi + id) \circ dstl \circ {(id \times h))^\#)}^* \circ ((\eta + id) \circ dstr \circ (g \times id))^\#
|
||||||
\\=\;&(((\psi + id) \circ dstl \circ (id \times h))^\#)^* \circ (((\sigma \circ (\eta \times id)) + id) \circ dstr \circ (g \times id))^\#
|
\\=\;&(((\psi + id) \circ dstl \circ {(id \times h))^\#)}^* \circ (((\sigma \circ (\eta \times id)) + id) \circ dstr \circ (g \times id))^\#
|
||||||
\\=\;&(((\psi + id) \circ dstl \circ (id \times h))^\#)^* \circ \sigma \circ (((\eta + id) \circ g)^\# \times id)
|
\\=\;&(((\psi + id) \circ dstl \circ {(id \times h))^\#)}^* \circ \sigma \circ (((\eta + id) \circ g)^\# \times id)
|
||||||
\\=\;&(((\psi^* + id) \circ (\eta + id) \circ dstl \circ (id \times h))^\#)^* \circ \sigma \circ (((\eta + id) \circ g)^\# \times id)
|
\\=\;&(((\psi^* + id) \circ (\eta + id) \circ dstl \circ {(id \times h))^\#)}^* \circ \sigma \circ (((\eta + id) \circ g)^\# \times id)
|
||||||
\\=\;&\psi^* \circ (((\eta + id) \circ dstl \circ (id \times h))^\#)^* \circ \sigma \circ (((\eta + id) \circ g)^\# \times id)
|
\\=\;&\psi^* \circ (((\eta + id) \circ dstl \circ {(id \times h))^\#)}^* \circ \sigma \circ (((\eta + id) \circ g)^\# \times id)
|
||||||
\\=\;&\psi^* \circ (((\eta + id) \circ dstl \circ (id \times h))^\#)^* \circ \sigma \circ (((\eta + id) \circ g)^\# \times id)
|
\\=\;&\psi^* \circ (((\eta + id) \circ dstl \circ {(id \times h))^\#)}^* \circ \sigma \circ (((\eta + id) \circ g)^\# \times id)
|
||||||
\\=\;&\psi^* \circ ((((\tau \circ (id \times \eta)) + id) \circ dstl \circ (id \times h))^\#)^* \circ \sigma \circ (((\eta + id) \circ g)^\# \times id)
|
\\=\;&\psi^* \circ ((((\tau \circ (id \times \eta)) + id) \circ dstl \circ {(id \times h))^\#)}^* \circ \sigma \circ (((\eta + id) \circ g)^\# \times id)
|
||||||
\\=\;&\psi^* \circ (((\tau + id) \circ dstl \circ (id \times ((\eta + id) \circ h)))^\#)^* \circ \sigma \circ (((\eta + id) \circ g)^\# \times id)
|
\\=\;&\psi^* \circ (((\tau + id) \circ dstl \circ (id \times ({(\eta + id) \circ h)))^\#)}^* \circ \sigma \circ (((\eta + id) \circ g)^\# \times id)
|
||||||
\\=\;&\psi^* \circ (\tau \circ (id \times ((\eta + id) \circ h)^\#))^* \circ \sigma \circ (((\eta + id) \circ g)^\# \times id)
|
\\=\;&\psi^* \circ (\tau \circ (id \times ({(\eta + id) \circ h)^\#))}^* \circ \sigma \circ (((\eta + id) \circ g)^\# \times id)
|
||||||
\\=\;&\psi^* \circ \tau^* \circ K(id \times ((\eta + id) \circ h)^\#) \circ \sigma \circ (((\eta + id) \circ g)^\# \times id)
|
\\=\;&\psi^* \circ \tau^* \circ K(id \times ((\eta + id) \circ h)^\#) \circ \sigma \circ (((\eta + id) \circ g)^\# \times id)
|
||||||
\\=\;&\psi^* \circ \tau^* \circ \sigma \circ (id \times ((\eta + id) \circ h)^\#) \circ (((\eta + id) \circ g)^\# \times id)
|
\\=\;&\psi^* \circ \tau^* \circ \sigma \circ (id \times ((\eta + id) \circ h)^\#) \circ (((\eta + id) \circ g)^\# \times id)
|
||||||
\\=\;&\psi^* \circ \tau^* \circ \sigma \circ (((\eta + id) \circ g)^\# \times ((\eta + id) \circ h)^\#),
|
\\=\;&\psi^* \circ \tau^* \circ \sigma \circ (((\eta + id) \circ g)^\# \times ((\eta + id) \circ h)^\#),
|
||||||
\end{alignat*}
|
\end{alignat*}
|
||||||
and by a symmetric argument
|
and by a symmetric argument
|
||||||
\begin{alignat*}{1}
|
\begin{alignat*}{1}
|
||||||
&((((\psi + id) \circ dstr \circ (g \times id))^\# + id) \circ dstl \circ (id \times h))^\#
|
& ((((\psi + id) \circ dstr \circ (g \times id))^\# + id) \circ dstl \circ (id \times h))^\#
|
||||||
\\=\;&\psi^* \circ \sigma^* \circ \tau \circ (((\eta + id) \circ g)^\# \times ((\eta + id) \circ h)^\#).
|
\\=\;&\psi^* \circ \sigma^* \circ \tau \circ (((\eta + id) \circ g)^\# \times ((\eta + id) \circ h)^\#).
|
||||||
\end{alignat*}
|
\end{alignat*}
|
||||||
|
|
||||||
We are thus done by
|
We are thus done by
|
||||||
\begin{alignat*}{1}
|
\begin{alignat*}{1}
|
||||||
&((\psi + id) \circ dstl \circ (id \times h))^\# \circ (g^\# \times id)
|
& ((\psi + id) \circ dstl \circ (id \times h))^\# \circ (g^\# \times id)
|
||||||
\\=\;&((((\psi + id) \circ dstr \circ (g \times id))^\# + id) \circ dstl \circ (id \times h))^\#\tag{\ref{law:uniformity}}
|
\\=\;&((((\psi + id) \circ dstr \circ (g \times id))^\# + id) \circ dstl \circ (id \times h))^\#\tag{\ref{law:uniformity}}
|
||||||
\\=\;&\psi^* \circ \sigma^* \circ \tau \circ (((\eta + id) \circ g)^\# \times ((\eta + id) \circ h)^\#)
|
\\=\;&\psi^* \circ \sigma^* \circ \tau \circ (((\eta + id) \circ g)^\# \times ((\eta + id) \circ h)^\#)
|
||||||
\\=\;&\psi^* \circ \tau^* \circ \sigma \circ (((\eta + id) \circ g)^\# \times ((\eta + id) \circ h)^\#)\tag{\ref{lem:KCommKey}}
|
\\=\;&\psi^* \circ \tau^* \circ \sigma \circ (((\eta + id) \circ g)^\# \times ((\eta + id) \circ h)^\#)\tag{\ref{lem:KCommKey}}
|
||||||
|
@ -830,34 +824,34 @@ The following Lemma is central to the proof of commutativity.
|
||||||
\end{proof}
|
\end{proof}
|
||||||
|
|
||||||
\begin{theorem}\label{thm:Klifting}
|
\begin{theorem}\label{thm:Klifting}
|
||||||
$\mathbf{K}$ is an equational lifting monad.
|
\(\mathbf{K}\) is an equational lifting monad.
|
||||||
\end{theorem}
|
\end{theorem}
|
||||||
|
|
||||||
\begin{proof}
|
\begin{proof}
|
||||||
We need to show that $\tau \circ \Delta = K \langle \eta , id \rangle$. Note that $K \langle \eta , id \rangle = \free{\eta \circ \langle \eta , id \rangle}$, which is a unique Elgot algebra morphism satisfying $K \langle \eta , id \rangle \circ \eta = \eta \circ \langle \eta , id \rangle$. It thus suffices to show that $\tau \circ \Delta$ satisfies the same identity and is iteration preserving.
|
Since we have already shown commutativity, we are left to show that \(\tau \circ \Delta = K \langle \eta , id \rangle \). Note that \(K \langle \eta , id \rangle = \free{\eta \circ \langle \eta , id \rangle}\), which is the unique Elgot algebra morphism satisfying \(K \langle \eta , id \rangle \circ \eta = \eta \circ \langle \eta , id \rangle \). It thus suffices to show that \(\tau \circ \Delta \) satisfies the same identity and is iteration preserving.
|
||||||
|
|
||||||
The identity follows easily
|
The identity follows easily
|
||||||
\begin{alignat*}{1}
|
\begin{alignat*}{1}
|
||||||
&\tau \circ \Delta \circ \eta
|
& \tau \circ \Delta \circ \eta
|
||||||
\\=\;&\tau \circ \langle \eta , \eta \rangle
|
\\=\;&\tau \circ \langle \eta , \eta \rangle
|
||||||
\\=\;&\tau \circ (id \times \eta) \circ \langle \eta , id \rangle
|
\\=\;&\tau \circ (id \times \eta) \circ \langle \eta , id \rangle
|
||||||
\\=\;&\eta \circ \langle \eta , id \rangle.
|
\\=\;&\eta \circ \langle \eta , id \rangle.
|
||||||
\end{alignat*}
|
\end{alignat*}
|
||||||
|
|
||||||
For iteration preservation of $\tau \circ \Delta$ consider $Z \in \obj{\C}$ and $h : Z \rightarrow KX + Z$, then
|
For iteration preservation of \(\tau \circ \Delta \) consider \(Z \in \obj{\C}\) and \(h : Z \rightarrow KX + Z\), then
|
||||||
\begin{alignat*}{1}
|
\begin{alignat*}{1}
|
||||||
&\tau \circ \Delta \circ h^{\#}
|
& \tau \circ \Delta \circ h^{\#}
|
||||||
\\=\;&\tau \circ \langle h^{\#} , h^{\#} \rangle
|
\\=\;&\tau \circ \langle h^{\#} , h^{\#} \rangle
|
||||||
\\=\;&\tau \circ (id \times h^{\#}) \circ \langle h^{\#} , id \rangle
|
\\=\;&\tau \circ (id \times h^{\#}) \circ \langle h^{\#} , id \rangle
|
||||||
\\=\;&((\tau + id) \circ dstl \circ (id \times f))^\# \circ \langle h^{\#} , id \rangle
|
\\=\;&((\tau + id) \circ dstl \circ (id \times f))^\# \circ \langle h^{\#} , id \rangle
|
||||||
\\=\;&(((\tau \circ \Delta) + id) \circ f)^\#.\tag{\ref{law:uniformity}}
|
\\=\;&(((\tau \circ \Delta) + id) \circ f)^\#.\tag{\ref{law:uniformity}}
|
||||||
\end{alignat*}
|
\end{alignat*}
|
||||||
|
|
||||||
Note that by monicity of $dstl^{-1}$ and by \ref{law:fixpoint}
|
Note that by monicity of \(dstl^{-1}\) and by~\ref{law:fixpoint}
|
||||||
\[(\Delta + \langle f^\# , id \rangle) \circ f = dstl \circ \langle f^\# , f \rangle. \]
|
\[(\Delta + \langle f^\# , id \rangle) \circ f = dstl \circ \langle f^\# , f \rangle. \]
|
||||||
The application of \ref{law:uniformity} is then justified by
|
The application of \ref{law:uniformity} is then justified by
|
||||||
\begin{alignat*}{1}
|
\begin{alignat*}{1}
|
||||||
&(id + \langle f^\# , id \rangle) \circ ((\tau \circ \Delta) + id) \circ f
|
& (id + \langle f^\# , id \rangle) \circ ((\tau \circ \Delta) + id) \circ f
|
||||||
\\=\;&((\tau \circ \Delta) + \langle f^\# , id \rangle) \circ f
|
\\=\;&((\tau \circ \Delta) + \langle f^\# , id \rangle) \circ f
|
||||||
\\=\;&(\tau + id) \circ (\Delta + \langle f^\# , id \rangle) \circ f
|
\\=\;&(\tau + id) \circ (\Delta + \langle f^\# , id \rangle) \circ f
|
||||||
\\=\;&(\tau + id) \circ dstl \circ \langle f^\# , f \rangle
|
\\=\;&(\tau + id) \circ dstl \circ \langle f^\# , f \rangle
|
||||||
|
@ -866,9 +860,55 @@ The following Lemma is central to the proof of commutativity.
|
||||||
\end{proof}
|
\end{proof}
|
||||||
|
|
||||||
\begin{theorem}
|
\begin{theorem}
|
||||||
$\mathbf{K}$ is the initial (strong) pre-Elgot monad.
|
\(\mathbf{K}\) is the initial (strong) pre-Elgot monad.
|
||||||
\end{theorem}
|
\end{theorem}
|
||||||
\begin{proof}
|
\begin{proof}
|
||||||
Note that $\mathbf{K}$ is a pre-Elgot monad by definition.
|
Note that \(\mathbf{K}\) is a pre-Elgot monad by definition and strong pre-Elgot by \autoref{lem:Kstrong}. Let us first show that \(\mathbf{K}\) is the initial pre-Elgot monad.
|
||||||
\todo[inline]{Proof that K is initial strong pre-Elgot}
|
|
||||||
|
Given any pre-Elgot monad \(\mathbf{T}\), let us introduce alternative names for the monad operations of \(\mathbf{T}\) and \(\mathbf{K}\) to avoid confusion:
|
||||||
|
\[\mathbf{T} = (T , \eta^T, \mu^T, {(-)}^{\#_T})\]
|
||||||
|
and
|
||||||
|
\[\mathbf{K} = (K , \eta^K, \mu^T, {(-)}^{\#_K}).\]
|
||||||
|
|
||||||
|
For every \(X \in \obj{\C} \) we define \(¡ = \free{(\eta^T : X \rightarrow TX)} : KX \rightarrow TX \). Note that \(¡\) is the unique iteration preserving morphism that satisfies \(¡ \circ \eta^K = \eta^T\). We are done after showing that \(¡\) is natural and respects the monad multiplication.
|
||||||
|
|
||||||
|
Let \(f : X \rightarrow Y\). For naturality of \(¡\) it suffices to show
|
||||||
|
\[¡ \circ Kf = \free{Tf \circ \eta^T} = Tf \circ ¡,\]
|
||||||
|
where \(\free{Tf \circ \eta^T}\) is the unique Elgot algebra morphism satisfying \(\free{Tf \circ \eta^T} \circ \eta^K = Tf \circ \eta^T \).
|
||||||
|
Note that both \(¡ \circ Kf \) and \(Tf \circ ¡ \) are iteration preserving since they are composed of iteration preserving morphisms and both satisfy the requisite property, since \(Tf \circ ¡ \circ \eta^K = Tf \circ \eta^T \) follows instantly and
|
||||||
|
\begin{alignat*}{1}
|
||||||
|
& ¡ \circ Kf \circ \eta^K
|
||||||
|
\\=\;&¡ \circ \eta^K \circ f
|
||||||
|
\\=\;&\eta^T \circ f
|
||||||
|
\\=\;&Tf \circ \eta^T
|
||||||
|
\end{alignat*}
|
||||||
|
|
||||||
|
Let us proceed similarly for showing that \(¡\) respects the monad multiplication, i.e.\ consider
|
||||||
|
\[¡ \circ \mu = \free{¡} = \mu^T \circ T ¡ \circ ¡,\]
|
||||||
|
where \(\free{¡}\) is the unique Elgot algebra morphism satisfying \(\free{¡} \circ \eta^K = ¡\). Note that again both sides of the identity are iteration preserving, since they are composed of iteration preserving morphisms. Consider also that \(¡ \circ \mu^K \circ \eta^K = ¡\) and
|
||||||
|
\begin{alignat*}{1}
|
||||||
|
& \mu^T \circ T¡ \circ ¡ \circ \eta^K
|
||||||
|
\\=\;&\mu^T \circ ¡ \circ K¡ \circ \eta^K
|
||||||
|
\\=\;&\mu^T \circ ¡ \circ \eta^K \circ ¡
|
||||||
|
\\=\;&\mu^T \circ \eta^T \circ ¡
|
||||||
|
\\=\;&¡.
|
||||||
|
\end{alignat*}
|
||||||
|
|
||||||
|
Thus, \(\mathbf{K}\) is an initial pre-Elgot monad. To show that \(\mathbf{K}\) is also initial strong pre-Elgot, assume that \(\mathbf{T}\) is strong with strength \(\tau^T\) and let us call the strength of \(\mathbf{K}\) \(\tau^K\). We are left to show that \(¡\) respects strength, i.e.\ \( ¡ \circ \tau^K = \tau^T \circ (id \times ¡) : X \times KY \rightarrow T(X \times Y) \). Note that
|
||||||
|
% https://q.uiver.app/#q=WzAsNSxbMSwwLCJYIFxcdGltZXMgS1kiXSxbMywwLCJLKFggXFx0aW1lcyBZKSJdLFszLDIsIlQoWCBcXHRpbWVzIFkpIl0sWzEsMiwiWCBcXHRpbWVzIFRZIl0sWzAsMywiWCBcXHRpbWVzIFkiXSxbMCwxLCJcXHRhdV5LIl0sWzEsMiwiwqEiXSxbMCwzLCJpZCBcXHRpbWVzIMKhIiwyXSxbMywyLCJcXHRhdV5UIiwyXSxbNCwwLCJpZCBcXHRpbWVzIFxcZXRhIiwwLHsiY3VydmUiOi0yfV0sWzQsMiwiXFxldGFeVCIsMix7ImN1cnZlIjoyfV1d
|
||||||
|
\[
|
||||||
|
\begin{tikzcd}[ampersand replacement=\&]
|
||||||
|
\& {X \times KY} \&\& {K(X \times Y)} \\
|
||||||
|
\\
|
||||||
|
\& {X \times TY} \&\& {T(X \times Y)} \\
|
||||||
|
{X \times Y}
|
||||||
|
\arrow["{\tau^K}", from=1-2, to=1-4]
|
||||||
|
\arrow["{¡}", from=1-4, to=3-4]
|
||||||
|
\arrow["{id \times ¡}"', from=1-2, to=3-2]
|
||||||
|
\arrow["{\tau^T}"', from=3-2, to=3-4]
|
||||||
|
\arrow["{id \times \eta}", curve={height=-12pt}, from=4-1, to=1-2]
|
||||||
|
\arrow["{\eta^T}"', curve={height=12pt}, from=4-1, to=3-4]
|
||||||
|
\end{tikzcd}
|
||||||
|
\]
|
||||||
|
commutes, since \( ¡ \circ \tau^K = \eta^T = \tau^T \circ (id \times \eta^T) = \tau^T \circ (id \times ¡) \circ (id \times \eta^T) \). Using \autoref{rem:proofbystability} we are done, since \(¡ \circ \tau^K\) and \(\tau^T \circ (id \times ¡)\) are both right iteration preserving for the reason that both are composed of (right) iteration preserving morphisms.
|
||||||
\end{proof}
|
\end{proof}
|
|
@ -1,31 +1,31 @@
|
||||||
\chapter{A Case Study on Setoids}\label{chp:setoids}
|
\chapter{A Case Study on Setoids}\label{chp:setoids}
|
||||||
|
|
||||||
In chapter~\ref{chp:partiality} we have argued that the delay monad is not an equational lifting monad, because it does not only model partiality, but it also respects computation time. One way to remedy this is to take the quotient of the delay monad where computations with the same result are identified. In this chapter we will use the quotients-as-setoid approach, i.e. we will work in the category of setoids and show that the quotiented delay monad is the initial pre-Elgot monad in this category.
|
In \autoref{chp:partiality} we have argued that the delay monad is not an equational lifting monad, because it does not only model partiality, but it also respects computation time. One way to remedy this is to take the quotient of the delay monad where computations with the same result are identified. In this chapter we will use the quotients-as-setoid approach, i.e. we will work in the category of setoids and show that the quotiented delay monad is the initial pre-Elgot monad in this category.
|
||||||
|
|
||||||
Let us introduce the category that we are working in:
|
Let us introduce the category that we are working in:
|
||||||
|
|
||||||
\section{Setoids in Type Theory}
|
\section{Setoids in Type Theory}
|
||||||
|
|
||||||
\begin{definition}[Setoid]
|
\begin{definition}[Setoid]
|
||||||
A setoid is a tuple $(A, \hat{=})$ where $A$ (usually called the \textit{carrier}) is a type and $\hat{=}$ an equivalence relation on the inhabitants of $A$.
|
A setoid is a tuple \((A, \hat{=})\) where \(A\) (usually called the \textit{carrier}) is a type and \(\hat{=}\) an equivalence relation on the inhabitants of \(A\).
|
||||||
\end{definition}
|
\end{definition}
|
||||||
|
|
||||||
Morphisms between setoids are functions that respect the equivalence relation:
|
Morphisms between setoids are functions that respect the equivalence relation.
|
||||||
|
|
||||||
\begin{definition}[Setoid Morphism]
|
\begin{definition}[Setoid Morphism]
|
||||||
A morphism between two setoids $(A , =^A)$ and $(B , =^B)$ is a function $f : A \rightarrow B$ such that $x =^A y$ implies $fx =^B fy$ for any $x, y : A$.
|
A morphism between two setoids \((A , =^A)\) and \((B , =^B)\) is a function \(f : A \rightarrow B\) such that \(x =^A y\) implies \(fx =^B fy\) for any \(x, y : A\).
|
||||||
\end{definition}
|
\end{definition}
|
||||||
|
|
||||||
Setoids and setoid morphisms form a category that we call $\setoids$.
|
Setoids and setoid morphisms form a category that we call \(\setoids\).
|
||||||
|
|
||||||
\improvement[inline]{Talk about equality between setoid morphisms}
|
\improvement[inline]{Talk about equality between setoid morphisms}
|
||||||
\improvement[inline]{Text is not good}
|
\improvement[inline]{Text is not good}
|
||||||
|
|
||||||
\begin{lemma}
|
\begin{lemma}
|
||||||
$\setoids$ is a distributive category.
|
\(\setoids\) is a distributive category.
|
||||||
\end{lemma}
|
\end{lemma}
|
||||||
\begin{proof}
|
\begin{proof}
|
||||||
To show that $\setoids$ is (co-)cartesian we will give the respective data types and unique morphisms, this also introduces notation we will use for the rest of the chapter. We will not include the proofs that the morphisms are setoid morphisms, these can be looked up in the Agda standard library.
|
To show that \(\setoids\) is (co-)cartesian we will give the respective data types and unique morphisms, this also introduces notation we will use for the rest of the chapter. We will not include the proofs that the morphisms are setoid morphisms, these can be looked up in the Agda standard library.
|
||||||
|
|
||||||
\begin{itemize}
|
\begin{itemize}
|
||||||
\item \textbf{Products}:
|
\item \textbf{Products}:
|
||||||
|
@ -68,7 +68,7 @@ Setoids and setoid morphisms form a category that we call $\setoids$.
|
||||||
\end{minted}
|
\end{minted}
|
||||||
\end{itemize}
|
\end{itemize}
|
||||||
|
|
||||||
Lastly we need to show that the canonical distributivity morphism is an iso. Recall that the canonical distributive morphism is defined as $dstl^{-1} = [ id \times i_1 , id \times i_2 ] : A \times B + A \times C \rightarrow A \times (B + C)$. This corresponds to the following definition using pattern matching:
|
Lastly we need to show that the canonical distributivity morphism is an iso. Recall that the canonical distributive morphism is defined as \(dstl^{-1} = [ id \times i_1 , id \times i_2 ] : A \times B + A \times C \rightarrow A \times (B + C)\). This corresponds to the following definition using pattern matching:
|
||||||
\begin{minted}{agda}
|
\begin{minted}{agda}
|
||||||
distributeˡ⁻¹ : ∀ {a b c} {A : Set a} {B : Set b} {C : Set c}
|
distributeˡ⁻¹ : ∀ {a b c} {A : Set a} {B : Set b} {C : Set c}
|
||||||
→ (A × B) + (A × C) → A × (B + C)
|
→ (A × B) + (A × C) → A × (B + C)
|
||||||
|
@ -86,11 +86,11 @@ Setoids and setoid morphisms form a category that we call $\setoids$.
|
||||||
\end{proof}
|
\end{proof}
|
||||||
|
|
||||||
\begin{lemma}
|
\begin{lemma}
|
||||||
$\setoids$ is cartesian closed.
|
\(\setoids\) is cartesian closed.
|
||||||
\end{lemma}
|
\end{lemma}
|
||||||
\begin{proof}
|
\begin{proof}
|
||||||
We have already shown that $\setoids$ is cartesian, we need to show that given two setoids $(A, =^A), (B, =^B)$ we can construct an exponential object.
|
We have already shown that \(\setoids\) is cartesian, we need to show that given two setoids \((A, =^A), (B, =^B)\) we can construct an exponential object.
|
||||||
Indeed, take the function space setoid $(A \rightarrow B, \doteq)$ where $\doteq$ is point wise equality of setoid morphisms i.e. $f , g : A \rightarrow B$ are point wise equal $f \doteq g$ \textit{iff} $f x =^B g x$ for any $x : A$. $curry$ and $eval$ are then defined as usual:
|
Indeed, take the function space setoid \((A \rightarrow B, \doteq)\) where \(\doteq\) is point wise equality of setoid morphisms i.e. \(f , g : A \rightarrow B\) are point wise equal \(f \doteq g\) \textit{iff} \(f x =^B g x\) for any \(x : A\). \(curry\) and \(eval\) are then defined as usual:
|
||||||
\begin{minted}{agda}
|
\begin{minted}{agda}
|
||||||
curry : ∀ {a b c} {A : Set a} {B : Set b} {C : Set c}
|
curry : ∀ {a b c} {A : Set a} {B : Set b} {C : Set c}
|
||||||
→ (C × A → B) → C → A → B
|
→ (C × A → B) → C → A → B
|
||||||
|
@ -103,9 +103,9 @@ Setoids and setoid morphisms form a category that we call $\setoids$.
|
||||||
|
|
||||||
\section{Quotienting the Delay Monad}
|
\section{Quotienting the Delay Monad}
|
||||||
% TODO merge this into introduction
|
% TODO merge this into introduction
|
||||||
% Chapman et al. have already proven that quotienting the delay datatype by weak bisimilarity using the quotients-as-setoids approach yields a monad~\cite{quotienting}, we will build upon their results and show that this quotient is indeed an instance of our monad $\mathbf{K}$.
|
% Chapman et al. have already proven that quotienting the delay datatype by weak bisimilarity using the quotients-as-setoids approach yields a monad~\cite{quotienting}, we will build upon their results and show that this quotient is indeed an instance of our monad \(\mathbf{K}\).
|
||||||
% Historically proof assistants like Agda and Coq have been offering multiple ways of defining coinductive types, nowadays the manuals of both Agda and Coq advise users to use coinductive records instead of defining coinductive types by constructors, we will heed this advice.
|
% Historically proof assistants like Agda and Coq have been offering multiple ways of defining coinductive types, nowadays the manuals of both Agda and Coq advise users to use coinductive records instead of defining coinductive types by constructors, we will heed this advice.
|
||||||
% Since the delay monad is usually defined by the constructors $now$ and $later$
|
% Since the delay monad is usually defined by the constructors \(now\) and \(later\)
|
||||||
|
|
||||||
Originally the delay monad has been introduced as a coinductive datatype with two constructors, in pseudo Agda like code this would look something like:
|
Originally the delay monad has been introduced as a coinductive datatype with two constructors, in pseudo Agda like code this would look something like:
|
||||||
\begin{minted}{agda}
|
\begin{minted}{agda}
|
||||||
|
@ -133,43 +133,43 @@ Here \Verb{Delay} is defined as an inductive datatype where the coinductive part
|
||||||
For the sake of readability we will introduce other concepts only by inference rules instead of Agda code, for the delay monad this looks like:
|
For the sake of readability we will introduce other concepts only by inference rules instead of Agda code, for the delay monad this looks like:
|
||||||
|
|
||||||
\[
|
\[
|
||||||
\inferrule*{x : A}{now\; x : Delay \;A} \hskip 1cm
|
\inferrule*{x : A}{now\; x : Delay \;A} \hskip 1cm
|
||||||
\inferrule*{x : Delay' \;A}{later \;x : Delay\; A} \hskip 1cm
|
\inferrule*{x : Delay' \;A}{later \;x : Delay\; A} \hskip 1cm
|
||||||
\mprset{fraction={===}}\inferrule*{x : Delay' \;A}{force \;x : Delay \;A}
|
\mprset{fraction={===}}\inferrule*{x : Delay' \;A}{force \;x : Delay \;A}
|
||||||
\]
|
\]
|
||||||
|
|
||||||
We will now introduce two notions of equality on inhabitants of the delay type, given a setoid $(A, =^A)$ we call the equivalence received by lifting $=^A$ to $Delay\;A$ \textit{strong bisimilarity}, the definition is as follows:
|
We will now introduce two notions of equality on inhabitants of the delay type, given a setoid \((A, =^A)\) we call the equivalence received by lifting \(=^A\) to \(Delay\;A\) \textit{strong bisimilarity}, the definition is as follows:
|
||||||
|
|
||||||
\[
|
\[
|
||||||
\inferrule*{eq : x =^A y}{now \;eq : x \sim y} \hskip 1cm
|
\inferrule*{eq : x =^A y}{now \;eq : x \sim y} \hskip 1cm
|
||||||
\inferrule*{eq : force \;x \sim' force\; y}{later\;eq : later\; x \sim later\; y} \hskip 1cm
|
\inferrule*{eq : force \;x \sim' force\; y}{later\;eq : later\; x \sim later\; y} \hskip 1cm
|
||||||
\mprset{fraction={===}}\inferrule*{eq : x \sim' y}{force\; eq : x \sim y}
|
\mprset{fraction={===}}\inferrule*{eq : x \sim' y}{force\; eq : x \sim y}
|
||||||
\]
|
\]
|
||||||
|
|
||||||
\begin{lemma}
|
\begin{lemma}
|
||||||
$(Delay\;A, \sim)$ is a setoid.
|
\((Delay\;A, \sim)\) is a setoid.
|
||||||
\end{lemma}
|
\end{lemma}
|
||||||
|
|
||||||
In $(Delay\;A, \sim)$ computations that evaluate to the same result but in a different amount of time are not equal. We will now build the quotient of this type by weak bisimilarity, i.e. we will identify all computations that terminate with the same result. Let us first consider what it means for a computation to evaluate to some result:
|
In \((Delay\;A, \sim)\) computations that evaluate to the same result but in a different amount of time are not equal. We will now build the quotient of this type by weak bisimilarity, i.e. we will identify all computations that terminate with the same result. Let us first consider what it means for a computation to evaluate to some result:
|
||||||
|
|
||||||
\[
|
\[
|
||||||
\inferrule*{eq : x =^A y}{now\; eq : now\;x \downarrow y} \hskip 1cm
|
\inferrule*{eq : x =^A y}{now\; eq : now\;x \downarrow y} \hskip 1cm
|
||||||
\inferrule*{d : force\;x \downarrow c}{later\;d : later\;x \downarrow c }
|
\inferrule*{d : force\;x \downarrow c}{later\;d : later\;x \downarrow c }
|
||||||
\]
|
\]
|
||||||
|
|
||||||
Now we can relate two computations \textit{iff} they evaluate to the same result:
|
Now we can relate two computations \textit{iff} they evaluate to the same result:
|
||||||
\[
|
\[
|
||||||
\inferrule*{eq : a =^A b \\ xa : x \downarrow a \\ yb : y \downarrow b}{\downarrow\approx \; eq \; xa \; yb : x \approx y} \hskip 1cm
|
\inferrule*{eq : a =^A b \\ xa : x \downarrow a \\ yb : y \downarrow b}{\downarrow\approx \; eq \; xa \; yb : x \approx y} \hskip 1cm
|
||||||
\inferrule*{eq : force \;x \approx' force \;y}{later\;eq : later \;x \approx later \;y} \hskip 1cm
|
\inferrule*{eq : force \;x \approx' force \;y}{later\;eq : later \;x \approx later \;y} \hskip 1cm
|
||||||
\mprset{fraction={===}}\inferrule*{eq : x \approx' y}{force\;eq : x \approx y}
|
\mprset{fraction={===}}\inferrule*{eq : x \approx' y}{force\;eq : x \approx y}
|
||||||
\]
|
\]
|
||||||
|
|
||||||
\begin{lemma}
|
\begin{lemma}
|
||||||
$(Delay\;A, \approx)$ is a setoid.
|
\((Delay\;A, \approx)\) is a setoid.
|
||||||
\end{lemma}
|
\end{lemma}
|
||||||
|
|
||||||
\begin{theorem}
|
\begin{theorem}
|
||||||
$(Delay\;A, \approx)$ is a monad.
|
\((Delay\;A, \approx)\) is a monad.
|
||||||
\end{theorem}
|
\end{theorem}
|
||||||
\begin{proof}
|
\begin{proof}
|
||||||
The monad unit is the constructor \Verb{now} and monad multiplication can be defined as follows:
|
The monad unit is the constructor \Verb{now} and monad multiplication can be defined as follows:
|
||||||
|
@ -186,50 +186,50 @@ Now we can relate two computations \textit{iff} they evaluate to the same result
|
||||||
\end{proof}
|
\end{proof}
|
||||||
|
|
||||||
\begin{theorem}
|
\begin{theorem}
|
||||||
$(Delay\;A , \approx)$ is an instance of $\mathbf{K}$ in the category $\setoids$.
|
\((Delay\;A , \approx)\) is an instance of \(\mathbf{K}\) in the category \(\setoids\).
|
||||||
\end{theorem}
|
\end{theorem}
|
||||||
\begin{proof}
|
\begin{proof}
|
||||||
We need to show that for every setoid $(A, =^A)$ the resulting setoid $(Delay\;A, \approx)$ can be extended to a stable free Elgot algebra.
|
We need to show that for every setoid \((A, =^A)\) the resulting setoid \((Delay\;A, \approx)\) can be extended to a stable free Elgot algebra.
|
||||||
Stability follows automatically by theorem~\ref{thm:stability} and the fact that $\setoids$ is cartesian closed, so it suffices to define a free Elgot Algebra on $(Delay\;A, \approx)$.
|
Stability follows automatically by theorem~\ref{thm:stability} and the fact that \(\setoids\) is cartesian closed, so it suffices to define a free Elgot Algebra on \((Delay\;A, \approx)\).
|
||||||
|
|
||||||
Let $(X , =^X) \in \obj{\setoids}$ and $f : X \rightarrow Delay\; A + X$ be a setoid morphism, we define $f^\# : X \rightarrow Delay\;A$ point wise:
|
Let \((X , =^X) \in \obj{\setoids}\) and \(f : X \rightarrow Delay\; A + X\) be a setoid morphism, we define \(f^\# : X \rightarrow Delay\;A\) point wise:
|
||||||
\[
|
\[
|
||||||
f^\# (x) :=
|
f^\# (x) :=
|
||||||
\begin{cases}
|
\begin{cases}
|
||||||
a & \text{if } f\;x = i_1 (a)\\
|
a & \text{if } f\;x = i_1 (a) \\
|
||||||
later\;(f^{\#'} a) & \text{if } f\;x = i_2 (a)
|
later\;(f^{\#'} a) & \text{if } f\;x = i_2 (a)
|
||||||
\end{cases}
|
\end{cases}
|
||||||
\]
|
\]
|
||||||
where $f^{\#'} : X \rightarrow Delay'\;A$ is defined corecursively by:
|
where \(f^{\#'} : X \rightarrow Delay'\;A\) is defined corecursively by:
|
||||||
\[
|
\[
|
||||||
force (f^{\#'}(x)) = f^\#(x)
|
force (f^{\#'}(x)) = f^\#(x)
|
||||||
\]
|
\]
|
||||||
|
|
||||||
Let us first show that $f^\#$ is a setoid morphism, i.e. given $x, y : X$ with $x =^X y$, we need to show that $f^\#(x) = f^\#(y)$. Since $f$ is a setoid morphism we know that $f(x) =^+ f(y)$ in the coproduct setoid $(Delay\;A + X, =^+)$. We proceed by case distinction on $f(x)$:
|
Let us first show that \(f^\#\) is a setoid morphism, i.e. given \(x, y : X\) with \(x =^X y\), we need to show that \(f^\#(x) = f^\#(y)\). Since \(f\) is a setoid morphism we know that \(f(x) =^+ f(y)\) in the coproduct setoid \((Delay\;A + X, =^+)\). We proceed by case distinction on \(f(x)\):
|
||||||
|
|
||||||
\begin{itemize}
|
\begin{itemize}
|
||||||
\item Case $f(x) = i_1 (a)$:
|
\item Case \(f(x) = i_1 (a)\):
|
||||||
\[f^\# (x) = a = f^\#(y)\]
|
\[f^\# (x) = a = f^\#(y)\]
|
||||||
|
|
||||||
\item Case $f(x) = i_2 (a)$:
|
\item Case \(f(x) = i_2 (a)\):
|
||||||
\[f^\# (x) = later (f^{\#'}(a)) = f^\# (y)\]
|
\[f^\# (x) = later (f^{\#'}(a)) = f^\# (y)\]
|
||||||
\end{itemize}
|
\end{itemize}
|
||||||
|
|
||||||
Now we check the iteration laws:
|
Now we check the iteration laws:
|
||||||
|
|
||||||
\change[inline]{change the equivalence sign of coproducts}
|
\change[inline]{change the equivalence sign of coproducts}
|
||||||
|
|
||||||
\begin{itemize}
|
\begin{itemize}
|
||||||
\item \textbf{Fixpoint}: We need to show that $f^\# (x) \approx ([ id , f^\# ] \circ f)(x)$:
|
\item \textbf{Fixpoint}: We need to show that \(f^\# (x) \approx ([ id , f^\# ] \circ f)(x)\):
|
||||||
|
|
||||||
\begin{itemize}
|
\begin{itemize}
|
||||||
\item Case $f(x) =^+ i_1 (a)$:
|
\item Case \(f(x) =^+ i_1 (a)\):
|
||||||
\[ f^\#(x) \approx a \approx [ id , f^\# ] (i_1 (a)) = ([ id , f^\# ] \circ f) (x) \]
|
\[ f^\#(x) \approx a \approx [ id , f^\# ] (i_1 (a)) = ([ id , f^\# ] \circ f) (x) \]
|
||||||
\item Case $f(x) =^+ i_2 (a)$:
|
\item Case \(f(x) =^+ i_2 (a)\):
|
||||||
\[ f^\#(x) \approx later (f^{\#'}(a)) \overset{(*)}{\approx} f^\#(a) \approx [ id , f^\# ] (i_2 (a)) \approx ([ id , f^\# ] \circ f) (x)\]
|
\[ f^\#(x) \approx later (f^{\#'}(a)) \overset{(*)}{\approx} f^\#(a) \approx [ id , f^\# ] (i_2 (a)) \approx ([ id , f^\# ] \circ f) (x)\]
|
||||||
\end{itemize}
|
\end{itemize}
|
||||||
where $(*)$ follows from a general fact: any $z : Delay'\;A$ satisfies $force\;z \approx later\;z$.
|
where \((*)\) follows from a general fact: any \(z : Delay'\;A\) satisfies \(force\;z \approx later\;z\).
|
||||||
\item \textbf{Uniformity}: Let $(Y , =^Y) \in \setoids$ and $g : Y \rightarrow Delay\; A + Y, h : X \rightarrow Y$ be setoid morphisms with $(id + h) \circ f = g \circ h$.
|
\item \textbf{Uniformity}: Let \((Y , =^Y) \in \setoids\) and \(g : Y \rightarrow Delay\; A + Y, h : X \rightarrow Y\) be setoid morphisms with \((id + h) \circ f = g \circ h\).
|
||||||
\item \textbf{Folding}:
|
\item \textbf{Folding}:
|
||||||
\end{itemize}
|
\end{itemize}
|
||||||
|
|
||||||
|
|
|
@ -1,129 +0,0 @@
|
||||||
\chapter{Some Introduction and Examples}
|
|
||||||
You can freely use the present template for your final thesis (i.e.~master or
|
|
||||||
bachelor or project thesis).
|
|
||||||
|
|
||||||
This template was made from the following theses:
|
|
||||||
\begin{itemize}
|
|
||||||
\item \url{http://thorsten-wissmann.de/theses/ma-wissmann.pdf}
|
|
||||||
\item \url{http://thorsten-wissmann.de/theses/project-wissmann.pdf}
|
|
||||||
\item \url{http://thorsten-wissmann.de/theses/bachelor-thesis-wissmann.pdf}
|
|
||||||
\end{itemize}
|
|
||||||
|
|
||||||
\section{Meaning}
|
|
||||||
It is not mandatory at all to use this template for your final thesis. It is
|
|
||||||
just a suggestion! You are also allowed to change anything you would like to
|
|
||||||
change in order to fit your needs/taste/$\ldots$.
|
|
||||||
|
|
||||||
Of course, you should adjust some places when using it for your final thesis:
|
|
||||||
\begin{enumerate}
|
|
||||||
\item In the parameters to the \texttt{hyperref}-package, you should adjust the
|
|
||||||
fields \texttt{pdfauthor} and \texttt{pdftitle} to your name and the title of
|
|
||||||
your thesis.
|
|
||||||
|
|
||||||
\item In \texttt{src/titlepage.tex} you should adjust the title and (possibly
|
|
||||||
the) subtitle of your thesis, the degree of your thesis (Masters degree?
|
|
||||||
Bachelor?), your name and the name of your advisors.
|
|
||||||
|
|
||||||
\end{enumerate}
|
|
||||||
|
|
||||||
\section{Some hints}
|
|
||||||
\subsection{Macros}
|
|
||||||
|
|
||||||
% some macros only needed for these hints here
|
|
||||||
\newcommand{\C}{\ensuremath{\mathcal{C}}\xspace}
|
|
||||||
\newcommand{\preview}[2]{
|
|
||||||
\begin{center}
|
|
||||||
\fbox{\begin{minipage}[t]{.47\textwidth}
|
|
||||||
#1
|
|
||||||
\end{minipage}}%
|
|
||||||
\hspace{.02\textwidth}%
|
|
||||||
\fbox{\begin{minipage}[t]{.47\textwidth}
|
|
||||||
#2
|
|
||||||
\end{minipage}}%
|
|
||||||
\end{center}}
|
|
||||||
|
|
||||||
When using certain mathematical symbols very often, it makes sense to define
|
|
||||||
macros for them, e.g.~
|
|
||||||
\begin{verbatim}
|
|
||||||
\newcommand{\C}{\ensuremath{\mathcal{C}}\xspace}
|
|
||||||
\end{verbatim}
|
|
||||||
The \texttt{ensuremath} enforces mathmode and the \texttt{xspace} inserts a
|
|
||||||
space if necessary:
|
|
||||||
\preview{
|
|
||||||
\Verb|Some \textbackslash C in the midle of the sentence|
|
|
||||||
\Verb|and at the end: \textbackslash C.|
|
|
||||||
}{
|
|
||||||
Some \C in the midle of the sentence
|
|
||||||
and at the end: \C.
|
|
||||||
}
|
|
||||||
|
|
||||||
\subsection{UTF-8}
|
|
||||||
|
|
||||||
I strongly recommend exploiting the utf8 capability of \LaTeX:
|
|
||||||
|
|
||||||
\begin{verbatim}
|
|
||||||
\usepackage{newunicodechar}
|
|
||||||
\newunicodechar{∀}{\ensuremath{\forall}}
|
|
||||||
\newunicodechar{∃}{\ensuremath{\exists}}
|
|
||||||
\newunicodechar{×}{\ensuremath{\times}}
|
|
||||||
\newunicodechar{ø}{\ensuremath{\emptyset}}
|
|
||||||
\newunicodechar{≤}{\ensuremath{\le}}
|
|
||||||
\newunicodechar{∈}{\ensuremath{\in}}
|
|
||||||
\newunicodechar{→}{\ensuremath{\to}}
|
|
||||||
\newunicodechar{⊆}{\ensuremath{\subseteq}}
|
|
||||||
\newunicodechar{⊗}{\ensuremath{\otimes}}
|
|
||||||
\newunicodechar{∧}{\ensuremath{\wedge}}
|
|
||||||
\end{verbatim}
|
|
||||||
|
|
||||||
with that, you can write:
|
|
||||||
\begin{verbatim}
|
|
||||||
\begin{definition}[Transitivity]
|
|
||||||
A relation $\text{``}≤\text{''} ⊆ X×X$ has upper bounds if
|
|
||||||
\[
|
|
||||||
∀a,b ∈ X\ ∃ c ∈ X: a ≤ c ∧ b ≤ c
|
|
||||||
\]
|
|
||||||
\end{definition}
|
|
||||||
\end{verbatim}
|
|
||||||
|
|
||||||
It will result in the following:
|
|
||||||
|
|
||||||
\begin{definition}[Transitivity]
|
|
||||||
A relation $\text{``}≤\text{''} ⊆ X×X$ has upper bounds if
|
|
||||||
\[
|
|
||||||
∀a,b ∈ X\ ∃ c ∈ X: a ≤ c ∧ b ≤ c
|
|
||||||
\]
|
|
||||||
\end{definition}
|
|
||||||
|
|
||||||
In order to input unicode characters, just configure a compose key, e.g.:
|
|
||||||
\begin{itemize}
|
|
||||||
\item \url{https://en.wikipedia.org/wiki/Compose_key}
|
|
||||||
\item
|
|
||||||
\url{https://wiki.archlinux.org/index.php/Keyboard_configuration_in_Xorg#Configuring_compose_key}
|
|
||||||
|
|
||||||
\end{itemize}
|
|
||||||
|
|
||||||
\subsection{Autoref}
|
|
||||||
|
|
||||||
Let \LaTeX~include whether something references is a definition or what else
|
|
||||||
using the \texttt{\textbackslash autoref} command:
|
|
||||||
|
|
||||||
\begin{verbatim}
|
|
||||||
\begin{definition}[label={relation},name={Relation}]
|
|
||||||
A relation $R$ between sets $X$ and $Y$ is just a subset of $X×Y$.
|
|
||||||
\end{definition}
|
|
||||||
We have just seen \autoref{relation}.
|
|
||||||
\end{verbatim}
|
|
||||||
|
|
||||||
This results in:
|
|
||||||
|
|
||||||
|
|
||||||
\begin{definition}[label={relation},name={Relation}]
|
|
||||||
A relation $R$ between sets $X$ and $Y$ is just a subset of $X×Y$.
|
|
||||||
\end{definition}
|
|
||||||
We have just seen \autoref{relation}.
|
|
||||||
|
|
||||||
\subsection{Further Comments}
|
|
||||||
For even more convenience while writing, you should look at the following:
|
|
||||||
synctex, git (for managing your \TeX-sources).
|
|
||||||
|
|
||||||
% vim: tw=80 nospell spelllang=en nocul
|
|
Loading…
Reference in a new issue