Build knowledge one relationship at a time.
Use → to advance · Esc for slide overview
parent(alex, sam).
parent(sam, pat).Read parent(alex, sam) as “Alex is a parent of Sam.”
grandparent(X, Z) :-
parent(X, Y),
parent(Y, Z).Read :- as “if”. The comma means both goals must hold.
?- grandparent(alex, pat).
true.Prolog can use the rule and the facts together.
Will the following query succeed using only the facts and rule above?
?- grandparent(sam, pat).No: we have not given a child of Pat.
Facts state relationships. Rules let us derive new ones.