From 59be792c520599bca60d893db3bacff3bee88d4e Mon Sep 17 00:00:00 2001 From: Roman-Manevich Date: Sat, 23 Mar 2024 15:52:05 +0000 Subject: [PATCH] [asl][semantics] Addressing feedback. --- asllib/Interpreter.ml | 98 +- asllib/doc/ASLNotations.tex | 20 +- asllib/doc/ASLSemanticsReference.tex | 2347 ++++++++++------- asllib/doc/ASLSyntaxReference.tex | 21 + asllib/doc/ASLTypingReference.tex | 27 +- asllib/doc/ASLmacros.tex | 7 + asllib/instrumentation.ml | 3 + .../SemanticsRule.EGetArrayTooSmall.asl | 7 +- .../SemanticsRule.Lit.asl | 5 +- asllib/tests/ASLSemanticsReference.t/run.t | 4 +- 10 files changed, 1528 insertions(+), 1011 deletions(-) diff --git a/asllib/Interpreter.ml b/asllib/Interpreter.ml index 061c700a6d..ce89bf1a5f 100644 --- a/asllib/Interpreter.ml +++ b/asllib/Interpreter.ml @@ -392,17 +392,17 @@ module Make (B : Backend.S) (C : Config) = struct (* End *) (* Begin Binop *) | E_Binop (op, e1, e2) -> - let*^ m1, env' = eval_expr env e1 in - let*^ m2, new_env = eval_expr env' e2 in + let*^ m1, env1 = eval_expr env e1 in + let*^ m2, new_env = eval_expr env1 e2 in let* v1 = m1 and* v2 = m2 in let* v = B.binop op v1 v2 in return_normal (v, new_env) |: SemanticsRule.Binop (* End *) (* Begin Unop *) - | E_Unop (op, e') -> - let** v', env' = eval_expr env e' in - let* v = B.unop op v' in - return_normal (v, env') |: SemanticsRule.Unop + | E_Unop (op, e1) -> + let** v1, env1 = eval_expr env e1 in + let* v = B.unop op v1 in + return_normal (v, env1) |: SemanticsRule.Unop (* End *) (* Begin ECond *) | E_Cond (e_cond, e1, e2) -> @@ -420,14 +420,14 @@ module Make (B : Backend.S) (C : Config) = struct (* Begin ESlice *) | E_Slice (e_bv, slices) -> let*^ m_bv, env1 = eval_expr env e_bv in - let*^ m_positions, env' = eval_slices env1 slices in + let*^ m_positions, new_env = eval_slices env1 slices in let* v_bv = m_bv and* positions = m_positions in let* v = B.read_from_bitvector positions v_bv in - return_normal (v, env') |: SemanticsRule.ESlice + return_normal (v, new_env) |: SemanticsRule.ESlice (* End *) (* Begin ECall *) | E_Call (name, actual_args, params) -> - let**| ms, env = eval_call (to_pos e) name env actual_args params in + let**| ms, new_env = eval_call (to_pos e) name env actual_args params in let* v = match ms with | [ m ] -> m @@ -435,12 +435,12 @@ module Make (B : Backend.S) (C : Config) = struct let* vs = sync_list ms in B.create_vector vs in - return_normal (v, env) |: SemanticsRule.ECall + return_normal (v, new_env) |: SemanticsRule.ECall (* End *) (* Begin EGetArray *) | E_GetArray (e_array, e_index) -> ( let*^ m_array, env1 = eval_expr env e_array in - let*^ m_index, env' = eval_expr env1 e_index in + let*^ m_index, new_env = eval_expr env1 e_index in let* v_array = m_array and* v_index = m_index in match B.v_to_int v_index with | None -> @@ -449,20 +449,20 @@ module Make (B : Backend.S) (C : Config) = struct fatal_from e (Error.UnsupportedExpr e_index) | Some i -> let* v = B.get_index i v_array in - return_normal (v, env') |: SemanticsRule.EGetArray) + return_normal (v, new_env) |: SemanticsRule.EGetArray) (* End *) (* Begin ERecord *) | E_Record (_, e_fields) -> let names, fields = List.split e_fields in - let** v_fields, env' = eval_expr_list env fields in + let** v_fields, new_env = eval_expr_list env fields in let* v = B.create_record (List.combine names v_fields) in - return_normal (v, env') |: SemanticsRule.ERecord + return_normal (v, new_env) |: SemanticsRule.ERecord (* End *) (* Begin EGetField *) | E_GetField (e_record, field_name) -> - let** v_record, env' = eval_expr env e_record in + let** v_record, new_env = eval_expr env e_record in let* v = B.get_field field_name v_record in - return_normal (v, env') |: SemanticsRule.EGetBitField + return_normal (v, new_env) |: SemanticsRule.EGetBitField (* End *) (* Begin EGetFields *) | E_GetFields _ -> @@ -470,15 +470,15 @@ module Make (B : Backend.S) (C : Config) = struct (* End *) (* Begin EConcat *) | E_Concat e_list -> - let** v_list, env' = eval_expr_list env e_list in + let** v_list, new_env = eval_expr_list env e_list in let* v = B.concat_bitvectors v_list in - return_normal (v, env') |: SemanticsRule.EConcat + return_normal (v, new_env) |: SemanticsRule.EConcat (* End *) (* Begin ETuple *) | E_Tuple e_list -> - let** v_list, env' = eval_expr_list env e_list in + let** v_list, new_env = eval_expr_list env e_list in let* v = B.create_vector v_list in - return_normal (v, env') |: SemanticsRule.ETuple + return_normal (v, new_env) |: SemanticsRule.ETuple (* End *) (* Begin EUnknown *) | E_Unknown t -> @@ -487,9 +487,9 @@ module Make (B : Backend.S) (C : Config) = struct (* End *) (* Begin EPattern *) | E_Pattern (e, p) -> - let** v1, env' = eval_expr env e in + let** v1, new_env = eval_expr env e in let* v = eval_pattern env e v1 p in - return_normal (v, env') |: SemanticsRule.EPattern + return_normal (v, new_env) |: SemanticsRule.EPattern (* End *) (* Evaluation of Side-Effect-Free Expressions *) @@ -646,22 +646,22 @@ module Make (B : Backend.S) (C : Config) = struct | LE_SetArray (re_array, e_index) -> let*^ rm_array, env1 = expr_of_lexpr re_array |> eval_expr env in let*^ m_index, env2 = eval_expr env1 e_index in - let m' = + let m1 = let* v = m and* v_index = m_index and* rv_array = rm_array in match B.v_to_int v_index with | None -> fatal_from le (Error.UnsupportedExpr e_index) | Some i -> B.set_index i v rv_array in - eval_lexpr ver re_array env2 m' |: SemanticsRule.LESetArray + eval_lexpr ver re_array env2 m1 |: SemanticsRule.LESetArray (* End *) (* Begin LESetField *) | LE_SetField (re_record, field_name) -> let*^ rm_record, env1 = expr_of_lexpr re_record |> eval_expr env in - let m' = + let m1 = let* v = m and* rv_record = rm_record in B.set_field field_name v rv_record in - eval_lexpr ver re_record env1 m' |: SemanticsRule.LESetField + eval_lexpr ver re_record env1 m1 |: SemanticsRule.LESetField (* End *) (* Begin LEDestructuring *) | LE_Destructuring le_list -> @@ -712,8 +712,8 @@ module Make (B : Backend.S) (C : Config) = struct let eval_one env = function (* Begin SliceSingle *) | Slice_Single e -> - let** start, new_env = eval_expr env e in - return_normal ((start, one), new_env) |: SemanticsRule.SliceSingle + let** v_start, new_env = eval_expr env e in + return_normal ((v_start, one), new_env) |: SemanticsRule.SliceSingle (* End *) (* Begin SliceLength *) | Slice_Length (e_start, e_length) -> @@ -727,19 +727,21 @@ module Make (B : Backend.S) (C : Config) = struct let*^ m_top, env1 = eval_expr env e_top in let*^ m_start, new_env = eval_expr env1 e_start in let* v_top = m_top and* v_start = m_start in - let* length = B.binop MINUS v_top v_start >>= B.binop PLUS one in - return_normal ((v_start, length), new_env) |: SemanticsRule.SliceRange + let* v_length = B.binop MINUS v_top v_start >>= B.binop PLUS one in + return_normal ((v_start, v_length), new_env) |: SemanticsRule.SliceRange (* End *) (* Begin SliceStar *) | Slice_Star (e_factor, e_length) -> let*^ m_factor, env1 = eval_expr env e_factor in let*^ m_length, new_env = eval_expr env1 e_length in let* v_factor = m_factor and* v_length = m_length in - let* start = B.binop MUL v_factor v_length in - return_normal ((start, v_length), new_env) |: SemanticsRule.SliceStar + let* v_start = B.binop MUL v_factor v_length in + return_normal ((v_start, v_length), new_env) |: SemanticsRule.SliceStar (* End *) in - fold_par_list eval_one env + (* Begin Slices *) + fold_par_list eval_one env |: SemanticsRule.Slices + (* End *) (* Evaluation of Patterns *) (* ---------------------- *) @@ -761,18 +763,18 @@ module Make (B : Backend.S) (C : Config) = struct (* End *) (* Begin PGeq *) | Pattern_Geq e -> - let* v' = eval_expr_sef env e in - B.binop GEQ v v' |: SemanticsRule.PGeq + let* v1 = eval_expr_sef env e in + B.binop GEQ v v1 |: SemanticsRule.PGeq (* End *) (* Begin PLeq *) | Pattern_Leq e -> - let* v' = eval_expr_sef env e in - B.binop LEQ v v' |: SemanticsRule.PLeq + let* v1 = eval_expr_sef env e in + B.binop LEQ v v1 |: SemanticsRule.PLeq (* End *) (* Begin PNot *) - | Pattern_Not p' -> - let* b' = eval_pattern env pos v p' in - B.unop BNOT b' |: SemanticsRule.PNot + | Pattern_Not p1 -> + let* b1 = eval_pattern env pos v p1 in + B.unop BNOT b1 |: SemanticsRule.PNot (* End *) (* Begin PRange *) | Pattern_Range (e1, e2) -> @@ -787,8 +789,8 @@ module Make (B : Backend.S) (C : Config) = struct (* End *) (* Begin PSingle *) | Pattern_Single e -> - let* v' = eval_expr_sef env e in - B.binop EQ_OP v v' |: SemanticsRule.PSingle + let* v1 = eval_expr_sef env e in + B.binop EQ_OP v v1 |: SemanticsRule.PSingle (* End *) (* Begin PMask *) | Pattern_Mask m -> @@ -826,22 +828,22 @@ module Make (B : Backend.S) (C : Config) = struct >>= return_normal |: SemanticsRule.LDVar (* End *) (* Begin LDTyped *) - | LDI_Typed (ldi', _t), Some m -> - eval_local_decl s ldi' env (Some m) |: SemanticsRule.LDTyped + | LDI_Typed (ldi1, _t), Some m -> + eval_local_decl s ldi1 env (Some m) |: SemanticsRule.LDTyped (* End *) (* Begin LDUninitialisedTyped *) - | LDI_Typed (ldi', t), None -> + | LDI_Typed (ldi1, t), None -> let m = base_value env t in - eval_local_decl s ldi' env (Some m) + eval_local_decl s ldi1 env (Some m) |: SemanticsRule.LDUninitialisedTyped (* End *) (* Begin LDTuple *) | LDI_Tuple ldis, Some m -> let n = List.length ldis in let liv = List.init n (fun i -> m >>= B.get_index i) in - let folder envm ldi' vm = + let folder envm ldi1 vm = let**| env = envm in - eval_local_decl s ldi' env (Some vm) + eval_local_decl s ldi1 env (Some vm) in List.fold_left2 folder (return_normal env) ldis liv |: SemanticsRule.LDTuple diff --git a/asllib/doc/ASLNotations.tex b/asllib/doc/ASLNotations.tex index d87e6257ac..2a11163bb2 100644 --- a/asllib/doc/ASLNotations.tex +++ b/asllib/doc/ASLNotations.tex @@ -10,11 +10,15 @@ The notation $\rightarrowfin$ stands for a function whose domain is finite. \begin{definition}[Function Update\label{def:FunctionUpdate}] - The notation $f[x \mapsto v]$ is the function $f$ modified so that $x$ is bound - to $v$: $f[x \mapsto v] \triangleq \lambda\ z.\ \begin{cases} + The notation $f[x \mapsto v]$ is a function identical to $f$, except that $x$ is bound + to $v$. That is, if $g = f[x \mapsto v]$ then + \[ + g(z) = + \begin{cases} f(z) & \text{if } z \neq x\\ v & \text{if } z = x \enspace . - \end{cases}$ + \end{cases} + \] The notation $\{i=1..k: a_i\mapsto b_i\}$ stands for the function formed from the corresponding input-output pairs: $\emptyfunc[a_1\mapsto b_1]\ldots[a_k\mapsto b_k]$. @@ -42,9 +46,12 @@ \paragraph{Rules} The following notation states that when the \emph{premises} $P_{1..k}$ hold then the \emph{verdict} $V$ holds as well: \begin{mathpar} - \inferrule{P_1 \and \ldots \and P_k}{V} + \inferrule[Name]{P_1 \and \ldots \and P_k}{V} \end{mathpar} That is, the premises of a rule are interpreted as a conjunction. +% +Optionally, the name of the rule, which is useful for referencing it, appears above and to the left of it. +% The variables appearing in the premises and verdict are interpreted universally. % A set of rules is interpreted disjunctively. That is, each rule is used to determine whether its verdict @@ -65,8 +72,9 @@ \paragraph{Value Deconstruction} We will often want to deconstruct compound values to refer to their internal values. -To achieve that, we will write $v \eqname \textit{deconstructed}(v)$ where the expression on the right -exposes the internal structure of $v$, allowing us to alias its internal components. +To achieve that, we will write $v \eqname \textit{f}(u_{1..k})$ where the expression on the right +hand side exposes the internal structure of $v$, allowing us to alias its internal components +via the new variables $u_{1..k}$. For example, suppose we know that $v$ is a pair of values. Then, $v \eqname (a, b)$ allows us to alias $a$ and $b$. Similarly, if $v$ is a non-empty list, then $v \eqname [h] + t$ deconstructs the list into the diff --git a/asllib/doc/ASLSemanticsReference.tex b/asllib/doc/ASLSemanticsReference.tex index 4997bf1865..d14cd4d6e2 100644 --- a/asllib/doc/ASLSemanticsReference.tex +++ b/asllib/doc/ASLSemanticsReference.tex @@ -5,14 +5,10 @@ \newcommand\defref[1]{Def.~\ref{def:#1}} \newcommand\secref[1]{Section~\ref{sec:#1}} -\newcommand\torexpr[0]{\textsf{rexpr}} -\newcommand\semantic[1]{\llbracket #1 \rrbracket} \newcommand\tododefine[1]{\texttt{#1}} \usepackage{relsize} -%\newcommand\eqname[0]{=} \newcommand\eqname[0]{\stackrel{\mathsmaller{\mathsf{name}}}{=}} -%\newcommand\overname[2]{#1} \newcommand\overname[2]{\overbracket{#1}^{#2}} \newcommand\eq[0]{\textsf{eq}} @@ -26,7 +22,7 @@ \newcommand\WriteEffect[0]{\textsf{WriteEffect}} \newcommand\ReadEffect[0]{\textsf{ReadEffect}} -\newcommand\emptyenv[0]{\underline{e}} +\newcommand\emptyenv[0]{\env_{\emptyset}} \newcommand\tenv[0]{\textsf{tenv}} \newcommand\denv[0]{\textsf{denv}} \newcommand\denvtwo[0]{\textsf{denv2}} @@ -64,6 +60,8 @@ \newcommand\ThrowingConfig[0]{\texttt{\#T}} \newcommand\ErrorConfig[0]{\texttt{\#E}} \newcommand\OrAbnormal[0]{\terminateas \ThrowingConfig, \ErrorConfig} +\newcommand\ProseOrAbnormal[0]{or an abnormal configuration, which short-circuits the entire evaluation} +\newcommand\ProseOrError[0]{or an error configuration, which short-circuits the entire evaluation} \newcommand\TError[0]{\textsf{TError}} \newcommand\TThrowing[0]{\textsf{TThrowing}} \newcommand\TContinuing[0]{\textsf{TContinuing}} @@ -109,12 +107,15 @@ \newcommand\constantsvalues[1]{\text{constants\_values}} \newcommand\exprvals[0]{\textsf{ExprVals}} +\newcommand\valuereadfrom[0]{\textsf{value\_read\_from}} \newcommand\Normal[0]{\textsf{Normal}} \newcommand\Throwing[0]{\textsf{Throwing}} \newcommand\Continuing[0]{\textsf{Continuing}} \newcommand\Returning[0]{\textsf{Returning}} \newcommand\Error[0]{\textsf{Error}} +\newcommand\ErrorVal[1]{\Error(\texttt{"ERROR[#1]"})} + %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %% Names for variables appearing in rules @@ -126,9 +127,9 @@ \newcommand\envfour[0]{\texttt{env4}} \newcommand\envp[0]{\texttt{env'}} \newcommand\vc[0]{\texttt{c}} -\newcommand\ve[0]{\texttt{e}} \newcommand\vi[0]{\texttt{i}} \newcommand\vg[0]{\texttt{g}} +\newcommand\newg[0]{\texttt{new\_g}} \newcommand\vgp[0]{\texttt{g'}} \newcommand\vvp[0]{\texttt{v'}} \newcommand\vep[0]{\texttt{e'}} @@ -136,17 +137,19 @@ \newcommand\vm[0]{\texttt{m}} \newcommand\vn[0]{\texttt{n}} \newcommand\vp[0]{\texttt{p}} +\newcommand\vpone[0]{\texttt{p1}} \newcommand\vv[0]{\texttt{v}} -\newcommand\vx[0]{\texttt{x}} +\newcommand\vy[0]{\texttt{y}} \newcommand\vs[0]{\texttt{s}} \newcommand\vt[0]{\texttt{t}} +\newcommand\vtone[0]{\texttt{t1}} \newcommand\vu[0]{\texttt{u}} \newcommand\vw[0]{\texttt{w}} \newcommand\vvsg[0]{\texttt{vsg}} \newcommand\vvs[0]{\texttt{vs}} \newcommand\vms[0]{\texttt{ms}} +\newcommand\vmsone[0]{\texttt{ms1}} \newcommand\vmstwo[0]{\texttt{ms2}} -\newcommand\vle[0]{\texttt{le}} \newcommand\vles[0]{\texttt{les}} \newcommand\vre[0]{\texttt{re}} \newcommand\vres[0]{\texttt{res}} @@ -167,7 +170,10 @@ \newcommand\mcond[0]{\texttt{m\_cond}} \newcommand\vbv[0]{\texttt{v\_bv}} \newcommand\mpositions[0]{\texttt{m\_positions}} +\newcommand\vslice[0]{\texttt{slice}} +\newcommand\vsliceone[0]{\texttt{slice1}} \newcommand\slices[0]{\texttt{slices}} +\newcommand\slicesone[0]{\texttt{slices1}} \newcommand\indices[0]{\texttt{indices}} \newcommand\positions[0]{\texttt{positions}} \newcommand\name[0]{\texttt{name}} @@ -180,7 +186,6 @@ \newcommand\nargsone[0]{\texttt{nargs1}} \newcommand\nargstwo[0]{\texttt{nargs2}} \newcommand\nargsthree[0]{\texttt{nargs3}} -\newcommand\vargs[0]{\texttt{vargs}} \newcommand\vargsm[0]{\texttt{vargs\_m}} \newcommand\params[0]{\texttt{params}} \newcommand\earray[0]{\texttt{e\_array}} @@ -209,6 +214,8 @@ \newcommand\rvrecord[0]{\texttt{rv\_record}} \newcommand\vlelist[0]{\texttt{le\_list}} \newcommand\vmlist[0]{\texttt{vm\_list}} +\newcommand\vlelistone[0]{\texttt{le\_list1}} +\newcommand\vmlistone[0]{\texttt{vm\_list1}} \newcommand\nmonads[0]{\texttt{nmonads}} \newcommand\start[0]{\texttt{start}} \newcommand\mstart[0]{\texttt{m\_start}} @@ -219,6 +226,7 @@ \newcommand\length[0]{\texttt{length}} \newcommand\mlength[0]{\texttt{m\_length}} \newcommand\vlength[0]{\texttt{v\_length}} +\newcommand\vdiff[0]{\texttt{v\_diff}} \newcommand\etop[0]{\texttt{e\_top}} \newcommand\vvtop[0]{\texttt{v\_top}} \newcommand\mtop[0]{\texttt{m\_top}} @@ -227,7 +235,9 @@ \newcommand\vfactor[0]{\texttt{v\_factor}} \newcommand\range[0]{\texttt{range}} \newcommand\ranges[0]{\texttt{ranges}} +\newcommand\rangesone[0]{\texttt{ranges1}} \newcommand\ldi[0]{\texttt{ldi}} +\newcommand\ldione[0]{\texttt{ldi1}} \newcommand\ldis[0]{\texttt{ldis}} \newcommand\liv[0]{\texttt{liv}} \newcommand\minitopt[0]{\texttt{m\_init\_opt}} @@ -278,6 +288,8 @@ \newcommand\velem[0]{\texttt{v\_elem}} \newcommand\vcs[0]{\texttt{cs}} \newcommand\bits[0]{\texttt{bits}} +\newcommand\eid[0]{\texttt{e\_id}} +\newcommand\newmbv[0]{\texttt{new\_m\_bv}} \input{ASLSemanticsLines} @@ -386,7 +398,7 @@ \section{Mathematical Definitions and Notations} where $\None\triangleq\langle\rangle$ denotes an empty set and $\langle v \rangle$ denotes a set containing the single element $v$. % -The notation $\langle T \rangle$, where $T$ denotes a mathematical types of values, stands for +The notation $\langle T \rangle$, where $T$ denotes a mathematical type, stands for $\{ \langle\rangle \} \cup \{\langle v \rangle \;|\; v \in T\}$. \paragraph{Miscellaneous} @@ -511,9 +523,11 @@ \subsection{Concurrent Execution Graphs \label{sec:concurrentexecutiongraphs}} The concurrent semantics of an ASL specification utilizes \emph{concurrent execution graphs} (\emph{execution graphs}, for short), -which track the Read and Write Effects over variables, yielded by the sequential semantics, and the \emph{ordering constraints} -between those effects. -Concurrent execution graphs are introduced, defined, and used in~\cite{AlglaveMT14,alglave2016syntax,AlglaveDGHM21}, +which track the Read and Write Effects over variables, yielded by the sequential semantics, +and the \emph{ordering constraints} between those effects. +The graphs resulting from executing an ASL specification are converted into +\emph{candidate execution graphs}, which are introduced, defined, +and used in~\cite{AlglaveMT14,alglave2016syntax,AlglaveDGHM21}. Formally, an execution graph $\xgraph = (N^\xgraph, E^\xgraph, O^\xgraph) \in \XGraphs$ is defined via a set of \emph{nodes} ($N^\xgraph$), \emph{edges} ($E^\xgraph$), and \emph{output nodes} ($O^\xgraph$): @@ -528,7 +542,7 @@ \subsection{Concurrent Execution Graphs \label{sec:concurrentexecutiongraphs}} Nodes represent unique Read and Write Effects. Formally, a node $(u,l,\id)$ associates a unique instance counter $u$ to an \emph{ordering label} $l$, which specifies whether it represents a Read Effect of a Write Effect to a variable named $\id$. % -We say that en Effect $E_1$ is \emph{$l$-before} another Effect $E_2$, for $l\in \Labels$ and a given execution graph +We say that en Effect \texttt{E1} is \emph{$l$-before} another Effect \texttt{E2}, for $l\in \Labels$ and a given execution graph $g$, when $(\texttt{E1}, l, \texttt{E2}) \in E^g$. An edge represents an ordering constraint between two effects, which can be one of the following: @@ -607,9 +621,15 @@ \subsection{Input Configurations and Output Configurations} \item $\Normal((\vals\times\XGraphs)^*, \envs)$. \end{itemize} - \item[Exceptions.] Configurations in $\Throwing((\langle\vals \times \ty\rangle \times \XGraphs, \envs)$ - represent thrown exceptions, - either without an exception value (as in \texttt{throw;}) or ones with an exception value and an associated type. + \item[Exceptions.] Configurations in + \[ + \Throwing((\langle \valuereadfrom(\vals,\identifier) \times \ty\rangle \times \XGraphs, \envs) + \] + represent thrown exceptions. + There are two flavors of exceptions: + exceptions without an exception value (as in \texttt{throw;}), and ones with an exception value, + an identifier to which the read effect is attributed, and an associated type. + The type $\valuereadfrom(\vals,\identifier)$ is a configuration nested inside The ASL semantics propagates these \emph{exceptional configurations} to the nearest catch clause that matches them, and otherwise they are ``caught'' at the top-level and reported as errors (see dynamic errors below). @@ -626,8 +646,8 @@ \subsection{Input Configurations and Output Configurations} represent runtime errors (for example, division by zero). The ASL semantics is set up such that when these \emph{error configurations} appear, the evaluation of the entire specification terminates by outputting them. - The actual strings in an error configuration are not considered part of the specification. - That is, an implementation of the semantics may use other strings. + Every implementation of this semantics must start with the strings appearing in this + semantics and optionally end with a longer description of the error. \end{description} Helper relations often have output configurations that are just tuples, without an associated domain. @@ -653,7 +673,7 @@ \subsection{Input Configurations and Output Configurations} \subsection{Extracting and Substituting Elements of Configurations} -We define the \emph{domain} of a configuration $C=M(\ldots)$, denoted $\configdomain{C}$, to be $M$. +We define the \emph{domain} of a configuration $C=D(\ldots)$, denoted $\configdomain{C}$, to be $D$. Given a configuration $C$, we define the graph component of the configuration, $\graphof{C}$, and the environment of the configuration, $\environof{C}$, as follows: @@ -667,7 +687,7 @@ \subsection{Extracting and Substituting Elements of Configurations} \Normal(\vg, \env) & \vg & \env\\ \Normal([\vv_{1..k}], \vg) & \vg & \env\\ \Normal([i=1..k: (\vv_i,\vg_i)], \env) & \text{undefined} & \env\\ - \Throwing((\vx,\vg), \env) & \vg & \env\\ + \Throwing((\valuereadfrom(\vx,\vv),\vg), \env) & \vg & \env\\ \Returning(([\vv_{1..k}],\vg), \env) & \vg & \env\\ \Continuing(\vg, \env) & \vg & \env\\ \end{array} @@ -685,7 +705,7 @@ \subsection{Extracting and Substituting Elements of Configurations} \Normal(\vg, \env) & \Normal(\vgp, \env)\\ \Normal(i=1..k: \vv_i, \vg) & \Normal(i=1..k: \vv_i, \vgp)\\ \Normal([i=1..k: (\vv_i,\vg_i)], \env) & \text{undefined}\\ - \Throwing((\vx,\vg), \env) & \Throwing((\vx,\vgp), \env)\\ + \Throwing((\valuereadfrom(\vx,\vv),\vg), \env) & \Throwing((\valuereadfrom(\vx,\vv),\vgp), \env)\\ \Returning((i=1..k: \vv_i,\vg), \env) & \Returning((i=1..k: \vv_i,\vgp), \env)\\ \Continuing(\vg, \env) & \Continuing(\vgp, \env)\\ \end{array} @@ -702,7 +722,7 @@ \subsection{Extracting and Substituting Elements of Configurations} \Normal(\vg, \env) & \Normal(\vg, \envp)\\ \Normal(i=1..k: \vv_i, \vg) & \Normal(i=1..k: \vv_i, \vg)\\ \Normal([i=1..k: (\vv_i,\vg_i)], \env) & \Normal([i=1..k: (\vv_i,\vg_i)], \envp)\\ - \Throwing((\vx,\vg), \env) & \Throwing((\vx,\vg), \envp)\\ + \Throwing((\valuereadfrom(\vx,\vv),\vg), \env) & \Throwing((\valuereadfrom(\vx,\vv),\vg), \envp)\\ \Returning((i=1..k: \vv_i,\vg), \env) & \Returning((i=1..k: \vv_i,\vg), \envp)\\ \Continuing(\vg, \env) & \Continuing(\vg, \envp)\\ \end{array} @@ -711,23 +731,13 @@ \subsection{Extracting and Substituting Elements of Configurations} \section{Semantic Evaluation} The semantics of ASL is given by the relations\footnote{The reason that relations, rather than functions, are used is due to the -potential non-determinism in the primitive subprograms, -the choice of execution graph node identifiers, +potential non-determinism in the primitive subprograms and the non-determinism inherent in the \texttt{UNKOWN} expression.} $\evalarrow$ and $\evalprimitivearrow$. -The latter relation provides the semantics of primitive functions and is not otherwise defined +The latter relation provides the semantics of primitive subprograms and is not otherwise defined constructively. The relation $\evalarrow$ is defined as the disjoint union of the relations defined in this document. -% \[ -% \begin{array}{rcl} -% \evalarrow &\triangleq& \textit{main\_asl\_relations} \cupdot \textit{secondary\_asl\_relations}\\ -% \textit{main\_asl\_relations} &\triangleq& \texttt{eval\_expr} \cupdot \texttt{eval\_lexpr} \cupdot \texttt{eval\_slices}\\ -% & & \texttt{eval\_pattern} \cupdot \texttt{eval\_local\_decl} \cupdot \texttt{eval\_stmt}\\ -% & & \texttt{eval\_block} \cup \texttt{eval\_loop}\\ -% & & \texttt{eval\_catchers} \cupdot \texttt{eval\_call} \cupdot \texttt{eval\_spec}\\ -% \textit{secondary\_asl\_relations} &\triangleq& ... -% \end{array} -% \] +% The semantics of the various types of AST nodes is given by a set of \emph{semantic relations} between input configurations and output configurations. @@ -779,13 +789,6 @@ \section{Semantic Evaluation} We use the notation $C \evalarrow C'$ to denote a transition between input and output configurations. That is, $(C, C') \in\ \evalarrow$. -% We denote elements of a semantic relation by $\texttt{eval\_