Old unstaged changes

I hope these are mostly non dangerous.  Looks like it's mainly some reformatting.
This commit is contained in:
Frederik Hanghøj Iversen 2018-07-17 16:51:16 +02:00
parent 6f275247dd
commit 188bba6c8d
6 changed files with 390 additions and 377 deletions

View file

@ -3,22 +3,21 @@ The usual notion of propositional equality in intensional type-theory
is restrictive. For instance it does not admit functional is restrictive. For instance it does not admit functional
extensionality nor univalence. This poses a severe limitation on both extensionality nor univalence. This poses a severe limitation on both
what is \emph{provable} and the \emph{re-usability} of proofs. Recent what is \emph{provable} and the \emph{re-usability} of proofs. Recent
developments have however resulted in cubical type theory which developments have, however, resulted in cubical type theory, which
permits a constructive proof of these two important notions. The permits a constructive proof of univalence. The programming language
programming language Agda has been extended with capabilities for Agda has been extended with capabilities for working in such a cubical
working in such a cubical setting. This thesis will explore the setting. This thesis will explore the usefulness of this extension in
usefulness of this extension in the context of category theory. the context of category theory.
The thesis will motivate the need for univalence and explain why The thesis will motivate the need for univalence and explain why
propositional equality in cubical Agda is more expressive than in propositional equality in cubical Agda is more expressive than in
standard Agda. Alternative approaches to Cubical Agda will be standard Agda. Alternative approaches to Cubical Agda will be
presented and their pros and cons will be explained. As an example of presented and their pros and cons will be explained. As an example of
the application of univalence two formulations of monads will be the application of univalence, two formulations of monads will be
presented: Namely monads in the monoidal form and monads in the presented: Namely monads in the monoidal form and monads in the
Kleisli form and under the univalent interpretation it will be shown Kleisli form. Using univalence, it will be shown how these are equal.
how these are equal.
Finally the thesis will explain the challenges that a developer will Finally the thesis will explain the challenges that a developer will
face when working with cubical Agda and give some techniques to face when working with cubical Agda and give some techniques to
overcome these difficulties. It will also try to suggest how further overcome these difficulties. It will suggest how further work can
work can help alleviate some of these challenges. help alleviate some of these challenges.

View file

@ -12,27 +12,27 @@ thing Agda enjoys Uniqueness of Identity Proofs (UIP) though a flag
exists to turn this off. This feature is not present in Cubical Agda. exists to turn this off. This feature is not present in Cubical Agda.
Rather than having unique identity proofs cubical Agda gives rise to a Rather than having unique identity proofs cubical Agda gives rise to a
hierarchy of types with increasing \nomen{homotopical hierarchy of types with increasing \nomen{homotopical
structure}{homotopy levels}. It turns out to be useful to built the structure}{homotopy levels}. It turns out to be useful to build the
formalization with this hierarchy in mind as it can simplify proofs formalization with this hierarchy in mind as it can simplify proofs
considerably. Another issue one must overcome in Cubical Agda is when considerably. Another issue one must overcome in Cubical Agda is when
a type has a field whose type depends on a previous field. In this a type has a field whose type depends on a previous field. In this
case paths between such types will be heterogeneous paths. In case paths between such types will be heterogeneous paths. In
practice it turns out to be considerably more difficult to work with practice it turns out to be considerably more difficult to work with
heterogeneous paths than with homogeneous paths. The thesis heterogeneous paths than with homogeneous paths. This thesis
demonstrated the application of some techniques to overcome these demonstrated the application of some techniques to overcome these
difficulties, such as based path induction. difficulties, such as based path induction.
This thesis formalizes some of the core concepts from category theory This thesis formalizes some of the core concepts from category theory
including; categories, functors, products, exponentials, Cartesian including: categories, functors, products, exponentials, Cartesian
closed categories, natural transformations, the yoneda embedding, closed categories, natural transformations, the yoneda embedding,
monads and more. Category theory is an interesting case study for the monads and more. Category theory is an interesting case study for the
application of cubical Agda for two reasons in particular: Because application of cubical Agda for two reasons in particular. One reason
category theory is the study of abstract algebra of functions, meaning is because category theory is the study of abstract algebra of
that functional extensionality is particularly relevant. Another functions, meaning that functional extensionality is particularly
reason is that in category theory it is commonplace to identify relevant. Another reason is that in category theory it is commonplace
isomorphic structures. Univalence allows for making this notion to identify isomorphic structures. Univalence allows for making this
precise. This thesis also demonstrated another technique that is notion precise. This thesis also demonstrated another technique that
common in category theory; namely to define categories to prove is common in category theory; namely to define categories to prove
properties of other structures. Specifically a category was defined properties of other structures. Specifically a category was defined
to demonstrate that any two product objects in a category are to demonstrate that any two product objects in a category are
isomorphic. Furthermore the thesis showed two formulations of monads isomorphic. Furthermore the thesis showed two formulations of monads

View file

