mirror of
https://git8.cs.fau.de/theses/bsc-leon-vatthauer.git
synced 2024-05-31 07:28:34 +02:00
103 lines
No EOL
3.6 KiB
TeX
103 lines
No EOL
3.6 KiB
TeX
\section{Categorical Notions of Partiality}
|
|
|
|
\begin{frame}[t, fragile]{Capturing Partiality Categorically}{Moggi's categorical semantics~\cite{moggi}}
|
|
Goal: interpret an effectul programming language in a category $\mathcal{C}$
|
|
|
|
\begin{itemize}
|
|
\item<2-> Take a Monad $T$ on $\mathcal{C}$, then values are denoted by objects $A$ and programs by $TA$
|
|
\item<3-> Programs form a category $\mathcal{C}_T$ with $\mathcal{C}_T(X,Y) := \mathcal{C}(X, TY)$
|
|
\end{itemize}
|
|
|
|
\onslide<4->
|
|
What properties should a partiality monad $T$ have?
|
|
|
|
\begin{enumerate}
|
|
\item<5-> Commutativity (also entails strength), i.e. the following programs should yield equal results:
|
|
\begin{multicols}{2}
|
|
\begin{minted}{haskell}
|
|
do x <- p
|
|
y <- q
|
|
return (x, y)
|
|
\end{minted}
|
|
|
|
\begin{minted}{haskell}
|
|
do y <- q
|
|
x <- p
|
|
return (x, y)
|
|
\end{minted}
|
|
\end{multicols}
|
|
where p and q are programs.
|
|
\item<6-> Morphisms in $\mathcal{C}_T$ should be partial maps (How?)
|
|
\end{enumerate}
|
|
|
|
\end{frame}
|
|
|
|
\newcommand{\tdom}{\text{dom}}
|
|
|
|
\begin{frame}[t, fragile]{Capturing Partiality Categorically}{Restriction Categories~\cite{restriction}}
|
|
\begin{definition}<1->
|
|
A restriction structure on $\mathcal{C}$ is a mapping $\tdom : \mathcal{C}(X,Y) \rightarrow \mathcal{C}(X,X)$ with the following properties:
|
|
\begin{alignat}{1}
|
|
f \circ (\tdom f) &= f\\
|
|
(\tdom f) \circ (\tdom g) &= (\tdom g) \circ (\tdom f)\\
|
|
\tdom(g \circ (\tdom f)) &= (\tdom g) \circ (\tdom f)\\
|
|
(\tdom h) \circ f &= f \circ \tdom (h \circ f)
|
|
\end{alignat}
|
|
for any $X, Y, Z \in \vert\mathcal{C}\vert, f : X \rightarrow KY, g : X \rightarrow KZ, h: Y \rightarrow KZ$.
|
|
\end{definition}
|
|
|
|
Intuitively $\tdom f$ captures the domain of definiteness of $f$.
|
|
|
|
\begin{block}{Remark}<2->
|
|
Every category has a trivial restriction structure $\tdom f = id$, we call categories with a non-trivial restriction structure \textit{restriction categories}.
|
|
\end{block}
|
|
\end{frame}
|
|
|
|
\begin{frame}[t, fragile]{Capturing Partiality Categorically}{Equational Lifting Monads~\cite{eqlm}}
|
|
The following criterion is sufficient for guaranteeing that the kleisli category is a restriction category:
|
|
\begin{definition}
|
|
A commutative monad $T$ is called an \textit{equational lifting monad} if the following diagram commutes:
|
|
|
|
% https://q.uiver.app/#q=WzAsMyxbMCwwLCJUWCJdLFsyLDAsIlRYIFxcdGltZXMgVFgiXSxbMiwyLCJUKFRYIFxcdGltZXMgWCkiXSxbMCwxLCJcXERlbHRhIl0sWzEsMiwiXFx0YXUiXSxbMCwyLCJUIFxcbGFuZ2xlIFxcZXRhICwgaWQgXFxyYW5nbGUiLDJdXQ==
|
|
\[\begin{tikzcd}
|
|
TX && {TX \times TX} \\
|
|
\\
|
|
&& {T(TX \times X)}
|
|
\arrow["\Delta", from=1-1, to=1-3]
|
|
\arrow["\tau", from=1-3, to=3-3]
|
|
\arrow["{T \langle \eta , id \rangle}"', from=1-1, to=3-3]
|
|
\end{tikzcd}\]
|
|
\end{definition}
|
|
\pause
|
|
\begin{theorem}
|
|
The Kleisli category of an equational lifting monad is a restriction category.
|
|
\end{theorem}
|
|
\end{frame}
|
|
|
|
% TODO is the maybe monad an equational lifting monad? Ask sergey
|
|
|
|
\begin{frame}[t, fragile]{The Maybe Monad}
|
|
\begin{itemize}
|
|
\item Short definition
|
|
\item is equational lifting monad
|
|
\end{itemize}
|
|
\end{frame}
|
|
|
|
% TODO is delay equational lifting?? maybe rethink the story here...
|
|
|
|
\begin{frame}[t, fragile]{The Delay Monad}
|
|
\begin{itemize}
|
|
\item Definition
|
|
\item Strong-Bisimilarity
|
|
\item Weak-Bisimilarity (Monad?)
|
|
\end{itemize}
|
|
\end{frame}
|
|
|
|
\begin{frame}[t, fragile]{Iteration}
|
|
\begin{itemize}
|
|
\item Elgot-Algebras
|
|
\item Free Elgot-Algebras yield monad K
|
|
\item K is equational lifting
|
|
\item K instantiates to maybe and delay
|
|
\end{itemize}
|
|
\end{frame} |