Prolog Cheat Sheet

  



  1. Prolog Cheat Sheet Pdf
  2. Prolog Cheat Sheet
  3. List Prolog
  4. Prolog Cheat Sheet

Mode indicator cheat sheet / overview

Determinism illustrated with Byrd Box diagrams

PROLOG (PROgramming in LOGic) - Cheat Sheet. Prolog originated in France University of Marseilles (Prolog: Manuel de Reference et d'Utilisation by P. Using SWI-Prolog’s modules. Prolog Cheat Sheet by Musa Al-hassy. Newsletter (Free) Association for Logic Programming. The Power of Prolog is a great online book (with some video links) explaining prolog from the ground up, including DCGs and Constraint Logic Programming; it is very good.

The determinism indicators can be illustrated using 'Byrd Box' diagrams,slightly extended relative to the original form as it appears in Lawrence Byrd's1980 paper. Here, the idea of 'leaving no choicepoint' is shown as bypassingthe 'Redo Port' when backtracking. Remember that a single Byrd Box (B-Box) representsa not a predicate but a predicate activation, i.e. a running predicate call,conceptually congruent to a stack frame. The B-Box is understood to reside ina cross-wired graph of B-Boxes that corresponds to a predicate's clause structure(as given by conjunctions, disjunctions, cuts, if-then-else operators etc.)You can envision the graph of B-Boxes being created immediately when thedefining predicate is called, or on demand when the execution token that ispictured as moving across the wires is about to be passed to the next B-Box.

(Below the port traditionally labeled 'Exit' has been relabeled 'Succ', because it's the 'success' port after all.)

A predicate activation of a deterministic predicate:

Prolog Cheat Sheet Pdf

A predicate activation of a semi-deterministic predicate:

A predicate activation of a multi or non-deterministic predicate:

The multi' predicate succeeds at least once, whereas thenon-deterministic' predicate may not succeed even once. Anyother behaviour is left unspecified. A redo mightre-enter the predicate activation even if there are nosolutions left.

See also

The Mercury Language Manual on 'determinism'

Byrd Box Model

There is a separate page in the manual where the Byrd Box model is explained in the context of the debugger: Byrd Box Model

Prolog cheat sheet pdf

See also my page on the Byrd Box Model, in particular: Predicate well-behavedness

Cheat

Prolog Cheat Sheet

More vocabulary

List Prolog

Predicate annotations

Prolog Cheat Sheet

There is also a related page for pldoc document generator