/* Example with a family tree */ father(bob, alice). father(bob, peter). mother(carol,peter). mother(carol,alice). siblings(X,Y) :- father(Z,X), mother(W,X), father(Z,Y), mother(W,Y), X \= Y. % print all of them as lists: allsibs :- siblings(A,B), write([A,B]), nl, fail. allsibsok :- not(allsibs). % as a list of lists: allsibslist(L) :-findall([X,Y],siblings(X,Y),L).