1
0
mirror of https://github.com/dhil/phd-dissertation synced 2026-03-13 11:08:25 +00:00

On tracking divergence.

This commit is contained in:
2020-01-28 20:21:22 +00:00
parent 11ade6aac3
commit f673ff3ba8

View File

@@ -1178,6 +1178,27 @@ progress theorem as some programs may now diverge.
\subsection{Tracking divergence via the effect system}
\label{sec:tracking-div}
%
With the $\Rec$-operator in \BCalcRec{} we can now implement the
customary factorial function.
%
\[
\bl
\dec{fac} : \Int \to \Int \eff \{\varepsilon\}\\
\dec{fac} \defas \Rec\;f~n.
\ba[t]{@{}l}
\Let\;is\_zero \revto n = 0\;\In\\
\If\;is\_zero\;\Then\; \Return\;1\\
\Else\;\Let\; n' \revto n - 1 \;\In\;f~n'
\ea
\el
\]
%
The $\dec{fac}$ function computes $n!$ for any non-negative integer
$n$. If $n$ is negative then $\dec{fac}$ diverges as the function will
repeatedly select the $\Else$-branch in the conditional
expression. Thus this function is not total on its domain. Yet the
effect signature tells us nothing about the potential divergence.
\section{Row polymorphism}
\label{sec:row-polymorphism}