4.2.3 Control Structures

As we have seen, the goals in the body of a sentence are linked by the operator `,', which can be interpreted as conjunction (and). The Prolog language provides a number of other operators, known as control structures, for building complex goals. Apart from being built-in predicates, these control structures play a special role in certain language features, namely Grammar Rules (see ref-gru), and when code is loaded or asserted in the context of modules (see ref-mod). The set of control structures is described in this section, and consists of:

prove P and Q
prove P or Q
call P in module M
:P->:Q;:R ISO
if P succeeds, prove Q; if not, prove R
:P->:Q ISO
if P succeeds, prove Q; if not, fail
cut any choices taken in the current procedure
\+ :P ISO
goal P is not provable
?X ^ :P
there exists an X such that P is provable (used in setof/3 and bagof/3)
for each solution of P succeeds, prove Q; if none, prove R
once(:P) ISO
Find the first solution, if any, of goal P.

Send feedback on this subject.