Module hypo

This module provides a couple of primitives for hypothetical reasoning. The primitives come in two flavours. The first flavour is the continuation variant where the effect of the primitive per-sists for the continuation. The second flavour is the temporary variant where the effect of the primitive only persist for the duration of a given goal.

Syntax:
<verb>(<arguments>)               % Continuation Variant
<verb>(<arguments>, <goal>) % Temporary Variant

Since the temporary variant uses an additional goal argument, given the continuation variant the temporary variant can be easily invoked with the help of call/2. The clause primitives are implemented with the help of clause references and the module assume. The other primitives extend some logical meta-predicates to the temporary variant.

Examples:
?- assumez(p), p.
Yes
?- assumez(p), retire(p), p.
No

The continuation variants of true/1, fail/1, (',')/3 and (;)/3 are already defined in the runtime library. By default the assume predicate will create a thread local predicate, if the predicate of the head of the given clause was not yet defined. Further the retire predicate will silently fail if the predicate of the head of the given clause was not yet defined.

The following hypothetical reasoning predicates are provided:

true(G):
The construct does nothing before further solving.
fail(G):
The construct prevents further solving.
assumea(C):
assumea(C, G):
The construct assumes the clause C at the top before further solving.
assumez(C):
assumez(C, G):
The construct assumes the clause C at the bottom before further solving.
retire(C):
retire(C, G):
The construct retires the clause C before further solving. Need not preserve the input order.
retireall(H):
retireall(H, G):
The construct retires all the clauses with head H before further solving. Need not preserve the input order.
','(A, B, G):
The construct does A and then B before further solving.
;(A, B, G):
The construct does A before further solving or it does B before further solving.

Comments