The problem here is X\=Ythis part of lucks is logical purity, since it is \=/2nonmonotonic. Just make him change the order:
brother(X,Y) :- X\=Y, parent(X,A), parent(Y,A), male(Y).
at
brother(X,Y) :- parent(X,A), parent(Y,A), male(Y), X\=Y.
But a much better solution would be to use dif/2that keeps it clean:
brother(X,Y) :- dif(X,Y), parent(X,A), parent(Y,A), male(Y).
coder source
share