0

I'm trying to write a prolog rule about someone's sister being searched. It's really quite simple, but I get caught in an infinite loop.

Given ->

male(john).
male(hubert).
male(jude).

female(alice).
female(jane).
female(isabella).

issibling( john  , hubert ).
issibling( alice , bob    ).
issibling( alice , jane   ).
issibling( Y     , X      ) :- issibling(X,Y).

My Rule->

issister(X,Y) :- issibling(X,Y), female(X).

Thank you for your help.

Nicholas Carey
  • 71,308
  • 16
  • 93
  • 135
Maki
  • 1
  • 1
  • You're not the first with this problem:https://stackoverflow.com/questions/15328936/trying-to-implement-commutativity-in-prolog. Alternativly you have to limit recursion in issibling by a counter or so – Turo Aug 18 '20 at 07:44
  • The problem is that `issibling(Y,X) :- issibling(X,Y)` will keep swapping the parameters. You can fix this by using two predicates: https://stackoverflow.com/a/63317196/67579 – Willem Van Onsem Aug 18 '20 at 14:15

0 Answers0