...
authorFrancesco Mazzoli <f@mazzo.li>
Tue, 11 Jun 2013 15:36:47 +0000 (16:36 +0100)
committerFrancesco Mazzoli <f@mazzo.li>
Tue, 11 Jun 2013 15:36:47 +0000 (16:36 +0100)
thesis.lagda

index 3dcd9a97d6e680a475ddd3a6793fa597ba7751ac..64b1ca0c07de275555d9cfe55d4d6162f96cca64 100644 (file)
@@ -1,6 +1,18 @@
-\documentclass[report]{article}
+\documentclass[report, 11pt]{article}
 \usepackage{etex}
 
+\usepackage[sc,slantedGreek]{mathpazo}
+\linespread{1.05}
+% \usepackage{times}
+
+\oddsidemargin 0in
+\evensidemargin 0in
+\textheight 9.5in 
+\textwidth     6.2in
+\topmargin     -7mm  
+\parindent     10pt
+
+
 %% Narrow margins
 % \usepackage{fullpage}
 
 \newcommand{\mydesc}[3]{
   \noindent
   \mbox{
-      \vspace{0.1cm}
     \parbox{\textwidth}{
       {\small
+        \vspace{0.2cm}
         \hfill \textbf{#1} $#2$
         \framebox[\textwidth]{
           \parbox{\textwidth}{
             \centering{
               #3
             }
-            \vspace{0.1cm}
+            \vspace{0.2cm}
           }
         }
       }
@@ -370,7 +382,6 @@ complete.  As a corollary, we must be able to devise a term that reduces forever
   (\myapp{\omega}{\omega}) \myred (\myapp{\omega}{\omega}) \myred \cdots \text{, with $\omega = \myabs{x}{\myapp{x}{x}}$}
 \]
 }
-
 A \emph{redex} is a term that can be reduced.  In the untyped $\lambda$-calculus
 this will be the case for an application in which the first term is an
 abstraction, but in general we call aterm reducible if it appears to the left of
@@ -1152,6 +1163,8 @@ Finally, the well-order type, or in short $\mytyc{W}$-type, which will
 let us represent inductive data in a general (but clumsy) way.  The core
 idea is to
 
+% TODO finish
+
 
 \section{The struggle for equality}
 \label{sec:equality}
@@ -1185,7 +1198,7 @@ formalised in Agda in appendix \ref{app:agda-itt}.
     $
     \myjeq{\myse{P}}{(\myapp{\myrefl}{\mytmm})}{\mytmn} \myred \mytmn
     $
-  \vspace{0.87cm}
+  \vspace{0.9cm}
 }
 \end{minipage}
 
@@ -1287,17 +1300,11 @@ $\eta$-expansion.  We can then have
   \DisplayProof
 }
 
-%   \mydesc{definitional equality:}{\mytmsyn \mydefeq \mytmsyn}{
-%     \begin{tabular}{cc}
-%       \AxiomC{}
-%       &
-%       foo
-%     \end{tabular}
-%   }
-% \end{description}
+% TODO finish
 
 \subsubsection{Uniqueness of identity proofs}
 
+% TODO finish
 % TODO reference the fact that J does not imply J
 % TODO mention univalence
 
@@ -1384,13 +1391,16 @@ that this causes:
 \item The rule is syntax directed, and the type checker is presumably expected
   to come up with equality proofs when needed.
 \item More worryingly, type checking becomes undecidable also because
