So, im working with this following code:
test:- p(X,Y), r(Y), s(X), write(X), nl, fail.
test.
test2(X,Y):- p(X,Y), r(Y).
p(3,4).
p(6,9).
p(7,8).
r(X):- s(X), t(X).
s(7).
s(6):-!.
s(8).
t(9).
t(8).
t(5):-!.
t(4).
s(X) returns X=7;X=6.
t(X) returns X=9;X=8;X=5.
Obviously, r(X) returns false.
My question is, how the hell then test2(X,Y) returns X=7,Y=8?