
The fixpoint analysis can use assertion information to obtain more precise analysis results. In particular, when run-time checking of assertions is enabled, check assertions may affect the semantics of the analyzed program: a failed run-time check can cause execution to fail. The fixpoint analysis can therefore take these assertions into account to approximate the behavior that will occur at run time.
This behavior is enabled by setting the following flags:
In this mode, applicable check assertions are used as trust information during the fixpoint computation.
For example:
:- module(_,[foo/2], []).
:- pred foo(X,Y) : term(X) => (atm(X), int(Y)).
foo(X,Y) :-
X = Y.Analyzing this program with the eterms abstract domain (eterms) produces::- true pred foo(X,Y) : (term(X), term(Y)) => (atm(X), int(Y)).The definition of foo/2 does not provide enough information to infer that X is an atom and Y is an integer. These properties are obtained from the assertion and used as trusted information during the fixpoint computation.
Applying assertions during fixpoint is also compatible with compile-time assertion checking (acheck). For the previous example, compile-time checking produces:
:- checked calls foo(X,Y) : (term(X) ; term(X)). :- check success foo(X,Y) => int(Y). :- true pred foo(X,Y) : (term(X), term(Y)) => (atm(X), int(Y)).The true pred assertion records the information used by the analysis, including the information obtained from the original assertion. The success assertion is not completely simplified because only information independent of the check assertion is used to establish it.
For example:
:- module(_,[p/1],[assertions]). :- pred p(X) => atm(X). p(X) :- X = a.With fixp_stick_to_success set to on, the analysis result is:
:- module(_,[p/1],[assertions]). :- true pred p(X) => atm(X). p(X) :- X = a.The success assertion is used as specified, rather than being replaced by the information inferred by the fixpoint.
With fixp_stick_to_success set to off, the assertion is used only when it provides additional precision. In this example, the fixpoint result is more precise:
:- module(_,[p/1],[assertions,regtypes]). :- true pred p(X) => rta(X). p(X) :- X = a. :- regtype rta/1. rta(a).For details on the implementation, see Applying assertions during fixpoint (Internals).