Next: ref-sem-sec, Previous: ref-sem-typ, Up: ref-sem [Contents][Index]
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:
:P,:Q ISOprove P and Q
:P;:Q ISOprove P or Q
+M::P ISOcall P in module M
:P->:Q;:R ISOif P succeeds, then prove Q; if not, then prove R
:P->:Q ISOif P succeeds, then prove Q; if not, then fail
! ISOcut any choices taken in the current procedure
\+ :P ISOgoal P is not provable
?X ^ :Pthere exists an X such that P is provable (used in setof/3 and bagof/3)
+Iterators do :Bodyexecutes Body iteratively according to Iterators
if(:P,:Q,:R)for each solution of P succeeds, prove Q; if none, then prove R
once(:P) ISOFind the first solution, if any, of goal P.
| • ref-sem-ctr-cut | The Cut | |
| • ref-sem-ctr-dis | Disjunctions | |
| • ref-sem-ctr-ite | If-Then-Else | |
| • ref-sem-ctr-naf | Negation as Failure | |
| • ref-sem-ctr-dol | Do Loops | |
| • ref-sem-ctr-oth | Other Control Structures |