A note on the quantification of variables

next up previous contents
Next: The top-level interpreter
Up: Introduction to Prolog for Mathematicians
Previous: Symbolic differentiation

A note on the quantification of variables

Like lists, clauses have two parts, head and tail.

Head :- Tail.

In the second clause, the tail is assumed to be true.

Variables which appear in the head of the clause are universally quantified.

d( U+V, X, A+B ) :-
   d( U, X, A ),
   d( V, X, B ).

Variables which appear only in the tail of the clause are existentially quantified.

is_grandparent_of(X, Z) :-
    is_parent_of(X, Y),
    is_parent_of(Y, Z).

Read this as

X is a grandparent of Z if
    there is some Y for which
    X is a parent of Y and
    Y is a parent of Z.

These are the only quantifications possible. You can't write explicit quantifiers into a clause (though they can sometimes be simulated with various programming tricks).

Jocelyn Ireson-Ireson-Paine
Mon Jul 17 22:27:41 BST 1995