Skip to content

Commit cf60199

Browse files
[aslspec][asl reference] stronger subsumption test for functions and imported static_env_to_env to aslspec
1 parent ce8f8ce commit cf60199

3 files changed

Lines changed: 27 additions & 37 deletions

File tree

asllib/aslspec/spec.ml

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1237,20 +1237,21 @@ module Check = struct
12371237
(fun { term = sub_term; _ } { term = super_term; _ } ->
12381238
subsumed_rec spec expanded_types sub_term super_term)
12391239
sub_fields super_fields
1240-
| ( Function { from_type = _, sub_from_term; to_type = _, sub_to_term },
1240+
| ( Function
1241+
{
1242+
from_type = _, sub_from_term;
1243+
to_type = _, sub_to_term;
1244+
total = sub_total;
1245+
},
12411246
Function
1242-
{ from_type = _, super_from_term; to_type = _, super_to_term } )
1243-
->
1244-
(* Functions can be partial or total, which require different subsumption tests.
1245-
To make this simple, we require equivalence of the from-terms and to-terms,
1246-
which is sufficient for our needs.
1247-
*)
1248-
let equivalence_test term term' =
1249-
subsumed_rec spec expanded_types term term'
1250-
&& subsumed_rec spec expanded_types term' term
1251-
in
1252-
equivalence_test sub_from_term super_from_term
1253-
&& equivalence_test sub_to_term super_to_term
1247+
{
1248+
from_type = _, super_from_term;
1249+
to_type = _, super_to_term;
1250+
total = super_total;
1251+
} ) ->
1252+
((not sub_total) || super_total) (* sub_total implies super_total *)
1253+
&& subsumed_rec spec expanded_types super_from_term sub_from_term
1254+
&& subsumed_rec spec expanded_types sub_to_term super_to_term
12541255
| ConstantsSet sub_names, ConstantsSet super_names ->
12551256
List.for_all (fun name -> List.mem name super_names) sub_names
12561257
| _ ->

asllib/doc/StaticEvaluation.tex

Lines changed: 1 addition & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -53,25 +53,4 @@ \chapter{Static Evaluation\label{chap:StaticEvaluation}}
5353
\{ \dynamicenvsG: \{\vHALFWORDSIZE \mapsto \nvint(32)\}, \dynamicenvsL: \emptyfunc \} \enspace.
5454
\]
5555

56-
\ProseParagraph
57-
\AllApply
58-
\begin{itemize}
59-
\item define the global dynamic environment $\vglobal$ as the map that binds
60-
each $\id$ in the domain of $\tenv.\staticenvsG.\constantvalues$ to $\NVLiteral(\vl)$
61-
if
62-
$\tenv.\staticenvsG.\constantvalues(\id) = \vl$;
63-
\item define the local dynamic environment $\vlocal$ as the empty map;
64-
\item define the environment $\env$ to have the static component $\tenv$ and the dynamic
65-
environment $\{\dynamicenvsG: \vglobal, \dynamicenvsL: \vlocal\}$;
66-
\end{itemize}
67-
\FormallyParagraph
68-
\begin{mathpar}
69-
\inferrule{
70-
\vglobal \eqdef [\id \mapsto \NVLiteral(\vl) \;|\; \tenv.\staticenvsG.\constantvalues(\id) = \vl]\\
71-
\vlocal \eqdef \emptyfunc
72-
}{
73-
\staticenvtoenv(\tenv) \typearrow \overname{(\tenv, \{\dynamicenvsG: \vglobal, \dynamicenvsL: \vlocal\})}{\env}
74-
}
75-
\end{mathpar}
76-
% TODO: re-translate once empty_func has been introduced.
77-
% \RenderProseAndFormally{static_env_to_env}
56+
\RenderProseAndFormally{static_env_to_env}

asllib/doc/asl.spec

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10266,8 +10266,18 @@ semantics function static_env_to_env(tenv: static_envs) ->
1026610266
\staticenvironmentterm{} {tenv} into an environment
1026710267
{env}.",
1026810268
prose_transition = "transforming the constants defined in {tenv} into an \environmentterm{} yields",
10269-
};
10270-
10269+
} =
10270+
constant_bindings := bindings(tenv.static_envs_G.constant_values);
10271+
constant_bindings =: list_combine(constant_ids, constant_literals);
10272+
constant_values := list_map(l, constant_literals, NV_Literal(l));
10273+
global_storage_bindings := list_combine(constant_ids, constant_values);
10274+
global_storage := bindings_to_map(global_storage_bindings);
10275+
empty_global := empty_denv.dynamic_envs_G;
10276+
new_global := empty_global(storage: global_storage);
10277+
new_denv := empty_denv(dynamic_envs_G: new_global);
10278+
--
10279+
(tenv, new_denv);
10280+
;
1027110281

1027210282
//////////////////////////////////////////////////
1027310283
// Relations for Subprogram Calls

0 commit comments

Comments
 (0)