<predicate> [:- <predicate_list>].
- Prolog has the simplest syntax and semantics of any programming language, but yet is extremely powerful.
where <predicate> is <name>(<parameter_list>)
Prolog is very similar to a functional language, but does not require the embedding of function references to provide sequencing of action.
A predicate is
a function whose result is either true or false.
The sequence of execution of Prolog statements depends on which statement is applicable in the current state of the machine.
A Prolog program consists
of a database of predicates composed of facts and rules involving constants and variables.
Variables are identified by character strings that start with an upper case character - such as X, Y, Number, Constant.
Constants are similarly character strings but with a first character that is in lower case - x, y, number, constant.
A fact is just something
that is always true about some constants; i.e. has no conditional clauses:
Peggy is the mother
mother (peggy, george).
NOTE the period at the end of each rule. This is another use of "Forward Polish" notation where the relationship precedes the operands.
A rule is an implication (predicate)
If X is the mother of Y and Y is a parent of Z, then X is a grandmother
of Z. Or put the "Prolog" way, X is the grandmother of Z provided that X is the mother of Y and Y is a parent of Z.
grandmother(X,Z) :- mother(X,Y),
In Prolog read ":-" as "provided that" and "," as "and". Though not shown here, Prolog uses ";" in rules to mean "or".
Last Updated 11/03/2000
J.A.N. Lee, 2000