In Prolog, backtracking is employed to explore the search space for a query and a program. Goals in the query are executed from left to right, and the clauses in each predicate are tried sequentially from the top. A query may succeed, may fail, or may be terminated because of exceptions. When a query succeeds, the variables in it may be bound to some terms. The call true always succeeds, and the call fail always fails. There are several control constructs for controlling backtracking, for specifying conjunction, negation, disjunction, and if-then-else, and for finding all solutions. B-Prolog also provide loop constructs for describing loops (see
).
Subsections
Neng-Fa Zhou
2012-01-03