Skip to content

Commit 72710a6

Browse files
Merge pull request herd#1602 from herd/aslspec-phase7
[aslspec] phase7: expressions
2 parents 63a725d + 61bcbfa commit 72710a6

15 files changed

Lines changed: 864 additions & 378 deletions

asllib/doc/ASLFormal.tex

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -357,7 +357,7 @@ \subsection{Lists}
357357
\]
358358
\end{definition}
359359
\hypertarget{operator-listcombine}{} % DO NOT LINT
360-
As a shorthand, we use the notation $a \listcombine b = c$ for $\unziplist(c) = (a, b)$.
360+
As a shorthand, we use the notation $\listcombine{a}{b} = c$ for $\unziplist(c) = (a, b)$.
361361

362362
\hypertarget{def-unziplistthree}{}
363363
\begin{definition}[Unzipping a List of Triples]
@@ -373,6 +373,8 @@ \subsection{Lists}
373373
\end{cases}
374374
\]
375375
\end{definition}
376+
\hypertarget{operator-listcombinethree}{} % DO NOT LINT
377+
As a shorthand, we use the notation $\listcombinethree{a}{b}{c} = d$ for $\unziplistthree(d) = (a, b, c)$.
376378

377379
\hypertarget{def-uniquelist}{}
378380
\hypertarget{def-uniquep}{}
@@ -396,6 +398,16 @@ \subsection{Lists}
396398
\]
397399
\end{definition}
398400

401+
\begin{definition}[Finding a Value in a List of Pairs]
402+
\hypertarget{operator-assocopt}{}
403+
The function
404+
\[
405+
\assocopt{\overname{\KleeneStar{(\Identifier\times T)}}{\vli}}{\overname{\Identifier}{\id}} \aslto \Option{\overname{T}{\vv}}
406+
\]
407+
returns $\some{\vv}$ for the first pair $(\id, \vv)$ in the list of pairs $\vli$,
408+
or $\None$ if no such pair exists.
409+
\end{definition}
410+
399411
\begin{definition}[Taking the union of a list of sets]
400412
The parametric function
401413
\hypertarget{def-unionlist}{}
@@ -409,8 +421,8 @@ \subsection{Lists}
409421
\end{definition}
410422

411423
\subsection{Strings}
412-
\hypertarget{def-stringconcat}{}
413-
The function $\stringconcat : \Strings \times \Strings \rightarrow \Strings$
424+
\hypertarget{operator-stringconcat}{}
425+
The function $\concatstrings : \Strings \times \Strings \rightarrow \Strings$
414426
concatenates two strings.
415427

416428
\hypertarget{def-stringofnat}{}

asllib/doc/ASLRefBET0ChangeLog.tex

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@ \subsection{ASL-796: introduce \texttt{readonly} and \texttt{pure} keywords}
2323
A subprogram marked \texttt{readonly} or \texttt{pure} identifies a \readonlyterm{} or \pureterm{} subprogram respectively.
2424
These have the following behaviour:
2525
\begin{itemize}
26-
\item A \readonlyterm{} subprogram does not modify global storage elements or throw exceptions, but can read global storage elements and use non-determinism ($\ARBITRARY$).
26+
\item A \readonlyterm{} subprogram does not modify global storage elements or throw exceptions, but can read global storage elements
27+
and use non-determinism\\ ($\ARBITRARY$).
2728
It can only call read-only or pure subprograms.
2829
\item A \pureterm{} subprogram does not read or modify global storage elements, throw exceptions, or use non-determinism. It can only call pure subprograms. It can therefore be considered read-only too.
2930
\item Both pure and read-only subprograms may use assertions (including asserting type conversions), or cause \dynamicerrorsterm{} (e.g.\ divide by zero, calling the \unreachablestatementterm{}, etc.).

asllib/doc/ASLmacros.tex

