% Run as % $ swipl -g "main,halt." grandparent.pl % main/0, mother/2, and father/2 was added by hakan: main :- grandparent(X,Y), format("~w is a grandparent of ~w~n",[X,Y]), fail. mother(ann,amy). mother(ann,andy). mother(amy,amelia). mother(linda,gavin). father(steve,amy). father(steve,andy). father(gavin,amelia). father(andy,spongebob). grandparent(X, Y) :- mother(X, Z), mother(Z, Y). grandparent(X, Y) :- mother(X, Z), father(Z, Y). grandparent(X, Y) :- father(X, Z), mother(Z, Y). grandparent(X, Y) :- father(X, Z), father(Z, Y).