Cuts and If-Then-Else

This standard execution behaviour of SB-Prolog can be changed using constructs like cut (!) and if-then-else (->). In SB-Prolog, cuts are usually treated as hard, i.e. discard choice points of all the literals to the left of the cut in the clause containing the cut being executed, and also the choice point for the parent predicate, i.e. any remaining clauses for the predicate containing the cut being executed. There are some situations, however, where the scope of a cut is restricted to be smaller than this. Restrictions apply under the following conditions:
  1. The cut occurs in a term which has been constructed at runtime and called through call/1, e.g. in
    …, X = (p(Y), !, q(Y)), …, call(X), …
    In this case, the scope of the cut is restricted to be within the call, unless one of the following cases also apply and serve to restrict its scope further.
  2. The cut occurs in a negated goal, or within the scope of the test of an if-then-else (in an if-then-else of the form Test -> TruePart; FalsePart, the test is the goal Test). In these cases, the scope of the cut is restricted to be within the negation or the test of the if-then-else, respectively.

In cases involving nested occurrences of these situations, the scope of the cut is restricted to that for the deepest such nested construct, i.e. most restricted. For example, in the construct

…, not((p(X) -> not((q(X), (r(X) -> s(X) ; (t(X), !, u(X))))))), …
the scope of the cut is restricted to the inner negation, and does not affect any choice point that may have been set up for p(X).