status(P, married) :- spouse(P,_). status(P, single) :- \+ spouse(P,_). spouse(P,S) :- wife(P,S). spouse(P,S) :- husband(P,S). wife(paul, mary). wife(steve, heather). wife(rob, donna). husband(mary, paul). husband(heather, steve). husband(donna, rob).
Q: status(paul,X)
A: X = married
no more solutions
Q: status(ahmed,X)
A: X = single
status(P, married) :- spouse(P,_),!. status(P, single).