@ -7,7 +7,7 @@ $n$ simply by expanding the definition of $+$.
On the other hand, propositional equality is something defined within On the other hand, propositional equality is something defined within
the language itself. Propositional equality cannot be derived the language itself. Propositional equality cannot be derived
automatically. The normal definition of judgmental equality is an automatically. The normal definition of propositional equality is an
inductive data type. Cubical Agda discards this type in favor of some inductive data type. Cubical Agda discards this type in favor of some
new primitives. new primitives.
@ -73,7 +73,7 @@ $$
p \tp \prod_{i \tp \I} P\ i p \tp \prod_{i \tp \I} P\ i
$$ $$
% %
Which must satisfy being judgmentally equal to $a_0$ at the This function must satisfy being judgmentally equal to $a_0$ at the
left endpoint and equal to $a_1$ at the other end. I.e.: left endpoint and equal to $a_1$ at the other end. I.e.:
% %
\begin{align*} \begin{align*}
@ -93,8 +93,8 @@ I will generally prefer to use the notation $a \equiv b$ when talking
about non-dependent paths and use the notation $\Path\ (\lambda\; i about non-dependent paths and use the notation $\Path\ (\lambda\; i
\to P\ i)\ a\ b$ when the path space is of particular interest. \to P\ i)\ a\ b$ when the path space is of particular interest.
With this definition we can also recover reflexivity. That is, for any $A \tp With this definition we can recover reflexivity. That is, for any $A
\MCU$ and $a \tp A$: \tp \MCU$ and $a \tp A$:
% %
\begin{equation} \begin{equation}
\begin{aligned} \begin{aligned}
@ -105,7 +105,7 @@ With this definition we can also recover reflexivity. That is, for any $A \tp
% %
Here the path space is $P \defeq \lambda\; i \to A$ and it satsifies Here the path space is $P \defeq \lambda\; i \to A$ and it satsifies
$P\ i = A$ definitionally. So to inhabit it, is to give a path $\I \to $P\ i = A$ definitionally. So to inhabit it, is to give a path $\I \to
A$ which is judgmentally $a$ at either endpoint. This is satisfied by A$ that is judgmentally $a$ at either endpoint. This is satisfied by
the constant path; i.e.\ the path that is constantly $a$ at any index the constant path; i.e.\ the path that is constantly $a$ at any index
$i \tp \I$. $i \tp \I$.
@ -120,14 +120,15 @@ Functional extensionality is the proposition that given a type $A \tp
\end{equation} \end{equation}
% %
%% p = λ\; i a → p a i %% p = λ\; i a → p a i
So given $η \tp \prod_{a \tp A} f\ a \equiv g\ a$ we must give a path $f \equiv So given $η \tp \prod_{a \tp A} f\ a \equiv g\ a$ we must give a path
g$. That is a function $\I \to \prod_{a \tp A} B\ a$. So let $i \tp \I$ be given. $f \equiv g$. That is a function $\I \to \prod_{a \tp A} B\ a$. So let
We must now give an expression $\phi \tp \prod_{a \tp A} B\ a$ satisfying $i \tp \I$ be given. We must now give an expression $\phi \tp
$\phi\ 0 \equiv f\ a$ and $\phi\ 1 \equiv g\ a$. This neccesitates that the \prod_{a \tp A} B\ a$ satisfying $\phi\ 0 \equiv f\ a$ and $\phi\ 1
expression must be a lambda-abstraction, so let $a \tp A$ be given. Now we can \equiv g\ a$. This neccesitates that the expression must be a lambda
apply $a$ to $η$ and get the path $η\ a \tp f\ a \equiv g\ a$. And this exactly abstraction, so let $a \tp A$ be given. We can now apply $a$ to $η$
satisfies the conditions for $\phi$. In conclustion \ref{eq:funExt} is inhabited and get the path $η\ a \tp f\ a \equiv g\ a$. This exactly
by the term: satisfies the conditions for $\phi$. In conclusion \ref{eq:funExt} is
inhabited by the term:
% %
\begin{equation*} \begin{equation*}
\funExt\ η \defeq λ\; i\ a → η\ a\ i \funExt\ η \defeq λ\; i\ a → η\ a\ i
@ -149,10 +150,10 @@ In ITT all equality proofs are identical (in a closed context). This
means that, in some sense, any two inhabitants of $a \equiv b$ are means that, in some sense, any two inhabitants of $a \equiv b$ are
``equally good''. They do not have any interesting structure. This is ``equally good''. They do not have any interesting structure. This is
referred to as Uniqueness of Identity Proofs (UIP). Unfortunately it referred to as Uniqueness of Identity Proofs (UIP). Unfortunately it
is not possible to have a type theory with both univalence and UIP. In is not possible to have a type theory with both univalence and UIP.
stead in cubical Agda we have a hierarchy of types with an increasing Instead in cubical Agda we have a hierarchy of types with an
amount of homotopic structure. At the bottom of this hierarchy is the increasing amount of homotopic structure. At the bottom of this
set of contractible types: hierarchy is the set of contractible types:
% %
\begin{equation} \begin{equation}
\begin{aligned} \begin{aligned}
@ -214,8 +215,8 @@ proving e.g.\ $\isProp\ \bN$ directly is not so straightforward (see
\cite[\S3.1.4]{hott-2013}). Hedberg's theorem states that any type \cite[\S3.1.4]{hott-2013}). Hedberg's theorem states that any type
with decidable equality is a set. There will be examples of sets later with decidable equality is a set. There will be examples of sets later
in this report. At this point it should be noted that the term ``set'' in this report. At this point it should be noted that the term ``set''
is somewhat conflated; there is the notion of sets from set-theory, in is somewhat conflated; there is the notion of sets from set theory.
Agda types are denoted \texttt{Set}. I will use it consistently to In Agda types are denoted \texttt{Set}. I will use it consistently to
refer to a type $A$ as a set exactly if $\isSet\ A$ is a proposition. refer to a type $A$ as a set exactly if $\isSet\ A$ is a proposition.
As the reader may have guessed the next step in the hierarchy is the type: As the reader may have guessed the next step in the hierarchy is the type:
@ -227,11 +228,12 @@ As the reader may have guessed the next step in the hierarchy is the type:
\end{aligned} \end{aligned}
\end{equation} \end{equation}
% %
And so it continues. In fact we can generalize this family of types by indexing So it continues. In fact we can generalize this family of types by
them with a natural number. For historical reasons, though, the bottom of the indexing them with a natural number. For historical reasons, though,
hierarchy, the contractible types, is said to be a \nomen{-2-type}{homotopy the bottom of the hierarchy, the contractible types, is said to be a
levels}, propositions are \nomen{-1-types}{homotopy levels}, (homotopical) \nomen{-2-type}{homotopy levels}, propositions are
sets are \nomen{0-types}{homotopy levels} and so on\ldots \nomen{-1-types}{homotopy levels}, (homotopical) sets are
\nomen{0-types}{homotopy levels} and so on\ldots
Just as with paths, homotopical sets are not at the center of focus for this Just as with paths, homotopical sets are not at the center of focus for this
thesis. But I mention here some properties that will be relevant for this thesis. But I mention here some properties that will be relevant for this
@ -250,7 +252,7 @@ Specifically the results come from the Agda library \texttt{cubical}
(\cite{cubical-demo}). I have used a handful of results from this (\cite{cubical-demo}). I have used a handful of results from this
library as well as contributed a few lemmas myself% library as well as contributed a few lemmas myself%
\footnote{The module \texttt{Cat.Prelude} lists the upstream \footnote{The module \texttt{Cat.Prelude} lists the upstream
dependencies. As well my contribution to \texttt{cubical} can be dependencies. My contribution to \texttt{cubical} can as well be
found in the git logs which are available at found in the git logs which are available at
\hrefsymb{https://github.com/Saizan/cubical-demo}{\texttt{https://github.com/Saizan/cubical-demo}}. \hrefsymb{https://github.com/Saizan/cubical-demo}{\texttt{https://github.com/Saizan/cubical-demo}}.
}. }.
@ -279,12 +281,11 @@ $$
D \tp \prod_{b \tp A} \prod_{p \tp a ≡ b} \MCU D \tp \prod_{b \tp A} \prod_{p \tp a ≡ b} \MCU
$$ $$
% %
And an inhabitant of $D$ at $\refl$: and an inhabitant of $D$ at $\refl$:
% %
$$ $$
d \tp D\ a\ \refl d \tp D\ a\ \refl
$$ $$
%
We have the function: We have the function:
% %
\begin{equation} \begin{equation}
@ -343,7 +344,7 @@ over the family:
T\ d'\ r' & \defeq \trans\ p\ (\trans\ q\ r') ≡ \trans\ (\trans\ p\ q)\ r' T\ d'\ r' & \defeq \trans\ p\ (\trans\ q\ r') ≡ \trans\ (\trans\ p\ q)\ r'
\end{align*} \end{align*}
% %
So the base case is proven with $t$ which is defined as: The base case is proven with $t$ which is defined as:
% %
\begin{align*} \begin{align*}
\trans\ p\ (\trans\ q\ \refl) & \trans\ p\ (\trans\ q\ \refl) &
@ -376,7 +377,7 @@ $$
$$ $$
% %
Note that $d_0$ and $d_1$, though points of the same family, have Note that $d_0$ and $d_1$, though points of the same family, have
different types. This is quite a mouthful. So let me try to show how different types. This is quite a mouthful, so let me try to show how
this is a very general and useful result. this is a very general and useful result.
Often when proving equalities between elements of some dependent types Often when proving equalities between elements of some dependent types
@ -388,7 +389,7 @@ $$
T \defeq \sum_{a \tp A} D\ a T \defeq \sum_{a \tp A} D\ a
$$ $$
% %
For some proposition $D \tp A \to \MCU$. That is we have $\var{propD} for some proposition $D \tp A \to \MCU$. That is we have $\var{propD}
\tp \prod_{a \tp A} \isProp\ (D\ a)$. If we want to prove $t_0 \equiv \tp \prod_{a \tp A} \isProp\ (D\ a)$. If we want to prove $t_0 \equiv
t_1$ for two elements $t_0, t_1 \tp T$ then this will be a pair of t_1$ for two elements $t_0, t_1 \tp T$ then this will be a pair of
paths: paths:
@ -408,7 +409,7 @@ $$
$$ $$
% %
\subsection{Functions over propositions} \subsection{Functions over propositions}
\label{sec:propPi} \label{sec:propPi}%
$\prod$-types preserve propositionality when the co-domain is always a $\prod$-types preserve propositionality when the co-domain is always a
proposition. proposition.
% %
@ -419,7 +420,7 @@ $$
\label{sec:propSig} \label{sec:propSig}
% %
$\sum$-types preserve propositionality whenever its first component is $\sum$-types preserve propositionality whenever its first component is
a proposition, and its second component is a proposition for all a proposition and its second component is a proposition for all
points of the left type. points of the left type.
% %
$$ $$

View file

@ -10,8 +10,8 @@ mere propositions.
\subsection{Computational properties} \subsection{Computational properties}
The new contribution of cubical Agda is that it has a constructive The new contribution of cubical Agda is that it has a constructive
proof of functional extensionality\index{functional extensionality} proof of functional extensionality\index{functional extensionality}
and univalence\index{univalence}. This means that in particular that and univalence\index{univalence}. This means in particular that the
the type checker can reduce terms defined with these theorems. So one type checker can reduce terms defined with these theorems. One
interesting result of this development is how much this influenced the interesting result of this development is how much this influenced the
development. In particular having a functional extensionality that development. In particular having a functional extensionality that
``computes'' should simplify some proofs. ``computes'' should simplify some proofs.
@ -33,24 +33,24 @@ module:
% %
I will not reproduce it in full here as the type is quite involved. In I will not reproduce it in full here as the type is quite involved. In
stead I have put this in a source listing in \ref{app:abstract-funext}. stead I have put this in a source listing in
The method used to find in what places the computational behaviour of \ref{app:abstract-funext}. The method used to find in what places the
these proofs are needed has the caveat of only working for places that computational behaviour of these proofs are needed has the caveat of
directly or transitively uses these two proofs. Fortunately though only working for places that directly or transitively uses these two
the code is structured in such a way that this is the case. So in proofs. Fortunately though the code is structured in such a way that
conclusion the way I have structured these proofs means that the this is the case. In conclusion the way I have structured these proofs
computational behaviour of functional extensionality and univalence means that the computational behaviour of functional extensionality
has not been so relevant. and univalence has not been so relevant.
Barring this the computational behaviour of paths can still be useful. Barring this the computational behaviour of paths can still be useful.
E.g.\ if a programmer wants to reuse functions that operate on a 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 monoidal monads to work with a monad in the Kleisli form that the
programmer has specified. To make this idea concrete, say we are programmer has specified. To make this idea concrete, say we are
given some function $f \tp \Kleisli \to T$ having a path between $p given some function $f \tp \Kleisli \to T$, having a path between $p
\tp \Monoidal \equiv \Kleisli$ induces a map $\coe\ p \tp \Monoidal \tp \Monoidal \equiv \Kleisli$ induces a map $\coe\ p \tp \Monoidal
\to \Kleisli$. We can compose $f$ with this map to get $f \comp \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 \coe\ p \tp \Monoidal \to T$. Of course, since that map was
constructed with an isomorphism these maps already exist and could be constructed with an isomorphism, these maps already exist and could be
used directly. So this is arguably only interesting when one also used directly. So this is arguably only interesting when one also
wants to prove properties of applying such functions. wants to prove properties of applying such functions.

View file

@ -57,11 +57,11 @@ The concepts formalized in this development are:
\end{center} \end{center}
\end{samepage}% \end{samepage}%
% %
As well as a range of various results about these. E.g.\ I have shown I also provide a various results about these. E.g.\ I have shown that
that the category of sets has products. In the following I aim to the category of sets has products. In the following I aim to
demonstrate some of the techniques employed in this formalization and demonstrate some of the techniques employed in this formalization.
in the interest of brevity I will not detail all the things I have In the interest of brevity I will not detail all the things I have
formalized. In stead I have selected parts of this formalization that formalized. Instead I have selected parts of this formalization that
highlight some interesting proof techniques relevant to doing proofs highlight some interesting proof techniques relevant to doing proofs
in Cubical Agda. This chapter will focus on the definition of in Cubical Agda. This chapter will focus on the definition of
\emph{categories}, \emph{equivalences}, the \emph{opposite category}, \emph{categories}, \emph{equivalences}, the \emph{opposite category},
@ -82,15 +82,15 @@ mathematical way'', where one can reason about two categories by
simply focusing on the data. This is achieved by creating a function simply focusing on the data. This is achieved by creating a function
embodying the equality principle for a given type. embodying the equality principle for a given type.
For the rest of this chapter I will present some of these results. For For the rest of this chapter I will present some of these results.
didactic reasons no source-code has been included in this chapter. To For didactic reasons no source-code has been included in this chapter.
see the formal definitions the reader is referred to the To see the formal definitions the reader is referred to the
implementation which is linked in the tables above. implementation which is linked in the tables above.
\section{Categories} \section{Categories}
\label{sec:categories} \label{sec:categories}
The data for a category consist of a type for the sort of objects; a The data for a category consist of a type for the sort of objects, a
type for the sort of arrows; an identity arrow and a composition type for the sort of arrows, an identity arrow and a composition
operation for arrows. Another record encapsulates some laws about operation for arrows. Another record encapsulates some laws about
this data: associativity of composition, identity law for the identity this data: associativity of composition, identity law for the identity
morphism. These are standard constituents of a category and can be morphism. These are standard constituents of a category and can be
@ -98,17 +98,18 @@ found in typical mathematical expositions on the topic. We shall
impose one further requirement on what it means to be a category, impose one further requirement on what it means to be a category,
namely that the type of arrows form a set. namely that the type of arrows form a set.
Such categories are called \nomen{1-categories}{1-category}. It is Categories whose type of arrows form a set are called
possible to relax this requirement. This would lead to the notion of \nomen{1-categories}{1-category}. It is possible to relax this
higher categories (\cite[p. 307]{hott-2013}). For the purpose of this requirement. This would lead to the notion of higher categories
thesis however, this report will restrict itself to (\cite[p. 307]{hott-2013}). However this thesis will restrict itself
1-categories\index{1-category}. Generalizing this work to higher to 1-categories\index{1-category}. Generalizing this work to higher
categories would be a very natural extension of this work. categories would be a very natural extension of this work.
Raw categories satisfying all of the above requirements are called a Raw categories satisfying all of the above requirements are called a
\nomenindex{pre-categories}. As a further requirement to be a proper category we \nomenindex{pre-categories}. As a further requirement to be a proper
require it to be univalent. Before we can define this, I must introduce two more category we require the arrows to be univalent. Before we can define
definitions: If we let $p$ be a witness to the identity law, which formally is: this, I must introduce two additional definitions: If we let $p$ be a
witness to the identity law, which formally is:
% %
\begin{equation} \begin{equation}
\label{eq:identity} \label{eq:identity}
@ -118,20 +119,20 @@ definitions: If we let $p$ be a witness to the identity law, which formally is:
\end{equation} \end{equation}
% %
Then we can construct the identity isomorphism $\idIso \tp (\identity, Then we can construct the identity isomorphism $\idIso \tp (\identity,
\identity, p) \tp A ≊ A$ for any object $A$. Here $$ \identity, p) \tp A ≊ A$ for any object $A$. Here $$ denotes
denotes isomorphism on objects (whereas $\cong$ denotes isomorphism on isomorphism on objects (whereas $\cong$ denotes isomorphism on types).
types). This will be elaborated further on in sections This will be elaborated further on in sections \S\ref{sec:equiv} and
\S\ref{sec:equiv} and \S\ref{sec:univalence}. Moreover due to \S\ref{sec:univalence}. Moreover due to substitution for paths we can
substitution for paths we can construct an isomorphism from \emph{any} construct an isomorphism from \emph{any} path:
path:
% %
\begin{equation} \begin{equation}
\idToIso \tp A ≡ B → A ≊ B \idToIso \tp A ≡ B → A ≊ B
\end{equation} \end{equation}
% %
The univalence criterion for categories states that this map must be an The univalence criterion for categories states that $\idToIso$ must be
equivalence. The requirement is similar to univalence for types, but where an equivalence. The requirement is similar to univalence for types,
isomorphism on objects play the role of equivalence on types. Formally: but where isomorphism on objects play the role of equivalence on
types. Formally:
% %
\begin{align} \begin{align}
\label{eq:cat-univ} \label{eq:cat-univ}
@ -146,10 +147,10 @@ Note that \ref{eq:cat-univ} is \emph{not} the same as:
(A ≡ B) ≃ (A ≊ B) (A ≡ B) ≃ (A ≊ B)
\end{equation} \end{equation}
% %
However the two are logically equivalent: One can construct the latter However the two are logically equivalent: one can construct the latter
from the former simply by ``forgetting'' that $\idToIso$ plays the from the former simply by ``forgetting'' that $\idToIso$ plays the
role of the equivalence. The other direction is more involved and will role of the equivalence. The other direction is more involved and
be discussed in section \S\ref{sec:univalence}. will be discussed in section \S\ref{sec:univalence}.
In summary the definition of a category is the following collection of In summary the definition of a category is the following collection of
data: data:
@ -161,7 +162,7 @@ data:
\lll & \tp \Arrow\ B\ C → \Arrow\ A\ B → \Arrow\ A\ C \lll & \tp \Arrow\ B\ C → \Arrow\ A\ B → \Arrow\ A\ C
\end{align} \end{align}
% %
And laws: and laws:
% %
\begin{align} \begin{align}
%% \tag{associativity} %% \tag{associativity}
@ -182,16 +183,16 @@ And laws:
\isEquiv\ (A ≡ B)\ (A ≊ B)\ \idToIso \isEquiv\ (A ≡ B)\ (A ≊ B)\ \idToIso
\end{align} \end{align}
% %
The function $\lll$ denotes arrow composition (right-to-left), and The function $\lll$ denotes arrow composition (right-to-left) and
reverse function composition (left-to-right, diagrammatic order) is reverse function composition (left-to-right, diagrammatic order) is
denoted $\rrr$. The objects ($A$, $B$ and $C$) and arrow ($f$, $g$, denoted $\rrr$. The objects ($A$, $B$ and $C$) and arrows ($f$, $g$,
$h$) are implicitly universally quantified. $h$) are implicitly universally quantified.
With all this in place it is now possible to prove that all the laws With all this in place it is now possible to prove that all the laws
are indeed mere propositions. Most of the proofs simply use the fact are indeed mere propositions. Most of the proofs simply use the fact
that the type of arrows are sets. This is because most of the laws are that the type of arrows are sets. This is because most of the laws are
a collection of equations between arrows in the category. And since a collection of equations between arrows in the category. And since
such a proof does not have any content exactly because the type of such a proof does not have any content, exactly because the type of
arrows form a set, two witnesses must be the same. All the proofs are arrows form a set, two witnesses must be the same. All the proofs are
really quite mechanical. Let us have a look at one of them: Proving really quite mechanical. Let us have a look at one of them: Proving
that \ref{eq:identity} is a mere proposition: that \ref{eq:identity} is a mere proposition:
@ -217,10 +218,10 @@ $$
\isProp\ \left( \left( \id \comp f ≡ f \right) \x \left( f \comp \id ≡ f \right) \right) \isProp\ \left( \left( \id \comp f ≡ f \right) \x \left( f \comp \id ≡ f \right) \right)
$$ $$
% %
Then we eliminate the (non-dependent) sigma-type by applying $\propSig$ giving We then eliminate the (non-dependent) sigma-type by applying
us the two obligations $\isProp\ (\id \comp f ≡ f)$ and $\isProp\ (f \comp $\propSig$ giving us the two obligations $\isProp\ (\id \comp f ≡ f)$
\id ≡ f)$ which follows from the type of arrows being a and $\isProp\ (f \comp \id ≡ f)$ which follows from the type of arrows
set. being a set.
This example illustrates nicely how we can use these combinators to This example illustrates nicely how we can use these combinators to
reason about `canonical' types like $$ and $$. Similar reason about `canonical' types like $$ and $$. Similar
@ -246,7 +247,7 @@ Where the definition of $\IsPreCategory$ is the triple:
% %
Each corresponding to the first three laws for categories. Note that Each corresponding to the first three laws for categories. Note that
since $\IsPreCategory$ is not formulated with a chain of sigma-types since $\IsPreCategory$ is not formulated with a chain of sigma-types
we will not have any combinators available to help us here. In stead we will not have any combinators available to help us here. Instead
the path type must be used directly. the path type must be used directly.
The type \ref{eq:propIsPreCategory} is judgmentally the same as: The type \ref{eq:propIsPreCategory} is judgmentally the same as:
@ -255,13 +256,13 @@ $$
_{a, b \tp \IsPreCategory} a ≡ b _{a, b \tp \IsPreCategory} a ≡ b
$$ $$
% %
So to prove the proposition let $a, b \tp \IsPreCategory$ be given. To To prove the proposition let $a, b \tp \IsPreCategory$ be given. To
prove the equality $a ≡ b$ is to give a continuous path from the prove the equality $a ≡ b$ is to give a continuous path from the
index-type into the path-space. I.e.\ a function $\I index-type into the path space; i.e.\ a function $\I
\IsPreCategory$. This path must satisfy being being judgmentally the \IsPreCategory$. This path must satisfy being being judgmentally the
same as $a$ at the left endpoint and $b$ at the right endpoint. We same as $a$ at the left endpoint and $b$ at the right endpoint. We
know we can form a continuous path between all projections of $a$ and know we can form a continuous path between all projections of $a$ and
$b$, this follows from the type of all the projections being mere $b$. This follows from the type of all the projections being mere
propositions. For instance, the path between $a.\isIdentity$ and propositions. For instance, the path between $a.\isIdentity$ and
$b.\isIdentity$ is simply formed by: $b.\isIdentity$ is simply formed by:
% %
@ -271,14 +272,15 @@ $$
a.\isIdentity ≡ b.\isIdentity a.\isIdentity ≡ b.\isIdentity
$$ $$
% %
So to give the continuous function $\I\IsPreCategory$, which is our goal, we To give the continuous function $\I\IsPreCategory$, which is our
introduce $i \tp \I$ and proceed by constructing an element of $\IsPreCategory$ goal, we introduce $i \tp \I$ and proceed by constructing an element
by using the fact that all the projections are propositions to generate paths of $\IsPreCategory$ by using the fact that all the projections are
between all projections. Once we have such a path e.g.\ $p \tp a.\isIdentity propositions to generate paths between all projections. Once we have
≡ b.\isIdentity$ we can eliminate it with $i$ and thus obtain $p\ i \tp such a path e.g.\ $p \tp a.\isIdentity ≡ b.\isIdentity$ we can
(p\ i).\isIdentity$. This element satisfies exactly that it corresponds to the eliminate it with $i$ and thus obtain $p\ i \tp (p\ i).\isIdentity$.
corresponding projections at either endpoint. Thus the element we construct at This element satisfies exactly that it corresponds to the
$i$ becomes the triple: corresponding projections at either endpoint. Thus the element we
construct at $i$ becomes the triple:
% %
\begin{equation} \begin{equation}
\label{eq:proof-prop-IsPreCategory} \label{eq:proof-prop-IsPreCategory}
@ -296,7 +298,7 @@ I have found this to be a general pattern when proving things in
homotopy type theory, namely that you have to wrap and unwrap homotopy type theory, namely that you have to wrap and unwrap
equalities at different levels. It is worth noting that proving this equalities at different levels. It is worth noting that proving this
theorem with the regular inductive equality type would already not be theorem with the regular inductive equality type would already not be
possible, since we at least need functional possible since we at least need functional
extensionality\index{functional extensionality} (the projections are extensionality\index{functional extensionality} (the projections are
all $$-types). Assuming we had functional extensionality available to all $$-types). Assuming we had functional extensionality available to
us as an axiom, we would use functional extensionality to retrieve the us as an axiom, we would use functional extensionality to retrieve the
@ -307,9 +309,9 @@ a~priori that equality proofs are unique.
The situation is a bit more complicated when we have a dependent type. The situation is a bit more complicated when we have a dependent type.
For instance when we want to show that $\IsCategory$ is a mere For instance when we want to show that $\IsCategory$ is a mere
proposition. The type $\IsCategory$ is a record with two fields, a proposition. The type $\IsCategory$ is a record with two fields: a
witness of being a pre-category and the univalence condition. Recall witness of being a pre-category and the univalence condition. Recall
that the univalence condition is indexed by the identity-proof. So to that the univalence condition is indexed by the identity-proof. To
follow the same recipe as above, let $a, b \tp \IsCategory$ be given, follow the same recipe as above, let $a, b \tp \IsCategory$ be given,
to show them equal, we now need to give two paths. One homogeneous: to show them equal, we now need to give two paths. One homogeneous:
% %
@ -332,13 +334,13 @@ result that univalence is a proposition to a heterogeneous path. To
this end we can use $\lemPropF$, which was introduced in this end we can use $\lemPropF$, which was introduced in
\S\ref{sec:lemPropF}. \S\ref{sec:lemPropF}.
In this case $A = \var{IsIdentity}\ \identity$ and $B = Looking at the definition of $\lemPropF$ we have that $A =
\Univalent$. We have shown that being a category is a proposition, a \var{IsIdentity}\ \identity$ and $D = \Univalent$ to give the path at
result that holds for any choice of identity proof so it will also hand. We have shown that being a category is a proposition, a result
hold for the witness obtained at an arbitrary point along $p$. Finally that holds for any choice of identity proof so it will also hold for
we must provide a proof that the identity proofs at $a$ and $b$ are the witness obtained at an arbitrary point along $p$. Finally we must
indeed the same, this we can extract from $p$ by applying congruence provide a proof that the identity proofs at $a$ and $b$ are indeed the
of paths: same, this we can extract from $p$ by applying congruence of paths:
% %
$$ $$
\congruence\ \isIdentity\ p \congruence\ \isIdentity\ p
@ -350,10 +352,10 @@ $$
\var{lemPropF}\ \var{propUnivalent}\ (\var{cong}\ p.\var{isIdentity}) \var{lemPropF}\ \var{propUnivalent}\ (\var{cong}\ p.\var{isIdentity})
$$ $$
% %
And this finishes the proof that being-a-category is a mere proposition This finishes the proof that being-a-category is a mere proposition
(\ref{eq:propIsPreCategory}). (\ref{eq:propIsPreCategory}).
When we have a proper category we can make precise the notion of When we have a proper category, we can make precise the notion of
``identifying isomorphic types''. That is, we can construct the ``identifying isomorphic types''. That is, we can construct the
function: function:
% %
@ -395,8 +397,8 @@ $\Isomorphism\ f$. This also gives rise to the following type:
A \cong B ≜ ∑_{f \tp A → B} \Isomorphism\ f A \cong B ≜ ∑_{f \tp A → B} \Isomorphism\ f
\end{equation} \end{equation}
% %
At the same place \cite{hott-2013} gives an ``interface'' for what the judgment At the same place \cite{hott-2013} gives an ``interface'' for what
$\isEquiv \tp (A → B)\MCU$ must provide: the judgment $\isEquiv \tp (A → B)\MCU$ must provide:
% %
\begin{align} \begin{align}
\var{fromIso} & \tp \Isomorphism\ f → \isEquiv\ f \\ \var{fromIso} & \tp \Isomorphism\ f → \isEquiv\ f \\
@ -465,7 +467,7 @@ As mentioned the univalence criterion for some category $\bC$ says that for all
$$ $$
\isEquiv\ (A ≡ B)\ (A ≊ B)\ \idToIso \isEquiv\ (A ≡ B)\ (A ≊ B)\ \idToIso
$$ $$
And I mentioned that this was logically equivalent to This is logically equivalent to
% %
$$ $$
(A ≡ B) ≃ (A ≊ B) (A ≡ B) ≃ (A ≊ B)
@ -484,10 +486,10 @@ dwell on this for a few seconds. This type looks very similar to
univalence for types and is therefore perhaps a bit more intuitive to univalence for types and is therefore perhaps a bit more intuitive to
grasp the implications of. Of course univalence for types (which is a grasp the implications of. Of course univalence for types (which is a
theorem -- i.e.\ provably holds) does not imply univalence of all theorem -- i.e.\ provably holds) does not imply univalence of all
pre-category since morphisms in a category are not regular functions pre-category since morphisms in a category are not regular functions,
-- in stead they can be thought of as a generalization hereof. The instead they can be thought of as a generalization hereof. The
univalence criterion therefore is simply a way of restricting arrows univalence criterion therefore is simply a way of restricting arrows
to behave like maps with respect to univalence. to behave like regular functions with respects to paths.
I will now mention a few helpful theorems that follow from univalence that will I will now mention a few helpful theorems that follow from univalence that will
become useful later. become useful later.
@ -554,7 +556,7 @@ are trying to prove but talks about paths rather than isomorphisms:
Again $p_{\var{dom}}$ denotes the path $\Arrow\ A\ X ≡ \Arrow\ B\ X$ Again $p_{\var{dom}}$ denotes the path $\Arrow\ A\ X ≡ \Arrow\ B\ X$
induced by $p$. To prove this statement let $f$ and $p$ be given then induced by $p$. To prove this statement let $f$ and $p$ be given then
we invoke based path induction. The induction will be based at $A \tp we invoke based path induction. The induction will be based at $A \tp
\Object$ Let $\widetilde{B} \tp \Object$ and $\widetilde{p} \tp A ≡ \Object$. Let $\widetilde{B} \tp \Object$ and $\widetilde{p} \tp A ≡
\widetilde{B}$ be given. The family that we perform induction over \widetilde{B}$ be given. The family that we perform induction over
will be: will be:
% %
@ -590,28 +592,30 @@ term:
\pathJ\ D\ d\ B\ p \pathJ\ D\ d\ B\ p
\end{equation} \end{equation}
% %
And this finishes the proof of \ref{eq:coeDomIso} and thus \ref{eq:coeDom}. This finishes the proof of \ref{eq:coeDomIso} and thus
\ref{eq:coeDom}.
% %
\section{Categories} \section{Categories}
\subsection{Opposite category} \subsection{Opposite category}
\label{op-cat} \label{op-cat}
The first category I will present is a pure construction on categories. Given The first category I will present is a pure construction on
some category we can construct its dual, called the opposite category. Starting categories. Given some category we can construct its dual, called the
with a simple example allows us to focus on how we work with equivalences and opposite category. Starting with a simple example allows us to focus
univalence in a very simple category where the structure of the category is on how we work with equivalences and univalence rather than being
rather simple. distracted by some intricate structure of the category.
Let $\bC$ be some category, we then define the opposite category Let $\bC$ be some category, we then define the opposite category
$\bC^{\var{Op}}$. It has the same objects, but the type of arrows are flipped, $\bC^{\var{Op}}$. It has the same objects, but the type of arrows are
that is to say an arrow from $A$ to $B$ in the opposite category corresponds to flipped, that is to say an arrow from $A$ to $B$ in the opposite
an arrow from $B$ to $A$ in the underlying category. The identity arrow is the category corresponds to an arrow from $B$ to $A$ in the underlying
same as the one in the underlying category (they have the same type). Function category. The identity arrow is the same as the one in the underlying
composition will be reverse function composition from the underlying category. category (they have the same type). Function composition will be
reverse function composition from the underlying category.
I will refer to things in terms of the underlying category, unless they have an I will refer to things in terms of the underlying category unless they
over-bar. So e.g.\ $\idToIso$ is a function in the underlying category and the have a line above them. E.g.\ $\idToIso$ is a function in the
corresponding thing is denoted $\wideoverbar{\idToIso}$ in the opposite underlying category and the corresponding thing is denoted
category. $\wideoverbar{\idToIso}$ in the opposite category.
Showing that this forms a pre-category is rather straightforward. Showing that this forms a pre-category is rather straightforward.
% %
@ -628,9 +632,9 @@ $$
% %
This is just the swapped version of identity. This is just the swapped version of identity.
Finally, that the arrows form sets just follows by flipping the order of the Finally, that the arrows form sets just follows by flipping the order
arguments. Or in other words; since $\Arrow\ A\ B$ is a set for all $A\;B \tp of the arguments. Or in other words: since $\Arrow\ A\ B$ is a set
\Object$ then so is $Arrow\ B\ A$. for all $A\;B \tp \Object$ then so is $Arrow\ B\ A$.
Now, to show that this category is univalent is not as straightforward. Luckily Now, to show that this category is univalent is not as straightforward. Luckily
section \S\ref{sec:equiv} gave us some tools to work with equivalences. We saw section \S\ref{sec:equiv} gave us some tools to work with equivalences. We saw
@ -649,9 +653,9 @@ opposite direction. I name these maps $\shufflef \tp (A ≊ B) → (A
\wideoverbar{} B)$ and $\shufflef^{-1} \tp (A \wideoverbar{} B) → (A \wideoverbar{} B)$ and $\shufflef^{-1} \tp (A \wideoverbar{} B) → (A
≊ B)$ respectively. ≊ B)$ respectively.
As the inverse of $\wideoverbar{\idToIso}$ I will pick $\wideoverbar{\isoToId} As the inverse of $\wideoverbar{\idToIso}$ I will pick
\isoToId \comp \shufflef$. The proof that they are inverses go as $\wideoverbar{\isoToId}\isoToId \comp \shufflef$. The proof that
follows: they are inverses goes as follows:
% %
\begin{align*} \begin{align*}
\wideoverbar{\isoToId} \comp \wideoverbar{\idToIso} & = \wideoverbar{\isoToId} \comp \wideoverbar{\idToIso} & =
@ -673,13 +677,15 @@ follows:
% %
The other direction is analogous. The other direction is analogous.
The lemma used in step 2 of this proof states that $\wideoverbar{idToIso} The lemma used in step 2 of this proof states that
\inv{\shufflef} \comp \idToIso$. This is a rather straightforward proof $\wideoverbar{idToIso}\inv{\shufflef} \comp \idToIso$. This is a
since being-an-inverse-of is a proposition, so it suffices to show that their rather straightforward proof since being-an-inverse-of is a
first components are equal, but this holds judgmentally. proposition, so it suffices to show that their first components are
equal but this holds judgmentally.
This finished the proof that the opposite category is in fact a category. Now, This concludes the proof that the opposite category is in fact a
to prove that opposite-of is an involution we must show: category. Now, to prove that opposite-of is an involution we must
show:
% %
$$ $$
_{\bC \tp \Category} \left(\bC^{\var{Op}}\right)^{\var{Op}}\bC _{\bC \tp \Category} \left(\bC^{\var{Op}}\right)^{\var{Op}}\bC
@ -713,10 +719,10 @@ Univalence does not follow immediately from univalence for types:
% %
$$(A ≡ B)(A ≃ B)$$ $$(A ≡ B)(A ≃ B)$$
% %
Because here $A, B \tp \Type$ whereas the objects in this category have the type because here $A, B \tp \Type$, whereas the objects in this category
$\Set$ so we cannot form the type $\var{hA}\var{hB}$ for objects have the type $\Set$ so we cannot form the type $\var{hA}\var{hB}$
$\var{hA}\;\var{hB} \tp \Set$. In stead I show that this category for objects $\var{hA}\;\var{hB} \tp \Set$. Instead I show that this
satisfies: category satisfies:
% %
$$ $$
(\var{hA}\var{hB}) ≃ (\var{hA}\var{hB}) (\var{hA}\var{hB}) ≃ (\var{hA}\var{hB})
@ -734,7 +740,7 @@ of equivalences:
& ≃ ((A, s_A) ≊ (B, s_B)) && \text{\ref{eq:equivSig} and \ref{eq:equivIso}} & ≃ ((A, s_A) ≊ (B, s_B)) && \text{\ref{eq:equivSig} and \ref{eq:equivIso}}
\end{align*} \end{align*}
And since $$ is an equivalence relation we can chain these equivalences Since $$ is an equivalence relation we can chain these equivalences
together. Step one will be proven with the lemma: together. Step one will be proven with the lemma:
% %
\begin{align} \begin{align}
@ -753,19 +759,20 @@ for types. Step three will be proven with the following lemma:
_{a \tp A} \left( P\ a ≃ Q\ a \right) → ∑_{a \tp A} P\ a ≃ ∑_{a \tp A} Q\ a _{a \tp A} \left( P\ a ≃ Q\ a \right) → ∑_{a \tp A} P\ a ≃ ∑_{a \tp A} Q\ a
\end{align} \end{align}
% %
Which says that if two type-families are equivalent at all points, then pairs which says that if two type-families are equivalent at all points,
with identical first components and these families as second components will then pairs with identical first components and these families as
also be equivalent. For our purposes $P\isEquiv\ A\ B$ and $Q second components will also be equivalent. For our purposes $P
\Isomorphism$. So we must finally prove: \isEquiv\ A\ B$ and $Q ≜ \Isomorphism$. We must finally prove:
% %
\begin{align} \begin{align}
\label{eq:equivIso} \label{eq:equivIso}
_{f \tp A → B} \left( \isEquiv\ A\ B\ f ≃ \Isomorphism\ f \right) _{f \tp A → B} \left( \isEquiv\ A\ B\ f ≃ \Isomorphism\ f \right)
\end{align} \end{align}
First, lets prove \ref{eq:equivPropSig}: Let $propP \tp_{a \tp A} \isProp\ (P\ a)$ and $x\;y \tp_{a \tp A} P\ a$ be given. Because Lets us first prove \ref{eq:equivPropSig}: Let $propP \tp_{a \tp A}
of $\var{fromIsomorphism}$ it suffices to give an isomorphism between \isProp\ (P\ a)$ and $x\;y \tp_{a \tp A} P\ a$ be given. Because of
$x ≡ y$ and $\fst\ x ≡ \fst\ y$: $\var{fromIsomorphism}$ it suffices to give an isomorphism between $x
≡ y$ and $\fst\ x ≡ \fst\ y$:
% %
%% FIXME: Too much alignement? %% FIXME: Too much alignement?
\begin{equation*} \begin{equation*}
@ -778,7 +785,7 @@ $x ≡ y$ and $\fst\ x ≡ \fst\ y$:
\end{equation*} \end{equation*}
% %
Here $\var{lemSig}$ is a lemma that says that if the second component Here $\var{lemSig}$ is a lemma that says that if the second component
of a pair is a proposition, it suffices to give a path between its of a pair is a proposition it suffices to give a path between its
first components to construct an equality of the two pairs: first components to construct an equality of the two pairs:
% %
\begin{align*} \begin{align*}
@ -811,7 +818,7 @@ choose:
\end{align*} \end{align*}
% %
As mentioned in section \S\ref{sec:equiv}. These maps are not in general inverses As mentioned in section \S\ref{sec:equiv}. These maps are not in general inverses
of each other. In stead, we will use the fact that $A$ and $B$ are sets. The first thing we must prove is: of each other. Instead, we will use the fact that $A$ and $B$ are sets. The first thing we must prove is:
% %
\begin{align*} \begin{align*}
\var{fromIso} \comp \var{toIso}\identity_{\isEquiv\ f} \var{fromIso} \comp \var{toIso}\identity_{\isEquiv\ f}
@ -843,20 +850,22 @@ $\mathcal{X}$ and $\mathcal{Y}$ denotes the witnesses that $x$
& = y & = y
\end{align*} \end{align*}
% %
For the other (dependent) path we can prove that being-an-inverse-of is a For the other (dependent) path we can prove that being-an-inverse-of
proposition and then use $\lemPropF$. So we prove the generalization: is a proposition and then use $\lemPropF$. To this end we prove the
generalization:
% %
\begin{align} \begin{align}
\label{eq:propAreInversesGen} \label{eq:propAreInversesGen}
_{g \tp B → A} \isProp\ (\var{AreInverses}\ f\ g) _{g \tp B → A} \isProp\ (\var{AreInverses}\ f\ g)
\end{align} \end{align}
% %
But $\var{AreInverses}\ f\ g$ is a pair of equations on arrows, so we use but $\var{AreInverses}\ f\ g$ is a pair of equations on arrows, so we
$\propSig$ and the fact that both $A$ and $B$ are sets to close this proof. use $\propSig$ and the fact that both $A$ and $B$ are sets to close
this proof.
%% \subsection{Category of categories} %% \subsection{Category of categories}
%% Note that this category does in fact not exist. In stead I provide %% Note that this category does in fact not exist. Instead I provide
%% the definition of the ``raw'' category as well as some of the laws. %% the definition of the ``raw'' category as well as some of the laws.
%% Furthermore I provide some helpful lemmas about this raw category. %% Furthermore I provide some helpful lemmas about this raw category.
@ -878,13 +887,13 @@ $$
_{\bC \tp \Category}_{A\;B \tp \Object} \isProp\ (\var{Product}\ \bC\ A\ B) _{\bC \tp \Category}_{A\;B \tp \Object} \isProp\ (\var{Product}\ \bC\ A\ B)
$$ $$
% %
Where $\var{Product}\ \bC\ A\ B$ denotes the type of products of where $\var{Product}\ \bC\ A\ B$ denotes the type of products of
objects $A$ and $B$ in the category $\bC$. I do this by constructing a objects $A$ and $B$ in the category $\bC$. I do this by constructing
category whose terminal objects are equivalent to products in $\bC$, a category whose terminal objects are equivalent to products in $\bC$.
and since terminal objects are propositional in a proper category and Since terminal objects are propositional in a proper category and
equivalences preserve homotopy level, then we know that products are equivalences preserve homotopy level, then we know that products are
also propositions. But before we get to that, we recall the definition also propositions. But before we get to that, we recall the
of products. definition of products.
\subsection{Definition of products} \subsection{Definition of products}
Given a category $\bC$ and two objects $A$ and $B$ in $\bC$ we say Given a category $\bC$ and two objects $A$ and $B$ in $\bC$ we say
@ -910,7 +919,7 @@ The arrow $\pi$ is called the product (arrow) of $f$ and $g$.
Given a base category $\bC$ and two objects in this category $\pairA$ Given a base category $\bC$ and two objects in this category $\pairA$
and $\pairB$ we construct the \nomenindex{span category}. The type of and $\pairB$ we construct the \nomenindex{span category}. The type of
objects in this category shall be an object in the underlying objects in this category shall be an object in the underlying
category, $X$, and two arrows (also from the underlying category) category, $X$ and two arrows (also from the underlying category)
$\Arrow\ X\ \pairA$ and $\Arrow\ X\ \pairB$. $\Arrow\ X\ \pairA$ and $\Arrow\ X\ \pairB$.
\newcommand\pairf{\ensuremath{f}} \newcommand\pairf{\ensuremath{f}}
@ -974,30 +983,32 @@ The proof obligations consists of two things. The first one is:
(h \lll g) \lll f (h \lll g) \lll f
\end{align} \end{align}
% %
And the other proof obligation is that the witness to \ref{eq:pairArrowLaw} for The other proof obligation is that the witness to
the left-hand-side and the right-hand-side are the same. \ref{eq:pairArrowLaw} for the left-hand-side and the right-hand-side
are the same.
The proof of the first goal comes directly from the underlying The proof of the first goal comes directly from the underlying
category. The type of the second goal is very complicated. I will not category. The type of the second goal is very complicated. I will
write it out in full here, but for the purpose of the present not write it out in full here, but for the purpose of this exposition
exposition it will suffices to show the type of the path-space. Note it will suffice to show the type of the path space. Note that the
that the arrows in \ref{eq:productAssoc} are arrows between objects on arrows in \ref{eq:productAssoc} are arrows between objects on the form
the form $\wideoverbar{A} = (A , a_{\pairA} , a_{\pairB})$ to $\wideoverbar{A} = (A , a_{\pairA} , a_{\pairB})$ to $\wideoverbar{D}
$\wideoverbar{D} = (D , d_{\pairA} , d_{\pairB})$ where $a_{\pairA}$, = (D , d_{\pairA} , d_{\pairB})$ where $a_{\pairA}$, $a_{\pairB}$,
$a_{\pairB}$, $d_{\pairA}$ and $d_{\pairB}$ are arrows in the $d_{\pairA}$ and $d_{\pairB}$ are arrows in the underlying category.
underlying category. Given that $p$ is the chosen proof of Given that $p$ is the chosen proof of \ref{eq:productAssocUnderlying}
\ref{eq:productAssocUnderlying} we then have that the witness to we then have that the witness to \ref{eq:pairArrowLaw} vary over the
\ref{eq:pairArrowLaw} vary over the type: type:
% %
\begin{align} \begin{align}
\label{eq:productPath} \label{eq:productPath}
λ \; i → d_{\pairA} \lll p\ i ≡ a_{\pairA} × d_{\pairB} \lll p\ i ≡ a_{\pairB} λ \; i → d_{\pairA} \lll p\ i ≡ a_{\pairA} × d_{\pairB} \lll p\ i ≡ a_{\pairB}
\end{align} \end{align}
% %
And these paths are in the type of the hom-set of the underlying category, so These paths are in the type of the hom-set of the underlying
they are mere propositions. We cannot apply the fact that arrows in $\bC$ are category, so they are mere propositions. We cannot apply the fact
sets directly, however, since $\isSet$ only talks about non-dependent paths, in that arrows in $\bC$ are sets directly, however, since $\isSet$ only
stead we generalize \ref{eq:productPath} to: talks about non-dependent paths, instead we generalize
\ref{eq:productPath} to:
% %
\begin{align} \begin{align}
\label{eq:productEqPrinc} \label{eq:productEqPrinc}
@ -1005,33 +1016,33 @@ stead we generalize \ref{eq:productPath} to:
\end{align} \end{align}
% %
For all objects $X , x_{\pairA} , x_{\pairB}$ and $Y , y_{\pairA} , For all objects $X , x_{\pairA} , x_{\pairB}$ and $Y , y_{\pairA} ,
y_{\pairB}$, but this follows from the fact that $$ and $$ preserve y_{\pairB}$. This follows from the fact that $$ and $$ preserve
homotopical structure. This gives us an equality principle for arrows homotopical structure. \ref{eq:productEqPrinc} gives us an equality
in this category that says that to prove two arrows $f, f_0, f_1$ and principle for arrows in this category. The equality principle says
$g, g_0, g_1$ equal it suffices to give a proof that $f$ and $g$ are that to prove two arrows $(f, f_0, f_1)$ and $(g, g_0, g_1)$ equal it
equal. suffices to give a proof that $f$ and $g$ are equal.
%% % %% %
%% $$ %% $$
%%_{(f, f_0, f_1)\; (g,g_0,g_1) \tp \Arrow\ X\ Y} f ≡ g \to (f, f_0, f_1) ≡ (g,g_0,g_1) %%_{(f, f_0, f_1)\; (g,g_0,g_1) \tp \Arrow\ X\ Y} f ≡ g \to (f, f_0, f_1) ≡ (g,g_0,g_1)
%% $$ %% $$
%% % %% %
And thus we have proven \ref{eq:productAssoc} simply with And thus we have proven \ref{eq:productAssoc} using
\ref{eq:productAssocUnderlying}. \ref{eq:productAssocUnderlying}.
Now we must prove that arrows form a set: We must now prove that the arrows form a set:
% %
$$ $$
\isSet\ (\Arrow\ \wideoverbar{X}\ \wideoverbar{Y}) \isSet\ (\Arrow\ \wideoverbar{X}\ \wideoverbar{Y})
$$ $$
% %
Since pairs preserve homotopical structure this reduces to the two Since pairs preserve homotopical structure this reduces to the
obligations: following two obligations: The first one is:
% %
$$ $$
\isSet\ (\bC.\Arrow\ X\ Y) \isSet\ (\bC.\Arrow\ X\ Y)
$$ $$
% %
Which holds. And which holds. The other one is:
% %
$$ $$
_{f \tp \Arrow\ X\ Y} _{f \tp \Arrow\ X\ Y}
@ -1040,15 +1051,16 @@ $$
\right) \right)
$$ $$
% %
This we get from \ref{eq:productEqPrinc} and the fact that homotopical structure We get this from \ref{eq:productEqPrinc} and the fact that homotopical
is cumulative. structure is cumulative.
This finishes the proof that this is a valid pre-category. That concludes the proof that this is a valid pre-category.
\subsubsection{Univalence} \subsubsection{Univalence}
To prove that this is a proper category it must be shown that it is univalent. To prove that this is a proper category we must additionally prove the
That is, for any two objects $\mathcal{X} = (X, x_{\mathcal{A}} , x_{\mathcal{B}})$ univalence criterion. That is, for any two objects $\mathcal{X} = (X,
and $\mathcal{Y} = Y, y_{\mathcal{A}}, y_{\mathcal{B}}$ I will show: x_{\mathcal{A}} , x_{\mathcal{B}})$ and $\mathcal{Y} = Y,
y_{\mathcal{A}}, y_{\mathcal{B}}$ I will show:
% %
\begin{align} \begin{align}
(\mathcal{X}\mathcal{Y}) \cong (\mathcal{X}\mathcal{Y}) (\mathcal{X}\mathcal{Y}) \cong (\mathcal{X}\mathcal{Y})
@ -1075,8 +1087,8 @@ The next types will be the triple:
%% \end{split} %% \end{split}
\end{align} \end{align}
The next type is very similar, but in stead of a path we will have an The next type is very similar, but instead of a path we will have an
isomorphism, and create a path from this: isomorphism and create a path from this:
% %
\begin{align} \begin{align}
\label{eq:univ-2} \label{eq:univ-2}
@ -1087,7 +1099,7 @@ isomorphism, and create a path from this:
\end{split} \end{split}
\end{align} \end{align}
% %
Where $\widetilde{p}\isoToId\ \var{iso} \tp X ≡ Y$. where $\widetilde{p}\isoToId\ \var{iso} \tp X ≡ Y$.
Finally we have the type: Finally we have the type:
% %
@ -1096,10 +1108,10 @@ Finally we have the type:
(X , x_{\mathcal{A}} , x_{\mathcal{B}}) ≊ (Y , y_{\mathcal{A}} , y_{\mathcal{B}}) (X , x_{\mathcal{A}} , x_{\mathcal{B}}) ≊ (Y , y_{\mathcal{A}} , y_{\mathcal{B}})
\end{align} \end{align}
% %
So the proof is a chain of isomorphisms between the types The proof is a chain of isomorphisms between the types
\ref{eq:univ-0}, \ref{eq:univ-1}, \ref{eq:univ-2} and \ref{eq:univ-0}, \ref{eq:univ-1}, \ref{eq:univ-2} and \ref{eq:univ-3}.
\ref{eq:univ-3}. I will highlight the most interesting bits of this I will highlight the most interesting bits of this proof. For the
proof. For the full proof see the implementation in the module: full proof see the implementation in the same module:
% %
\begin{center} \begin{center}
\sourcelink{Cat.Categories.Span} \sourcelink{Cat.Categories.Span}
@ -1116,13 +1128,13 @@ This proof of this has been omitted but can be found in the module:
\sourcelink{Cat.Categories.Span} \sourcelink{Cat.Categories.Span}
\end{center} \end{center}
% %
\emph{Proposition} \ref{eq:univ-2} is isomorphic to \ref{eq:univ-3}: For this I \emph{Proposition} \ref{eq:univ-2} is isomorphic to \ref{eq:univ-3}:
will show two corollaries of \ref{eq:coeCod}: For an isomorphism $(\iota, For this I will show two corollaries of \ref{eq:coeCod}: For an
\inv{\iota}, \var{inv}) \tp A \cong B$, arrows $f \tp \Arrow\ A\ X$, $g \tp isomorphism $(\iota, \inv{\iota}, \var{inv}) \tp A \cong B$, arrows $f
\Arrow\ B\ X$ and a heterogeneous path between them, $q \tp \Path\ (\lambda\; i \tp \Arrow\ A\ X$, $g \tp \Arrow\ B\ X$ and a heterogeneous path
→ p_{\var{dom}}\ i)\ f\ g$, where $p_{\var{dom}} \tp \Arrow\ A\ X ≡ between them, $q \tp \Path\ (\lambda\; i → p_{\var{dom}}\ i)\ f\ g$,
\Arrow\ B\ X$ is a path induced by $\var{iso}$, we have the following two where $p_{\var{dom}} \tp \Arrow\ A\ X ≡ \Arrow\ B\ X$ is a path
results induced by $\var{iso}$, we have the following two results
% %
\begin{align} \begin{align}
\label{eq:domain-twist-0} \label{eq:domain-twist-0}
@ -1157,16 +1169,17 @@ shall be:
f \tp \Arrow\ X\ Y f \tp \Arrow\ X\ Y
\end{align} \end{align}
% %
To show that this choice fits the bill I must now verify that it satisfies To show that this choice fits the bill, I must verify that it
\ref{eq:pairArrowLaw}, which in this case becomes: satisfies \ref{eq:pairArrowLaw}, which in this case becomes:
% %
\begin{align} \begin{align}
(y_{\mathcal{A}} \lll f ≡ x_{\mathcal{A}}) × (y_{\mathcal{B}} \lll f ≡ x_{\mathcal{B}}) (y_{\mathcal{A}} \lll f ≡ x_{\mathcal{A}}) × (y_{\mathcal{B}} \lll f ≡ x_{\mathcal{B}})
\end{align} \end{align}
% %
Which, since $f$ is an isomorphism and $p_{\mathcal{A}}$ (resp.\ $p_{\mathcal{B}}$) which, since $f$ is an isomorphism and $p_{\mathcal{A}}$
is a path varying according to a path constructed from this isomorphism, this is (resp.\ $p_{\mathcal{B}}$) is a path varying according to a path
exactly what \ref{eq:domain-twist-0} gives us. constructed from this isomorphism, this is exactly what
\ref{eq:domain-twist-0} gives us.
% %
The other direction is quite analogous. We choose $\inv{f}$ as the morphism and The other direction is quite analogous. We choose $\inv{f}$ as the morphism and
prove that it satisfies \ref{eq:pairArrowLaw} with \ref{eq:domain-twist-1}. prove that it satisfies \ref{eq:pairArrowLaw} with \ref{eq:domain-twist-1}.
@ -1222,7 +1235,7 @@ This is achieved with the following lemma:
\Path\ (λ \; i → q\ i)\ a\ b \Path\ (λ \; i → q\ i)\ a\ b
\end{align} \end{align}
% %
Which is used without proof. See the implementation for the details. which is used without proof. See the implementation for the details.
\ref{eq:product-paths} is then proven with the propositions: \ref{eq:product-paths} is then proven with the propositions:
% %
@ -1249,7 +1262,7 @@ isomorphism-of is a proposition and that arrows (in both categories)
are sets. The reader is referred to the implementation for the full are sets. The reader is referred to the implementation for the full
gory details. gory details.
% %
\subsection{Products are propositions} \subsection{To have products is a property of a category}
% %
Now that we have constructed the span category\index{span category} I Now that we have constructed the span category\index{span category} I
will demonstrate how to use this to prove that products are will demonstrate how to use this to prove that products are
@ -1264,14 +1277,19 @@ that terminal objects in the span category are equivalent to products:
\var{Terminal}\var{Product}\ \ \mathcal{A}\ \mathcal{B} \var{Terminal}\var{Product}\ \ \mathcal{A}\ \mathcal{B}
\end{align} \end{align}
% %
And as always we do this by constructing an isomorphism: and as always we do this by constructing an isomorphism:
% %
In the direction $\var{Terminal}\var{Product}\ \ \mathcal{A}\ \mathcal{B}$ In the direction
we are given a terminal object $X, x_𝒜, x_$. $X$ will be the product-object and %
$x_𝒜, x_$ will be the product arrows, so it just remains to verify that this is $$
indeed a product. That is, for an object $Y$ and two arrows $y_𝒜 \tp \var{Terminal}\var{Product}\ \ \mathcal{A}\ \mathcal{B}
\Arrow\ Y\ 𝒜$, $y_\ \Arrow\ Y\ $ we must find a unique arrow $f \tp $$
\Arrow\ Y\ X$ satisfying: %
we are given a terminal object $X, x_𝒜, x_$. $X$ will be the
product-object and $x_𝒜, x_$ will be the product arrows, so it just
remains to verify that this is indeed a product. That is, for an
object $Y$ and two arrows $y_𝒜 \tp \Arrow\ Y\ 𝒜$, $y_\ \Arrow\ Y\ $
we must find a unique arrow $f \tp \Arrow\ Y\ X$ satisfying:
% %
\begin{align} \begin{align}
\label{eq:pairCondRev} \label{eq:pairCondRev}
@ -1282,23 +1300,23 @@ indeed a product. That is, for an object $Y$ and two arrows $y_𝒜 \tp
%% \end{split} %% \end{split}
\end{align} \end{align}
% %
Since $X, x_𝒜, x_$ is a terminal object there is a \emph{unique} Since $X, x_𝒜, x_$ is a terminal object, there is a \emph{unique}
arrow from this object to any other object, so in particular also $Y, arrow from this object to any other object. In particular we have $Y,
y_𝒜, y_$. The arrow we will play the role of $f$ and it immediately y_𝒜, y_$. The arrow we will play the role of $f$ and it immediately
satisfies \ref{eq:pairCondRev}. Any other arrow satisfying these satisfies \ref{eq:pairCondRev}. Any other arrow satisfying these
conditions will be equal since $f$ is unique. conditions will be equal since $f$ is unique.
For the other direction we are now given a product $X, x_𝒜, x_$. For the other direction we are now given a product $X, x_𝒜, x_$.
Again this will be the terminal object. So now it remains that for Again this will be the terminal object. Now it remains that for any
any other object there is a unique arrow from that object into $X, other object there is a unique arrow from that object into $X, x_𝒜,
x_𝒜, x_$. Let $Y, y_𝒜, y_$ be another object. As the arrow x_$. Let $Y, y_𝒜, y_$ be another object. As the arrow
$\Arrow\ Y\ X$ we choose the product-arrow $y_𝒜 \x y_$. Since this $\Arrow\ Y\ X$ we choose the product-arrow $y_𝒜 \x y_$. Since this
is a product-arrow it satisfies \ref{eq:pairCondRev}. Let us name the is a product-arrow it satisfies \ref{eq:pairCondRev}. Let us name the
witness to this $\phi_{y_𝒜 \x y_}$. So we have picked as our center witness to this $\phi_{y_𝒜 \x y_}$. We have picked as our center of
of contraction $y_𝒜 \x y_ , \phi_{y_𝒜 \x y_}$ we must now show that contraction $y_𝒜 \x y_ , \phi_{y_𝒜 \x y_}$ we must now show that it
it is contractible. So let $f \tp \Arrow\ X\ Y$ and $\phi_f$ be given is contractible. Let $f \tp \Arrow\ X\ Y$ and $\phi_f$ be given (here
(here $\phi_f$ is the proof that $f$ satisfies \ref{eq:pairCondRev}). $\phi_f$ is the proof that $f$ satisfies \ref{eq:pairCondRev}). The
The proof will be a pair of proofs: proof will be a pair of proofs:
% %
\begin{alignat}{3} \begin{alignat}{3}
p \tp & \Path\ (\lambda\; i → \Arrow\ X\ Y)\quad p \tp & \Path\ (\lambda\; i → \Arrow\ X\ Y)\quad
@ -1330,11 +1348,10 @@ $$
Which follows from arrows being sets and pairs preserving such. Thus we can Which follows from arrows being sets and pairs preserving such. Thus we can
close the final proof with an application of $\lemPropF$. close the final proof with an application of $\lemPropF$.
This concludes the proof This concludes the proof $\var{Terminal}
$\var{Terminal}\var{Product}\ \ \mathcal{A}\ \mathcal{B}$ \var{Product}\ \ \mathcal{A}\ \mathcal{B}$ and since we have that
and since we have that equivalences preserve homotopic levels along equivalences preserve homotopic levels along with \ref{eq:termProp} we
with \ref{eq:termProp} we get our final result. That is, in any get our final result. That is, in any category $\bC$ we have:
category $\bC$ we have:
% %
\begin{align} \begin{align}
_{A, B \tp \Object} \isProp\ (\var{Product}\ \bC\ A\ B) _{A, B \tp \Object} \isProp\ (\var{Product}\ \bC\ A\ B)
@ -1354,7 +1371,7 @@ following data:
\fmap & \tp .\Arrow\ A\ B → 𝔻.\Arrow\ (\omapF\ A)\ (\omapF\ B) \fmap & \tp .\Arrow\ A\ B → 𝔻.\Arrow\ (\omapF\ A)\ (\omapF\ B)
\end{align*} \end{align*}
% %
And the following laws: and the following laws:
\begin{align*} \begin{align*}
\fmap\ .\identity &𝔻.identity \\ \fmap\ .\identity &𝔻.identity \\
\fmap\ (g \clll f) &\fmap\ g \dlll \fmap\ f \fmap\ (g \clll f) &\fmap\ g \dlll \fmap\ f
@ -1462,7 +1479,7 @@ The objects $X$ and $Y$ are implicitly universally quantified. With this data w
f \fish g & ≜ f \rrr (\bind\ g) f \fish g & ≜ f \rrr (\bind\ g)
\end{align*} \end{align*}
% %
It is interesting to note here that this formulation does mention It is interesting to note here that this formulation does not mention
functors nor natural transformations. All we have here is a regular functors nor natural transformations. All we have here is a regular
map on objects and a pair of arrows. map on objects and a pair of arrows.
% %
@ -1502,7 +1519,7 @@ In the monoidal formulation we can define $\bind$:
\bind\ f ≜ \join \lll \fmap\ f \bind\ f ≜ \join \lll \fmap\ f
\end{align} \end{align}
% %
And likewise in the Kleisli formulation we can define $\join$: and likewise in the Kleisli formulation we can define $\join$:
% %
\begin{align} \begin{align}
\join\bind\ \identity \join\bind\ \identity
@ -1596,7 +1613,7 @@ the monoidal formulation we pick:
We must now not only show the monad laws given for the monoidal We must now not only show the monad laws given for the monoidal
formulation (\monoidallaws), we must also verify that $\EndoR$ is a formulation (\monoidallaws), we must also verify that $\EndoR$ is a
functor and that $\pure$ and $\join$ are natural transformations. I functor and that $\pure$ and $\join$ are natural transformations. I
will ommit this here. In stead we shall see how these two mappings will ommit this here. Instead we shall see how these two mappings
are indeed inverses. The full construction can be found in the are indeed inverses. The full construction can be found in the
module: module:
\begin{center} \begin{center}
@ -1614,7 +1631,7 @@ other. To recap, these maps are:
→ (\EndoR, \pure, \bind\ \identity) → (\EndoR, \pure, \bind\ \identity)
\end{align*} \end{align*}
% %
Where $\EndoR(\omapR, \bind\ (\pure \lll f))$. The proof that where $\EndoR(\omapR, \bind\ (\pure \lll f))$. The proof that
this is indeed a functor is left implicit as well as the monad laws. this is indeed a functor is left implicit as well as the monad laws.
Likewise the proof that $\pure$ and $\bind\ \identity$ are natural Likewise the proof that $\pure$ and $\bind\ \identity$ are natural
transformations are left implicit. The inverse map will be: transformations are left implicit. The inverse map will be:
@ -1639,9 +1656,9 @@ For \ref{eq:monad-forwards} let $(\omapR, \pure, \bind)$ be a monad in
the Kleisli form. Since being-a-monad is a proposition\footnote{The the Kleisli form. Since being-a-monad is a proposition\footnote{The
proof was omitted here but can be found in the implementation.} we proof was omitted here but can be found in the implementation.} we
get an equality-principle for kleisli-monads that say that to equate get an equality-principle for kleisli-monads that say that to equate
two such monads it suffices to equate their data-part. So it suffices two such monads it suffices to equate their data part. It thus
to equate the data-parts of the \ref{eq:monad-forwards}. Such a proof suffices to equate the data parts of \ref{eq:monad-forwards}. Such a
is a triple equating the three projections of proof is a triple equating the three projections of
\ref{eq:monad-kleisli-data}. The first two hold definitionally -- \ref{eq:monad-kleisli-data}. The first two hold definitionally --
essentially one just wraps and unwraps the morphism in a functor. For essentially one just wraps and unwraps the morphism in a functor. For
the last equation a little more work is required: the last equation a little more work is required:

