This construct is similar to the standard conditional construct
Condition -> Then ; Elseexcept that it does not discard alternative solutions to Condition. This means that, on backtracking, alternative solutions to Condition are found, and the Then branch will be executed for each solution of the Condition (rather than just the first one).
This functionality is sometimes referred to as 'soft cut'. A soft cut is a cut that discards an alternative which is not the chronologically most recent one (the Else-alternative is older than the alternatives within Condition).
The operational semantics is as follows: if Condition succeeds, Then is executed, and on backtracking subsequent solutions of Condition and Then are returned, but Else is never executed. Only if Condition has no solutions at all, Else is executed.
Although it is allowed to use *->/2 without ;/2, this is of little use since (Condition *-> Then) is the same as the simple conjunction (Condition , Then).
Also note that Condition must not contain a !/0. If a !/0 appears in Then or Else, it cuts through the whole construct.
Since *->/2 and ;/2 have a lower precedence than ,/2, the whole construct should always be enclosed in parentheses:
( Condition *-> Then ; Else )
?- ( member(X,[1,2,3]) *-> writeln(then(X)) ; writeln(else(X)) ). then(1) X = 1 Yes (0.00s cpu, solution 1, maybe more) ? ; then(2) X = 2 Yes (0.00s cpu, solution 2, maybe more) ? ; then(3) X = 3 Yes (0.00s cpu, solution 3) ?- X=4, ( member(X,[1,2,3]) *-> writeln(then(X)) ; writeln(else(X)) ). else(4) Yes (0.00s cpu) ?- ( member(X,[1,2]) *-> member(Y,[a,b]) ; member(Y,[c,d]) ). X = 1 Y = a Yes (0.00s cpu, solution 1, maybe more) X = 1 Y = b Yes (0.02s cpu, solution 2, maybe more) X = 2 Y = a Yes (0.02s cpu, solution 3, maybe more) X = 2 Y = b Yes (0.03s cpu, solution 4)