/* soap.pro */ /* Here's a summary of the current situation on the fictitious television opera Edge of Boredom: Jason and Phoebe are married, but Phoebe is in love with Perry. Perry doesn't love her because he is still married to Stacey, but Zack is also romantically inclined toward Phoebe. He' in competition with Lane, who also love Phoebe despite being married to Eulalie, whom Jason is feeling romantic about. a. Represent the basic meaning of these statement by facts using only two different predicate names. Notice that if X is married to Y, Y is married to X. You might want to use some form of the word "marry" and some form of the word "love" as your predicates. b. A marriage is on the rocks if both its participants are in love with other people and not with each other. Which people are in marriages on the rocks. Show the necessary Prolog query and its result. c. A person is jealous when a preson they love is loved by a third person, or a person is jealous when married to someone loved by a third person. Which people are jealous? show the necessary Prolog query and result. */ /* married (A,B) -> A is married to B */ married(jason, phoebe). married(phoebe,jason). married(perry,stacey). married(stacey,perry). married(lane,eulalie). married(eulalie,lane). /* loves (A,B) -> A loves B */ loves(phoebe,perry). loves(jack,phoebe). loves(lane,phoebe). loves(jason,eulalie). /* marriage_on_rocks(A,B) -> A and B's marriage is on the rocks */ marriage_on_rocks(A,B) :- married(A,B) , loves(A,D), not loves(A,B), loves(B,_), not loves(B,A), nl, write (' The marriage of '), write (A), write (' and '), write (B), write (' is on the rocks '). /* marriage_on_rocks(A) -> A's marriage is on the rocks */ marriage_on_rocks(C) :- married(C,E) , loves (C,_), loves(E,_), not loves(C,E) , not loves(E,C), write (' The marriage of '), write (C), (' is on the rocks '). /* jealous(A) -> A is jealous */ jealous (A) :- loves(A,B), loves(C,B) , not A = C. jealous (A) :- married(A,B), loves (D,B), not A = D.