I am just beginning to learn Prolog:
% Doors
door(kitchen, office).
connect(X, Y) :- door(X, Y).
connect(X, Y) :- door(Y, X).
Now, when I consult:
?- connect(kitchen, office).
true ;
false.
?- connect(office, kitchen).
true.
?-
Why in the first query Prolog thought there's more, and had me press ; ?
Because it can get to the first answer checking
door(X,Y)and not yet checkingdoor(Y,X)and had left a choicepoint. When you asked it to look for more, it looked atdoor(Y,X)and found no more answers. It can't get to the second query result without checking both, so there's no more to check.