Lucia S. Arce Rafael M. Manlutac
Lucia S. Arce Rafael M. Manlutac
Manlutac
Paradigm
Logic Programming
Appeared in
1972
Designed by
Alain Colmerauer
Major implementations
Amzi! Prolog, BProlog, Ciao Prolog, ECLiPSe, GNU Prolog, Logic Programming Associates, Poplog Prolog, P#, Quintus, SICStus, Strawberry, SWIProlog, tuProlog, YAP-Prolog, Jekejeke Prolog
Dialects
ISO Prolog, Edinburgh Prolog
Influenced
Visual Prolog, Mercury, Oz, Erlang, Strand, KL0, KL1, Datalog
Atom
Numbers
is a general-purpose name with no inherent meaning. Examples of atoms include x, blue, 'Taco', and 'some atom'.
can be floats or integers are denoted by a string consisting of letters, numbers and underscore characters, and beginning with an upper-case letter or underscore. Variables closely resemble variables in logic in that they are placeholders for arbitrary terms.
Variables
compound term
composed of an atom called a "functor" and a number of "arguments", which are again terms. Compound terms are ordinarily written as a functor followed by a comma-separated list of argument terms, which is contained in parentheses The number of arguments is called the term's arity
Prolog programs describe relations, defined by means of clauses. Pure Prolog is restricted to Horn clauses. There are two types of clauses: Facts and rules. A rule is of the form
Head :- Body.
and is read as "Head is true if Body is true". A rule's body consists of calls to predicates, which are called the rule's goals.
The built-in predicate ,/2 (meaning a 2-arity operator with name ,) denotes conjunction of goals, and ;/2 denotes disjunction. Conjunctions and disjunctions can only appear in the body, not in the head of a rule.
Clauses with empty bodies are called facts. An example of a fact is:
cat(tom).
cat(tom) :- true.
The built-in predicate true/0 is always true. Given the above fact, one can ask:
is tom a cat? ?- cat(tom). Yes what things are cats? ?- cat(X). X = tom