mother(X, Y) :- parent(X, Y), female(X).
Declarative reading: X is the mother of Y
if X is a parent of Y and
X is female.
Approximate procedural reading: To show that X is the
mother of Y, first show that X is a parent
of Y, then show that X is female.
Suppose we have the additional base clauses:
parent(john, bill).
parent(jane, bill).
female(jane).
Now if we inquire:
| ?- mother(M, bill).
the clause of mother/2 will be located, and the
unifications X=M, Y=bill will occur. (Parameter
transmission is by unification.) Then parent(M, bill)
will be attempted, resulting in the unification M=john.
Next, female(john) will be attempted, but will fail.
Prolog will backtrack to parent(M, bill) and look for
another solution for this; it will succeed and unify
M=jane. Finally, it will attempt
female(jane), and succeed; so the inquiry will succeed,
having performed the unification M=jane.
Typically Prolog predicates work regardless of which arguments are
instantiated, and may instantiate the others. Thus
mother/2 works equally well for the calls
mother(jane,C), mother(M,C), and
mother(jane,bill) [but the procedural reading is different in
each case.] Injudicious use of control predicates, particularly
``cut,'', can destroy this property.
![]() |
![]() |
![]() |