on master help sign in
Tinker with spacing
2b3634aEdwin Brady
papers/impl-paper/conclusions.tex+4−4
@@ -54,8 +54,8 @@ implicit syntax and pattern matching --- Norell gives an algorithm for type chec
54a dependently typed language with pattern matching and metavariables
54a dependently typed language with pattern matching and metavariables
55\cite{norell2007thesis}. Unlike the present \Idris{} implementation, metavariables
55\cite{norell2007thesis}. Unlike the present \Idris{} implementation, metavariables
56and implicit arguments are part of the type theory. This has the advantage that
56and implicit arguments are part of the type theory. This has the advantage that
57−implicit arguments can be used more freely, at the expense of complicating the type
57+implicit arguments can be used more freely (for example, in higher order
58−system.
58+function arguments) at the expense of complicating the type system.
59
59
60Epigram \cite{McBride2004a} and Oleg \cite{McBride1999}
60Epigram \cite{McBride2004a} and Oleg \cite{McBride1999}
61have provided much of the inspiration for the \Idris{} elaborator. Indeed,
61have provided much of the inspiration for the \Idris{} elaborator. Indeed,
@@ -132,8 +132,8 @@ of high level languages, especially when augmented with primitive operators.
132We have not discussed the performance of the elaboration
132We have not discussed the performance of the elaboration
133algorithm, or described how \Idris{} compiles to executable code. In practice,
133algorithm, or described how \Idris{} compiles to executable code. In practice,
134we have found performance to be acceptable --- for example, the \Idris{}
134we have found performance to be acceptable --- for example, the \Idris{}
135−library (25 files, 3532 lines of code in total at the time of writing)
135+library (31 files, 3718 lines of code in total at the time of writing)
136−elaborates in around 10 seconds\footnote{On a MacBook Pro, 2.8GHz Intel Core 2
136+elaborates in around 12 seconds\footnote{On a MacBook Pro, 2.8GHz Intel Core 2
137Duo, 4Gb RAM}. Profiling suggests that the main bottleneck is locating holes
137Duo, 4Gb RAM}. Profiling suggests that the main bottleneck is locating holes
138in a proof term, which can be improved by choosing a better representation
138in a proof term, which can be improved by choosing a better representation
139for proof terms, perhaps based on a zipper \cite{Huet1997}. Compilation is made
139for proof terms, perhaps based on a zipper \cite{Huet1997}. Compilation is made
papers/impl-paper/elaboration.tex+247−246
@@ -49,18 +49,18 @@ instantiating one such variable also instantiates all of its dependencies.
49\FFIG{
49\FFIG{
50\begin{array}{c}
50\begin{array}{c}
51\vb ::= \ldots
51\vb ::= \ldots
52− \:\mid\: \hole{\vx}{\vt} \:\:(\mbox{hole binding}) \:\:
52+ \;\mid\; \hole{\vx}{\vt} \;\;(\mbox{hole binding}) \;\;
53− \:\mid\: \guess{\vx}{\vt}{\vt} \:\:(\mbox{guess})
53+ \;\mid\; \guess{\vx}{\vt}{\vt} \;\;(\mbox{guess})
54\medskip\\
54\medskip\\
55−\mathsf{HoleVar}\:
55+\mathsf{HoleVar}\;
56\Rule{(\hole{\vx}{\vS})\in\Gamma}
56\Rule{(\hole{\vx}{\vS})\in\Gamma}
57{\Gamma\vdash\vx\Hab\vS}
57{\Gamma\vdash\vx\Hab\vS}
58\hg
58\hg
59−\mathsf{GuessVar}\:
59+\mathsf{GuessVar}\;
60\Rule{(\guess{\vx}{\vS}{\vs})\in\Gamma}
60\Rule{(\guess{\vx}{\vS}{\vs})\in\Gamma}
61{\Gamma\vdash\vx\Hab\vS}
61{\Gamma\vdash\vx\Hab\vS}
62\\
62\\
63−\mathsf{Hole}\:
63+\mathsf{Hole}\;
64\Rule{
64\Rule{
65\Gamma;\hole{\vx}{\vS}\proves\ve\Hab\vT
65\Gamma;\hole{\vx}{\vS}\proves\ve\Hab\vT
66}
66}
@@ -69,7 +69,7 @@ instantiating one such variable also instantiates all of its dependencies.
69}
69}
70%\hspace*{0.1cm}\vx\not\in\vT
70%\hspace*{0.1cm}\vx\not\in\vT
71\hg
71\hg
72−\mathsf{Guess}\:
72+\mathsf{Guess}\;
73\Rule{
73\Rule{
74\Gamma;\guess{\vx}{\vS}{\ve_1}\proves\ve_2\Hab\vT
74\Gamma;\guess{\vx}{\vS}{\ve_1}\proves\ve_2\Hab\vT
75}
75}
@@ -127,12 +127,12 @@ Exceptions are captured by the option type $\MO{Result}$ which
127either indicates success, or reports an error $\MO{Err}$:
127either indicates success, or reports an error $\MO{Err}$:
128
128
129\DM{
129\DM{
130−\RW{data}\:\MO{Result}\:\vt\:=\:\MO{Success}\:\vt\:\mid\:\MO{Failure}\:\MO{Err}
130+\RW{data}\;\MO{Result}\;\vt\;=\;\MO{Success}\;\vt\;\mid\;\MO{Failure}\;\MO{Err}
131}
131}
132
132
133\noindent
133\noindent
134If any operation fails during a proof (e.g. a subterm fails to type check)
134If any operation fails during a proof (e.g. a subterm fails to type check)
135−then the entire proof fails (i.e. returns $\MO{Failure}\:\ve$ with some error
135+then the entire proof fails (i.e. returns $\MO{Failure}\;\ve$ with some error
136message $\ve$) unless otherwise handled.
136message $\ve$) unless otherwise handled.
137
137
138The \texttt{Elab} monad supports various operations for querying and updating
138The \texttt{Elab} monad supports various operations for querying and updating
@@ -172,7 +172,7 @@ contain hole or guess bindings, it may nevertheless \remph{refer} to hole- or
172guess-bound variables.
172guess-bound variables.
173
173
174The proof state is initialised with the $\MO{NewProof}$ operation. Given a
174The proof state is initialised with the $\MO{NewProof}$ operation. Given a
175−global context $\vC$, $\MO{NewProof}\:\vt$ sets up the proof state as:
175+global context $\vC$, $\MO{NewProof}\;\vt$ sets up the proof state as:
176
176
177\DM{
177\DM{
178(\vC, \cdot, \hole{\vx}{\vt}\SC\vx, \langle\rangle, \langle\vx\rangle)
178(\vC, \cdot, \hole{\vx}{\vt}\SC\vx, \langle\rangle, \langle\vx\rangle)
@@ -181,7 +181,7 @@ global context $\vC$, $\MO{NewProof}\:\vt$ sets up the proof state as:
181The local context is initially empty, and the initial hole queue is the $\vx$ standing for
181The local context is initially empty, and the initial hole queue is the $\vx$ standing for
182the entire expression. The proof term is reset with the $\MO{NewTerm}$ operation.
182the entire expression. The proof term is reset with the $\MO{NewTerm}$ operation.
183In an existing proof state $(\vC, \Delta, \ve, \vQ)$,
183In an existing proof state $(\vC, \Delta, \ve, \vQ)$,
184−$\MO{NewTerm}\:\vt$ discards the proof term and hole queue, and
184+$\MO{NewTerm}\;\vt$ discards the proof term and hole queue, and
185updates the proof state to:
185updates the proof state to:
186
186
187\DM{
187\DM{
@@ -211,21 +211,21 @@ may fail. We have the following primitive meta-operations:
211\item $\MO{Get}$ and $\MO{Put}$ which allow direct access to the proof state.
211\item $\MO{Get}$ and $\MO{Put}$ which allow direct access to the proof state.
212% Focus and Unfocus don't need to be primitive, we could show in terms of
212% Focus and Unfocus don't need to be primitive, we could show in terms of
213% Get and Put
213% Get and Put
214−%\item $\MO{Focus}\:\vn$, which moves $\vn$ to the head of the hole queue.
214+%\item $\MO{Focus}\;\vn$, which moves $\vn$ to the head of the hole queue.
215%\item $\MO{Unfocus}$, which moves the current hole to the back of the hole queue.
215%\item $\MO{Unfocus}$, which moves the current hole to the back of the hole queue.
216−\item $\Check\:\ve$, which type checks an expression $\ve$ relative to a context
216+\item $\Check\;\ve$, which type checks an expression $\ve$ relative to a context
217$\Gamma$, returning its type.
217$\Gamma$, returning its type.
218$\MO{Check}$ will fail
218$\MO{Check}$ will fail
219if the expression is not well-typed.
219if the expression is not well-typed.
220−\item $\Eval\:\ve$, which evaluates a well-typed expression $\ve$ relative to a context
220+\item $\Eval\;\ve$, which evaluates a well-typed expression $\ve$ relative to a context
221$\Gamma$, returning its normal form. $\MO{Normalise}$ reduces under binders,
221$\Gamma$, returning its normal form. $\MO{Normalise}$ reduces under binders,
222but does not reduce definitions which are not total.
222but does not reduce definitions which are not total.
223\item
223\item
224−$\PrimUnify\:\ve_1\:\ve_2$,
224+$\PrimUnify\;\ve_1\;\ve_2$,
225which attempts to unify $\ve_1$ and $\ve_2$ by finding the values with which
225which attempts to unify $\ve_1$ and $\ve_2$ by finding the values with which
226holes must be instantiated for $\ve_1$ and $\ve_2$ to be convertible relative
226holes must be instantiated for $\ve_1$ and $\ve_2$ to be convertible relative
227to $\Gamma$ (i.e. for $\Gamma\proves\ve_1\converts\ve_2$ to hold).
227to $\Gamma$ (i.e. for $\Gamma\proves\ve_1\converts\ve_2$ to hold).
228−\item $\Subst\:\vx\:\ve$, which instantiates a hole $\vx$ directly with a term
228+\item $\Subst\;\vx\;\ve$, which instantiates a hole $\vx$ directly with a term
229$\ve$, typically arising from unification.
229$\ve$, typically arising from unification.
230\end{itemize}
230\end{itemize}
231
231
@@ -233,12 +233,12 @@ $\ve$, typically arising from unification.
233Additionally, we have $\MO{Focus}$, $\MO{Unfocus}$, $\MO{NewHole}$
233Additionally, we have $\MO{Focus}$, $\MO{Unfocus}$, $\MO{NewHole}$
234and $\MO{NextHole}$
234and $\MO{NextHole}$
235operations which manipulate and inspect
235operations which manipulate and inspect
236−the hole queue. $\MO{Focus}\:\vn$ moves a hole to the head of the hole queue:
236+the hole queue. $\MO{Focus}\;\vn$ moves a hole to the head of the hole queue:
237
237
238\DM{
238\DM{
239−\MO{Focus}\:\vn\:=\:\RW{do}\:\AR{
239+\MO{Focus}\;\vn\;=\;\RW{do}\;\AR{
240(\vC,\Delta,\vP,\vQ;\vn;\vQ')\gets\MO{Get}\\
240(\vC,\Delta,\vP,\vQ;\vn;\vQ')\gets\MO{Get}\\
241−\MO{Put}\:(\vC,\Delta,\vP,\vn;\vQ;\vQ')\\
241+\MO{Put}\;(\vC,\Delta,\vP,\vn;\vQ;\vQ')\\
242}
242}
243}
243}
244
244
@@ -247,9 +247,9 @@ Correspondingly, $\MO{Unfocus}$ moves the currently in focus hole to the
247end of the hole queue:
247end of the hole queue:
248
248
249\DM{
249\DM{
250−\MO{Unfocus}\:=\:\RW{do}\:\AR{
250+\MO{Unfocus}\;=\;\RW{do}\;\AR{
251(\vC,\Delta,\vP,\vn;\vQ)\gets\MO{Get}\\
251(\vC,\Delta,\vP,\vn;\vQ)\gets\MO{Get}\\
252−\MO{Put}\:(\vC,\Delta,\vP,\vQ;\vn)\\
252+\MO{Put}\;(\vC,\Delta,\vP,\vQ;\vn)\\
253}
253}
254}
254}
255
255
@@ -259,14 +259,14 @@ next, and $\MO{NextHole}$ returns the next hole to be solved:
259
259
260\DM{
260\DM{
261\AR{
261\AR{
262−\MO{NewHole}\:=\:\RW{do}\:\AR{
262+\MO{NewHole}\;=\;\RW{do}\;\AR{
263(\vC,\Delta,\vP,\vQ)\gets\MO{Get}\\
263(\vC,\Delta,\vP,\vQ)\gets\MO{Get}\\
264−\MO{Put}\:(\vC,\Delta,\vP,\vn;\vQ)\\
264+\MO{Put}\;(\vC,\Delta,\vP,\vn;\vQ)\\
265}
265}
266\\
266\\
267−\MO{NextHole}\:=\:\RW{do}\:\AR{
267+\MO{NextHole}\;=\;\RW{do}\;\AR{
268(\vC,\Delta,\vP,\vn;\vQ)\gets\MO{Get}\\
268(\vC,\Delta,\vP,\vn;\vQ)\gets\MO{Get}\\
269−\MO{Return}\:\vn
269+\MO{Return}\;\vn
270}
270}
271}
271}
272}
272}
@@ -278,7 +278,7 @@ form:
278
278
279\DM{
279\DM{
280\PA{\A\A}{
280\PA{\A\A}{
281−\MO{Tactic}_\Gamma & \:\vec{\VV{args}} & \:\vt & \MoRet{\vt'}
281+\MO{Tactic}_\Gamma & \;\vec{\VV{args}} & \;\vt & \MoRet{\vt'}
282}
282}
283}
283}
284
284
@@ -304,40 +304,40 @@ tactic.
304
304
305\FFIG{
305\FFIG{
306\AR{
306\AR{
307−\MO{Tactic}\:\VV{tac}\:=\:\RW{do}\:\AR{
307+\MO{Tactic}\;\VV{tac}\;=\;\RW{do}\;\AR{
308\ve\Gets\MO{Term}\\
308\ve\Gets\MO{Term}\\
309\vh\Gets\MO{NextHole}\\
309\vh\Gets\MO{NextHole}\\
310−\ve'\Gets\MO{Tactic'}\:\langle\rangle\:\ve\:\VV{tac}\:\vh\\
310+\ve'\Gets\MO{Tactic'}\;\langle\rangle\;\ve\;\VV{tac}\;\vh\\
311−\MO{SetTerm}\:\ve'
311+\MO{SetTerm}\;\ve'
312}
312}
313\medskip
313\medskip
314\\
314\\
315\PA{\A\A\A}{
315\PA{\A\A\A}{
316\RW{where} \\
316\RW{where} \\
317& \MO{Tactic'} & \Gamma & (\hole{\vx}{\vT}\SC\ve)
317& \MO{Tactic'} & \Gamma & (\hole{\vx}{\vT}\SC\ve)
318−& \MoRet{\VV{tac}_\Gamma\:(\hole{\vx}{\vT}\SC\ve)\hg\mbox{if}\:\vx=\vh} \\
318+& \MoRet{\VV{tac}_\Gamma\;(\hole{\vx}{\vT}\SC\ve)\hg\mbox{if}\;\vx=\vh} \\
319& \MO{Tactic'} & \Gamma & (\guess{\vx}{\vT}{\vv}\SC\ve)
319& \MO{Tactic'} & \Gamma & (\guess{\vx}{\vT}{\vv}\SC\ve)
320−& \MoRet{\VV{tac}_\Gamma\:(\guess{\vx}{\vT}{\vv}\SC\ve)\hg\mbox{if}\:\vx=\vh} \\
320+& \MoRet{\VV{tac}_\Gamma\;(\guess{\vx}{\vT}{\vv}\SC\ve)\hg\mbox{if}\;\vx=\vh} \\
321& \MO{Tactic'} & \Gamma & (\lam{\vx}{\vT}\SC\ve)
321& \MO{Tactic'} & \Gamma & (\lam{\vx}{\vT}\SC\ve)
322& \MoRet{
322& \MoRet{
323−\RW{do}\: \AR{\vT'\Gets\:\MO{Tactic'}\:\Gamma\:\vT\\
323+\RW{do}\; \AR{\vT'\Gets\;\MO{Tactic'}\;\Gamma\;\vT\\
324−\lam{\vx}{\vT'}\SC \MO{Tactic'}\:(\Gamma;\lam{\vx}{\vT'})\:\ve}
324+\lam{\vx}{\vT'}\SC \MO{Tactic'}\;(\Gamma;\lam{\vx}{\vT'})\;\ve}
325}
325}
326\\
326\\
327& \MO{Tactic'} & \Gamma & (\all{\vx}{\vT}\SC\ve)
327& \MO{Tactic'} & \Gamma & (\all{\vx}{\vT}\SC\ve)
328& \MoRet{
328& \MoRet{
329−\RW{do}\: \AR{\vT'\Gets\:\MO{Tactic'}\:\Gamma\:\vT\\
329+\RW{do}\; \AR{\vT'\Gets\;\MO{Tactic'}\;\Gamma\;\vT\\
330−\all{\vx}{\vT'}\SC \MO{Tactic'}\:(\Gamma;\all{\vx}{\vT'})\:\ve}
330+\all{\vx}{\vT'}\SC \MO{Tactic'}\;(\Gamma;\all{\vx}{\vT'})\;\ve}
331}
331}
332\\
332\\
333−& \MO{Tactic'} & \Gamma & (\LET\:\vx\defq\vt\Hab\vT\SC\ve)
333+& \MO{Tactic'} & \Gamma & (\LET\;\vx\defq\vt\Hab\vT\SC\ve)
334−& \MoRet{\RW{do}\:\AR{\vt'\Gets\:\MO{Tactic'}\:\Gamma\:\vt\\
334+& \MoRet{\RW{do}\;\AR{\vt'\Gets\;\MO{Tactic'}\;\Gamma\;\vt\\
335−\vT'\Gets\:\MO{Tactic'}\:\Gamma\:\vT\\
335+\vT'\Gets\;\MO{Tactic'}\;\Gamma\;\vT\\
336−\LET\:\vx\defq\vt'\Hab\vT'\SC
336+\LET\;\vx\defq\vt'\Hab\vT'\SC
337−\MO{Tactic'}\:(\Gamma;\LET\:\vx\defq\vt'\Hab\vT')\:\ve}} \\
337+\MO{Tactic'}\;(\Gamma;\LET\;\vx\defq\vt'\Hab\vT')\;\ve}} \\
338−& \MO{Tactic'} & \Gamma & (\vf\:\va) &
338+& \MO{Tactic'} & \Gamma & (\vf\;\va) &
339−\MoRet{\MO{Return}\:(\MO{Tactic'}\:\Gamma\:\vf)\: (\MO{Tactic'}\:\Gamma\:\va)}\\
339+\MoRet{\MO{Return}\;(\MO{Tactic'}\;\Gamma\;\vf)\; (\MO{Tactic'}\;\Gamma\;\va)}\\
340−& \MO{Tactic'} & \Gamma & \vt & \MoRet{\MO{Return}\:\vt}
340+& \MO{Tactic'} & \Gamma & \vt & \MoRet{\MO{Return}\;\vt}
341}
341}
342}
342}
343}
343}
@@ -359,10 +359,10 @@ affect the solution to other unification problems. Instead,
359$\MO{PrimUnify}$ may give one of the following results:
359$\MO{PrimUnify}$ may give one of the following results:
360
360
361\begin{itemize}
361\begin{itemize}
362−\item $\MO{Success}\:(\tx=\te, \tp)$, containing the solved holes mapping
362+\item $\MO{Success}\;(\tx=\te, \tp)$, containing the solved holes mapping
363$\vx$ to $\ve$, and a possibly empty set of blocked unification problems $\tp$.
363$\vx$ to $\ve$, and a possibly empty set of blocked unification problems $\tp$.
364If $\tp$ is empty, there is a solution for $\ve_1$ and $\ve_2$.
364If $\tp$ is empty, there is a solution for $\ve_1$ and $\ve_2$.
365−\item $\MO{Failure}\:\ve$, if no solution is found due to a failure to unify
365+\item $\MO{Failure}\;\ve$, if no solution is found due to a failure to unify
366sub-terms in normal form.
366sub-terms in normal form.
367\end{itemize}
367\end{itemize}
368
368
@@ -381,21 +381,21 @@ resolve the existing problems with $\MO{ReUnify}$.
381%operation to update
381%operation to update
382%the proof state with new problems, and solve the old ones
382%the proof state with new problems, and solve the old ones
383\AR{
383\AR{
384−\Unify\:\ve_1\:\ve_2\:=\:\RW{do}\:
384+\Unify\;\ve_1\;\ve_2\;=\;\RW{do}\;
385\AR{
385\AR{
386−(\tx=\te,\tp)\gets\PrimUnify\:\ve_1\:\ve_2\\
386+(\tx=\te,\tp)\gets\PrimUnify\;\ve_1\;\ve_2\\
387−\vec{\MO{Subst}}\:\tx\:\te\\
387+\vec{\MO{Subst}}\;\tx\;\te\\
388−\MO{SubstProblems}\:(\tx=\te)\\
388+\MO{SubstProblems}\;(\tx=\te)\\
389(\vC,\Delta,\VV{term},\tP,\vQ)\gets\MO{Get}\\
389(\vC,\Delta,\VV{term},\tP,\vQ)\gets\MO{Get}\\
390−\vec{\MO{ReUnify}}\:\tP
390+\vec{\MO{ReUnify}}\;\tP
391}
391}
392\medskip
392\medskip
393\\
393\\
394\AR{
394\AR{
395−\MO{ReUnify}\:(\Gamma,\ve_1,\ve_2)\:=\:\RW{do}\:\AR{
395+\MO{ReUnify}\;(\Gamma,\ve_1,\ve_2)\;=\;\RW{do}\;\AR{
396−(\tx=\te,\tp)\Gets\PrimUnify\:\ve_1\:\ve_2\\
396+(\tx=\te,\tp)\Gets\PrimUnify\;\ve_1\;\ve_2\\
397−\vec{\MO{Subst}}\:\tx\:\te\\
397+\vec{\MO{Subst}}\;\tx\;\te\\
398−\MO{Return}\:\tp
398+\MO{Return}\;\tp
399}
399}
400}
400}
401}
401}
@@ -413,7 +413,7 @@ keeping $\vx$ at the head:
413\DM{
413\DM{
414\PA{\A\A}{
414\PA{\A\A}{
415\MO{Claim}_\Gamma & (\vy \Hab\vS) & (\hole{\vx}{\vT}\SC\ve) &
415\MO{Claim}_\Gamma & (\vy \Hab\vS) & (\hole{\vx}{\vT}\SC\ve) &
416− \MoRet{\RW{return}\:\hole{\vx}{\vT}\SC\hole{\vy}{\vS}\SC\ve} \\
416+ \MoRet{\RW{return}\;\hole{\vx}{\vT}\SC\hole{\vy}{\vS}\SC\ve} \\
417}
417}
418}
418}
419
419
@@ -429,10 +429,10 @@ solve other holes by unifying the expected type of $\vx$ with the type of $\vv$:
429\DM{
429\DM{
430\PA{\A\A}{
430\PA{\A\A}{
431\MO{Fill}_\Gamma & \vv & (\hole{\vx}{\vT}\SC\ve) &
431\MO{Fill}_\Gamma & \vv & (\hole{\vx}{\vT}\SC\ve) &
432− \MoRet{\RW{do}\:\AR{
432+ \MoRet{\RW{do}\;\AR{
433− \vT' \leftarrow \Check\:\vv\\
433+ \vT' \leftarrow \Check\;\vv\\
434− \Unify\:\vT\:\vT'\\
434+ \Unify\;\vT\;\vT'\\
435− \RW{return}\:\guess{\vx}{\vT}{\vv}\SC\ve}
435+ \RW{return}\;\guess{\vx}{\vT}{\vv}\SC\ve}
436 } \\
436 } \\
437}
437}
438}
438}
@@ -443,9 +443,9 @@ For example, consider the following proof term:
443\DM{
443\DM{
444\AR{
444\AR{
445\hole{\vA}{\Type}\SC\hole{\vk}{\Nat}\SC
445\hole{\vA}{\Type}\SC\hole{\vk}{\Nat}\SC
446−\hole{\vx}{\vA}\SC\hole{\vxs}{\Vect\:\vA\:\vk}\SC
446+\hole{\vx}{\vA}\SC\hole{\vxs}{\Vect\;\vA\;\vk}\SC
447\\
447\\
448−\hole{\vys}{\Vect\:\vA\:(\suc\:\vk)}\SC\vys
448+\hole{\vys}{\Vect\;\vA\;(\suc\;\vk)}\SC\vys
449}
449}
450}
450}
451
451
@@ -455,9 +455,9 @@ attempts to
455$\MO{Fill}$ it with an $\TC{Int}$ value $42$, we have:
455$\MO{Fill}$ it with an $\TC{Int}$ value $42$, we have:
456
456
457\begin{itemize}
457\begin{itemize}
458−\item $\Check\:42\:\mq\:\TC{Int}$
458+\item $\Check\;42\;\mq\;\TC{Int}$
459\item Unifying $\TC{Int}$ with $\vA$ (the type of $\vx$) is only possible if
459\item Unifying $\TC{Int}$ with $\vA$ (the type of $\vx$) is only possible if
460−$\vA\:=\:\TC{Int}$, so solve $\vA$.
460+$\vA\;=\;\TC{Int}$, so solve $\vA$.
461\end{itemize}
461\end{itemize}
462
462
463\noindent
463\noindent
@@ -466,9 +466,9 @@ Therefore the resulting proof term is:
466\DM{
466\DM{
467\AR{
467\AR{
468\hole{\vk}{\Nat}\SC
468\hole{\vk}{\Nat}\SC
469−\guess{\vx}{\TC{Int}}{42}\SC\hole{\vxs}{\Vect\:\TC{Int}\:\vk}\SC
469+\guess{\vx}{\TC{Int}}{42}\SC\hole{\vxs}{\Vect\;\TC{Int}\;\vk}\SC
470\\
470\\
471−\hole{\vys}{\Vect\:\TC{Int}\:(\suc\:\vk)}\SC\vys
471+\hole{\vys}{\Vect\;\TC{Int}\;(\suc\;\vk)}\SC\vys
472}
472}
473}
473}
474
474
@@ -479,7 +479,7 @@ the guess is substituted into its scope:
479\DM{
479\DM{
480\PA{\A}{
480\PA{\A}{
481\MO{Solve}_\Gamma & (\guess{\vx}{\vT}{\vv}\SC\ve) &
481\MO{Solve}_\Gamma & (\guess{\vx}{\vT}{\vv}\SC\ve) &
482− \MoRet{\RW{return}\:\ve[\vv/\vx]\hg\mbox{(if $\MO{Pure}\:\vv$)}}
482+ \MoRet{\RW{return}\;\ve[\vv/\vx]\hg\mbox{(if $\MO{Pure}\;\vv$)}}
483}
483}
484}
484}
485
485
@@ -495,9 +495,9 @@ handle failure using the $\MO{Try}$ tactic combinator:
495\DM{
495\DM{
496\PA{\A\A\A}{
496\PA{\A\A\A}{
497\MO{Try}_\Gamma & \VV{t1} & \VV{t2} & \vt &
497\MO{Try}_\Gamma & \VV{t1} & \VV{t2} & \vt &
498− \MoRet{\RW{case}\:\AR{\VV{t1}_\Gamma\:\vt\:\RW{of}\\
498+ \MoRet{\RW{case}\;\AR{\VV{t1}_\Gamma\;\vt\;\RW{of}\\
499− \MO{Success}\:\vt'\cq\MO{Success}\:\vt'\\
499+ \MO{Success}\;\vt'\cq\MO{Success}\;\vt'\\
500− \MO{Failure}\:\_\cq\VV{t2}_\Gamma\:\vt\\
500+ \MO{Failure}\;\_\cq\VV{t2}_\Gamma\;\vt\\
501 }}
501 }}
502}
502}
503}
503}
@@ -514,9 +514,9 @@ binding requires that the goal normalises to a function type:
514\DM{
514\DM{
515\PA{\A\A}{
515\PA{\A\A}{
516\MO{Lambda}_\Gamma & \vn & (\hole{\vx}{\vT}\SC\vx) &
516\MO{Lambda}_\Gamma & \vn & (\hole{\vx}{\vT}\SC\vx) &
517− \MoRet{\RW{do}\:\AR{
517+ \MoRet{\RW{do}\;\AR{
518− \all{\vy}{\vS}\SC\vT'\:\leftarrow\:\Eval\:\vT \\
518+ \all{\vy}{\vS}\SC\vT'\;\leftarrow\;\Eval\;\vT \\
519− \RW{return}\:\lam{\vn}{\vS}\SC\hole{\vx}{\vT'[\vn/\vy]}\SC\vx
519+ \RW{return}\;\lam{\vn}{\vS}\SC\hole{\vx}{\vT'[\vn/\vy]}\SC\vx
520 }
520 }
521 }
521 }
522}
522}
@@ -528,9 +528,9 @@ Creating a $\forall$ binding requires that the goal is a $\TC{Type}$:
528\DM{
528\DM{
529\PA{\A\A}{
529\PA{\A\A}{
530\MO{Pi}_\Gamma & (\vn\Hab\vS) & (\hole{\vx}{\Type}\SC\vx) &
530\MO{Pi}_\Gamma & (\vn\Hab\vS) & (\hole{\vx}{\Type}\SC\vx) &
531− \MoRet{\RW{do}\:\AR{
531+ \MoRet{\RW{do}\;\AR{
532− \Type\:\leftarrow\:\Check\:\vS\\
532+ \Type\;\leftarrow\;\Check\;\vS\\
533− \RW{return}\:\all{\vn}{\vS}\SC\hole{\vx}{\Type}\SC\vx
533+ \RW{return}\;\all{\vn}{\vS}\SC\hole{\vx}{\Type}\SC\vx
534 }
534 }
535 }
535 }
536}
536}
@@ -542,11 +542,11 @@ Creating a $\LET$ binding requires a type and a value.
542\DM{
542\DM{
543\PA{\A\A}{
543\PA{\A\A}{
544\MO{Let}_\Gamma & (\vn\Hab\vS\defq\vv) & (\hole{\vx}{\vT}\SC\vx) &
544\MO{Let}_\Gamma & (\vn\Hab\vS\defq\vv) & (\hole{\vx}{\vT}\SC\vx) &
545− \MoRet{\RW{do}\:\AR{
545+ \MoRet{\RW{do}\;\AR{
546− \Type\:\leftarrow\:\Check\:\vS\\
546+ \Type\;\leftarrow\;\Check\;\vS\\
547− \vS'\:\leftarrow\:\Check\:\vv\\
547+ \vS'\;\leftarrow\;\Check\;\vv\\
548− \Unify\:\vS\:\vS'\\
548+ \Unify\;\vS\;\vS'\\
549− \RW{return}\:\LET\:\vn\Hab\vS\defq\vv\SC\hole{\vx}{\vT}\SC\vx
549+ \RW{return}\;\LET\;\vn\Hab\vS\defq\vv\SC\hole{\vx}{\vT}\SC\vx
550 }
550 }
551 }
551 }
552}
552}
@@ -563,7 +563,7 @@ head of the queue:
563\DM{
563\DM{
564\PA{\A}{
564\PA{\A}{
565\MO{Attack}_\Gamma & (\hole{\vx}{\vT}\SC\ve) &
565\MO{Attack}_\Gamma & (\hole{\vx}{\vT}\SC\ve) &
566− \MoRet{\RW{do}\:\AR{
566+ \MoRet{\RW{do}\;\AR{
567 \MO{NewHole}\;\vx'\\
567 \MO{NewHole}\;\vx'\\
568 \RW{return}\;\guess{\vx}{\vT}{(\hole{\vx'}{\vT}\SC\vx')}\SC\ve}}
568 \RW{return}\;\guess{\vx}{\vT}{(\hole{\vx'}{\vT}\SC\vx')}\SC\ve}}
569}
569}
@@ -573,17 +573,17 @@ head of the queue:
573For example, consider the following proof term:
573For example, consider the following proof term:
574
574
575\DM{
575\DM{
576−\hole{\vx}{\va\to\vb}\SC\vx\:\ve
576+\hole{\vx}{\va\to\vb}\SC\vx\;\ve
577}
577}
578
578
579\noindent
579\noindent
580If we try to instantiate $\vx$ with a $\lambda$-binding $\vn$ immediately,
580If we try to instantiate $\vx$ with a $\lambda$-binding $\vn$ immediately,
581without applying $\MO{Attack}$ first, the $\lambda$ will scope over the
581without applying $\MO{Attack}$ first, the $\lambda$ will scope over the
582−entirety of $\vx\:\ve$, and the resulting term is not well-typed:
582+entirety of $\vx\;\ve$, and the resulting term is not well-typed:
583
583
584\DM{
584\DM{
585\AR{
585\AR{
586−\lam{\vn}{\va}\SC\hole{\vx}{\vb}\SC\vx\:\ve
586+\lam{\vn}{\va}\SC\hole{\vx}{\vb}\SC\vx\;\ve
587}
587}
588}
588}
589
589
@@ -593,10 +593,10 @@ a $\lambda$ binding $\vn$, we get:
593
593
594\DM{
594\DM{
595\begin{array}{ll}
595\begin{array}{ll}
596−\guess{\vx}{\va\to\vb}{\hole{\vx'}{\va\to\vb}\SC\vx'}\SC\vx\:\ve
596+\guess{\vx}{\va\to\vb}{\hole{\vx'}{\va\to\vb}\SC\vx'}\SC\vx\;\ve
597& \hg\mbox{(after $\MO{Attack}$)}\\
597& \hg\mbox{(after $\MO{Attack}$)}\\
598−\guess{\vx}{\va\to\vb}{\lam{\vn}{\va}\SC\hole{\vx'}{\vb}\SC\vx'}\SC\vx\:\ve
598+\guess{\vx}{\va\to\vb}{\lam{\vn}{\va}\SC\hole{\vx'}{\vb}\SC\vx'}\SC\vx\;\ve
599−& \hg\mbox{(after $\MO{Lambda}\:\vn$)}
599+& \hg\mbox{(after $\MO{Lambda}\;\vn$)}
600\end{array}
600\end{array}
601}
601}
602
602
@@ -614,9 +614,9 @@ with the pattern variable directly:
614\DM{
614\DM{
615\PA{\A\A}{
615\PA{\A\A}{
616\MO{Pat}_\Gamma & \vn & (\hole{\vx}{\vT}\SC\ve) &
616\MO{Pat}_\Gamma & \vn & (\hole{\vx}{\vT}\SC\ve) &
617− \MoRet{\RW{do}\:\AR{
617+ \MoRet{\RW{do}\;\AR{
618− \MO{PatBind}\:(\vn\Hab\vT)\\
618+ \MO{PatBind}\;(\vn\Hab\vT)\\
619− \RW{return}\:\ve[\vn/\vx]
619+ \RW{return}\;\ve[\vn/\vx]
620 }}
620 }}
621}
621}
622}
622}
@@ -635,7 +635,7 @@ complete term by refining a proof state, let us consider the following
635\DM{
635\DM{
636\AR{
636\AR{
637\FN{id}\Hab\all{\vA}{\Type}\SC\all{\va}{\vA}\SC\vA \\
637\FN{id}\Hab\all{\vA}{\Type}\SC\all{\va}{\vA}\SC\vA \\
638−\FN{id}\:=\:\lam{\vA}{\Type}\SC\lam{\va}{\vA}\SC\va
638+\FN{id}\;=\;\lam{\vA}{\Type}\SC\lam{\va}{\vA}\SC\va
639}
639}
640}
640}
641
641
@@ -647,9 +647,9 @@ the goal type.
647
647
648\DM{
648\DM{
649\AR{
649\AR{
650−\MO{MkId}\:\mq\:\RW{do}\:
650+\MO{MkId}\;\mq\;\RW{do}\;
651 \AR{
651 \AR{
652− \MO{NewProof}\:\all{\vA}{\Type}\SC\all{\va}{\vA}\SC\vA \\
652+ \MO{NewProof}\;\all{\vA}{\Type}\SC\all{\va}{\vA}\SC\vA \\
653 \MO{Tactic}\;\MO{Attack} \\
653 \MO{Tactic}\;\MO{Attack} \\
654 \MO{Tactic}\;(\MO{Lambda}\;\vA) \\
654 \MO{Tactic}\;(\MO{Lambda}\;\vA) \\
655 \MO{Tactic}\;\MO{Attack} \\
655 \MO{Tactic}\;\MO{Attack} \\
@@ -683,7 +683,7 @@ the goal type.
683&
683&
684\langle\vh_0,\vx\rangle\\
684\langle\vh_0,\vx\rangle\\
685%
685%
686−\MO{Lambda}\:\vA &
686+\MO{Lambda}\;\vA &
687\guess{\vx}{\all{\vA}{\Type}\SC\all{\va}{\vA}\SC\vA}{
687\guess{\vx}{\all{\vA}{\Type}\SC\all{\va}{\vA}\SC\vA}{
688\underline{
688\underline{
689\lam{\vA}{\Type}\SC\hole{\vh_0}{\all{\va}{\vA}\SC\vA}\SC\vh_0
689\lam{\vA}{\Type}\SC\hole{\vh_0}{\all{\va}{\vA}\SC\vA}\SC\vh_0
@@ -706,7 +706,7 @@ the goal type.
706&
706&
707\langle\vh_1,\vh_0,\vx\rangle\\
707\langle\vh_1,\vh_0,\vx\rangle\\
708%
708%
709−\MO{Lambda}\:\va &
709+\MO{Lambda}\;\va &
710\guess{\vx}{\all{\vA}{\Type}\SC\all{\va}{\vA}\SC\vA}{
710\guess{\vx}{\all{\vA}{\Type}\SC\all{\va}{\vA}\SC\vA}{
711\lam{\vA}{\Type}\SC
711\lam{\vA}{\Type}\SC
712\guess{\vh_0}{\all{\va}{\vA}\SC\vA}
712\guess{\vh_0}{\all{\va}{\vA}\SC\vA}
@@ -721,7 +721,7 @@ the goal type.
721&
721&
722\langle\vh_1,\vh_0,\vx\rangle\\
722\langle\vh_1,\vh_0,\vx\rangle\\
723%
723%
724−\MO{Fill}\:\va &
724+\MO{Fill}\;\va &
725\guess{\vx}{\all{\vA}{\Type}\SC\all{\va}{\vA}\SC\vA}{
725\guess{\vx}{\all{\vA}{\Type}\SC\all{\va}{\vA}\SC\vA}{
726\lam{\vA}{\Type}\SC
726\lam{\vA}{\Type}\SC
727\\
727\\
@@ -807,19 +807,19 @@ a Coq proof script.
807
807
808\FFIG{
808\FFIG{
809\AR{
809\AR{
810−\MO{MkIdType}\:\mq\:\RW{do}\;
810+\MO{MkIdType}\;\mq\;\RW{do}\;
811 \AR{
811 \AR{
812− \MO{NewProof}\:\Type\\
812+ \MO{NewProof}\;\Type\\
813− \MO{Attack} ; \MO{Pi}\:(\vA\Hab\Type) ;
813+ \MO{Attack} ; \MO{Pi}\;(\vA\Hab\Type) ;
814− \MO{Attack} ; \MO{Pi}\:(\va\Hab\vA) \\
814+ \MO{Attack} ; \MO{Pi}\;(\va\Hab\vA) \\
815 \MO{Fill}\;\vA \\
815 \MO{Fill}\;\vA \\
816 \MO{Solve} ; \MO{Solve} ; \MO{Solve} \\
816 \MO{Solve} ; \MO{Solve} ; \MO{Solve} \\
817 \MO{Term}
817 \MO{Term}
818 }
818 }
819 \medskip\\
819 \medskip\\
820−\MO{MkId}\:\mq\:\RW{do}\;
820+\MO{MkId}\;\mq\;\RW{do}\;
821 \AR{
821 \AR{
822− \vt\:\leftarrow\:\MO{MkIdType}; \MO{NewProof}\:\vt\\
822+ \vt\;\leftarrow\;\MO{MkIdType}; \MO{NewProof}\;\vt\\
823 \MO{Attack} ; \MO{Lambda}\;\vA ;
823 \MO{Attack} ; \MO{Lambda}\;\vA ;
824 \MO{Attack} ; \MO{Lambda}\;\va \\
824 \MO{Attack} ; \MO{Lambda}\;\va \\
825 \MO{Fill}\;\va \\
825 \MO{Fill}\;\va \\
@@ -928,11 +928,11 @@ are given explicitly, the application must be expanded.
928\begin{array}{rll@{\hg}rll}
928\begin{array}{rll@{\hg}rll}
929\ve ::= & \vc & (\mbox{constant}) &
929\ve ::= & \vc & (\mbox{constant}) &
930\mid & \vx & (\mbox{variable}) \\
930\mid & \vx & (\mbox{variable}) \\
931−\mid & \ilam{\vx}\:\ve & (\mbox{lambda abstraction}) &
931+\mid & \ilam{\vx}\;\ve & (\mbox{lambda abstraction}) &
932−\mid & \ve\:\ta & (\mbox{function application}) \\
932+\mid & \ve\;\ta & (\mbox{function application}) \\
933−\mid & \ilet{\vx}{\ve}\:\ve & (\mbox{let binding}) &
933+\mid & \ilet{\vx}{\ve}\;\ve & (\mbox{let binding}) &
934\mid & \piexp{\vx}{\vt}\vt & (\mbox{explicit function space}) \\
934\mid & \piexp{\vx}{\vt}\vt & (\mbox{explicit function space}) \\
935−%\mid & \icase\:\ve\:\iof\:\vec{\VV{alt}} & (\mbox{case expression}) &
935+%\mid & \icase\;\ve\;\iof\;\vec{\VV{alt}} & (\mbox{case expression}) &
936%\mid & \mvar{\vx} & (\mbox{metavariable}) \\
936%\mid & \mvar{\vx} & (\mbox{metavariable}) \\
937\mid & \_ & (\mbox{placeholder})
937\mid & \_ & (\mbox{placeholder})
938\end{array}
938\end{array}
@@ -971,9 +971,9 @@ are given explicitly, the application must be expanded.
971\begin{array}{ll}
971\begin{array}{ll}
972\begin{array}{rll}
972\begin{array}{rll}
973\VV{pclause} ::= &
973\VV{pclause} ::= &
974−\vx\:\ttt\:[\ibar\;\te]\mbox{\texttt{ = }}\ve \hg[\iwhere\;\td]\\
974+\vx\;\ttt\;[\ibar\;\te]\mbox{\texttt{ = }}\ve \hg[\iwhere\;\td]\\
975\mid & \AR{
975\mid & \AR{
976−\vx\:\ttt\:[\ibar\;\te]\;\iwith\;\ve\\
976+\vx\;\ttt\;[\ibar\;\te]\;\iwith\;\ve\\
977\hg\vec{\VV{pclause}}
977\hg\vec{\VV{pclause}}
978}
978}
979\end{array}
979\end{array}
@@ -984,7 +984,7 @@ are given explicitly, the application must be expanded.
984\medskip\\
984\medskip\\
985\VV{cdecl} ::= & \iclass\;[\VV{constr}]\;\vx\;(\ihab{\tx}{\ttt})\;\iwhere\;\td
985\VV{cdecl} ::= & \iclass\;[\VV{constr}]\;\vx\;(\ihab{\tx}{\ttt})\;\iwhere\;\td
986\\
986\\
987−\VV{idecl} ::= & \iinstance\:[\VV{constr}]\;\vx\;\ttt\;\iwhere\;\td
987+\VV{idecl} ::= & \iinstance\;[\VV{constr}]\;\vx\;\ttt\;\iwhere\;\td
988\end{array}
988\end{array}
989\end{array}
989\end{array}
990}
990}
@@ -997,8 +997,8 @@ and declaration syntax given in Figure \ref{idrismd}.
997\IdrisM{} is a subset of \Idris{} without syntactic sugar --- that is, without
997\IdrisM{} is a subset of \Idris{} without syntactic sugar --- that is, without
998tuple syntax, \texttt{do}-notation or infix operators --- and with implicit
998tuple syntax, \texttt{do}-notation or infix operators --- and with implicit
999arguments in types bound explicitly
999arguments in types bound explicitly
1000−(e.g. $\piimp{\va}{\_}\piimp{\vn}{\_}\TC{Vect}\:\va\:\vn$
1000+(e.g. $\piimp{\va}{\_}\piimp{\vn}{\_}\TC{Vect}\;\va\;\vn$
1001−instead of simply $\Vect\:\va\:\vn$).
1001+instead of simply $\Vect\;\va\;\vn$).
1002Note that we separate implicit and type constraint bindings, to ensure that they
1002Note that we separate implicit and type constraint bindings, to ensure that they
1003only appear in top level declarations.
1003only appear in top level declarations.
1004It is in general straightforward to
1004It is in general straightforward to
@@ -1032,7 +1032,7 @@ has already been set up, which means that elaboration can always be
1032are building.
1032are building.
1033
1033
1034In all cases except the elaboration of variables and constantes,
1034In all cases except the elaboration of variables and constantes,
1035−$\ttpinterp{\vx}\:=\:\ttinterp{\vx}$.
1035+$\ttpinterp{\vx}\;=\;\ttinterp{\vx}$.
1036
1036
1037\subsubsection{Elaborating variables and constants}
1037\subsubsection{Elaborating variables and constants}
1038
1038
@@ -1042,8 +1042,8 @@ the \MO{Fill} tactic:
1042
1042
1043\DM{
1043\DM{
1044\AR{
1044\AR{
1045−\ttinterp{\vx}\:\mq\:\RW{do}\:\MO{Fill}\:\vx;\:\MO{Solve}\\
1045+\ttinterp{\vx}\;\mq\;\RW{do}\;\MO{Fill}\;\vx;\;\MO{Solve}\\
1046−\ttinterp{\vc}\:\mq\:\RW{do}\:\MO{Fill}\:\vc;\:\MO{Solve}\\
1046+\ttinterp{\vc}\;\mq\;\RW{do}\;\MO{Fill}\;\vc;\;\MO{Solve}\\
1047}
1047}
1048}
1048}
1049
1049
@@ -1059,9 +1059,9 @@ context, we assume that attempting to elaborate a variable which does not type
1059check means that the variable is a pattern variable:
1059check means that the variable is a pattern variable:
1060
1060
1061\DM{
1061\DM{
1062−\ttpinterp{\vx}\:\mq\:
1062+\ttpinterp{\vx}\;\mq\;
1063−\MO{Try}\:\AR{(\RW{do}\:\MO{Fill}\:\vx;\:\MO{Solve})\\
1063+\MO{Try}\;\AR{(\RW{do}\;\MO{Fill}\;\vx;\;\MO{Solve})\\
1064−(\MO{Pat}\:\vx)
1064+(\MO{Pat}\;\vx)
1065}
1065}
1066}
1066}
1067
1067
@@ -1070,13 +1070,14 @@ solve by unification. In this case, we simply move on to the next hole in the qu
1070the current hole to the end of the queue with $\MO{Unfocus}$:
1070the current hole to the end of the queue with $\MO{Unfocus}$:
1071
1071
1072\DM{
1072\DM{
1073−\ttinterp{\_}\:\mq\:\MO{Unfocus}
1073+\ttinterp{\_}\;\mq\;\MO{Unfocus}
1074}
1074}
1075
1075
1076−On encountering a placeholder, our assumption is that unification will eventually solve
1076+On encountering a placeholder, our assumption is that unification will
1077−the hole. At the end of elaboration, any holes remaining unsolved on the left hand side
1077+eventually solve the hole. At the end of elaboration, any holes remaining
1078+unsolved on the left hand side become pattern variables. If there are any
1078−become pattern variables. If there are any unsolved on the right hand side, elaboration
1079+unsolved on the right hand side, elaboration is incomplete and an error will
1079−fails.
1080+be reported when the resulting term is type checked.
1080
1081
1081\subsubsection{Elaborating bindings}
1082\subsubsection{Elaborating bindings}
1082
1083
@@ -1085,10 +1086,10 @@ $\MO{Lambda}$ tactic, which will fail if the goal is not a function type. We
1085then elaborate the scope and $\MO{Solve}$, which discharges the $\MO{Attack}$:
1086then elaborate the scope and $\MO{Solve}$, which discharges the $\MO{Attack}$:
1086
1087
1087\DM{
1088\DM{
1088−\ttinterp{\ilam{\vx}\ve}\:\mq\:
1089+\ttinterp{\ilam{\vx}\ve}\;\mq\;
1089−\RW{do}\:
1090+\RW{do}\;
1090\AR{
1091\AR{
1091−\MO{Attack};\;\MO{Lambda}\:\vx\\
1092+\MO{Attack};\;\MO{Lambda}\;\vx\\
1092\ttinterp{\ve}\\
1093\ttinterp{\ve}\\
1093\MO{Solve}
1094\MO{Solve}
1094}
1095}
@@ -1108,12 +1109,12 @@ scope of the binding.
1108
1109
1109\DM{
1110\DM{
1110\AR{
1111\AR{
1111−\ttinterp{\piexp{\vx}{\vt}\ve}\:\mq\:
1112+\ttinterp{\piexp{\vx}{\vt}\ve}\;\mq\;
1112−\RW{do}\:
1113+\RW{do}\;
1113\AR{
1114\AR{
1114−\MO{Attack};\;\MO{Claim}\:(\vX\Hab\Type)\\
1115+\MO{Attack};\;\MO{Claim}\;(\vX\Hab\Type)\\
1115−\MO{Pi}\:(\vx\Hab\vX)\\
1116+\MO{Pi}\;(\vx\Hab\vX)\\
1116−\MO{Focus}\:\vX\\
1117+\MO{Focus}\;\vX\\
1117\ttinterp{\vt};\;
1118\ttinterp{\vt};\;
1118\ttinterp{\ve}\\
1119\ttinterp{\ve}\\
1119\MO{Solve}
1120\MO{Solve}
@@ -1134,13 +1135,13 @@ if elaborating the scope is successful, unification will solve the claimed varia
1134$\vV$ and $\vX$.
1135$\vV$ and $\vX$.
1135
1136
1136\DM{
1137\DM{
1137−\ttinterp{\ilet{\vx}{\vv}\:{\ve}}\:\mq\:\RW{do}\:
1138+\ttinterp{\ilet{\vx}{\vv}\;{\ve}}\;\mq\;\RW{do}\;
1138\AR{
1139\AR{
1139\MO{Attack};\;
1140\MO{Attack};\;
1140−\MO{Claim}\:(\vX\Hab\Type);\;
1141+\MO{Claim}\;(\vX\Hab\Type);\;
1141−\MO{Claim}\:(\vV\Hab\vX)\\
1142+\MO{Claim}\;(\vV\Hab\vX)\\
1142−\MO{Let}\:(\vx\Hab\vX\defq\vV)\\
1143+\MO{Let}\;(\vx\Hab\vX\defq\vV)\\
1143−\MO{Focus}\:\vV\\
1144+\MO{Focus}\;\vV\\
1144\ttinterp{\vv};\;
1145\ttinterp{\vv};\;
1145\ttinterp{\ve}
1146\ttinterp{\ve}
1146}
1147}
@@ -1158,7 +1159,7 @@ In the first case, the elaborator must expand the application to include implici
1158For example \texttt{vAdd xs ys} is expanded to
1159For example \texttt{vAdd xs ys} is expanded to
1159\texttt{vAdd \{a=\_\} \{n=\_\} \{\{\_\}\} xs ys}, adding the implicit arguments
1160\texttt{vAdd \{a=\_\} \{n=\_\} \{\{\_\}\} xs ys}, adding the implicit arguments
1160\texttt{a} and \texttt{n} and a type class instance argument. The meta-operation
1161\texttt{a} and \texttt{n} and a type class instance argument. The meta-operation
1161−$\MO{Expand}\:\vx\:\ta$, given a global function name $\vx$ and the
1162+$\MO{Expand}\;\vx\;\ta$, given a global function name $\vx$ and the
1162arguments supplied by the programmer $\ta$, returns a new argument list
1163arguments supplied by the programmer $\ta$, returns a new argument list
1163$\ta'$ with implicit and type class arguments added. Each value in
1164$\ta'$ with implicit and type class arguments added. Each value in
1164$\ta'$ is paired with an explicit name for the argument.
1165$\ta'$ is paired with an explicit name for the argument.
@@ -1172,17 +1173,17 @@ forms:
1172
1173
1173\DM{
1174\DM{
1174\AR{
1175\AR{
1175−\MO{Unify}_\Gamma\;\vf\:\TC{Int}\\
1176+\MO{Unify}_\Gamma\;\vf\;\TC{Int}\\
1176−\MO{Unify}_\Gamma\;(\vf\:\vx)\:\TC{Int}\\
1177+\MO{Unify}_\Gamma\;(\vf\;\vx)\;\TC{Int}\\
1177−\MO{Unify}_\Gamma\;(\vf\:\vx)\:(\vg\:\vx)\\
1178+\MO{Unify}_\Gamma\;(\vf\;\vx)\;(\vg\;\vx)\\
1178}
1179}
1179}
1180}
1180
1181
1181The first problem has a solution: $\vf=\TC{Int}$. The second and third problems
1182The first problem has a solution: $\vf=\TC{Int}$. The second and third problems
1182have no solution without further information. In the second case, we cannot
1183have no solution without further information. In the second case, we cannot
1183conclude anything about $\vf$ or $\vx$ just from knowing that
1184conclude anything about $\vf$ or $\vx$ just from knowing that
1184−$\vf\:\vx\:=\:\TC{Int}$. In the third case, although we have $\vx\:=\:\vx$ in
1185+$\vf\;\vx\;=\;\TC{Int}$. In the third case, although we have $\vx\;=\;\vx$ in
1185−argument position, we cannot conclude that $\vf\:=\:\vg$ in general as a
1186+argument position, we cannot conclude that $\vf\;=\;\vg$ in general as a
1186result.
1187result.
1187
1188
1188Once $\vf$ or $\vg$ is solved in some other way, perhaps by being given
1189Once $\vf$ or $\vg$ is solved in some other way, perhaps by being given
@@ -1198,16 +1199,16 @@ Finally, any type class instance arguments are resolved with the
1198built-in $\MO{Instance}$ tactic.
1199built-in $\MO{Instance}$ tactic.
1199
1200
1200\DM{
1201\DM{
1201−\ttinterp{\vx\:\ta}\:\mq\:
1202+\ttinterp{\vx\;\ta}\;\mq\;
1202\AR{
1203\AR{
1203−\RW{do}\:
1204+\RW{do}\;
1204\AR{
1205\AR{
1205−(\tn,\tv)\:\gets\:\MO{Expand}\:\vx\:\ta\\
1206+(\tn,\tv)\;\gets\;\MO{Expand}\;\vx\;\ta\\
1206−\vec{\MO{Claim}}\:(\tn\Hab\tT)\\
1207+\vec{\MO{Claim}}\;(\tn\Hab\tT)\\
1207−\MO{Fill}\:\vx\:\tn\\
1208+\MO{Fill}\;\vx\;\tn\\
1208−\vec{\MO{Focus}}\:\tn;\:\ttinterp{\tv}\hg\mbox{(for non-placeholder $\vv$)}\\
1209+\vec{\MO{Focus}}\;\tn;\;\ttinterp{\tv}\hg\mbox{(for non-placeholder $\vv$)}\\
1209\MO{Solve} \\
1210\MO{Solve} \\
1210−\vec{\MO{Instance}}\:\tn\hg\mbox{(for type class constraint argument $\vn$)}
1211+\vec{\MO{Instance}}\;\tn\hg\mbox{(for type class constraint argument $\vn$)}
1211}
1212}
1212}
1213}
1213}
1214}
@@ -1224,12 +1225,12 @@ applied. Since elaboration is type directed, however, there must be an
1224appropriate type for the function.
1225appropriate type for the function.
1225
1226
1226\DM{
1227\DM{
1227−\ttinterp{\ve\:\va}\:\mq\:\RW{do}\:
1228+\ttinterp{\ve\;\va}\;\mq\;\RW{do}\;
1228\AR{
1229\AR{
1229−\MO{Claim}\:(\vA\Hab\Type);\;\MO{Claim}\:(\vB\Hab\Type)\\
1230+\MO{Claim}\;(\vA\Hab\Type);\;\MO{Claim}\;(\vB\Hab\Type)\\
1230−\MO{Claim}\:(\vf\Hab\vA\to\vB);\;\MO{Claim}\:(\vs\Hab\vA)\\
1231+\MO{Claim}\;(\vf\Hab\vA\to\vB);\;\MO{Claim}\;(\vs\Hab\vA)\\
1231−\MO{Focus}\:\vf;\;\ttinterp{\ve}\\
1232+\MO{Focus}\;\vf;\;\ttinterp{\ve}\\
1232−\MO{Focus}\:\vs;\;\ttinterp{\va}\\
1233+\MO{Focus}\;\vs;\;\ttinterp{\va}\\
1233}
1234}
1234}
1235}
1235
1236
@@ -1244,7 +1245,7 @@ relative to the system state (see Section \ref{sect:sysstate}) and has access to
1244current proof state. $\MO{Elab}$ uses $\ttinterp{\cdot}$ to help translate
1245current proof state. $\MO{Elab}$ uses $\ttinterp{\cdot}$ to help translate
1245\IdrisM{} type, function and class declarations into \TT{} declarations.
1246\IdrisM{} type, function and class declarations into \TT{} declarations.
1246
1247
1247−\newcommand{\edo}[1]{\RW{do}\:\AR{#1}}
1248+\newcommand{\edo}[1]{\RW{do}\;\AR{#1}}
1248
1249
1249\subsubsection{Elaborating Type Declarations}
1250\subsubsection{Elaborating Type Declarations}
1250
1251
@@ -1253,11 +1254,11 @@ translating the \IdrisM{} type to a \TT{} type, then adding the resulting type
1253as a \TT{} declaration:
1254as a \TT{} declaration:
1254
1255
1255\DM{
1256\DM{
1256−\MO{Elab}\:(\vx\Hab\vt)\:\mq
1257+\MO{Elab}\;(\vx\Hab\vt)\;\mq
1257−\:\edo{\MO{NewProof}\:\Type\\
1258+\;\edo{\MO{NewProof}\;\Type\\
1258 \ttinterp{\vt}\\
1259 \ttinterp{\vt}\\
1259 \vt'\gets\MO{Term}\\
1260 \vt'\gets\MO{Term}\\
1260− \MO{TTDecl}\:(\vx\Hab\vt')
1261+ \MO{TTDecl}\;(\vx\Hab\vt')
1261}}
1262}}
1262
1263
1263The final $\MO{TTDecl}$ takes the result of elaboration, type checks it,
1264The final $\MO{TTDecl}$ takes the result of elaboration, type checks it,
@@ -1274,20 +1275,20 @@ adds a \TT{} data declaration.
1274
1275
1275\DM{
1276\DM{
1276\AR{
1277\AR{
1277−\MO{Elab}\:(\idata\;\ihab{\vx}{\vt}\;\iwhere\;\tc)\\
1278+\MO{Elab}\;(\idata\;\ihab{\vx}{\vt}\;\iwhere\;\tc)\\
1278−\hg\hg\mq\:\edo{\MO{NewProof}\:\Type\\
1279+\hg\hg\mq\;\edo{\MO{NewProof}\;\Type\\
1279 \ttinterp{\vt}\\
1280 \ttinterp{\vt}\\
1280 \vt'\gets\MO{Term}\\
1281 \vt'\gets\MO{Term}\\
1281− \MO{TTDecl}\:(\vx\Hab\vt')\\
1282+ \MO{TTDecl}\;(\vx\Hab\vt')\\
1282− \tc'\gets\vec{\MO{ElabCon}}\:\tc\\
1283+ \tc'\gets\vec{\MO{ElabCon}}\;\tc\\
1283− \MO{TTDecl}\:(\Data\:\vx\Hab\vt'\:\Where\:\tc')
1284+ \MO{TTDecl}\;(\Data\;\vx\Hab\vt'\;\Where\;\tc')
1284}
1285}
1285\AR{
1286\AR{
1286−\MO{ElabCon}\:(\vx\Hab\vt)\\
1287+\MO{ElabCon}\;(\vx\Hab\vt)\\
1287−\hg\hg\mq\: \edo{\MO{NewProof}\:\Type\\
1288+\hg\hg\mq\; \edo{\MO{NewProof}\;\Type\\
1288 \ttinterp{\vt}\\
1289 \ttinterp{\vt}\\
1289 \vt'\gets\MO{Term}\\
1290 \vt'\gets\MO{Term}\\
1290− \RW{return}\:(\vx\Hab\vt')
1291+ \RW{return}\;(\vx\Hab\vt')
1291}
1292}
1292}}}
1293}}}
1293
1294
@@ -1300,7 +1301,7 @@ to the global context, such as definitions in $\iwhere$ clauses.
1300First, let us consider the simplest case, with no $\iwhere$ clause:
1301First, let us consider the simplest case, with no $\iwhere$ clause:
1301
1302
1302\DM{
1303\DM{
1303−\MO{ElabClause}\:(\vx\:\ttt\:=\:\ve)\:\mq\:?
1304+\MO{ElabClause}\;(\vx\;\ttt\;=\;\ve)\;\mq\;?
1304}
1305}
1305
1306
1306How does the left hand side get elaborated, given that elaboration is type directed, and
1307How does the left hand side get elaborated, given that elaboration is type directed, and
@@ -1312,21 +1313,21 @@ a type $\TC{Infer}$:
1312\Data\hg\TC{Infer}\Hab\Type\hg\Where\hg\DC{MkInfer}\Hab\all{\va}{\Type}\SC\va\to\TC{Infer}
1313\Data\hg\TC{Infer}\Hab\Type\hg\Where\hg\DC{MkInfer}\Hab\all{\va}{\Type}\SC\va\to\TC{Infer}
1313}
1314}
1314
1315
1315−Now elaboration of the left hand side proceeds by elaborating $\DC{MkInfer}\:\_\:(\vx\:\ttt)$ and
1316+Now elaboration of the left hand side proceeds by elaborating $\DC{MkInfer}\;\_\;(\vx\;\ttt)$ and
1316extracting the value and unified type when complete.
1317extracting the value and unified type when complete.
1317
1318
1318\DM{
1319\DM{
1319\AR{
1320\AR{
1320−\MO{ElabClause}\:(\vx\:\ttt\:=\:\ve)\:\mq\:\\
1321+\MO{ElabClause}\;(\vx\;\ttt\;=\;\ve)\;\mq\;\\
1321\hg\hg\edo{
1322\hg\hg\edo{
1322−\MO{NewProof}\:\TC{Infer};\;
1323+\MO{NewProof}\;\TC{Infer};\;
1323−\ttpinterp{\DC{MkInfer}\:\_\:(\vx\:\ttt)}\\
1324+\ttpinterp{\DC{MkInfer}\;\_\;(\vx\;\ttt)}\\
1324−\DC{MkInfer}\:\vT\:\VV{lhs}\gets\MO{Term}\\
1325+\DC{MkInfer}\;\vT\;\VV{lhs}\gets\MO{Term}\\
1325\tp\gets\MO{Patterns}\\
1326\tp\gets\MO{Patterns}\\
1326−\MO{NewTerm}\:\vT;\;
1327+\MO{NewTerm}\;\vT;\;
1327\ttinterp{\ve}\\
1328\ttinterp{\ve}\\
1328\VV{rhs}\gets\MO{Term}\\
1329\VV{rhs}\gets\MO{Term}\\
1329−\RW{return}\:(\RW{var}\:\tp\SC\VV{lhs}\:=\:\VV{rhs})
1330+\RW{return}\;(\RW{var}\;\tp\SC\VV{lhs}\;=\;\VV{rhs})
1330}
1331}
1331}
1332}
1332}
1333}
@@ -1340,10 +1341,10 @@ the clauses and adding the resulting collection to \TT{}.
1340
1341
1341\DM{
1342\DM{
1342\AR{
1343\AR{
1343−\MO{Elab}\:\vec{\VV{pclause}}\:\mq\:
1344+\MO{Elab}\;\vec{\VV{pclause}}\;\mq\;
1344\edo{
1345\edo{
1345−\tc\gets\vec{\MO{ElabClause}}\:\vec{\VV{pclause}}\\
1346+\tc\gets\vec{\MO{ElabClause}}\;\vec{\VV{pclause}}\\
1346−\vec{\MO{TTDecl}}\:\tc
1347+\vec{\MO{TTDecl}}\;\tc
1347}
1348}
1348}
1349}
1349}
1350}
@@ -1355,18 +1356,18 @@ which are then recursively elaborated before the right hand side.
1355
1356
1356\DM{
1357\DM{
1357\AR{
1358\AR{
1358−\MO{ElabClause}\:(\vx\:\ttt\:=\:\ve\:\iwhere\:\td)\:\mq\:\\
1359+\MO{ElabClause}\;(\vx\;\ttt\;=\;\ve\;\iwhere\;\td)\;\mq\;\\
1359\hg\hg\edo{
1360\hg\hg\edo{
1360−\MO{NewProof}\:\TC{Infer};\;
1361+\MO{NewProof}\;\TC{Infer};\;
1361−\ttpinterp{\DC{MkInfer}\:\_\:(\vx\:\ttt)}\\
1362+\ttpinterp{\DC{MkInfer}\;\_\;(\vx\;\ttt)}\\
1362−\DC{MkInfer}\:\vT\:\VV{lhs}\gets\MO{Term}\\
1363+\DC{MkInfer}\;\vT\;\VV{lhs}\gets\MO{Term}\\
1363\tp\gets\MO{Patterns}\\
1364\tp\gets\MO{Patterns}\\
1364−(\td', \ve') \gets\MO{Lift}\:\tp\:\td\:\ve\\
1365+(\td', \ve') \gets\MO{Lift}\;\tp\;\td\;\ve\\
1365−\vec{\MO{Elab}}\:\td'\\
1366+\vec{\MO{Elab}}\;\td'\\
1366−\MO{NewTerm}\:\vT;\;
1367+\MO{NewTerm}\;\vT;\;
1367\ttinterp{\ve'}\\
1368\ttinterp{\ve'}\\
1368\VV{rhs}\gets\MO{Term}\\
1369\VV{rhs}\gets\MO{Term}\\
1369−\RW{return}\:(\RW{var}\:\tp\SC\VV{lhs}\:=\:\VV{rhs})
1370+\RW{return}\;(\RW{var}\;\tp\SC\VV{lhs}\;=\;\VV{rhs})
1370}
1371}
1371}
1372}
1372}
1373}
@@ -1449,32 +1450,32 @@ $\tp$, then splits these patterns into those necessary to type
1449$\vW$, and the rest ($\tp_w$ and $\tp_n$ respectively) using
1450$\vW$, and the rest ($\tp_w$ and $\tp_n$ respectively) using
1450$\MO{SplitContext}$. Then, it builds a new declaration, abstracting over
1451$\MO{SplitContext}$. Then, it builds a new declaration, abstracting over
1451the matched expression $\ve$ in the types of $\tp_n$.
1452the matched expression $\ve$ in the types of $\tp_n$.
1452−$\MO{Abstract}\:\ve\:\vw\:\vp$ simply replaces any occurrence of $\vw$ in
1453+$\MO{Abstract}\;\ve\;\vw\;\vp$ simply replaces any occurrence of $\vw$ in
1453$\vp$ with the name $\ve$.
1454$\vp$ with the name $\ve$.
1454
1455
1455\DM{
1456\DM{
1456\AR{
1457\AR{
1457−\MO{ElabClause}\:(\vx\:\ttt\:\iwith\:\ve\:\vec{\VV{pclause}})\:\mq\\
1458+\MO{ElabClause}\;(\vx\;\ttt\;\iwith\;\ve\;\vec{\VV{pclause}})\;\mq\\
1458\hg\hg\edo{
1459\hg\hg\edo{
1459−\MO{NewProof}\:\TC{Infer};\;
1460+\MO{NewProof}\;\TC{Infer};\;
1460−\ttinterp{\DC{MkInfer}\:\_\:(\vx\:\ttt)}\\
1461+\ttinterp{\DC{MkInfer}\;\_\;(\vx\;\ttt)}\\
1461−\DC{MkInfer}\:\vT\:\VV{lhs}\gets\MO{Term}\\
1462+\DC{MkInfer}\;\vT\;\VV{lhs}\gets\MO{Term}\\
1462\tp\gets\MO{Patterns}\\
1463\tp\gets\MO{Patterns}\\
1463−\MO{NewTerm}\:\TC{Infer};\;
1464+\MO{NewTerm}\;\TC{Infer};\;
1464−\ttinterp{\DC{MkInfer}\:\_\:\ve}\\
1465+\ttinterp{\DC{MkInfer}\;\_\;\ve}\\
1465−\DC{MkInfer}\:\vW\:\vw'\gets\MO{Term}\\
1466+\DC{MkInfer}\;\vW\;\vw'\gets\MO{Term}\\
1466−(\tp_w,\tp_n)\:\gets\:\MO{SplitContext}\:\vW\:\tp\\
1467+(\tp_w,\tp_n)\;\gets\;\MO{SplitContext}\;\vW\;\tp\\
1467−\MO{TTDecl}\:(\vx'\Hab\tp_{w}\to(\ve\Hab\vW)\to\vec{\MO{Abstract}}\:\ve\:\vw'\:\tp_{n}\to\vT)\\
1468+\MO{TTDecl}\;(\vx'\Hab\tp_{w}\to(\ve\Hab\vW)\to\vec{\MO{Abstract}}\;\ve\;\vw'\;\tp_{n}\to\vT)\\
1468−\tc'\gets\vec{\MO{MatchWith}}\:\tp\:\ttt\:\vec{\VV{pclause}}\\
1469+\tc'\gets\vec{\MO{MatchWith}}\;\tp\;\ttt\;\vec{\VV{pclause}}\\
1469−\vec{\MO{Elab}}\:\tc'\\
1470+\vec{\MO{Elab}}\;\tc'\\
1470−\RW{return}\:(\RW{var}\:\tp\SC\VV{lhs}\:=\:\vx'\:\tp_{w}\:\vw'\:\tp_{n})
1471+\RW{return}\;(\RW{var}\;\tp\SC\VV{lhs}\;=\;\vx'\;\tp_{w}\;\vw'\;\tp_{n})
1471}
1472}
1472\medskip\\
1473\medskip\\
1473−\MO{MatchWith}\:\tp_w\:\tp_n\:\ttt\:(\vx\:\tw\:\mid\:\ve\:\VV{rhs})\:\mq\\
1474+\MO{MatchWith}\;\tp_w\;\tp_n\;\ttt\;(\vx\;\tw\;\mid\;\ve\;\VV{rhs})\;\mq\\
1474\hg\hg\edo{
1475\hg\hg\edo{
1475−\tp'\gets\vec{\MO{Match}}\:\tw\:\ttt\\
1476+\tp'\gets\vec{\MO{Match}}\;\tw\;\ttt\\
1476−(\tp'_w,\tp'_n)\:\gets\:\MO{SplitPats}\:\tp_w\:\tp_n\:\tp'\\
1477+(\tp'_w,\tp'_n)\;\gets\;\MO{SplitPats}\;\tp_w\;\tp_n\;\tp'\\
1477−\RW{return}\:(\vx'\:\tp'_w\:\ve\:\tp'_{n}\:\VV{rhs})
1478+\RW{return}\;(\vx'\;\tp'_w\;\ve\;\tp'_{n}\;\VV{rhs})
1478}
1479}
1479}
1480}
1480}
1481}
@@ -1493,7 +1494,7 @@ $\ve$ which is the same type as the scrutinee of the \texttt{with}, $\vW$.
1493The right hand side, $\VV{rhs}$, may either return a value directly, containing
1494The right hand side, $\VV{rhs}$, may either return a value directly, containing
1494\texttt{where} clauses, or be a nested \texttt{with} block. In any case, it
1495\texttt{where} clauses, or be a nested \texttt{with} block. In any case, it
1495remains unchanged.
1496remains unchanged.
1496−$\MO{Match}\:\vw\:\vt$ returns a list of pattern bindings containing
1497+$\MO{Match}\;\vw\;\vt$ returns a list of pattern bindings containing
1497the variables in $\vt$ and their matches in $\vw$.
1498the variables in $\vt$ and their matches in $\vw$.
1498The resulting matches are split, using $\MO{SplitPats}$, into matches for those
1499The resulting matches are split, using $\MO{SplitPats}$, into matches for those
1499variables necessary to type $\vW$ and the rest, as before.
1500variables necessary to type $\vW$ and the rest, as before.
@@ -1604,28 +1605,28 @@ In general, \texttt{class} declarations are elaborated as follows:
1604
1605
1605\DM{
1606\DM{
1606\AR{
1607\AR{
1607−\MO{Elab}\:(\iclass\;\piconst{\tc}\TC{C}\:(\ta\Hab\ttt)\:\iwhere\:\td)
1608+\MO{Elab}\;(\iclass\;\piconst{\tc}\TC{C}\;(\ta\Hab\ttt)\;\iwhere\;\td)
1608\\
1609\\
1609\hg\hg
1610\hg\hg
1610−\mq\:\RW{do}\:\AR{
1611+\mq\;\RW{do}\;\AR{
1611(\vec{\VV{meth}}\Hab\ttt)\gets\td\\
1612(\vec{\VV{meth}}\Hab\ttt)\gets\td\\
1612−\MO{Elab}\:
1613+\MO{Elab}\;
1613−\AR{(\RW{data}\:\TC{C}\Hab(\ta\Hab\ttt)\to\Type\:\iwhere\\
1614+\AR{(\RW{data}\;\TC{C}\Hab(\ta\Hab\ttt)\to\Type\;\iwhere\\
1614−\hg\DC{InstanceC}\Hab\piconst{\tc}\td\to\TC{C}\:\ta)}\\
1615+\hg\DC{InstanceC}\Hab\piconst{\tc}\td\to\TC{C}\;\ta)}\\
1615−\vec{\MO{ElabMeth}}\:(\vec{\VV{meth}}\Hab\ttt)\\
1616+\vec{\MO{ElabMeth}}\;(\vec{\VV{meth}}\Hab\ttt)\\
1616−\vec{\MO{ElabParent}}\:\tc
1617+\vec{\MO{ElabParent}}\;\tc
1617}
1618}
1618\medskip\\
1619\medskip\\
1619−\MO{ElabMeth}\:(\vf\Hab\vt)\\
1620+\MO{ElabMeth}\;(\vf\Hab\vt)\\
1620−\hg\hg\mq\:\RW{do}\:\AR{
1621+\hg\hg\mq\;\RW{do}\;\AR{
1621−\MO{Elab}\:(\vf\Hab\TC{C}\:\ta\to\vt)\\
1622+\MO{Elab}\;(\vf\Hab\TC{C}\;\ta\to\vt)\\
1622−\MO{Elab}\:(\vf\:(\DC{InstanceC}\:\vec{\VV{meth}})\:=\:\vec{\VV{meth}[\vf]})
1623+\MO{Elab}\;(\vf\;(\DC{InstanceC}\;\vec{\VV{meth}})\;=\;\vec{\VV{meth}[\vf]})
1623}
1624}
1624\medskip\\
1625\medskip\\
1625−\MO{ElabParent}\:\vc\\
1626+\MO{ElabParent}\;\vc\\
1626−\hg\hg\mq\:\RW{do}\:\AR{
1627+\hg\hg\mq\;\RW{do}\;\AR{
1627−\MO{Elab}\:(\VV{cC}\Hab\TC{C}\:\ta\to\vc)\\
1628+\MO{Elab}\;(\VV{cC}\Hab\TC{C}\;\ta\to\vc)\\
1628−\MO{Elab}\:(\VV{cC}\:(\DC{InstanceC}\:\carg{\vc'}\:\vec{\VV{meth}})\:=\:\vc')
1629+\MO{Elab}\;(\VV{cC}\;(\DC{InstanceC}\;\carg{\vc'}\;\vec{\VV{meth}})\;=\;\vc')
1629}
1630}
1630}
1631}
1631}
1632}
@@ -1634,17 +1635,17 @@ In general, \texttt{class} declarations are elaborated as follows:
1634Then \texttt{instance} declarations are elaborated as follows. One complication
1635Then \texttt{instance} declarations are elaborated as follows. One complication
1635is that the function definitions in an \texttt{instance} declaration do not
1636is that the function definitions in an \texttt{instance} declaration do not
1636have explicit types, so we must retrieve the method types from the system state
1637have explicit types, so we must retrieve the method types from the system state
1637−and substitute $\TC{C}\:\ttt$, using $\MO{ExpandTypes}$:
1638+and substitute $\TC{C}\;\ttt$, using $\MO{ExpandTypes}$:
1638
1639
1639\DM{
1640\DM{
1640\AR{
1641\AR{
1641−\MO{Elab}\:(\iinstance\;\piconst{\tc}\TC{C}\:\ttt\:\iwhere\:\td)\\
1642+\MO{Elab}\;(\iinstance\;\piconst{\tc}\TC{C}\;\ttt\;\iwhere\;\td)\\
1642−\hg\hg\mq\:\RW{do}\:\AR{
1643+\hg\hg\mq\;\RW{do}\;\AR{
1643−(\vec{\VV{meth}}, \vec{\VV{ty}})\gets\MO{ExpandTypes}\:\td\\
1644+(\vec{\VV{meth}}, \vec{\VV{ty}})\gets\MO{ExpandTypes}\;\td\\
1644−\vec{\VV{ty'}}\:=\:\vec{\VV{ty}}[\ttt/\ta]\\
1645+\vec{\VV{ty'}}\;=\;\vec{\VV{ty}}[\ttt/\ta]\\
1645−\MO{Elab}\:(\FN{instanceC}\Hab\piconst{\tc}\TC{C}\:\ttt)\\
1646+\MO{Elab}\;(\FN{instanceC}\Hab\piconst{\tc}\TC{C}\;\ttt)\\
1646−\MO{Elab}\:\AR{
1647+\MO{Elab}\;\AR{
1647−(\FN{instanceC}\:=\:\DC{InstanceC}\;\vec{\VV{meth'}}\;\iwhere
1648+(\FN{instanceC}\;=\;\DC{InstanceC}\;\vec{\VV{meth'}}\;\iwhere
1648\\
1649\\
1649\hg\vec{\VV{meth'}}\Hab\vec{\VV{ty'}}\\
1650\hg\vec{\VV{meth'}}\Hab\vec{\VV{ty'}}\\
1650\hg\td
1651\hg\td
@@ -1678,15 +1679,15 @@ basic primitive for proof search, and is defined as follows:
1678
1679
1679\DM{
1680\DM{
1680\AR{
1681\AR{
1681−\MO{Trivial}\:\mq\:
1682+\MO{Trivial}\;\mq\;
1682−\RW{do}\:\AR{
1683+\RW{do}\;\AR{
1683 (\tv\Hab\ttt)\gets\MO{Context}\\
1684 (\tv\Hab\ttt)\gets\MO{Context}\\
1684− \MO{TryAll}\:\tv
1685+ \MO{TryAll}\;\tv
1685 }
1686 }
1686\medskip\\
1687\medskip\\
1687−\MO{TryAll}\:(\vv_1,\vv_2\ldots)\:\mq\:\MO{Try}\:(\MO{Fill}\:\vv_1)\:(\MO{TryAll}\:\vv_2\ldots)
1688+\MO{TryAll}\;(\vv_1,\vv_2\ldots)\;\mq\;\MO{Try}\;(\MO{Fill}\;\vv_1)\;(\MO{TryAll}\;\vv_2\ldots)
1688\\
1689\\
1689−\MO{TryAll}\:\langle\rangle\:\mq\:\MO{Fail}
1690+\MO{TryAll}\;\langle\rangle\;\mq\;\MO{Fail}
1690}
1691}
1691}
1692}
1692
1693
@@ -1707,11 +1708,11 @@ applying every type class instance, and attempting to resolve the instance's par
1707recursively. Given an instance $\vI$ with parameters $\ta$:
1708recursively. Given an instance $\vI$ with parameters $\ta$:
1708
1709
1709\DM{
1710\DM{
1710−\MO{TryInstance}\:(\vI\:\ta)\:\mq\:\RW{do}\;
1711+\MO{TryInstance}\;(\vI\;\ta)\;\mq\;\RW{do}\;
1711\AR{
1712\AR{
1712−\vec{\MO{Claim}}\:(\tx\Hab\ta)\\
1713+\vec{\MO{Claim}}\;(\tx\Hab\ta)\\
1713−\ttinterp{\vI\:\tx}\\
1714+\ttinterp{\vI\;\tx}\\
1714−\vec{\MO{Focus}}\:\tx;\;\vec{\MO{Instance}}
1715+\vec{\MO{Focus}}\;\tx;\;\vec{\MO{Instance}}
1715}
1716}
1716}
1717}
1717
1718
@@ -1719,13 +1720,13 @@ We define $\MO{Instance}$ as follows, using $\MO{AllInstances}$ to retrieve
1719all possible type class instances in the form required by $\MO{TryInstance}$:
1720all possible type class instances in the form required by $\MO{TryInstance}$:
1720
1721
1721\DM{
1722\DM{
1722−\MO{Instance}\:\mq\:
1723+\MO{Instance}\;\mq\;
1723−\MO{Try}\:
1724+\MO{Try}\;
1724\AR{
1725\AR{
1725\MO{Trivial}\\
1726\MO{Trivial}\\
1726−(\RW{do}\:\AR{
1727+(\RW{do}\;\AR{
1727\ti\gets\MO{AllInstances}\\
1728\ti\gets\MO{AllInstances}\\
1728−\vec{\MO{TryInstance}}\:\ti
1729+\vec{\MO{TryInstance}}\;\ti
1729)
1730)
1730}
1731}
1731}
1732}
@@ -1769,9 +1770,9 @@ and $\icase$ expressions:
1769\begin{array}{rll@{\hg}rll}
1770\begin{array}{rll@{\hg}rll}
1770\ve ::= & \ldots \\
1771\ve ::= & \ldots \\
1771\mid & \mvar{\vx} & (\mbox{metavariable}) &
1772\mid & \mvar{\vx} & (\mbox{metavariable}) &
1772−\mid & \icase\:\ve\:\iof\:\vec{\VV{alt}} & (\mbox{case expression}) \\
1773+\mid & \icase\;\ve\;\iof\;\vec{\VV{alt}} & (\mbox{case expression}) \\
1773\medskip\\
1774\medskip\\
1774−\VV{alt} ::= & \ve\:\fatarrow\:\ve & (\mbox{case alternative})\\
1775+\VV{alt} ::= & \ve\;\fatarrow\;\ve & (\mbox{case alternative})\\
1775\end{array}
1776\end{array}
1776}
1777}
1777}
1778}
@@ -1824,12 +1825,12 @@ Elaborating a metavariable involves adding a new top level definition which is a
1824to all of the variables in local scope.
1825to all of the variables in local scope.
1825
1826
1826\DM{
1827\DM{
1827−\ttinterp{\mvar{\vx}}\:\mq\:
1828+\ttinterp{\mvar{\vx}}\;\mq\;
1828\edo{
1829\edo{
1829(\tv\Hab\ttt)\gets\MO{Context}\\
1830(\tv\Hab\ttt)\gets\MO{Context}\\
1830\vT\gets\MO{Type}\\
1831\vT\gets\MO{Type}\\
1831−\MO{TTDecl}\:(\vx\Hab(\tv\Hab\ttt)\to\vT)\\
1832+\MO{TTDecl}\;(\vx\Hab(\tv\Hab\ttt)\to\vT)\\
1832−\ttinterp{\vx\:\tv}
1833+\ttinterp{\vx\;\tv}
1833}
1834}
1834}
1835}
1835
1836
@@ -1867,14 +1868,14 @@ and elaborate it:
1867
1868
1868\DM{
1869\DM{
1869\AR{
1870\AR{
1870−\ttinterp{\icase\:\ve\:\iof\:\vec{\VV{alt}}}\:\mq\:
1871+\ttinterp{\icase\;\ve\;\iof\;\vec{\VV{alt}}}\;\mq\;
1871\edo{
1872\edo{
1872−\ttinterp{\ilet{\VV{scrutinee}}{\ve}\:\mvar{\VV{xcase}}}\\
1873+\ttinterp{\ilet{\VV{scrutinee}}{\ve}\;\mvar{\VV{xcase}}}\\
1873(\tv\Hab\ttt)\gets\MO{Context}\\
1874(\tv\Hab\ttt)\gets\MO{Context}\\
1874−\vec{\MO{MkCase}}\:\tv\:\VV{alt}\\
1875+\vec{\MO{MkCase}}\;\tv\;\VV{alt}\\
1875}
1876}
1876\medskip\\
1877\medskip\\
1877−\MO{MkCase}\:\tv\:(\vl\:\fatarrow\:\vr)\:\mq\:\MO{Elab}\:(\VV{xcase}\:\tv\:\vl\:=\:\vr)
1878+\MO{MkCase}\;\tv\;(\vl\;\fatarrow\;\vr)\;\mq\;\MO{Elab}\;(\VV{xcase}\;\tv\;\vl\;=\;\vr)
1878}
1879}
1879}
1880}
1880
1881
papers/impl-paper/intro.tex+13−19
@@ -142,29 +142,23 @@ The \TT{} translation of \texttt{vAdd} is:
142
142
143\DM{
143\DM{
144\AR{
144\AR{
145−\begin{array}{ll}
146−\FN{vAdd} & \Hab(\va\Hab\Set)\to(\vn\Hab\Nat)\to\TC{Num}\:\va\to
145+\FN{vAdd} \Hab(\va\Hab\Type)\to(\vn\Hab\Nat)\to\TC{Num}\;\va\to
147− \Vect\:\va\:\vn\to\Vect\:\va\:\vn\to\Vect\:\va\:\vn\\
146+ \Vect\;\va\;\vn\to\Vect\;\va\;\vn\to\Vect\;\va\;\vn\\
148−\end{array}
149−\\
150−\begin{array}{lccccccc}
151−\multicolumn{5}{l}{
152−\RW{var}\:\va\Hab\Set,\:\vc\Hab\TC{Num}\;\va\SC}\\
147+\RW{var}\;\va\Hab\Type,\;\vc\Hab\TC{Num}\;\va\SC\\
153−\hg\FN{vAdd} & \va & \Z & \vc & (\DC{Nil}\;\va) & (\DC{Nil}\;\va) & \Ret{\DC{Nil}\;\va} \\
148+\hg\FN{vAdd} \; \va \; \Z \; \vc \; (\DC{Nil}\;\va) \; (\DC{Nil}\;\va) \;
154−\multicolumn{5}{l}{
149+\cq\;\DC{Nil}\;\va \\
155−\RW{var}\:\AR{
150+\RW{var}\;\AR{
156−\va\Hab\Set,\:\vk\Hab\Nat,\;\vc\Hab\TC{Num}\;\va,\\
151+\va\Hab\Type,\;\vk\Hab\Nat,\;\vc\Hab\TC{Num}\;\va,\\
157\vx\Hab\va,\;\vxs\Hab\Vect\;\va\;\vk,\;
152\vx\Hab\va,\;\vxs\Hab\Vect\;\va\;\vk,\;
158\vy\Hab\va,\;\vys\Hab\Vect\;\va\;\vk
153\vy\Hab\va,\;\vys\Hab\Vect\;\va\;\vk
159\SC
154\SC
155+\\
156+\FN{vAdd} \; \va \; (\suc\;\vk) \; \vc
157+ \; ((\DC{::})\;\va\;\vk\;\vx\;\vxs)
158+ \; ((\DC{::})\;\va\;\vk\;\vy\;\vys)
159+ \\
160+ \hg\hg\cq\:((\DC{::})\;\va\;\vk\;((+)\;\vc\;\vx\;\vy)\; (\FN{vAdd}\;\va\;\vk\;\vc\;\vxs\;\vys))
160}
161}
161−}\\
162−\hg\FN{vAdd} & \va & (\suc\;\vk) & \vc
163− & ((\DC{::})\;\va\;\vk\;\vx\;\vxs)
164− & ((\DC{::})\;\va\;\vk\;\vy\;\vys)
165− & \\
166− & & \MRet{5}{((\DC{::})\;\va\;\vk\;((+)\;\vc\;\vx\;\vy)\; (\FN{vAdd}\;\va\;\vk\;\vc\;\vxs\;\vys))}
167−\end{array}
168}
162}
169}
163}
170
164
papers/impl-paper/macros.ltx+1−1
@@ -430,7 +430,7 @@ Program & Version & Instructions & Thunks & Memory Accesses & Cells \\
430\newcommand{\pq}{\pad{\:}{=}}
430\newcommand{\pq}{\pad{\:}{=}}
431\newcommand{\dq}{\pad{\:}{:=}}
431\newcommand{\dq}{\pad{\:}{:=}}
432\newcommand{\iq}{\pad{\:}{\leadsto}}
432\newcommand{\iq}{\pad{\:}{\leadsto}}
433−\newcommand{\mq}{\Longrightarrow}
433+\newcommand{\mq}{=} %\Longrightarrow}
434\newcommand{\retq}{\Rightarrow}
434\newcommand{\retq}{\Rightarrow}
435\newcommand{\hq}{\pad{\:}{=}}
435\newcommand{\hq}{\pad{\:}{=}}
436\newcommand{\defq}{\mapsto}
436\newcommand{\defq}{\mapsto}
papers/impl-paper/typechecking.tex+79−84
@@ -37,9 +37,9 @@ inferred by the machine~\cite{pollack1990implicit}.
37\hg\vb ::= & \lam{\vx}{\vt} & (\mbox{abstraction}) \\
37\hg\vb ::= & \lam{\vx}{\vt} & (\mbox{abstraction}) \\
38
38
39 \mid & \vx & (\mbox{variable}) &
39 \mid & \vx & (\mbox{variable}) &
40− \mid & \LET\:\vx\defq\vt\Hab\vt & (\mbox{let binding}) \\
40+ \mid & \LET\;\vx\defq\vt\Hab\vt & (\mbox{let binding}) \\
41
41
42− \mid & \vb\SC\:\vt & (\mbox{binding}) &
42+ \mid & \vb\SC\;\vt & (\mbox{binding}) &
43 \mid & \all{\vx}{\vt} & (\mbox{function space}) \\
43 \mid & \all{\vx}{\vt} & (\mbox{function space}) \\
44
44
45 \mid & \vt\;\vt & (\mbox{application}) &
45 \mid & \vt\;\vt & (\mbox{application}) &
@@ -80,7 +80,7 @@ $\LET$ binding:
80{\Gamma;\all{\vx}{\vS}\proves\RW{valid}}
80{\Gamma;\all{\vx}{\vS}\proves\RW{valid}}
81\hg
81\hg
82\Rule{\Gamma\proves\vS\Hab\Type_i\hg\Gamma\proves\vs\Hab\vS}
82\Rule{\Gamma\proves\vS\Hab\Type_i\hg\Gamma\proves\vs\Hab\vS}
83−{\Gamma;\LET\:\vx\:\defq\:\vs\Hab\vS\proves\RW{valid}}
83+{\Gamma;\LET\;\vx\;\defq\;\vs\Hab\vS\proves\RW{valid}}
84}
84}
85
85
86\subsubsection{Evaluation}
86\subsubsection{Evaluation}
@@ -103,8 +103,8 @@ The following contextual closure rule reduces a $\LET$ binding by creating
103a $\delta$-reducible expression:
103a $\delta$-reducible expression:
104
104
105\DM{
105\DM{
106−\Rule{\Gamma;\LET\:\vx\defq\vs\Hab\vS\proves\vt\leadsto\vu}
106+\Rule{\Gamma;\LET\;\vx\defq\vs\Hab\vS\proves\vt\leadsto\vu}
107−{\Gamma\proves\LET\:\vx\defq\vs\Hab\vS\SC\vt\leadsto\vu}
107+{\Gamma\proves\LET\;\vx\defq\vs\Hab\vS\SC\vt\leadsto\vu}
108}
108}
109
109
110\demph{Reduction} ($\reduces$) is the structural closure of contraction, and evaluation
110\demph{Reduction} ($\reduces$) is the structural closure of contraction, and evaluation
@@ -122,11 +122,11 @@ reduction rules.
122\begin{array}{lc}
122\begin{array}{lc}
123\beta\mathrm{-contraction} &
123\beta\mathrm{-contraction} &
124\Axiom{
124\Axiom{
125−\Gamma\proves(\lam{\vx}{\vS}\SC\vt)\:\vs\leadsto\LET\:\vx\defq\vs\Hab\vS\SC\vt
125+\Gamma\proves(\lam{\vx}{\vS}\SC\vt)\;\vs\leadsto\LET\;\vx\defq\vs\Hab\vS\SC\vt
126} \\
126} \\
127\delta\mathrm{-contraction} &
127\delta\mathrm{-contraction} &
128\Axiom{
128\Axiom{
129−\Gamma;\LET\:\vx\defq\vs\Hab\vS;\Gamma'
129+\Gamma;\LET\;\vx\defq\vs\Hab\vS;\Gamma'
130\proves
130\proves
131\vx\leadsto\vs
131\vx\leadsto\vs
132}
132}
@@ -153,71 +153,71 @@ are no cycles. Otherwise, the typing rules are standard and type inference can
153be implemented in the usual way~\cite{loh2010tutorial}.
153be implemented in the usual way~\cite{loh2010tutorial}.
154
154
155\FFIG{\begin{array}{c}
155\FFIG{\begin{array}{c}
156−\mathsf{Type}\:
156+\mathsf{Type}\;
157\Rule{\Gamma\proves\RW{valid}}
157\Rule{\Gamma\proves\RW{valid}}
158{\Gamma\vdash\Type_n\Hab\Type_{n+1}}
158{\Gamma\vdash\Type_n\Hab\Type_{n+1}}
159\\
159\\
160−\mathsf{Const}_1\:
160+\mathsf{Const}_1\;
161\Rule{\Gamma\proves\RW{valid}}
161\Rule{\Gamma\proves\RW{valid}}
162{\Gamma\vdash\vi\Hab\TC{Int}}
162{\Gamma\vdash\vi\Hab\TC{Int}}
163\hg
163\hg
164−\mathsf{Const}_2\:
164+\mathsf{Const}_2\;
165\Rule{\Gamma\proves\RW{valid}}
165\Rule{\Gamma\proves\RW{valid}}
166{\Gamma\vdash\VV{str}\Hab\TC{String}}
166{\Gamma\vdash\VV{str}\Hab\TC{String}}
167\\
167\\
168−\mathsf{Const}_3\:
168+\mathsf{Const}_3\;
169\Rule{\Gamma\proves\RW{valid}}
169\Rule{\Gamma\proves\RW{valid}}
170{\Gamma\vdash\TC{Int}\Hab\Type_0}
170{\Gamma\vdash\TC{Int}\Hab\Type_0}
171\hg
171\hg
172−\mathsf{Const}_4\:
172+\mathsf{Const}_4\;
173\Rule{\Gamma\proves\RW{valid}}
173\Rule{\Gamma\proves\RW{valid}}
174{\Gamma\vdash\TC{String}\Hab\Type_0}
174{\Gamma\vdash\TC{String}\Hab\Type_0}
175\\
175\\
176−%\mathsf{Pat}_1\:
176+%\mathsf{Pat}_1\;
177%\Rule{(\pat{\vx}{\vS})\in\Gamma}
177%\Rule{(\pat{\vx}{\vS})\in\Gamma}
178%{\Gamma\vdash\vx\Hab\vS}
178%{\Gamma\vdash\vx\Hab\vS}
179%\hg
179%\hg
180−%\mathsf{Pat}_2\:
180+%\mathsf{Pat}_2\;
181%\Rule{(\pty{\vx}{\vS})\in\Gamma}
181%\Rule{(\pty{\vx}{\vS})\in\Gamma}
182%{\Gamma\vdash\vx\Hab\vS}
182%{\Gamma\vdash\vx\Hab\vS}
183\\
183\\
184−\mathsf{Var}_1\:
184+\mathsf{Var}_1\;
185\Rule{(\lam{\vx}{\vS})\in\Gamma}
185\Rule{(\lam{\vx}{\vS})\in\Gamma}
186{\Gamma\vdash\vx\Hab\vS}
186{\Gamma\vdash\vx\Hab\vS}
187\hg
187\hg
188−\mathsf{Var}_2\:
188+\mathsf{Var}_2\;
189\Rule{(\all{\vx}{\vS})\in\Gamma}
189\Rule{(\all{\vx}{\vS})\in\Gamma}
190{\Gamma\vdash\vx\Hab\vS}
190{\Gamma\vdash\vx\Hab\vS}
191\hg
191\hg
192−\mathsf{Val}\:
192+\mathsf{Val}\;
193−\Rule{(\LET\:\vx\defq\vs\Hab\vS)\in\Gamma}
193+\Rule{(\LET\;\vx\defq\vs\Hab\vS)\in\Gamma}
194{\Gamma\vdash\vx\Hab\vS}
194{\Gamma\vdash\vx\Hab\vS}
195\\
195\\
196−\mathsf{App}\:
196+\mathsf{App}\;
197\Rule{\Gamma\vdash\vf\Hab\fbind{\vx}{\vS}{\vT}\hg\Gamma\vdash\vs\Hab\vS}
197\Rule{\Gamma\vdash\vf\Hab\fbind{\vx}{\vS}{\vT}\hg\Gamma\vdash\vs\Hab\vS}
198−{\Gamma\vdash\vf\:\vs\Hab\vT[\vs/\vx]} % \LET\:\vx\Hab\vS\:\defq\:\vs\:\IN\:\vT}
198+{\Gamma\vdash\vf\;\vs\Hab\vT[\vs/\vx]} % \LET\;\vx\Hab\vS\;\defq\;\vs\;\IN\;\vT}
199\\
199\\
200−\mathsf{Lam}\:
200+\mathsf{Lam}\;
201\Rule{\Gamma;\lam{\vx}{\vS}\vdash\ve\Hab\vT\hg\Gamma\proves\fbind{\vx}{\vS}{\vT}\Hab\Type_n}
201\Rule{\Gamma;\lam{\vx}{\vS}\vdash\ve\Hab\vT\hg\Gamma\proves\fbind{\vx}{\vS}{\vT}\Hab\Type_n}
202{\Gamma\vdash\lam{\vx}{\vS}.\ve\Hab\fbind{\vx}{\vS}{\vT}}
202{\Gamma\vdash\lam{\vx}{\vS}.\ve\Hab\fbind{\vx}{\vS}{\vT}}
203\\
203\\
204−\mathsf{Forall}\:
204+\mathsf{Forall}\;
205\Rule{\Gamma;\all{\vx}{\vS}\vdash\vT\Hab\Type_m\hg\Gamma\vdash\vS\Hab\Type_n}
205\Rule{\Gamma;\all{\vx}{\vS}\vdash\vT\Hab\Type_m\hg\Gamma\vdash\vS\Hab\Type_n}
206{\Gamma\vdash\fbind{\vx}{\vS}{\vT}\Hab\Type_p}
206{\Gamma\vdash\fbind{\vx}{\vS}{\vT}\Hab\Type_p}
207−\:(\exists\vp.\vm\le\vp,\:\vn\le\vp)
207+\;(\exists\vp.\vm\le\vp,\;\vn\le\vp)
208\\
208\\
209−\mathsf{Let}\:
209+\mathsf{Let}\;
210\Rule{\begin{array}{c}\Gamma\proves\ve_1\Hab\vS\hg
210\Rule{\begin{array}{c}\Gamma\proves\ve_1\Hab\vS\hg
211− \Gamma;\LET\:\vx\defq\ve_1\Hab\vS\proves\ve_2\Hab\vT\\
211+ \Gamma;\LET\;\vx\defq\ve_1\Hab\vS\proves\ve_2\Hab\vT\\
212 \Gamma\proves\vS\Hab\Type_n\hg
212 \Gamma\proves\vS\Hab\Type_n\hg
213− \Gamma;\LET\:\vx\defq\ve_1\Hab\vS\proves\vT\Hab\Type_n\end{array}
213+ \Gamma;\LET\;\vx\defq\ve_1\Hab\vS\proves\vT\Hab\Type_n\end{array}
214 }
214 }
215−{\Gamma\vdash\LET\:\vx\defq\ve_1\Hab\vS\SC\:\ve_2\Hab
215+{\Gamma\vdash\LET\;\vx\defq\ve_1\Hab\vS\SC\;\ve_2\Hab
216 \vT[\ve_1/\vx]}
216 \vT[\ve_1/\vx]}
217−%\Let\:\vx\Hab\vS\defq\ve_1\:\IN\:\vT}
217+%\Let\;\vx\Hab\vS\defq\ve_1\;\IN\;\vT}
218\\
218\\
219
219
220−\mathsf{Conv}\:
220+\mathsf{Conv}\;
221\Rule{\Gamma\proves\vx\Hab\vA\hg\Gamma\proves\vA'\Hab\Type_n\hg
221\Rule{\Gamma\proves\vx\Hab\vA\hg\Gamma\proves\vA'\Hab\Type_n\hg
222 \Gamma\proves\vA\cumul\vA'}
222 \Gamma\proves\vA\cumul\vA'}
223 {\Gamma\proves\vx\Hab\vA'}
223 {\Gamma\proves\vx\Hab\vA'}
@@ -258,8 +258,8 @@ sequence of zero or more $\vx$ (i.e., $\vx_1,\vx_2,\ldots,\vx_n$):
258
258
259\DM{
259\DM{
260\AR{
260\AR{
261−\Data\hg\TC{T}\:(\tx\Hab\ttt)\Hab\vt\hg\Where\hg
261+\Data\hg\TC{T}\;(\tx\Hab\ttt)\Hab\vt\hg\Where\hg
262−\DC{c}_1\Hab\vt\:\mid\:\ldots\:\mid\:\DC{c}_n\Hab\vt
262+\DC{c}_1\Hab\vt\;\mid\;\ldots\;\mid\;\DC{c}_n\Hab\vt
263}
263}
264}
264}
265
265
@@ -272,7 +272,7 @@ constructor are structurally smaller than the value itself.
272For example, the \Idris{} data type \tTC{Nat} would be declared in \TT{} as follows:
272For example, the \Idris{} data type \tTC{Nat} would be declared in \TT{} as follows:
273
273
274\DM{
274\DM{
275−\Data\hg\Nat\Hab\Type\hg\Where\hg\Z\Hab\Nat\:\mid\:\suc\Hab\fbind{\vk}{\Nat}{\Nat}
275+\Data\hg\Nat\Hab\Type\hg\Where\hg\Z\Hab\Nat\;\mid\;\suc\Hab\fbind{\vk}{\Nat}{\Nat}
276}
276}
277
277
278A data type may have zero or more parameters (which are invariant
278A data type may have zero or more parameters (which are invariant
@@ -281,10 +281,11 @@ example, the \TT{} equivalent of \tTC{List} is parameterised over its element ty
281
281
282\DM{
282\DM{
283\AR{
283\AR{
284−\Data\hg\List\:(\va\Hab\Type)\Hab\Type\hg\Where
284+\Data\hg\List\:(\va\Hab\Type)\Hab\Type\hg\Where\\
285+\hg\hg
285\ARd{
286\ARd{
286−& \nil\Hab\List\:\va\\
287+& \nil\Hab\List\;\va\\
287−\mid & (\cons)\Hab\fbind{\vx}{\va}{\fbind{\vxs}{\List\:\va}{\List\:\va}}
288+\mid & (\cons)\Hab\fbind{\vx}{\va}{\fbind{\vxs}{\List\;\va}{\List\;\va}}
288}
289}
289}
290}
290}
291}
@@ -299,11 +300,11 @@ index $\vk$ is given \remph{explicitly}.
299
300
300\DM{
301\DM{
301\AR{
302\AR{
302−\Data\hg\Vect\:(\va\Hab\Type)\Hab\Nat\to\Type\hg\Where \\
303+\Data\hg\Vect\;(\va\Hab\Type)\Hab\Nat\to\Type\hg\Where \\
303\hg\hg\ARd{
304\hg\hg\ARd{
304−& \nil\Hab\Vect\:\va\:\Z\\
305+& \nil\Hab\Vect\;\va\;\Z\\
305\mid & (\cons)\Hab\fbind{\vk}{\Nat}{
306\mid & (\cons)\Hab\fbind{\vk}{\Nat}{
306−\fbind{\vx}{\va}{\fbind{\vxs}{\Vect\:\va\:\vk}{\Vect\:\va\:(\suc\:\vk)}}
307+\fbind{\vx}{\va}{\fbind{\vxs}{\Vect\;\va\;\vk}{\Vect\;\va\;(\suc\;\vk)}}
307}
308}
308}
309}
309}
310}
@@ -322,9 +323,9 @@ consisting of a type declaration followed by one or more pattern clauses:
322\DM{
323\DM{
323\AR{
324\AR{
324\FN{f}\Hab\vt\\
325\FN{f}\Hab\vt\\
325−\pat{\tx_1}{\ttt_1}\SC\FN{f}\:\ttt_1\:=\:\vt_1\\
326+\pat{\tx_1}{\ttt_1}\SC\FN{f}\;\ttt_1\;=\;\vt_1\\
326\ldots\\
327\ldots\\
327−\pat{\tx_n}{\ttt_n}\SC\FN{f}\:\ttt_n\:=\:\vt_n\\
328+\pat{\tx_n}{\ttt_n}\SC\FN{f}\;\ttt_n\;=\;\vt_n\\
328}
329}
329}
330}
330
331
@@ -341,11 +342,11 @@ clause is defined by the following rule:
341
342
342\DM{
343\DM{
343\Rule{
344\Rule{
344−\Gamma;\lam{\tx}{\tU}\proves\FN{f}\:\tts\Hab\vS\hg
345+\Gamma;\lam{\tx}{\tU}\proves\FN{f}\;\tts\Hab\vS\hg
345\Gamma;\lam{\tx}{\tU}\proves\ve\Hab\vT\hg
346\Gamma;\lam{\tx}{\tU}\proves\ve\Hab\vT\hg
346\Gamma\proves\vS\converts\vT}
347\Gamma\proves\vS\converts\vT}
347{
348{
348−\Gamma\proves\pat{\tx}{\tU}\SC\FN{f}\:\tts\:=\:\ve\:\RW{valid}
349+\Gamma\proves\pat{\tx}{\tU}\SC\FN{f}\;\tts\;=\;\ve\;\RW{valid}
349}
350}
350}
351}
351
352
@@ -386,13 +387,13 @@ trees~\cite{Augustsson1985}.
386% \FFIG{
387% \FFIG{
387% \AR{
388% \AR{
388% \PA{\A}{
389% \PA{\A}{
389−% & \MO{Clause} & (\pat{\tx}{\tU}\SC\FN{f}\:\tts\:=\:\ve)
390+% & \MO{Clause} & (\pat{\tx}{\tU}\SC\FN{f}\;\tts\;=\;\ve)
390−% & \MoRet{\FN{f}\:(\vec{\MO{Pat}}\:\tts)\:=\:\ve}
391+% & \MoRet{\FN{f}\;(\vec{\MO{Pat}}\;\tts)\;=\;\ve}
391% }
392% }
392% \medskip\\
393% \medskip\\
393% \PA{\A}{
394% \PA{\A}{
394−% & \MO{Pat} & (\vx\:\tts) & \MoRet{\vx\:(\vec{\MO{Pat}}\:\tts)
395+% & \MO{Pat} & (\vx\;\tts) & \MoRet{\vx\;(\vec{\MO{Pat}}\;\tts)
395−% \hg\mbox{(if $\MO{Con}\:\vx$ and $\MO{Arity}\:\vx = \MO{Length}\:\tts$)}} \\
396+% \hg\mbox{(if $\MO{Con}\;\vx$ and $\MO{Arity}\;\vx = \MO{Length}\;\tts$)}} \\
396% & \MO{Pat} & \vx & \MoRet{\vx} \hg\mbox(if $\vx$ is a pattern variable)\\
397% & \MO{Pat} & \vx & \MoRet{\vx} \hg\mbox(if $\vx$ is a pattern variable)\\
397% & \MO{Pat} & \cdot & \MoRet{\_} \hg\mbox(in all other cases)\\
398% & \MO{Pat} & \cdot & \MoRet{\_} \hg\mbox(in all other cases)\\
398% }
399% }
@@ -422,43 +423,43 @@ trees~\cite{Augustsson1985}.
422% with the next clause. The algorithm uses the following meta-operations:
423% with the next clause. The algorithm uses the following meta-operations:
423%
424%
424% \begin{itemize}
425% \begin{itemize}
425−% \item $\MO{Con}\:\vx$, which returns true if $\vx$ is a constructor name
426+% \item $\MO{Con}\;\vx$, which returns true if $\vx$ is a constructor name
426−% \item $\MO{Arity}\:\vx$, which, if $\vx$ is a constructor name, returns the number of arguments
427+% \item $\MO{Arity}\;\vx$, which, if $\vx$ is a constructor name, returns the number of arguments
427% $\vx$ requires.
428% $\vx$ requires.
428−% \item $\MO{Length}\:\tts$, which returns the length of the vector $\tts$
429+% \item $\MO{Length}\;\tts$, which returns the length of the vector $\tts$
429% \end{itemize}
430% \end{itemize}
430%
431%
431%
432%
432% \FFIG{
433% \FFIG{
433% \AR{
434% \AR{
434% \PA{\A\A}{
435% \PA{\A\A}{
435−% & \MO{MatchArg} & (\vx\:\tts) & (\vx\:\tts')
436+% & \MO{MatchArg} & (\vx\;\tts) & (\vx\;\tts')
436−% & \MoRet{\vec{\MO{MatchArg}}\:\tts\:\tts'\hg\mbox{(if $\MO{Con}\:\vx$)}}\\
437+% & \MoRet{\vec{\MO{MatchArg}}\;\tts\;\tts'\hg\mbox{(if $\MO{Con}\;\vx$)}}\\
437−% & \MO{MatchArg} & (\vx\:\tts) & \vx & \MoRet{\Blocked} \\
438+% & \MO{MatchArg} & (\vx\;\tts) & \vx & \MoRet{\Blocked} \\
438−% & \MO{MatchArg} & \vx & \vt & \MoRet{\Success\:(\vx\mapsto\vt)} \\
439+% & \MO{MatchArg} & \vx & \vt & \MoRet{\Success\;(\vx\mapsto\vt)} \\
439−% & \MO{MatchArg} & \_ & \vt & \MoRet{\Success\:()} \\
440+% & \MO{MatchArg} & \_ & \vt & \MoRet{\Success\;()} \\
440% & \MO{MatchArg} & \cdot & \cdot & \MoRet{\Failure}
441% & \MO{MatchArg} & \cdot & \cdot & \MoRet{\Failure}
441% }
442% }
442% \medskip\\
443% \medskip\\
443% \PA{\A\A}{
444% \PA{\A\A}{
444−% & \MO{MatchClause} & (\vf\:\tp = \ve) & (\vf\:\tts) &
445+% & \MO{MatchClause} & (\vf\;\tp = \ve) & (\vf\;\tts) &
445% \MoRet{
446% \MoRet{
446% \AR{
447% \AR{
447−% \Success\:\ve[\tx/\tv]\hg\mbox{(if $\vec{\MO{MatchArg}}\:\tp\:\tts \mq \Success\:(\tx,\tv)$)}\\
448+% \Success\;\ve[\tx/\tv]\hg\mbox{(if $\vec{\MO{MatchArg}}\;\tp\;\tts \mq \Success\;(\tx,\tv)$)}\\
448−% \Blocked\;\;\;\hg\hg\mbox{(if $\vec{\MO{MatchArg}}\:\tp\:\tts \mq \Blocked$)}\\
449+% \Blocked\;\;\;\hg\hg\mbox{(if $\vec{\MO{MatchArg}}\;\tp\;\tts \mq \Blocked$)}\\
449−% \Failure\;\;\;\;\;\hg\hg\mbox{(if $\vec{\MO{MatchArg}}\:\tp\:\tts \mq \Failure$)}\\
450+% \Failure\;\;\;\;\;\hg\hg\mbox{(if $\vec{\MO{MatchArg}}\;\tp\;\tts \mq \Failure$)}\\
450% }
451% }
451% } \\
452% } \\
452−% & \MO{MatchClause} & (\vf\:\tp = \ve) & \cdot & \MoRet{\Failure} \\
453+% & \MO{MatchClause} & (\vf\;\tp = \ve) & \cdot & \MoRet{\Failure} \\
453% }
454% }
454% \medskip\\
455% \medskip\\
455% \PA{\A\A}{
456% \PA{\A\A}{
456% & \MO{Match} & (\vc ; \tc) & \ve &
457% & \MO{Match} & (\vc ; \tc) & \ve &
457% \MoRet{
458% \MoRet{
458% \AR{
459% \AR{
459−% \Success\;\vx\;\;\hg\mbox{(if $\MO{MatchClause}\:\vc\:\ve \mq \Success\:\vx)$} \\
460+% \Success\;\vx\;\;\hg\mbox{(if $\MO{MatchClause}\;\vc\;\ve \mq \Success\;\vx)$} \\
460−% \Blocked\hg\;\;\;\;\mbox{(if $\MO{MatchClause}\:\vc\:\ve \mq \Blocked)$} \\
461+% \Blocked\hg\;\;\;\;\mbox{(if $\MO{MatchClause}\;\vc\;\ve \mq \Blocked)$} \\
461−% \MO{Match}\:\tc\:\ve\hg\mbox{(otherwise)}
462+% \MO{Match}\;\tc\;\ve\hg\mbox{(otherwise)}
462% }
463% }
463% } \\
464% } \\
464% & \MO{Match} & \cdot & \ve & \MoRet{\Failure}
465% & \MO{Match} & \cdot & \ve & \MoRet{\Failure}
@@ -469,7 +470,7 @@ trees~\cite{Augustsson1985}.
469% {pmatch}
470% {pmatch}
470%
471%
471% By convention, we write the application of a meta-operation $\MO{Op}$
472% By convention, we write the application of a meta-operation $\MO{Op}$
472−% across a vector $\tx$ as $\vec{\MO{Op}}\:\tx$.
473+% across a vector $\tx$ as $\vec{\MO{Op}}\;\tx$.
473% In practice, for efficiency, pattern matching is implemented by compiling the match clauses to
474% In practice, for efficiency, pattern matching is implemented by compiling the match clauses to
474% a tree of case expressions~\cite{Augustsson1985}.
475% a tree of case expressions~\cite{Augustsson1985}.
475
476
@@ -480,7 +481,7 @@ trees~\cite{Augustsson1985}.
480\mbox{\textbf{Church-Rosser}} &
481\mbox{\textbf{Church-Rosser}} &
481\begin{array}{ll}
482\begin{array}{ll}
482\mbox{If}\hg\Gamma\proves\vs\converts\vt \\
483\mbox{If}\hg\Gamma\proves\vs\converts\vt \\
483−\mbox{then there is a common reduct $\vr$ such that}\:\\
484+\mbox{then there is a common reduct $\vr$ such that}\;\\
484\Gamma\proves\vs\reducesto\vr\hg\Gamma\proves\vt\reducesto\vr
485\Gamma\proves\vs\reducesto\vr\hg\Gamma\proves\vt\reducesto\vr
485\end{array}
486\end{array}
486\medskip
487\medskip
@@ -494,7 +495,7 @@ trees~\cite{Augustsson1985}.
494\\
495\\
495\mbox{\textbf{Cut}} &
496\mbox{\textbf{Cut}} &
496\begin{array}{ll}
497\begin{array}{ll}
497−\mbox{If} & \Gamma_0,\LET\:\vx\defq\vs\Hab\vS,\Gamma_1\proves\vt\Hab\vT\\
498+\mbox{If} & \Gamma_0,\LET\;\vx\defq\vs\Hab\vS,\Gamma_1\proves\vt\Hab\vT\\
498\mbox{then} & \Gamma_0, \Gamma_1[\vs/\vx]\proves\vt[\vs/\vx]\Hab\vT[\vs/\vx]
499\mbox{then} & \Gamma_0, \Gamma_1[\vs/\vx]\proves\vt[\vs/\vx]\Hab\vT[\vs/\vx]
499\end{array}
500\end{array}
500\medskip
501\medskip
@@ -606,29 +607,23 @@ switching to \TT{} notation from the ASCII \Idris{} syntax.
606
607
607\FFIG{
608\FFIG{
608\AR{
609\AR{
609−\begin{array}{ll}
610−\FN{vAdd} & \Hab(\va\Hab\Type)\to(\vn\Hab\Nat)\to\TC{Num}\:\va\to
610+\FN{vAdd} \Hab(\va\Hab\Type)\to(\vn\Hab\Nat)\to\TC{Num}\;\va\to
611− \Vect\:\va\:\vn\to\Vect\:\va\:\vn\to\Vect\:\va\:\vn\\
611+ \Vect\;\va\;\vn\to\Vect\;\va\;\vn\to\Vect\;\va\;\vn\\
612−\end{array}
613−\\
614−\begin{array}{lccccccc}
615−\multicolumn{5}{l}{
616−\RW{var}\:\va\Hab\Type,\:\vc\Hab\TC{Num}\;\va\SC}\\
612+\RW{var}\;\va\Hab\Type,\;\vc\Hab\TC{Num}\;\va\SC\\
617−\hg\FN{vAdd} & \va & \Z & \vc & (\DC{Nil}\;\va) & (\DC{Nil}\;\va) & \Ret{\DC{Nil}\;\va} \\
613+\hg\FN{vAdd} \; \va \; \Z \; \vc \; (\DC{Nil}\;\va) \; (\DC{Nil}\;\va) \;
618−\multicolumn{5}{l}{
614+\cq\;\DC{Nil}\;\va \\
619−\RW{var}\:\AR{
615+\RW{var}\;\AR{
620−\va\Hab\Type,\:\vk\Hab\Nat,\;\vc\Hab\TC{Num}\;\va,\\
616+\va\Hab\Type,\;\vk\Hab\Nat,\;\vc\Hab\TC{Num}\;\va,\\
621\vx\Hab\va,\;\vxs\Hab\Vect\;\va\;\vk,\;
617\vx\Hab\va,\;\vxs\Hab\Vect\;\va\;\vk,\;
622\vy\Hab\va,\;\vys\Hab\Vect\;\va\;\vk
618\vy\Hab\va,\;\vys\Hab\Vect\;\va\;\vk
623\SC
619\SC
620+\\
621+\FN{vAdd} \; \va \; (\suc\;\vk) \; \vc
622+ \; ((\DC{::})\;\va\;\vk\;\vx\;\vxs)
623+ \; ((\DC{::})\;\va\;\vk\;\vy\;\vys)
624+ \\
625+ \hg\hg\cq\:((\DC{::})\;\va\;\vk\;((+)\;\vc\;\vx\;\vy)\; (\FN{vAdd}\;\va\;\vk\;\vc\;\vxs\;\vys))
624}
626}
625−}\\
626−\hg\FN{vAdd} & \va & (\suc\;\vk) & \vc
627− & ((\DC{::})\;\va\;\vk\;\vx\;\vxs)
628− & ((\DC{::})\;\va\;\vk\;\vy\;\vys)
629− & \\
630− & & \MRet{5}{((\DC{::})\;\va\;\vk\;((+)\;\vc\;\vx\;\vy)\; (\FN{vAdd}\;\va\;\vk\;\vc\;\vxs\;\vys))}
631−\end{array}
632}
627}
633}
628}
634{Pairwise addition of vectors in \TT{}}
629{Pairwise addition of vectors in \TT{}}