View file

@ -1,17 +1,17 @@
\chapter{Introduction} \chapter{Introduction}
This thesis is a case-study in the application of cubical Agda in the This thesis is a case study in the application of cubical Agda to the
context of category theory. At the center of this is the notion of formalization of category theory. At the center of this is the notion
\nomenindex{equality}. In type-theory there are two pervasive notions of \nomenindex{equality}. There are two pervasive notions of equality
of equality: \nomenindex{judgmental equality} and in type theory: \nomenindex{judgmental equality} and
\nomenindex{propositional equality}. Judgmental equality is a property \nomenindex{propositional equality}. Judgmental equality is a property
of the type system. Judgmental equality on the other hand is usually of the type system. Propositional equality on the other hand is
defined \emph{within} the system. When introducing definitions this usually defined \emph{within} the system. When introducing
report will use the symbol $\defeq$. Judgmental equalities will be definitions this report will use the symbol $\defeq$. Judgmental
denoted with $=$ and for propositional equalities the notation equalities will be denoted with $=$ and for propositional equalities
$\equiv$ is used. the notation $\equiv$ is used.
The rules of judgmental equality are related with $β$- and The rules of judgmental equality are related with $β$- and
$η$-reduction which gives a notion of computation in a given type $η$-reduction, which gives a notion of computation in a given type
theory. theory.
% %
There are some properties that one usually want judgmental equality to There are some properties that one usually want judgmental equality to
@ -19,20 +19,21 @@ satisfy. It must be \nomenindex{sound}, enjoy \nomenindex{canonicity}
and be a \nomenindex{congruence relation}. Soundness means that things and be a \nomenindex{congruence relation}. Soundness means that things
judged to be equal are equal with respects to the \nomenindex{model} judged to be equal are equal with respects to the \nomenindex{model}
of the theory or the \emph{meta theory}. It must be a congruence of the theory or the \emph{meta theory}. It must be a congruence
relation because otherwise the relation certainly does not adhere to relation, because otherwise the relation certainly does not adhere to
our notion of equality. One would be able to conclude things like: $x our notion of equality. E.g.\ One would be able to conclude things
\equiv y \rightarrow f\ x \nequiv f\ y$. Canonicity means that any like: $x \equiv y \rightarrow f\ x \nequiv f\ y$. Canonicity means
well typed term evaluates to a \emph{canonical} form. For example for that any well typed term evaluates to a \emph{canonical} form. For
a closed term $e \tp \bN$ it will be the case that $e$ reduces to $n$ example, for a closed term $e \tp \bN$, it will be the case that $e$
applications of $\mathit{suc}$ to $0$ for some $n$; $e = reduces to $n$ applications of $\mathit{suc}$ to $0$ for some $n$;
\mathit{suc}^n\ 0$. Without canonicity terms in the language can get i.e.\ $e = \mathit{suc}^n\ 0$. Without canonicity terms in the
``stuck'' meaning that they do not reduce to a canonical form. language can get ``stuck'', meaning that they do not reduce to a
canonical form.
To work as a programming languages it is necessary for judgmental For a system to work as a programming languages it is necessary for
equality to be \nomenindex{decidable}. Being decidable simply means judgmental equality to be \nomenindex{decidable}. Being decidable
that that an algorithm exists to decide whether two terms are equal. simply means that that an algorithm exists to decide whether two terms
For any practical implementation the decidability must also be are equal. For any practical implementation, the decidability must
effectively computable. also be effectively computable.
For propositional equality the decidability requirement is relaxed. It For propositional equality the decidability requirement is relaxed. It
is not in general possible to decide the correctness of logical is not in general possible to decide the correctness of logical
@ -47,28 +48,27 @@ inhabitant. In extensional type theory the principle of reflection
$$a ≡ b → a = b$$ $$a ≡ b → a = b$$
% %
is enough to make type checking undecidable. This report focuses on is enough to make type checking undecidable. This report focuses on
Agda which at a glance can be thought of as a version of intensional Agda, which at a glance can be thought of as a version of intensional
type theory. Pattern-matching in regular Agda lets one prove type theory. Pattern-matching in regular Agda lets one prove
\nomenindex{Uniqueness of Identity Proofs} (UIP). UIP states that any \nomenindex{Uniqueness of Identity Proofs} (UIP). UIP states that any
two identity proofs are propositionally identical. two identity proofs are propositionally identical.
The usual notion of propositional equality in ITT is quite The usual notion of propositional equality in ITT is quite
restrictive. In the next section a few motivating examples will restrictive. In the next section a few motivating examples will be
highlight this. There exist techniques to circumvent these problems, presented that highlight. There exist techniques to circumvent these
as we shall see. This thesis will explore an extension to Agda that problems, as we shall see. This thesis will explore an extension to
redefines the notion of propositional equality and as such is an Agda that redefines the notion of propositional equality and as such
alternative to these other techniques. The extension is called cubical is an alternative to these other techniques. The extension is called
Agda. Cubical Agda drops UIP as this does not permit cubical Agda. Cubical Agda drops UIP, as it does not permit
\nomenindex{functional extensionality} and \nomenindex{functional extensionality} nor \nomenindex{univalence}.
\nomenindex{univalence}. What makes this extension particularly What makes cubical Agda particularly interesting is that it gives a
interesting is that it gives a \emph{constructive} interpretation of \emph{constructive} interpretation of univalence. What all this means
univalence. What all this means will be elaborated in the following will be elaborated in the following sections.
sections.
% %
\section{Motivating examples} \section{Motivating examples}
% %
In the following two sections I present two examples that illustrate In the following two sections I present two examples that illustrate
some limitations inherent in ITT and -- by extension -- Agda. some limitations inherent in ITT and, by extension, Agda.
% %
\subsection{Functional extensionality} \subsection{Functional extensionality}
\label{sec:functional-extensionality}% \label{sec:functional-extensionality}%
@ -82,7 +82,7 @@ Consider the functions:
The term $n + 0$ is \nomenindex{definitionally} equal to $n$, which we The term $n + 0$ is \nomenindex{definitionally} equal to $n$, which we
write as $n + 0 = n$. This is also called \nomenindex{judgmental write as $n + 0 = n$. This is also called \nomenindex{judgmental
equality}. We call it definitional equality because the equality}. We call it definitional equality because the
\emph{equality} arises from the \emph{definition} of $+$ which is: \emph{equality} arises from the \emph{definition} of $+$, which is:
% %
\begin{align*} \begin{align*}
+ & \tp \bN \to \bN \to \bN \\ + & \tp \bN \to \bN \to \bN \\
@ -92,7 +92,7 @@ write as $n + 0 = n$. This is also called \nomenindex{judgmental
% %
Note that $0 + n$ is \emph{not} definitionally equal to $n$. This is Note that $0 + n$ is \emph{not} definitionally equal to $n$. This is
because $0 + n$ is in normal form. I.e.\ there is no rule for $+$ because $0 + n$ is in normal form. I.e.\ there is no rule for $+$
whose left hand side matches this expression. We do however have that whose left hand side matches this expression. We do, however, have that
they are \nomen{propositionally}{propositional equality} equal, which they are \nomen{propositionally}{propositional equality} equal, which
we write as $n \equiv n + 0$. Propositional equality means that there we write as $n \equiv n + 0$. Propositional equality means that there
is a proof that exhibits this relation. We can do induction over $n$ is a proof that exhibits this relation. We can do induction over $n$
@ -107,20 +107,20 @@ to prove this:
\end{split} \end{split}
\end{align} \end{align}
% %
This show that zero is a right neutral element hence the name $\var{zrn}$. This show that zero is a right neutral element (hence the name
Since equality is a transitive relation we have that $\forall n \to $\var{zrn}$). Since equality is a transitive relation we have that
\var{zeroLeft}\ n \equiv \var{zeroRight}\ n$. Unfortunately we don't $\forall n \to \var{zeroLeft}\ n \equiv \var{zeroRight}\ n$.
have $\var{zeroLeft} \equiv \var{zeroRight}$. There is no way to Unfortunately we don't have $\var{zeroLeft} \equiv \var{zeroRight}$.
construct a proof asserting the obvious equivalence of There is no way to construct a proof asserting the obvious equivalence
$\var{zeroLeft}$ and $\var{zeroRight}$. Actually showing this is of $\var{zeroLeft}$ and $\var{zeroRight}$. Actually showing this is
outside the scope of this text. Essentially it would involve giving a outside the scope of this text. It would essentially involve giving a
model for our type theory that validates all our axioms but where model for our type theory that validates all our axioms but where
$\var{zeroLeft} \equiv \var{zeroRight}$ is not true. We cannot show $\var{zeroLeft} \equiv \var{zeroRight}$ is not true. We cannot show
that they are equal even though we can prove them equal for all that they are equal even though we can prove them equal for all
points. For functions this is exactly the notion of equality that we points. This is exactly the notion of equality that we are interested
are interested in: Functions are considered equal when they are equal in for functions: Functions are considered equal when they are equal
for all inputs. This is called \nomenindex{pointwise equality}, where for all inputs. This is called \nomenindex{pointwise equality} where
the \emph{points} of a function refer to its arguments. \emph{points} of a function refer to its arguments.
% %
\subsection{Equality of isomorphic types} \subsection{Equality of isomorphic types}
% %
@ -128,15 +128,14 @@ Let $\top$ denote the unit type -- a type with a single constructor.
In the propositions as types interpretation of type theory $\top$ is In the propositions as types interpretation of type theory $\top$ is
the proposition that is always true. The type $A \x \top$ and $A$ has the proposition that is always true. The type $A \x \top$ and $A$ has
an element for each $a \tp A$. So in a sense they have the same shape an element for each $a \tp A$. So in a sense they have the same shape
(Greek; (Greek; \nomenindex{isomorphic}). The second element of the pair does
\nomenindex{isomorphic}). The second element of the pair does not not add any ``interesting information''. It can be useful to identify
add any ``interesting information''. It can be useful to identify such such types. In fact it is quite commonplace in mathematics. Say we
types. In fact, it is quite commonplace in mathematics. Say we look at look at a set $\{x \mid \phi\ x \land \psi\ x\}$ and somehow conclude
a set $\{x \mid \phi\ x \land \psi\ x\}$ and somehow conclude that that $\psi\ x \equiv \top$ for all $x$. A mathematician would
$\psi\ x \equiv \top$ for all $x$. A mathematician would immediately immediately conclude $\{x \mid \phi\ x \land \psi\ x\} \equiv \{x \mid
conclude $\{x \mid \phi\ x \land \psi\ x\} \equiv \{x \mid \phi\ x\}$ \phi\ x\}$ without thinking twice. Unfortunately such an
without thinking twice. Unfortunately such an identification can not identification can not be performed in ITT.
be performed in ITT.
More specifically what we are interested in is a way of identifying More specifically what we are interested in is a way of identifying
\nomenindex{equivalent} types. I will return to the definition of \nomenindex{equivalent} types. I will return to the definition of
@ -161,11 +160,11 @@ of Category Theory. At a glance category theory can be described as
``the mathematical study of (abstract) algebras of functions'' ``the mathematical study of (abstract) algebras of functions''
(\cite{awodey-2006}). By that token functional extensionality is (\cite{awodey-2006}). By that token functional extensionality is
particularly useful for formulating Category Theory. In Category particularly useful for formulating Category Theory. In Category
theory it is also commonplace to identify isomorphic structures and theory it is also commonplace to identify isomorphic structures.
univalence gives us a way to make this notion precise. In fact we can Univalence gives us a way to make this notion precise. In fact we can
formulate this requirement within our formulation of categories by formulate this requirement within our formulation of categories by
requiring the \emph{categories} themselves to be univalent as we shall requiring the \emph{categories} themselves to be univalent as we shall
see in \S\ref{sec:univalence}. see in section \S\ref{sec:univalence}.
\section{Context} \section{Context}
\label{sec:context} \label{sec:context}
@ -191,15 +190,16 @@ are a multitude of these available online. Notably:
\url{https://github.com/mortberg/cubicaltt} \url{https://github.com/mortberg/cubicaltt}
\end{itemize} \end{itemize}
% %
The contribution of this thesis is to explore how working in a cubical setting The contribution of this thesis is to explore how working in a cubical
will make it possible to prove more things and to reuse proofs and to try and setting will make it possible to prove more things, to reuse proofs
compare some aspects of this formalization with the existing ones. and to compare some aspects of this formalization with the existing
ones.
There are alternative approaches to working in a cubical setting where There are alternative approaches to working in a cubical setting where
one can still have univalence and functional extensionality. One one can still have univalence and functional extensionality. One
option is to postulate these as axioms. This approach, however, has option is to postulate these as axioms. This approach, however, has
other shortcomings, e.g. you lose \nomenindex{canonicity} other shortcomings, e.g.\ you lose \nomenindex{canonicity}
(\cite[p. 3]{huber-2016}). (\cite[p.\ 3]{huber-2016}).
Another approach is to use the \emph{setoid interpretation} of type Another approach is to use the \emph{setoid interpretation} of type
theory (\cite{hofmann-1995,huber-2016}). With this approach one works theory (\cite{hofmann-1995,huber-2016}). With this approach one works
@ -207,13 +207,13 @@ with \nomenindex{extensional sets} $(X, \sim)$. That is a type $X \tp
\MCU$ and an equivalence relation $\sim\ \tp X \to X \to \MCU$ on that \MCU$ and an equivalence relation $\sim\ \tp X \to X \to \MCU$ on that
type. Under the setoid interpretation the equivalence relation serve type. Under the setoid interpretation the equivalence relation serve
as a sort of ``local'' propositional equality. Since the developer as a sort of ``local'' propositional equality. Since the developer
gets to pick this relation it is not a~priori a congruence gets to pick this relation, it is not a~priori a congruence
relation. So this must be verified manually by the developer. relation. It must be manually verified by the developer. Furthermore,
Furthermore, functions between different setoids must be shown to be functions between different setoids must be shown to be setoid
setoid homomorphism, that is; they preserve the relation. homomorphism, that is; they preserve the relation.
This approach has other drawbacks; it does not satisfy all This approach has other drawbacks: It does not satisfy all
propositional equalities of type theory a\~priori. That is, the propositional equalities of type theory a~priori. That is, the
developer must manually show that e.g.\ the relation is a congruence. developer must manually show that e.g.\ the relation is a congruence.
Equational proofs $a \sim_{X} b$ are in some sense `local' to the Equational proofs $a \sim_{X} b$ are in some sense `local' to the
extensional set $(X , \sim)$. To e.g.\ prove that $x y → f\ x extensional set $(X , \sim)$. To e.g.\ prove that $x y → f\ x
@ -223,23 +223,19 @@ makes it very cumbersome to work with in practice (\cite[p.
4]{huber-2016}). 4]{huber-2016}).
\section{Conventions} \section{Conventions}
In the remainder of this paper I will use the term \nomenindex{Type} In the remainder of this thesis I will use the term \nomenindex{Type}
to describe -- well -- types. Thereby departing from the notation in to describe -- well -- types; thereby departing from the notation in
Agda where the keyword \texttt{Set} refers to types. \nomenindex{Set} Agda where the keyword \texttt{Set} refers to types.
on the other hand shall refer to the homotopical notion of a set. I \nomenindex{Set}, on the other hand, shall refer to the homotopical
will also leave all universe levels implicit. This of course does not notion of a set. I will also leave all universe levels implicit. This
mean that a statement such as $\MCU \tp \MCU$ means that we have of course does not mean that a statement such as $\MCU \tp \MCU$ means
type-in-type but rather that the arguments to the universes are that we have type-in-type but rather that the arguments to the
implicit. universes are implicit.
And I use the term I use the term \nomenindex{arrow} to refer to morphisms in a category,
\nomenindex{arrow} to refer to morphisms in a category, whereas the terms \nomenindex{morphism}, \nomenindex{map} or
whereas the terms \nomenindex{function} shall be reserved for talking about type
\nomenindex{morphism}, theoretic functions; i.e.\ functions in Agda.
\nomenindex{map} or
\nomenindex{function}
shall be reserved for talking about type theoretic functions; i.e.
functions in Agda.
As already noted $\defeq$ will be used for introducing definitions $=$ As already noted $\defeq$ will be used for introducing definitions $=$
will be used to for judgmental equality and $\equiv$ will be used for will be used to for judgmental equality and $\equiv$ will be used for