Logical Predicates

When a goal belonging to a defined predicate is invoked a new frame is created. When the interpreter encounters a cut (!) it will remove the choice points inside the frame. To instruct the interpreter that cuts can nevertheless propagate a defined predicate can be marked as cut transparent via the predicate property sys_nobarrier/1.

Examples:
?- X = a; X = b.
X = a ;
X = b
?- X = a, !; X = b.
X = a

Some of the predefined logical predicates are cut transparent in all arguments. This includes the predicates (,)/2 and (;)/2. Others are only cut transparent in a few arguments. This includes the predicates (->)/2 and (*->)/2, and also the special forms in connection with the predicate (;)/2. Others, such as call/1, once/1 and (\+)/1, are not cut transparent at all.

The following logical predicates are provided:

A; B: [ISO 7.8.6]
The predicate succeeds whenever A or B succeeds. Both goal arguments A and B are cut transparent.
A -> B: [ISO 7.8.7]
The predicate succeeds when A succeeds and then whenever B succeeds. Only the goal argument B is cut transparent.
A *-> B:
The predicate succeeds whenever A and B succeed. Only the goal argument B is cut transparent.
A -> B; C: [ISO 7.8.8]
The predicate succeeds when A succeeds and then whenever B succeeds, or else whenever C succeeds. Only the goal arguments B and C are cut transparent.
A *-> B; C:
The predicate succeeds whenever A and B succeed, or else if B didn’t succeed whenever C succeeds. Only the goal arguments B and C are cut transparent.
repeat: [ISO 8.15.3]
The predicate succeeds repeatedly.

The following predicate properties for logical predicates are provided:

sys_nobarrier:
The property indicates that the predicate is defined and cut transparent. The property can be changed for defined user predicates.
sys_proto:
The property indicates that the predicate is defined and the clause bodies should not be converted. The property can be changed for defined user predicates.

Comments