Skip to content

Commit bf33e4d

Browse files
[aslspec] imported apply_binop_extremities to aslspec
1 parent ce8f8ce commit bf33e4d

2 files changed

Lines changed: 49 additions & 96 deletions

File tree

asllib/doc/SymbolicSubsumptionTesting.tex

Lines changed: 1 addition & 95 deletions
Original file line numberDiff line numberDiff line change
@@ -479,101 +479,7 @@ \section{Symbolic Reasoning\label{sec:Symbolic Reasoning}}
479479
for cases where a binary operation involves two \rangeconstraintsterm.
480480
\ASLListing{Generating constraints for binary operations}{ApplyBinopExtremities}{\typingtests/TypingRule.ApplyBinopExtremities.asl}
481481

482-
\ProseParagraph
483-
\OneApplies
484-
\begin{itemize}
485-
\item \AllApplyCase{exact\_exact}
486-
\begin{itemize}
487-
\item $\vcone$ is a constraint for the expression $\va$;
488-
\item $\vctwo$ is a constraint for the expression $\vc$;
489-
\item define $\newcs$ as the list containing the constraint for the \binopexpressionterm{} $\AbbrevEBinop{\op}{\va}{\vc}$.
490-
\end{itemize}
491-
492-
\item \AllApplyCase{range\_exact}
493-
\begin{itemize}
494-
\item $\vcone$ is a range constraint for the expressions $\va$ and $\vb$;
495-
\item $\vctwo$ is a constraint for the expression $\vc$;
496-
\item applying $\possibleextremitiesleft$ to $\op$, $\va$, and $\vb$ yields $\extpairs$;
497-
\item define $\newcs$ as the list containing a constraint $\AbbrevConstraintRange{\AbbrevEBinop{\op}{\vap}{\vc}}{\AbbrevEBinop{\op}{\vbp}{\vc}}$
498-
for each pair of expressions $(\vap, \vbp)$ in $\extpairs$.
499-
\end{itemize}
500-
501-
\item \AllApplyCase{exact\_range}
502-
\begin{itemize}
503-
\item $\vcone$ is a constraint for the expression $\va$;
504-
\item $\vctwo$ is a range constraint for the expressions $\vc$ and $\vd$;
505-
\item applying $\possibleextremitiesright$ to $\op$, $\vc$, and $\vd$ yields $\extpairs$;
506-
\item define $\newcs$ as the list containing a constraint $\AbbrevConstraintRange{\AbbrevEBinop{\op}{\va}{\vcp}}{\AbbrevEBinop{\op}{\va}{\vdp}}$
507-
for each pair of expressions $(\vcp, \vdp)$ in $\extpairs$.
508-
\end{itemize}
509-
510-
\item \AllApplyCase{range\_range}
511-
\begin{itemize}
512-
\item $\vcone$ is a range constraint for the expressions $\va$ and $\vb$;
513-
\item $\vctwo$ is a range constraint for the expressions $\vc$ and $\vd$;
514-
\item applying $\possibleextremitiesleft$ to $\op$, $\va$, and $\vb$ yields $\extpairsab$;
515-
\item applying $\possibleextremitiesright$ to $\op$, $\vc$, and $\vd$ yields $\extpairscd$;
516-
\item define $\newcs$ as the list containing a constraint $\AbbrevConstraintRange{\AbbrevEBinop{\op}{\vap}{\vcp}}{\AbbrevEBinop{\op}{\vbp}{\vdp}}$
517-
for each pair of expressions
518-
$(\vap, \vbp)$ in $\extpairsab$
519-
and each pair of expressions
520-
$(\vcp, \vdp)$ in $\extpairscd$.
521-
\end{itemize}
522-
\end{itemize}
523-
524-
\FormallyParagraph
525-
\begin{mathpar}
526-
\inferrule[exact\_exact]{
527-
\vcone = \ConstraintExact(\va)\\
528-
\vctwo = \ConstraintExact(\vc)
529-
}{
530-
{
531-
\begin{array}{r}
532-
\applybinopextremities(\op, \vcone, \vctwo) \typearrow \\
533-
\overname{[ \ConstraintExact(\AbbrevEBinop{\op}{\va}{\vc}) ]}{\newcs}
534-
\end{array}
535-
}
536-
}
537-
\end{mathpar}
538-
539-
\begin{mathpar}
540-
\inferrule[range\_exact]{
541-
\vcone = \ConstraintRange(\va, \vb)\\
542-
\vctwo = \ConstraintExact(\vc)\hva\\
543-
\possibleextremitiesleft(\op, \va, \vb) \typearrow \extpairs\\
544-
\newcs \eqdef [(\vap, \vbp) \in \extpairs: \AbbrevConstraintRange{\AbbrevEBinop{\op}{\vap}{\vc}}{\AbbrevEBinop{\op}{\vbp}{\vc}}]
545-
}{
546-
\applybinopextremities(\op, \vcone, \vctwo) \typearrow
547-
\newcs
548-
}
549-
\end{mathpar}
550-
551-
\begin{mathpar}
552-
\inferrule[exact\_range]{
553-
\vcone = \ConstraintExact(\va)\\
554-
\vctwo = \ConstraintRange(\vc, \vd)\hva\\
555-
\possibleextremitiesright(\op, \vc, \vd) \typearrow \extpairs\\
556-
\newcs \eqdef [(\vcp, \vdp) \in \extpairs: \AbbrevConstraintRange{\AbbrevEBinop{\op}{\va}{\vcp}}{\AbbrevEBinop{\op}{\va}{\vdp}}]
557-
}{
558-
\applybinopextremities(\op, \vcone, \vctwo) \typearrow
559-
\newcs
560-
}
561-
\end{mathpar}
562-
563-
\begin{mathpar}
564-
\inferrule[range\_range]{
565-
\vcone = \ConstraintRange(\va, \vb)\\
566-
\vctwo = \ConstraintRange(\vc, \vd)\hva\\
567-
\possibleextremitiesleft(\op, \va, \vb) \typearrow \extpairsab\\
568-
\possibleextremitiesright(\op, \vc, \vd) \typearrow \extpairscd\hva\\
569-
\newcs \eqdef [(\vap, \vbp) \in \extpairsab, (\vcp, \vdp) \in \extpairscd:
570-
\AbbrevConstraintRange{\AbbrevEBinop{\op}{\vap}{\vcp}}{\AbbrevEBinop{\op}{\vbp}{\vdp}}]
571-
}{
572-
\applybinopextremities(\op, \vcone, \vctwo) \typearrow
573-
\newcs
574-
}
575-
\end{mathpar}
576-
%\RenderProseAndFormally{apply_binop_extremities}
482+
\RenderProseAndFormally{apply_binop_extremities}
577483

