Module residue

By default the top-level shows the current unification equations. An extension can show arbitrary constraints. It can do so by defining further clauses for the multi-file predicates sys_current_eq/2 and sys_unwrap_eq/3.

The predicate call_residue_var/2 can be used to determine the attributed variables that were freshly introduced while executing a goal. As a convenience, the predicate call_residue/2 will return the constraints of these variables. The later predicate is useful for writing test cases for uses of attributed variables.

Terms that are directly instantiated to a variable can be customized by the multi-file predicate sys_printable_value/2 and queried by the predicate printable/2. The former predicate should fail if there is no custom form and the later predicate will then return the original.

The following residue predicates are provided:

sys_current_eq(V, H):
The predicate succeeds for each equation H with variables wrapped that listens on the variable V. Constraint solvers should extend this multi-file predicate.
sys_unwrap_eq(H, I, O):
The predicate converts equation H with variables wrapped into equations I with variables unwrapped. The list uses the end O. Constraint solvers should extend this multi-file predicate..
call_residue_vars(G, L):
The predicate succeeds whenever the goal G succeeds and unifies L with the newly introduced attributed variables.
call_residue(G, L):
The predicate succeeds whenever the goal G succeeds and unifies L with the constraints of the newly introduced attributed variables.
printable(F, G):
The predicate succeeds in G with a custom form of F.
sys_printable_value(F, G):
The predicate succeeds in G with a custom form of F. The predicate should be extended for custom forms.

Comments