next up previous
Next: About this document Up: No Title Previous: Order of clauses

Exchanging NOT with CUT

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).



Omer F Rana
Sun Feb 16 21:01:24 GMT 1997