578484
\TypingRuleDef{PossibleExtremitiesLeft}
579485
\RenderRelation{possible_extremities_left}

asllib/doc/asl.spec

Lines changed: 48 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13930,7 +13930,54 @@ typing function apply_binop_extremities(op: binop, c1: int_constraint, c2: int_c
1393013930
{op} yields a \dynamicerrorterm{}.",
1393113931
prose_application = "the range constraints for {c1} and {c2}",
1393213932
prose_transition = "computing the range constraints for {c1} and {c2} yields",
13933-
};
13933+
} =
13934+
case exact_exact {
13935+
c1 =: Constraint_Exact(a);
13936+
c2 =: Constraint_Exact(c);
13937+
--
13938+
make_singleton_list(Constraint_Exact(AbbrevEBinop(op, a, c)));
13939+
}
13940+
13941+
case range_exact {
13942+
c1 =: Constraint_Range(a, b);
13943+
c2 =: Constraint_Exact(c);
13944+
possible_extremities_left(op, a, b) -> extpairs;
13945+
extpairs =: list_combine(ext_a, ext_b);
13946+
ext_a_c := list_map(i, indices(extpairs), AbbrevEBinop(op, ext_a[i], c));
13947+
ext_b_c := list_map(i, indices(extpairs), AbbrevEBinop(op, ext_b[i], c));
13948+
new_cs := list_map(i, indices(extpairs), AbbrevConstraintRange(ext_a_c[i], ext_b_c[i]));
13949+
--
13950+
new_cs;
13951+
}
13952+
13953+
case exact_range {
13954+
c1 =: Constraint_Exact(a);
13955+
c2 =: Constraint_Range(c, d);
13956+
possible_extremities_right(op, c, d) -> extpairs;
13957+
extpairs =: list_combine(ext_c, ext_d);
13958+
ext_a_c := list_map(i, indices(extpairs), AbbrevEBinop(op, a, ext_c[i]));
13959+
ext_a_d := list_map(i, indices(extpairs), AbbrevEBinop(op, a, ext_d[i]));
13960+
new_cs := list_map(i, indices(extpairs), AbbrevConstraintRange(ext_a_c[i], ext_a_d[i]));
13961+
--
13962+
new_cs;
13963+
}
13964+
13965+
case range_range {
13966+
c1 =: Constraint_Range(a, b);
13967+
c2 =: Constraint_Range(c, d);
13968+
possible_extremities_left(op, a, b) -> extpairs_a_b;
13969+
possible_extremities_right(op, c, d) -> extpairs_c_d;
13970+
ext_cross := list_cross(extpairs_a_b, extpairs_c_d);
13971+
ext_cross =: list_combine(cross_a_b, cross_c_d);
13972+
cross_a_b =: list_combine(ext_a, ext_b);
13973+
cross_c_d =: list_combine(ext_c, ext_d);
13974+
new_a_c := list_map(i, indices(ext_cross), AbbrevEBinop(op, ext_a[i], ext_c[i]));
13975+
new_b_d := list_map(i, indices(ext_cross), AbbrevEBinop(op, ext_b[i], ext_d[i]));
13976+
new_cs := list_map(i, indices(ext_cross), AbbrevConstraintRange(new_a_c[i], new_b_d[i]));
13977+
--
13978+
new_cs;
13979+
}
13980+
;
1393413981

1393513982
typing function possible_extremities_left(op: binop, a: expr, b: expr) ->
1393613983
(extpairs: list0((expr, expr)))

0 commit comments

Comments
 (0)