2018-05-07 22:25:34 +00:00
|
|
|
|
\chapter{Perspectives}
|
|
|
|
|
\section{Discussion}
|
2018-05-23 15:34:50 +00:00
|
|
|
|
In the previous chapter the practical aspects of proving things in
|
2018-05-29 13:09:38 +00:00
|
|
|
|
Cubical Agda were highlighted. I also demonstrated the usefulness of
|
|
|
|
|
separating ``laws'' from ``data''. One of the reasons for this is that
|
|
|
|
|
dependencies within types can lead to very complicated goals. One
|
2018-05-23 15:34:50 +00:00
|
|
|
|
technique for alleviating this was to prove that certain types are
|
|
|
|
|
mere propositions.
|
2018-05-07 22:25:34 +00:00
|
|
|
|
|
|
|
|
|
\subsection{Computational properties}
|
2018-05-23 15:34:50 +00:00
|
|
|
|
The new contribution of cubical Agda is that it has a constructive
|
|
|
|
|
proof of functional extensionality\index{functional extensionality}
|
2018-07-17 14:51:16 +00:00
|
|
|
|
and univalence\index{univalence}. This means in particular that the
|
|
|
|
|
type checker can reduce terms defined with these theorems. One
|
2018-05-23 15:34:50 +00:00
|
|
|
|
interesting result of this development is how much this influenced the
|
2018-05-29 13:09:38 +00:00
|
|
|
|
development. In particular having a functional extensionality that
|
2018-05-23 15:34:50 +00:00
|
|
|
|
``computes'' should simplify some proofs.
|
2018-05-07 22:25:34 +00:00
|
|
|
|
|
2018-05-29 13:09:38 +00:00
|
|
|
|
I have tested this by using a feature of Agda where one can mark
|
|
|
|
|
certain bindings as being \emph{abstract}. This means that the
|
|
|
|
|
type-checker will not try to reduce that term further during type
|
|
|
|
|
checking. I tried making univalence and functional extensionality
|
|
|
|
|
abstract. It turns out that the conversion behaviour of univalence is
|
|
|
|
|
not used anywhere. For functional extensionality there are two places
|
|
|
|
|
in the whole solution where the reduction behaviour is used to
|
|
|
|
|
simplify some proofs. This is in showing that the maps between the
|
|
|
|
|
two formulations of monads are inverses. See the notes in this
|
2018-05-23 15:34:50 +00:00
|
|
|
|
module:
|
|
|
|
|
%
|
|
|
|
|
\begin{center}
|
|
|
|
|
\sourcelink{Cat.Category.Monad.Voevodsky}
|
|
|
|
|
\end{center}
|
|
|
|
|
%
|
2018-05-29 13:09:38 +00:00
|
|
|
|
|
|
|
|
|
I will not reproduce it in full here as the type is quite involved. In
|
2018-07-17 14:51:16 +00:00
|
|
|
|
stead I have put this in a source listing in
|
|
|
|
|
\ref{app:abstract-funext}. The method used to find in what places the
|
|
|
|
|
computational behaviour of these proofs are needed has the caveat of
|
|
|
|
|
only working for places that directly or transitively uses these two
|
|
|
|
|
proofs. Fortunately though the code is structured in such a way that
|
|
|
|
|
this is the case. In conclusion the way I have structured these proofs
|
|
|
|
|
means that the computational behaviour of functional extensionality
|
|
|
|
|
and univalence has not been so relevant.
|
2018-05-07 22:25:34 +00:00
|
|
|
|
|
2018-05-29 13:09:38 +00:00
|
|
|
|
Barring this the computational behaviour of paths can still be useful.
|
|
|
|
|
E.g.\ if a programmer wants to reuse functions that operate on a
|
|
|
|
|
monoidal monads to work with a monad in the Kleisli form that the
|
|
|
|
|
programmer has specified. To make this idea concrete, say we are
|
2018-07-17 14:51:16 +00:00
|
|
|
|
given some function $f \tp \Kleisli \to T$, having a path between $p
|
2018-05-23 15:34:50 +00:00
|
|
|
|
\tp \Monoidal \equiv \Kleisli$ induces a map $\coe\ p \tp \Monoidal
|
2018-05-29 13:09:38 +00:00
|
|
|
|
\to \Kleisli$. We can compose $f$ with this map to get $f \comp
|
|
|
|
|
\coe\ p \tp \Monoidal \to T$. Of course, since that map was
|
2018-07-17 14:51:16 +00:00
|
|
|
|
constructed with an isomorphism, these maps already exist and could be
|
2018-05-29 13:09:38 +00:00
|
|
|
|
used directly. So this is arguably only interesting when one also
|
|
|
|
|
wants to prove properties of applying such functions.
|
2018-05-07 22:25:34 +00:00
|
|
|
|
|
|
|
|
|
\subsection{Reusability of proofs}
|
2018-05-23 15:34:50 +00:00
|
|
|
|
The previous example illustrate how univalence unifies two otherwise
|
|
|
|
|
disparate areas: The category-theoretic study of monads; and monads as
|
2018-05-29 13:09:38 +00:00
|
|
|
|
in functional programming. Univalence thus allows one to reuse proofs.
|
2018-05-23 15:34:50 +00:00
|
|
|
|
You could say that univalence gives the developer two proofs for the
|
2018-05-29 13:09:38 +00:00
|
|
|
|
price of one. As an illustration of this I proved that monads are
|
|
|
|
|
groupoids. I initially proved this for the Kleisli
|
2018-05-23 15:34:50 +00:00
|
|
|
|
formulation\footnote{Actually doing this directly turned out to be
|
|
|
|
|
tricky as well, so I defined an equivalent formulation which was not
|
2018-05-29 13:09:38 +00:00
|
|
|
|
formulated with a record, but purely with $\sum$-types.}. Since the
|
2018-05-23 15:34:50 +00:00
|
|
|
|
two formulations are equal under univalence, substitution directly
|
2018-05-29 13:09:38 +00:00
|
|
|
|
gives us that this also holds for the monoidal formulation. This of
|
2018-05-23 15:34:50 +00:00
|
|
|
|
course generalizes to any family $P \tp 𝒰 → 𝒰$ where $P$ is inhabited
|
|
|
|
|
at either formulation (i.e.\ either $P\ \Monoidal$ or $P\ \Kleisli$
|
|
|
|
|
holds).
|
2018-05-07 22:25:34 +00:00
|
|
|
|
|
2018-05-29 13:09:38 +00:00
|
|
|
|
The introduction (section \S\ref{sec:context}) mentioned that a
|
|
|
|
|
typical way of getting access to functional extensionality is to work
|
|
|
|
|
with setoids. Nowhere in this formalization has this been necessary,
|
|
|
|
|
$\Path$ has been used globally in the project for propositional
|
|
|
|
|
equality. One interesting place where this becomes apparent is in
|
|
|
|
|
interfacing with the Agda standard library. Multiple definitions in
|
|
|
|
|
the Agda standard library have been designed with the
|
|
|
|
|
setoid-interpretation in mind. E.g.\ the notion of \emph{unique
|
|
|
|
|
existential} is indexed by a relation that should play the role of
|
|
|
|
|
propositional equality. Equivalence relations are likewise indexed,
|
|
|
|
|
not only by the actual equivalence relation but also by another
|
|
|
|
|
relation that serve as propositional equality.
|
2018-05-23 15:34:50 +00:00
|
|
|
|
%% Unfortunately we cannot use the definition of equivalences found in
|
2018-05-29 13:09:38 +00:00
|
|
|
|
%% the standard library to do equational reasoning directly. The
|
2018-05-23 15:34:50 +00:00
|
|
|
|
%% reason for this is that the equivalence relation defined there must
|
|
|
|
|
%% be a homogenous relation, but paths are heterogeneous relations.
|
2018-05-07 22:25:34 +00:00
|
|
|
|
|
2018-05-23 15:34:50 +00:00
|
|
|
|
In the formalization at present a significant amount of energy has
|
|
|
|
|
been put towards proving things that would not have been needed in
|
2018-05-29 13:09:38 +00:00
|
|
|
|
classical Agda. The proofs that some given type is a proposition were
|
2018-05-23 15:34:50 +00:00
|
|
|
|
provided as a strategy to simplify some otherwise very complicated
|
2018-05-29 13:09:38 +00:00
|
|
|
|
proofs (e.g.\ \ref{eq:proof-prop-IsPreCategory}
|
|
|
|
|
and \ref{eq:productPath}). Often these proofs would not be this
|
|
|
|
|
complicated. If the J-rule holds definitionally the proof-assistant
|
|
|
|
|
can help simplify these goals considerably. The lack of the J-rule has
|
2018-05-23 15:34:50 +00:00
|
|
|
|
a significant impact on the complexity of these kinds of proofs.
|
2018-05-07 22:25:34 +00:00
|
|
|
|
|
2018-05-23 16:28:27 +00:00
|
|
|
|
\subsection{Motifs}
|
|
|
|
|
An oft-used technique in this development is using based path
|
2018-05-29 13:09:38 +00:00
|
|
|
|
induction to prove certain properties. One particular challenge that
|
2018-05-23 16:28:27 +00:00
|
|
|
|
arises when doing so is that Agda is not able to automatically infer
|
2018-05-29 13:09:38 +00:00
|
|
|
|
the family that one wants to do induction over. For instance in the
|
2018-05-23 16:28:27 +00:00
|
|
|
|
proof $\var{sym}\ (\var{sym}\ p) ≡ p$ from \ref{eq:sym-invol} the
|
|
|
|
|
family that we chose to do induction over was $D\ b'\ p' \defeq
|
2018-05-29 13:09:38 +00:00
|
|
|
|
\var{sym}\ (\var{sym}\ p') ≡ p'$. However, if one interactively tries
|
2018-05-23 16:28:27 +00:00
|
|
|
|
to give this hole, all the information that Agda can provide is that
|
2018-05-29 13:09:38 +00:00
|
|
|
|
one must provide an element of $𝒰$. Agda could be more helpful in this
|
|
|
|
|
context, perhaps even infer this family in some situations. In this
|
2018-05-23 16:28:27 +00:00
|
|
|
|
very simple example this is of course not a big problem, but there are
|
|
|
|
|
examples in the source code where this gets more involved.
|
|
|
|
|
|
2018-05-07 22:25:34 +00:00
|
|
|
|
\section{Future work}
|
|
|
|
|
\subsection{Compiling Cubical Agda}
|
|
|
|
|
\label{sec:compiling-cubical-agda}
|
2018-05-23 15:34:50 +00:00
|
|
|
|
Compilation of program written in Cubical Agda is currently not
|
2018-05-29 13:09:38 +00:00
|
|
|
|
supported. One issue here is that the backends does not provide an
|
2018-05-23 15:34:50 +00:00
|
|
|
|
implementation for the cubical primitives (such as the path-type).
|
|
|
|
|
This means that even though the path-type gives us a computational
|
|
|
|
|
interpretation of functional extensionality, univalence, transport,
|
|
|
|
|
etc., we do not have a way of actually using this to compile our
|
2018-05-29 13:09:38 +00:00
|
|
|
|
programs that use these primitives. It would be interesting to see
|
|
|
|
|
practical applications of this.
|
2018-05-28 15:32:56 +00:00
|
|
|
|
|
|
|
|
|
\subsection{Proving laws of programs}
|
|
|
|
|
Another interesting thing would be to use the Kleisli formulation of
|
2018-05-29 13:09:38 +00:00
|
|
|
|
monads to prove properties of functional programs. The existence of
|
2018-05-28 15:32:56 +00:00
|
|
|
|
univalence will make it possible to re-use proofs stated in terms of
|
|
|
|
|
the monoidal formulation in this setting.
|
2018-05-29 13:09:38 +00:00
|
|
|
|
|
|
|
|
|
%% \subsection{Higher inductive types}
|
|
|
|
|
%% This library has not explored the usefulness of higher inductive types
|
|
|
|
|
%% in the context of Category Theory.
|
|
|
|
|
|
|
|
|
|
\subsection{Initiality conjecture}
|
|
|
|
|
A fellow student at Chalmers, Andreas Källberg, is currently working
|
|
|
|
|
on proving the initiality conjecture. He will be using this library
|
|
|
|
|
to do so.
|