mirror of
https://git8.cs.fau.de/theses/bsc-leon-vatthauer.git
synced 2024-05-31 07:28:34 +02:00
82 lines
No EOL
6.3 KiB
Markdown
82 lines
No EOL
6.3 KiB
Markdown
<!--
|
|
<pre class="Agda"><a id="14" class="Symbol">{-#</a> <a id="18" class="Keyword">OPTIONS</a> <a id="26" class="Pragma">--guardedness</a> <a id="40" class="Symbol">#-}</a>
|
|
</pre>-->
|
|
|
|
# Implementing Categorical Notions of Partiality and Delay in Agda
|
|
|
|
To see a full list of all the modules go to:
|
|
|
|
<pre class="Agda"><a id="175" class="Keyword">open</a> <a id="180" class="Keyword">import</a> <a id="187" href="Everything.html" class="Module">Everything</a>
|
|
</pre>
|
|
For my bachelor thesis I am implementing categorical notions of partiality in agda using the *agda-categories* library. The repo for this project can be found [here](https://git8.cs.fau.de/theses/bsc-leon-vatthauer).
|
|
This is an implementation of this paper by Sergey Goncharov: [arxiv](https://arxiv.org/abs/2102.11828)
|
|
|
|
## Index
|
|
|
|
### Preliminaries
|
|
|
|
The work takes place in an ambient category that fits our needs:
|
|
|
|
<pre class="Agda"><a id="627" class="Keyword">open</a> <a id="632" class="Keyword">import</a> <a id="639" href="Category.Ambient.html" class="Module">Category.Ambient</a> <a id="656" class="Keyword">using</a> <a id="662" class="Symbol">(</a><a id="663" href="Category.Ambient.html#1681" class="Record">Ambient</a><a id="670" class="Symbol">)</a>
|
|
</pre>
|
|
### Delay Monad
|
|
|
|
We start out by formalizing Capretta's *Delay Monad* in a categorical setting and then proving that it is strong and commutative.
|
|
|
|
<pre class="Agda"><a id="833" class="Keyword">open</a> <a id="838" class="Keyword">import</a> <a id="845" href="Monad.Instance.Delay.html" class="Module">Monad.Instance.Delay</a>
|
|
<a id="866" class="Keyword">open</a> <a id="871" class="Keyword">import</a> <a id="878" href="Monad.Instance.Delay.Strong.html" class="Module">Monad.Instance.Delay.Strong</a>
|
|
<a id="906" class="Keyword">open</a> <a id="911" class="Keyword">import</a> <a id="918" href="Monad.Instance.Delay.Commutative.html" class="Module">Monad.Instance.Delay.Commutative</a>
|
|
</pre>
|
|
The next step is to quotient the delay monad by weak bisimilarity, but this quotiented structure is not monadic, so we postulate conditions under which it extends to a monad.
|
|
|
|
<pre class="Agda"><a id="1140" class="Keyword">open</a> <a id="1145" class="Keyword">import</a> <a id="1152" href="Monad.Instance.Delay.Quotienting.html" class="Module">Monad.Instance.Delay.Quotienting</a>
|
|
</pre>
|
|
### Monad K
|
|
|
|
The goal of this last section is to formalize an equational lifting monad **K** that generalizes both the maybe monad and the delay monad.
|
|
|
|
To do so we first need to look at iteration structures, i.e. functor algebras with an iteration operator, these are called *Elgot Algebras*.
|
|
|
|
<pre class="Agda"><a id="1493" class="Keyword">open</a> <a id="1498" class="Keyword">import</a> <a id="1505" href="Algebra.Elgot.html" class="Module">Algebra.Elgot</a>
|
|
</pre>
|
|
Afterwards we also introduce categories of iteration algebras with iteration preserving morphisms:
|
|
|
|
<pre class="Agda"><a id="1632" class="Keyword">open</a> <a id="1637" class="Keyword">import</a> <a id="1644" href="Category.Construction.ElgotAlgebras.html" class="Module">Category.Construction.ElgotAlgebras</a>
|
|
</pre>
|
|
Free Elgot algebras are free objects in the category of Elgot algebras, we will be needing a notion of stability for them:
|
|
|
|
<pre class="Agda"><a id="1817" class="Keyword">open</a> <a id="1822" class="Keyword">import</a> <a id="1829" href="Algebra.Elgot.Free.html" class="Module">Algebra.Elgot.Free</a>
|
|
<a id="1848" class="Keyword">open</a> <a id="1853" class="Keyword">import</a> <a id="1860" href="Algebra.Elgot.Stable.html" class="Module">Algebra.Elgot.Stable</a>
|
|
</pre>
|
|
In a CCC stability follows directly
|
|
<pre class="Agda"><a id="1930" class="Keyword">open</a> <a id="1935" class="Keyword">import</a> <a id="1942" href="Algebra.Elgot.Properties.html" class="Module">Algebra.Elgot.Properties</a>
|
|
</pre>
|
|
With this in hand we can now define *KX* as a *free Elgot algebra* and proof that under *stability* it is a strong monad.
|
|
|
|
<pre class="Agda"><a id="2104" class="Keyword">open</a> <a id="2109" class="Keyword">import</a> <a id="2116" href="Monad.Instance.K.html" class="Module">Monad.Instance.K</a>
|
|
<a id="2133" class="Keyword">open</a> <a id="2138" class="Keyword">import</a> <a id="2145" href="Monad.Instance.K.Strong.html" class="Module">Monad.Instance.K.Strong</a>
|
|
</pre>
|
|
and with this we can show that K is and equational lifting monad, i.e. a commutative monad satisfying the equational lifting law:
|
|
|
|
<pre class="Agda"><a id="2313" class="Keyword">open</a> <a id="2318" class="Keyword">import</a> <a id="2325" href="Monad.Instance.K.Commutative.html" class="Module">Monad.Instance.K.Commutative</a>
|
|
<a id="2354" class="Keyword">open</a> <a id="2359" class="Keyword">import</a> <a id="2366" href="Monad.Instance.K.EquationalLifting.html" class="Module">Monad.Instance.K.EquationalLifting</a>
|
|
</pre>
|
|
and lastly we formalize the notion of *pre-Elgot monad* and show that **K** is the initial (strong) pre-Elgot monad.
|
|
|
|
<pre class="Agda"><a id="2532" class="Keyword">open</a> <a id="2537" class="Keyword">import</a> <a id="2544" href="Monad.PreElgot.html" class="Module">Monad.PreElgot</a>
|
|
<a id="2559" class="Keyword">open</a> <a id="2564" class="Keyword">import</a> <a id="2571" href="Category.Construction.PreElgotMonads.html" class="Module">Category.Construction.PreElgotMonads</a>
|
|
<a id="2608" class="Keyword">open</a> <a id="2613" class="Keyword">import</a> <a id="2620" href="Category.Construction.StrongPreElgotMonads.html" class="Module">Category.Construction.StrongPreElgotMonads</a>
|
|
<a id="2663" class="Keyword">open</a> <a id="2668" class="Keyword">import</a> <a id="2675" href="Monad.Instance.K.PreElgot.html" class="Module">Monad.Instance.K.PreElgot</a>
|
|
<a id="2701" class="Keyword">open</a> <a id="2706" class="Keyword">import</a> <a id="2713" href="Monad.Instance.K.StrongPreElgot.html" class="Module">Monad.Instance.K.StrongPreElgot</a>
|
|
</pre>
|
|
### A case study on setoids
|
|
Lastly we do a case study on the category of setoids.
|
|
|
|
First we look at the (quotiented delay monad) on setoids:
|
|
|
|
<pre class="Agda"><a id="2900" class="Keyword">open</a> <a id="2905" class="Keyword">import</a> <a id="2912" href="Monad.Instance.Setoids.Delay.html" class="Module">Monad.Instance.Setoids.Delay</a>
|
|
</pre>
|
|
and then we show that it is an instance of K on setoids:
|
|
|
|
<pre class="Agda"><a id="3012" class="Keyword">open</a> <a id="3017" class="Keyword">import</a> <a id="3024" href="Monad.Instance.Setoids.K.html" class="Module">Monad.Instance.Setoids.K</a>
|
|
</pre> |