-  computing under false assumptions becomes unsafe.
-  Consider for example
-  {\small\[
-  \myabss{\myb{q}}{\mytya \mypeq{\mytyp} (\mytya \myarr \mytya)}{\myhole{?}}
+  computing under false assumptions becomes unsafe, since we can use
+  equality reflection and the conversion rule to have terms of any
+  type.
+  Consider for example {\small\[ \myabss{\myb{q}}{\mytya
+      \mypeq{\mytyp} (\mytya \myarr \mytya)}{\myhole{?}}
   \]}
-  Using the assumed proof in tandem with equality reflection we could easily
-  write a classic Y combinator, sending the compiler into a loop.
+Using the assumed proof in tandem with equality reflection we
+could easily write a classic Y combinator, sending the compiler into a
+loop.  In general, we using the conversion rule 
+% TODO check that this makes sense
 \end{itemize}
 
 Given these facts theories employing equality reflection, like NuPRL
@@ -1419,6 +1429,7 @@ gain extensionality?
 
 \subsection{Some alternatives}
 
+% TODO finish
 % TODO add `extentional axioms' (Hoffman), setoid models (Thorsten)
 
 \section{Observational equality}
@@ -1464,7 +1475,7 @@ exposition which follows closely the original paper.
 }
 
 \mydesc{propositions:}{\myjud{\myprsyn}{\myprop}}{
-    \begin{tabular}{cc}
+    \begin{tabular}{ccc}
       \AxiomC{\phantom{$\myjud{\myse{P}}{\myprop}$}}
       \UnaryInfC{$\myjud{\mytop}{\myprop}$}
       \noLine
@@ -1477,14 +1488,14 @@ exposition which follows closely the original paper.
       \noLine
       \UnaryInfC{\phantom{$\myjud{\mybot}{\myprop}$}}
       \DisplayProof
-    \end{tabular}
-
-    \myderivsp
-
+      &
       \AxiomC{$\myjud{\myse{A}}{\mytyp}$}
       \AxiomC{$\myjudd{\myctx; \myb{x} : \mytya}{\myse{P}}{\myprop}$}
       \BinaryInfC{$\myjud{\myprfora{\myb{x}}{\mytya}{\myse{P}}}{\myprop}$}
+      \noLine
+      \UnaryInfC{\phantom{$\myjud{\mybot}{\myprop}$}}
       \DisplayProof
+    \end{tabular}
 }
 
 Our foundation will be a type theory like the one of section
@@ -1752,16 +1763,16 @@ still compute.  Thus, we can take $\myfun{coh}$ as axiomatic, and we can
 add back familiar useful equality rules:
 
 \mydesc{typing:}{\myjud{\mytmsyn}{\mytmsyn}}{
+  \begin{tabular}{cc}
   \AxiomC{$\myjud{\mytmt}{\mytya}$}
   \UnaryInfC{$\myjud{\myapp{\myrefl}{\mytmt}}{\myprdec{\myjm{\myb{x}}{\myb{\mytya}}{\myb{x}}{\myb{\mytya}}}}$}
   \DisplayProof
-  
-  \myderivsp
-  
+  &
   \AxiomC{$\myjud{\mytya}{\mytyp}$}
   \AxiomC{$\myjudd{\myctx; \myb{x} : \mytya}{\mytyb}{\mytyp}$}
   \BinaryInfC{$\myjud{\mytyc{R} \myappsp (\myb{x} {:} \mytya) \myappsp \mytyb}{\myfora{\myb{y}\, \myb{z}}{\mytya}{\myprdec{\myjm{\myb{y}}{\mytya}{\myb{z}}{\mytya} \myimpl \mysub{\mytyb}{\myb{x}}{\myb{y}} \myeq \mysub{\mytyb}{\myb{x}}{\myb{z}}}}}$}
   \DisplayProof
+  \end{tabular}
 }
 
 $\myrefl$ is the equivalent of the reflexivity rule in propositional
@@ -2031,7 +2042,7 @@ To present the elaboration and operations on user defined data types, we
 frequently make use what de Bruijn called \emph{telescopes}
 \citep{Bruijn91}, a construct that will prove useful when dealing with
 the types of type and data constructors.  A telescope is a series of
-nested typed bindings, such as $(\myb{x} {:} \mynat); (\myb{p} :
+nested typed bindings, such as $(\myb{x} {:} \mynat); (\myb{p} {:}
 \myapp{\myfun{even}}{\myb{x}})$.  Consistently with the notation for
 contexts and term vectors, we use $\myemptyctx$ to denote an empty
 telescope and $\myarg ; \myarg$ to add a new binding to an existing
@@ -2300,7 +2311,60 @@ what we can defined, with some examples.
 
 \item[Ordered lists] Up to this point, the examples shown are nothing
   new to the \{Haskell, SML, OCaml, functional\} programmer.  However
-  dependent types let us express much more than 
+  dependent types let us express much more than that.  A useful example
+  is the type of ordered lists. There are many ways to define such a
+  thing, we will define our type to store the bounds of the list, making
+  sure that $\mydc{cons}$ing respects that.
+
+  First, using $\myunit$ and $\myempty$, we define a type expressing the
+  ordering on natural numbers, $\myfun{le}$---`less or equal'.
+  $\myfun{le}\myappsp \mytmm \myappsp \mytmn$ will be inhabited only if
+  $\mytmm \le \mytmn$:
+  {\small\[
+    \begin{array}{@{}l}
+      \myfun{le} : \mynat \myarr \mynat \myarr \mytyp \mapsto \\
+        \myind{2} \myabs{\myb{n}}{\\
+          \myind{2}\myind{2} \mynat.\myfun{elim} \\
+            \myind{2}\myind{2}\myind{2} \myb{n} \\
+            \myind{2}\myind{2}\myind{2} (\myabs{\myarg}{\mynat \myarr \mytyp}) \\
+            \myind{2}\myind{2}\myind{2} (\myabs{\myarg}{\myunit}) \\
+            \myind{2}\myind{2}\myind{2} (\myabs{\myb{n}\, \myb{f}\, \myb{m}}{
+              \mynat.\myfun{elim} \myappsp \myb{m} \myappsp (\myabs{\myarg}{\mytyp}) \myappsp \myempty \myappsp (\myabs{\myb{m'}\, \myarg}{\myapp{\myb{f}}{\myb{m'}}})
+                              })
+                              }
+    \end{array}
+    \]} We return $\myunit$ if the scrutinised is $\mydc{zero}$ (every
+  number in less or equal than zero), $\myempty$ if the first number is
+  a $\mydc{suc}$cessor and the second a $\mydc{zero}$, and we recurse if
+  they are both successors.  Since we want the list to have possibly
+  `open' bounds, for example for empty lists, we create a type for
+  `lifted' naturals with a bottom (less than everything) and top
+  (greater than everything) elements, along with an associated comparison
+  function:
+  {\small\[
+    \begin{array}{@{}l}
+    \myadt{\mytyc{Lift}}{ }{ }{\mydc{bot} \mydcsep \mydc{lift} \myappsp \mynat \mydcsep \mydc{top}}\\
+    \myfun{le'} : \mytyc{Lift} \myarr \mytyc{Lift} \myarr \mytyp \mapsto \cdots \\
+    \end{array}
+    \]} Finally, we can defined a type of ordered lists.  The type is
+  parametrised over two values representing the lower and upper bounds
+  of the elements, as opposed to the type parameters that we are used
+  to.  Then, an empty list will have to have evidence that the bounds
+  are ordered, and each time we add an element we require the list to
+  have a matching lower bound:
+  {\small\[
+    \begin{array}{@{}l}
+      \myadt{\mytyc{OList}}{\myappsp (\myb{low}\ \myb{upp} {:} \mytyc{Lift})}{\\ \myind{2}}{
+          \mydc{nil} \myappsp (\myfun{le'} \myappsp \myb{low} \myappsp \myb{upp}) \mydcsep \mydc{cons} \myappsp (\myb{n} {:} \mynat) \myappsp \mytyc{OList} \myappsp (\myfun{lift} \myappsp \myb{n}) \myappsp (\myfun{le'} \myappsp \myb{low} \myappsp (\myfun{lift} \myappsp \myb{n})
+        }
+    \end{array}
+    \]} If we want we can then employ this structure to write and prove
+  correct various sorting algorithms\footnote{See this presentation by
+    Conor McBride:
+    \url{https://personal.cis.strath.ac.uk/conor.mcbride/Pivotal.pdf},
+    and this blog post by the author:
+    \url{http://mazzo.li/posts/AgdaSort.html}.}.
+  
   % TODO
 
 \item[Dependent products] Apart from $\mysyn{data}$, $\mykant$\ offers
@@ -3071,6 +3135,16 @@ diagrammatically in figure \ref{fig:kant-process}:
 
 \section{Future work}
 
+\subsection{Coinduction}
+
+\subsection{Quotient types}
+
+\subsection{Partiality}
+
+\subsection{Pattern matching}
+
+\subsection{Pattern unification}
+
 % TODO coinduction (obscoin, gimenez), pattern unification (miller,
 % gundry), partiality monad (NAD)