Skip to content

Commit 3e7cc19

Browse files
committed
abstract and how-to
includes knowledgification of all notations
1 parent 2284cdb commit 3e7cc19

File tree

13 files changed

+421
-246
lines changed

13 files changed

+421
-246
lines changed

Manuscript/beyond-gcic.tex

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ \subsection{The discrete model}
5353
analysis} in order to resolve casts. For the former, we build upon the work of
5454
\sidetextcite{Pedrot2018} on the exceptional type theory \kl{ExTT}.
5555
For the latter, we reuse the technique of \textcite{Boulier2017} to equip the universe with
56-
an elimination principle $\typerec$%
56+
an elimination principle $\intro*\typerec$%
5757
\sidenote{Corresponding to a form of ad-hoc polymorphism.},
5858
which requires induction-recursion to be implemented.
5959
%
@@ -117,7 +117,7 @@ \subsection{The monotone model}
117117

118118
\AP The precision order of the monotone model can be reflected back to
119119
\kl{CCIC}, giving rise to the \intro{propositional precision} judgment
120-
$\tcol{\Gamma} \vdash \tcol{t} \precision{\tcol{T}}{\tcol{U}} \tcol{u}$, where
120+
$\tcol{\Gamma} \vdash \tcol{t} \intro*\precision{\tcol{T}}{\tcol{U}} \tcol{u}$, where
121121
$\tcol{T}$ and $\tcol{U}$ are the respective types of $\tcol{t}$ and $\tcol{u}$.
122122
Type dependency naturally demands such a notion of inhomogeneous precision,
123123
rather than a simpler notion relating only terms of the same type.
@@ -133,7 +133,7 @@ \subsection{The monotone model}
133133
a judgment that does not hold for \kl{definitional precision}.
134134
%
135135
In particular, \kl{propositional precision} is invariant by \kl{conversion}: if
136-
$\tcol{t} \conv \tcol{t'}$, $\tcol{u} \conv \tcol{u'}$ and
136+
$\tcol{t} \aconv \tcol{t'}$, $\tcol{u} \aconv \tcol{u'}$ and
137137
$\tcol{\Gamma} \vdash \tcol{t} \precision{\tcol{T}}{\tcol{U}} \tcol{u}$
138138
then
139139
$\tcol{\Gamma} \vdash \tcol{t'} \precision{\tcol{T}}{\tcol{U}}
@@ -180,10 +180,10 @@ \subsection{The monotone model}
180180
\tcol{\Gamma} \vdash \tcol{\cast{T}{U}{t}} \precision{\tcol{U}}{\tcol{U}} \tcol{u}
181181
\Leftrightarrow \tcol{\Gamma} \vdash \tcol{t} \precision{\tcol{T}}{\tcol{U}} \tcol{u}
182182
\Leftrightarrow \tcol{\Gamma} \vdash \tcol{t}
183-
\precision{\tcol{T}}{\tcol{T}} \tcol{\cast{U}{T} u}
183+
\precision{\tcol{T}}{\tcol{T}} \tcol{\cast{U}{T}{u}}
184184
\end{align*}
185185
And furthermore,
186-
$\tcol{\Gamma} \vdash \tcol{{\cast{U}{T}{\cast{T}{U}{t}}} \precision{\tcol{T}}{\tcol{T}} \tcol{t}}$ – this is the retraction property.
186+
$\tcol{\Gamma} \vdash \tcol{\cast{U}{T}{\cast{T}{U}{t}}} \precision{\tcol{T}}{\tcol{T}} \tcol{t}$ – this is the retraction property.
187187
\end{theorem}
188188

189189

@@ -224,7 +224,7 @@ \subsection{The issue with propositional equality}
224224
but are no longer equivalent in \kl{CCIC}.
225225
Consider the two functions $\tcol{\id_{\Nat}}$ and $\tcol{\addz}$ defined respectively as
226226
$\tcol{\id_{\Nat}} \coloneqq \tcol{\l x : \Nat.\ n}$ and
227-
$\tcol{\addz} \coloneqq \tcol{\l x : \Nat.\ x + 0}$.
227+
$\tcol{\addz} \coloneqq \tcol{\l x : \Nat.\ x + \z}$.
228228
In \kl{CIC}, these functions are not convertible, but they are pointwise equal,
229229
and observationally equivalent.
230230
However, they would not be observationally equivalent in \kl{GCIC} under our assumptions.
@@ -305,7 +305,7 @@ \subsection{Solutions for vectors}
305305
-> Vectf A m -> Vectf A n.
306306
\end{coqcode}
307307
Here, \coqe{eq_nat} is the type of \emph{decidable} equality proofs between natural numbers,
308-
expressing the constraints on $n$\eg $\eqty{n}{0}$ – but avoiding the use of the unavailable propositional equalities –, which can be defined like this:
308+
expressing the constraints on $n$\eg $\eqty{n}{\z}$ – but avoiding the use of the unavailable propositional equalities –, which can be defined like this:
309309
\begin{coqcode}
310310
Fixpoint eq_nat (m n : ℕ) : Type :=
311311
match m, n with
@@ -356,14 +356,14 @@ \subsection{Solutions for vectors}
356356
}}[V-cons-s]\label{red:v-S}
357357
\and
358358
\redrule{\tcol{
359-
\castrev{\left(\vcons[A][k]{a}{v}\right)}{\GVect(A,\S n)}{\GVect(B,0)}
359+
\castrev{\left(\vcons[A][k]{a}{v}\right)}{\GVect(A,\S n)}{\GVect(B,\z)}
360360
}}{\tcol{
361-
\err[\GVect(B,0)]
361+
\err[\GVect(B,\z)]
362362
}}[V-cons-0]\label{red:v-S0} \and
363363
\redrule{\tcol{
364-
\castrev{\left(\gvcons[A][k]{a}{v}\right)}{\GVect(A,\?[\Nat])}{\GVect(B,0)}
364+
\castrev{\left(\gvcons[A][k]{a}{v}\right)}{\GVect(A,\?[\Nat])}{\GVect(B,\z)}
365365
}}{\tcol{
366-
\err[\GVect(B,0)]
366+
\err[\GVect(B,\z)]
367367
}}[V-cons?-0]\label{red:v-S?0}
368368
\end{mathpar}
369369
\caption{Casts between gradual vector types (excerpt)}
@@ -384,7 +384,7 @@ \subsection{Solutions for vectors}
384384
%
385385
Finally, as expected, \ruleref{red:v-S0} raises an error when the indices do not match.
386386
Similarly, \ruleref{red:v-S?0} also raises an error when trying to create a vector of length
387-
$0$ from one with an unknown index, but whose underlying vector is non-empty.
387+
$\z$ from one with an unknown index, but whose underlying vector is non-empty.
388388