Lines changed: 40 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -383,6 +383,18 @@
383383
\newcommand\notmember[0]{\mathrel{\not\in}} % DO NOT LINT
384384
\newcommand\unionlist[0]{\hyperlink{def-unionlist}{\textfunc{union\_list}}}
385385
\newcommand\UNIONLIST[1]{\unionlist\left({#1}\right)} % A union of a list of sets
386+
\newcommand\assocopt[3][H]{% DO NOT LINT
387+
\ifnum\pdfstrcmp{#1}{H}=0\relax
388+
\hyperlink{operator-assocopt}{\textfunc{assoc\_opt}}({#2}, {#3})
389+
\else
390+
\hyperlink{operator-assocopt}{\textfunc{assoc\_opt}}
391+
\left(\begin{array}{l}
392+
({#2},\\
393+
{#3})\\
394+
\end{array}\right)
395+
\fi
396+
}
397+
\newcommand\assocoptname[0]{\hyperlink{operator-assocopt}{\textfunc{assoc\_opt}}} % DO NOT LINT
386398

387399
\newcommand\intplus[0]{\mathbin{+}} % DO NOT LINT
388400
\newcommand\intminus[0]{\mathbin{-}} % DO NOT LINT
@@ -403,7 +415,29 @@
403415
\newcommand\concat[0]{\hyperlink{operator-concat}{\mathbin{+}}}
404416
\newcommand\concatlist[1]{\hyperlink{operator-concatlist}{\textfunc{concat\_list}}(#1)}
405417
\newcommand\cons[0]{\hyperlink{operator-cons}{\mathbin{{+}{+}}}}
406-
\newcommand\listcombine[0]{\hyperlink{operator-listcombine}{\times}} % DO NOT LINT
418+
\newcommand\listcombine[3][H]{ % DO NOT LINT
419+
\ifnum\pdfstrcmp{#1}{H}=0\relax
420+
{#2} \mathbin{\hyperlink{operator-listcombine}{\times}} {#3} % DO NOT LINT
421+
\else
422+
\hyperlink{operator-listcombine}{\textfunc{list\_combine}} % DO NOT LINT
423+
\left(\begin{array}{l}
424+
{#2} \hyperlink{operator-listcombine}{\times}\\ % DO NOT LINT
425+
{#3}\\
426+
\end{array}\right)
427+
\fi
428+
}
429+
\newcommand\listcombinethree[4][H]{ % DO NOT LINT
430+
\ifnum\pdfstrcmp{#1}{H}=0\relax
431+
{#2} \mathbin{\hyperlink{operator-listcombinethree}{\times_3}} {#3} \mathbin{\hyperlink{operator-listcombinethree}{\times_3}} {#4} % DO NOT LINT
432+
\else
433+
\hyperlink{operator-listcombinethree}{\textfunc{list\_combine\_3}} % DO NOT LINT
434+
\left(\begin{array}{l}
435+
{#2} \hyperlink{operator-listcombinethree}{\times_3}\\ % DO NOT LINT
436+
{#3} \hyperlink{operator-listcombinethree}{\times_3}\\ % DO NOT LINT
437+
{#4}\\
438+
\end{array}\right)
439+
\fi
440+
}
407441

408442
\newcommand\parallelcomp[0]{\hyperlink{def-parallel}{\mathbin{\parallel}}}
409443
\newcommand\ordered[3]{{#1}\hyperlink{def-ordered}{\xrightarrow{#2}}{#3}}
@@ -416,6 +450,10 @@
416450
\newcommand\withgraph[3][H]{ {#2}(\hyperlink{operator-withgraph}{\textfunc{graph}}\mapsto{#3}) } % NO_SPECIFICATION_REQUIRED
417451
\newcommand\withenviron[3][H]{ {#2}(\hyperlink{def-withenviron}{\textfunc{environ}}\mapsto{#3}) } % NO_SPECIFICATION_REQUIRED
418452

453+
\newcommand\concatstrings[0]{\hyperlink{operator-stringconcat}{\mathbin{+}}}
454+
\newcommand\decimaltolitname[0]{\hyperlink{operator-decimaltolit}{\textfunc{dec\_to\_lit}}} % NO_SPECIFICATION_REQUIRED
455+
\newcommand\decimaltolit[1]{\decimaltolitname\left(#1\right)} % NO_SPECIFICATION_REQUIRED
456+
419457
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
420458

421459
\newcommand\overname[2]{\overbrace{#1}^{#2}}
@@ -439,7 +477,6 @@
439477
\newcommand\uniquelist[0]{\hyperlink{def-uniquelist}{\textfunc{unique}}}
440478
\newcommand\listset[0]{\hyperlink{def-listset}{\textfunc{list\_set}}}
441479
\newcommand\listprefix[0]{\hyperlink{def-listprefix}{\textfunc{prefix}}}
442-
\newcommand\stringconcat[0]{\hyperlink{def-stringconcat}{\texttt{+}}}
443480
\newcommand\stringofnat[0]{\hyperlink{def-stringofnat}{\texttt{string\_of\_nat}}}
444481

445482
\newcommand\Ignore[0]{\hyperlink{def-ignore}{\underline{\;\;}}}
@@ -897,7 +934,6 @@
897934
\newcommand\remaxmatch[0]{\hyperlink{def-rematch}{\textfunc{re\_max\_match}}} % NO_SPECIFICATION_REQUIRED
898935
\newcommand\Token[0]{\hyperlink{def-token}{\mathbb{T}\mathbb{O}\mathbb{K}\mathbb{E}\mathbb{N}}}
899936
\newcommand\discard[0]{\hyperlink{def-discard}{\textfunc{discard}}} % NO_SPECIFICATION_REQUIRED
900-
\newcommand\decimaltolit[0]{\hyperlink{def-decimaltolit}{\textfunc{dec\_to\_lit}}} % NO_SPECIFICATION_REQUIRED
901937
\newcommand\hextolit[0]{\hyperlink{def-hextolit}{\textfunc{hex\_to\_lit}}} % NO_SPECIFICATION_REQUIRED
902938
\newcommand\realtolit[0]{\hyperlink{def-realtolit}{\textfunc{real\_to\_lit}}} % NO_SPECIFICATION_REQUIRED
903939
\newcommand\strtolit[0]{\hyperlink{def-strtolit}{\textfunc{str\_to\_lit}}} % NO_SPECIFICATION_REQUIRED
@@ -913,7 +949,7 @@
913949
\newcommand\Terror[0]{\hyperlink{def-terror}{\terminal{T\_ERR}}}
914950
\newcommand\Twhitespace[0]{\hyperlink{def-twhitespace}{\textsf{WHITE\_SPACE}}}
915951
\newcommand\LexSpec[0]{\hyperlink{def-lexspec}{\textsf{LexSpec}}}
916-
\newcommand\Lang[0]{\hyperlink{def-lang}{\textsf{Lang}}}
952+
\newcommand\Lang[1]{\hyperlink{def-lang}{\textsf{Lang}}\left(#1\right)}
917953
\newcommand\RegExp[0]{\hyperlink{def-regex}{\textsf{RegExp}}}
918954
\newcommand\ascii[1]{\hyperlink{def-ascii}{\textsf{ASCII}}\texttt{\{#1\}}}
919955
\newcommand\vnewline[0]{\hyperlink{def-newline}{\texttt{newline}}}
@@ -1144,7 +1180,6 @@
11441180
\newcommand\Supers{\textsf{Supers}}
11451181
\newcommand\Prosecheckisnotcollection[2]{\hyperlink{relation-checkisnotcollection}{determining}
11461182
whether #2 is not a \collectiontypeterm{} in #1 yields $\True$\ProseOrTypeError}
1147-
\newcommand\assocopt[0]{\hyperlink{def-assocopt}{\textfunc{assoc\_opt}}} % SPECIFICATION_DEFERRED
11481183
\newcommand\Proseannotatesymbolicallyevaluableexpr[3]{\hyperlink{relation-annotatesymbolicallyevaluableexpr}{annotating} the
11491184
\symbolicallyevaluableterm\ expression #2 in the static environment #1 yields #3}
11501185
\newcommand\checkstructurelabel[0]{\hyperlink{relation-checkstructurelabel}{\textfunc{check\_structure}}} % SPECIFIED

asllib/doc/AssignableExpressions.tex

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -412,7 +412,7 @@ \subsection{Desugaring Assignable Expressions\label{sec:AssignableExpressionsDes
412412
\[
413413
\desugarlhsfieldstuple(\overname{\Identifier}{\id} \aslsep \overname{\KleeneStar{\Option{\Identifier}}}{\fieldopts}) \;\aslto\; \overname{\lexpr}{\vlexpr}
414414
\]
415-
transforms an assignment to a tuple of fields $\fields$ of variable $\id$ into an AST node $\vlexpr$. \\
415+
transforms an assignment to a tuple of fields $\fields$ of variable $\id$ into an AST node $\vlexpr$.
416416

417417
\ExampleDef{Desugaring a left-hand side fields tuple}
418418
\listingref{DesugarLHSFieldsTuple} shows an example of desugaring a left-hand side fields tuple.
@@ -1359,7 +1359,7 @@ \subsection{Typing}
13591359
\annotatelexpr(\tenv, \vleone, \vtleone) \typearrow (\vletwo, \vses) \OrTypeError\\\\
13601360
\makeanonymous(\tenv, \vtleone) \typearrow L(\fields) \OrTypeError\\\\
13611361
L \in \{\TException, \TRecord\}\\
1362-
\assocopt(\fields, \vfield) \typearrow \tyopt\\
1362+
\assocopt{\fields}{\vfield} \typearrow \tyopt\\
13631363
\techeck(\tyopt \neq \None, \BadField) \typearrow \True \OrTypeError\\\\
13641364
\tyopt \eqname \some{\vt}\\
13651365
\checktypesat(\tenv, \vte, \vt) \typearrow \True \OrTypeError\\\\
@@ -1405,7 +1405,7 @@ \subsection{Typing}
14051405
\annotateexpr(\tenv, \torexpr(\vleone)) \typearrow (\vtleone, \Ignore, \Ignore) \OrTypeError\\\\
14061406
\annotatelexpr(\tenv, \vleone, \vtleone) \typearrow (\vletwo, \vses) \OrTypeError\\\\
14071407
\makeanonymous(\tenv, \vtleone) \typearrow \TCollection(\fields) \OrTypeError\\\\
1408-
\assocopt(\fields, \vfield) \typearrow \tyopt\\
1408+
\assocopt{\fields}{\vfield} \typearrow \tyopt\\
14091409
\techeck(\tyopt \neq \None, \BadField) \typearrow \True \OrTypeError\\\\
14101410
\tyopt \eqname \some{\vt}\\
14111411
\checktypesat(\tenv, \vte, \vt) \typearrow \True \OrTypeError\\\\
@@ -1582,7 +1582,7 @@ \subsection{Typing}
15821582
\begin{itemize}
15831583
\item $\vlefields$ is the list with prefix $\vlefieldsone$ (the elements excluding the last one) and last element $\vfield$;
15841584
\item applying $\foldbitvectorfields$ to $\vbasefields$ and $\vlefieldsone$ in $\tenv$ yields $(\vstart, \vslicesone)$\ProseOrTypeError;
1585-
\item applying $\assocopt$ to $\vbasefields$ and $\vfield$ yields $\tyopt$;
1585+
\item applying $\assocoptname$ to $\vbasefields$ and $\vfield$ yields $\tyopt$;
15861586
\item checking that $\tyopt$ is different to $\None$ yields $\True$\ProseTerminateAs{\BadField};
15871587
\item view $\tyopt$ as $\some{\vtfield}$;
15881588
\item applying $\getbitvectorconstwidth$ to $\vtfield$ in $\tenv$ yields \\$\vfieldwidth$\ProseOrTypeError;
@@ -1601,7 +1601,7 @@ \subsection{Typing}
16011601
\begin{mathpar}
16021602
\inferrule[non\_empty]{
16031603
\foldbitvectorfields(\tenv, \vbasefields, \vlefieldsone) \typearrow (\vstart, \vslicesone)\OrTypeError\\\\
1604-
\assocopt(\vbasefields, \vfield) \typearrow \tyopt\\
1604+
\assocopt{\vbasefields}{\vfield} \typearrow \tyopt\\
16051605
\techeck(\tyopt \neq \None, \BadField) \typearrow \True \OrTypeError\\\\
16061606
\tyoptp \eqname \some{\vtfield}\\
16071607
\getbitvectorconstwidth(\tenv, \vtfield) \typearrow \vfieldwidth \OrTypeError\\\\

0 commit comments

Comments
 (0)