Slide 14.21: Variables and unification (cont.) Slide 14.23: Rules (cont.) Home |
“All men are mortal.”
We can express this as the following Prolog rule
mortal( X ) :- human( X ).
The clause can be read in two ways (called either a declarative or a procedural interpretation).
The declarative interpretation is “For a given X
, X
is mortal if X
is human.”
The procedural interpretation is “To prove the main goal that X
is mortal, prove the subgoal that X
is human.”
mortal( X ) :- human( X ). human( socrates ).If we now pose the question to Prolog
?- mortal( socrates ).
The Prolog interpreter would respond as follows:
yes
In order to prove someone mortal, we had to prove them to be human.
Thus from the goal Prolog generates the subgoal of showing human(socrates)
.
We were able to match human(socrates)
against the database.
In Prolog we say that the subgoal succeeded, and as a result the overall goal succeeded.
We know when this happens because Prolog prints yes
.