389389
\begin{figure}[ht]
390390
\ContinuedFloat
@@ -393,7 +393,7 @@ \subsection{Solutions for vectors}
393393
\redrule{\tcol{
394394
\ind{\Vect}{\gvnil[A]}{y.z.P}{b_{\vnil},y_1.y_2.y_3.p_{y_3}.b_{\vconsop}}
395395
}}
396-
{\tcol{\castrev{b_{\vnil}}{\mathop{P}0}{\mathop{P} \?[\Nat]}
396+
{\tcol{\castrev{b_{\vnil}}{\mathop{P}\z}{\mathop{P} \?[\Nat]}
397397
}}[V-rect-nil?]\label{red:v-rect-unk-0}
398398

399399
\end{mathpar}
@@ -409,7 +409,7 @@ \subsection{Solutions for vectors}
409409
Intuitively, they transfer the cast on vectors to a cast on the reduct.
410410

411411
Note that all of these rules crucially use the fact that it is possible to discriminate between
412-
$\tcol{0}$, $\tcol{\S n}$ and $\tcol{\?[\Nat]}$,
412+
$\tcol{\z}$, $\tcol{\S n}$ and $\tcol{\?[\Nat]}$,
413413
which is a specificity of the vector type and explains why
414414
this solution is not possible for \eg the equality.
415415

@@ -511,7 +511,7 @@ \section{A Reasonably Gradual Type Theory}
511511
Technically, the two layers are defined using two distinct universe hierarchies.
512512
%
513513
Second, based on the seminal work on Observational Type Theory \sidecite{Altenkirch2007},
514-
\kl{TTOBS} provides a setoidal equality in a specific universe $\SProp$
514+
\kl{TTOBS} provides a setoidal equality in a specific universe $\intro*\SProp$
515515
of definitionally proof-irrelevant propositions.
516516
This universe of strict propositions, introduced by \sidecite{Gilbert2019}
517517
and supported in recent versions of \kl{Coq} and \kl{Agda},

Manuscript/biblio.bib

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3683,6 +3683,16 @@ @Book{Curry1958
36833683
priority = {prio3},
36843684
}
36853685

3686+
@Article{QuantaPA,
3687+
author = {Kevin Hartnett},
3688+
date = {2020-10-01},
3689+
journaltitle = {Quanta Magazine},
3690+
title = {Building the Mathematical Library of the Future},
3691+
url = {https://www.quantamagazine.org/building-the-mathematical-library-of-the-future-20201001/},
3692+
urldate = {2022-04-20},
3693+
priority = {prio3},
3694+
}
3695+
36863696
@Comment{jabref-meta: databaseType:biblatex;}
36873697

36883698
@Comment{jabref-meta: grouping:

Manuscript/bidir-ccw.tex

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,14 @@ \subsection{McBride’s discipline}
2525
we mean:
2626
\begin{itemize}
2727
\item $\vdash \Gamma$ in the case of a context $\Gamma$,
28-
\item $\Gamma \vdash T : \uni$ in the case of a type $T$,
28+
\item $\Gamma \vdash T \ty \uni$ in the case of a type $T$,
2929
\item the existence of some $T$ such that $\Gamma \vdash t \ty T$ in the case of a term $t$.
3030
\end{itemize}
3131
We also use \reintro{well-typed} for a term, with the same meaning as \kl{well-formed}.
3232

33-
\AP In the case of \intro{inference} $\inferty{\Gamma}{t}{T}$, the subject is $t$,
33+
\AP In the case of \intro{inference} $\intro*\inferty{\Gamma}{t}{T}$, the subject is $t$,
3434
$\Gamma$ is an input and $T$ is an output.
35-
On the contrary, in \intro{checking} $\checkty{\Gamma}{t}{T}$, $t$ is still the subject
35+
On the contrary, in \intro{checking} $\intro*\checkty{\Gamma}{t}{T}$, $t$ is still the subject
3636
and $\Gamma$ is an input, but this time $T$ is an input as well.
3737
This means that one should consider whether $\inferty{\Gamma}{t}{T}$
3838
only in cases where $\vdash \Gamma$ is already known,
@@ -73,7 +73,7 @@ \subsection{McBride’s discipline}
7373

7474
\AP Beyond the already mentioned inference and checking judgements,
7575
we need to introduce a third one: \intro{constrained inference}, written
76-
$\pinferty{h}{\Gamma}{t}{T}$, where $h$ is either $\Pi$ or $\uni$.%
76+
$\intro*\pinferty{h}{\Gamma}{t}{T}$, where $h$ is either $\Pi$ or $\uni$.%
7777
\sidenote{These are the only type formers in \kl{CCω}, but
7878
in \kl{PCUIC}, $h$ can also be \eg an inductive type.}
7979
Constrained inference is a judgement – or, rather, a family of judgements indexed by $h$
@@ -236,7 +236,7 @@ \subsection{Constrained inference in disguise}
236236
and the other judgements are inlined.
237237
Once again, reduction is not enough to perform constrained inference, this time
238238
because type constructors can be hidden in subsets:
239-
an inhabitant of a type such as $\{f : \Nat \to \Nat \mid f\ 0 = 0 \}$
239+
an inhabitant of a type such as $\{f : \Nat \to \Nat \mid f\ \z = \z \}$
240240
should be usable as a function of type $\Nat \to \Nat$.
241241
An erasure procedure is therefore required on top of reduction to remove subsets in the places where we use constrained inference.
242242

Manuscript/bidir-intro.tex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646
bidirectional structure for itself. Moreover, in the case of
4747
\textcite{Coquand1996} and \textcite{Norell2007}, they concentrate on bidirectional typing
4848
as a way to remedy for the lack of annotations on their \kl{Curry-style} λ-abstractions.
49-
This is sensible when looking for lightness of the input syntax, but poses an inherent completeness problem: a term such as $(\l x . x)~0$ is not typeable in those systems.%
49+
This is sensible when looking for lightness of the input syntax, but poses an inherent completeness problem: a term such as $(\l x . x)~\z$ is not typeable in those systems.%
5050
\sidenote{They are actually only able to give types to normal forms.}
5151
In the context of \kl{Church-style} abstraction, the closest there is to a description of
5252
bidirectional typing for \kl{CIC} is probably the one given by the

Manuscript/gradual-dependent.tex

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -231,10 +231,10 @@ \section{Safety and Normalization, Endangered}[Safety and Normalization]
231231
%
232232

233233
First, any \kl{closed term} can be ascribed the unknown type $\?$
234-
and then any other type: for instance, $0 \ascop \? \ascop \Bool$ is a
234+
and then any other type: for instance, $\z \ascop \? \ascop \Bool$ is a
235235
well-typed closed term of type $\Bool$.%
236236
\sidenote{
237-
We write $a \ascop A$ for a type \intro{ascription}, which we define as syntactic sugar
237+
We write $\intro*\asc{a}{A}$ for a type \intro{ascription}, which we define as syntactic sugar
238238
for $(\l x:A.\ x)\ a$ \cite{Siek2006}; in
239239
other systems, it is taken as a primitive notion \cite{Garcia2016}.}%
240240
\margincite{Siek2006}%
@@ -274,7 +274,7 @@ \subsection{Axioms}
274274
why would one want to gradualize \kl{CIC} instead of simply postulating
275275
an axiom for any term (be it a program or a proof) that one does not feel like providing (yet)?
276276

277-
\AP Indeed, we can augment \kl{CIC} with a wildcard axiom $\axiom \ty \P A : \uni.\ A$.
277+
\AP Indeed, we can augment \kl{CIC} with a wildcard axiom $\intro*\axiom \ty \P A : \uni.\ A$.
278278
The resulting system, called \intro{CICax}, has an obvious practical benefit: we can use
279279
$\axiom A$%
280280
%\sidenote{Hereafter written $\axiom[A]$.}
@@ -335,13 +335,13 @@ \subsection{Exceptions}
335335
which coincides with that of programming languages with exceptions.
336336

337337
\kl{ExTT} is essentially \kl{CICrai}, that is, it
338-
extends \kl{CIC} with an indexed exceptional term $\rai[A]$ that can inhabit any type $A$.
338+
extends \kl{CIC} with an indexed exceptional term $\intro*\rai[A]$ that can inhabit any type $A$.
339339
But instead of being treated as a computational black box like $\axiom A$,
340340
$\rai[A]$ is endowed with computational content
341341
emulating exceptions in programming languages, which propagate instead of being stuck.
342342
%
343343
For instance, in \kl{ExTT} the following conversion holds:
344-
\[\ind{\Bool}{\rai[\Bool]}{\Nat}{0,1} \conv \rai[\Nat]\]
344+
\[\ind{\Bool}{\rai[\Bool]}{\Nat}{\z,1} \conv \rai[\Nat]\]
345345

346346
\AP Notably, such exceptions are \intro{call-by-name} exceptions, so one can only
347347
discriminate exceptions on positive types – \ie inductive types –, not on negative
@@ -490,7 +490,7 @@ \subsection{Gradual guarantees}
490490
possibilities for the impact of type information on program behaviour,
491491
compared to what was originally intended \sidecite{Siek2006}.
492492
%
493-
Consequently, \textcite{Siek2015} brought forth type \intro{precision} – denoted $\pre$
493+
Consequently, \textcite{Siek2015} brought forth type \intro{precision} – denoted $\intro*\pre$
494494
as the key notion, from which consistency can be derived: two types $A$ and $B$
495495
are consistent if and only if there exists $T$ such that $T \pre A$ and $T \pre B$.
496496
The \kl{unknown type} $\?$ is the most imprecise type of all,
@@ -546,15 +546,15 @@ \subsection{Gradual guarantees}
546546
\label{def:obsapprox}
547547
A term $\Gamma \vdash t \ty T$ \kl{observationally error-approximates}
548548
a term $\Gamma \vdash t' \ty T'$, noted $ t
549-
\obsApprox t'$, if for all boolean-valued observation contexts
549+
\intro*\obsApprox t'$, if for all boolean-valued observation contexts
550550
$\mathcal{C} : (\Gamma \vdash T) \Rightarrow (\vdash \Bool)$
551551
closing over all free variables, either
552552
\begin{itemize}
553553
\item $\mathcal{C}[t]$ and $\mathcal{C}[t']$ both diverge;
554554
\item otherwise if $\mathcal{C}[t'] \red \err[\Bool]$, then $\mathcal{C}[t] \red \err[\Bool]$.
555555
\end{itemize}
556556

557-
Two terms $t$ and $t'$ are \intro{observationally equivalent}, written $t \obsEquiv t'$,
557+
Two terms $t$ and $t'$ are \intro{observationally equivalent}, written $t \intro*\obsEquiv t'$,
558558
if they are related by \kl{observational error-approximation} in both directions.
559559
\end{definition}
560560

@@ -610,7 +610,7 @@ \subsection{Graduality}
610610
%
611611
\AP The retraction part further states that $a$ is not only more \kl{precise}
612612
than$\asc{\asc{a}{B}}{A}$ – which is given by the unit of the adjunction –
613-
but is \reintro{equi-precise} to it – noted $t \equiprecise \asc{\asc{t}{B}}{A}$.
613+
but is \reintro{equi-precise} to it – noted $t \intro*\equiprecise \asc{\asc{t}{B}}{A}$.
614614
Because the \kl{DGG} dictates that precision implies \kl{observational error-approximation},
615615
\kl{equi-precision} implies \kl{observational equivalence},
616616
and so losing and recovering precision must produce a term that is \kl{observationally
@@ -840,7 +840,7 @@ \subsection{Observational refinement}
840840
\begin{definition}[\intro{Observational refinement}]
841841
\label{def:obsref}
842842
A term $\Gamma \vdash t \ty A$ \kl{observationally refines} a term
843-
$\Gamma \vdash u \ty A$, noted $t \obsRef u$, if for all boolean-valued observation context
843+
$\Gamma \vdash u \ty A$, noted $\intro* t \obsRef u$, if for all boolean-valued observation context
844844
$\mathcal{C} \ty (\Gamma \vdash A) \Rightarrow (\vdash \Bool)$ closing over all
845845
free variables, if $\mathcal{C}[u] \red \err[\Bool]$ or diverges,
846846
then either $\mathcal{C}[t] \red \err[\Bool]$ or $\mathcal{C}[t]$ diverges.
@@ -1254,9 +1254,9 @@ \subsection{Typing, Conversion and Bidirectional Elaboration}
12541254
In order to satisfy \kl{conservativity} with respect to \kl{CIC}, ascriptions in \kl{GCIC}
12551255
are required to satisfy \kl(grad){consistency}. For instance, $\asc{\asc{\true}{\?}}{\Nat}$ is well-typed by \kl(grad){consistency} – used twice –, but $\asc{\true}{\Nat}$ is ill-typed.
12561256
Such ascriptions in \kl{CastCIC} are realized by casts.
1257-
For instance $\asc{\asc{0}{\?}}{\Bool}$ in \kl{GCIC} elaborates
1257+
For instance $\asc{\asc{\z}{\?}}{\Bool}$ in \kl{GCIC} elaborates
12581258
– up to desugaring and reduction – to
1259-
$\castrev{\castrev{0}{\Nat}{\?[\uni]}}{\?[\uni]}{\Bool}$ in \kl{CastCIC}.
1259+
$\castrev{\castrev{\z}{\Nat}{\?[\uni]}}{\?[\uni]}{\Bool}$ in \kl{CastCIC}.
12601260
A major difference between ascriptions in \kl{GCIC} and casts in \kl{CastCIC} is
12611261
that casts are not required to satisfy \kl(grad){consistency}: a cast between any
12621262
two types is well-typed, although of course it might produce an

0 commit comments

Comments
 (0)