Hi everybody, first off thanks for helping. I am writing a prolog program describing family relationships, including all versions of in-laws. The logic is all there, what I need help with is some prolog problems as I am not very experienced with it. I am trying to set up multiple possibilities for each rule through use of semicolons.
The way I am treating in-laws is so that my brother in law is also my brother, so I need multiple checks to see which is true. I want prolog to return true, and only true, if any of the options are true. However, it returns true and false as possible options, since of course one of the options is always going to be false and the other is always going to be true. Either they are my brother in law, or my natural brother. I cant get prolog to return true only, and not have the option of false as another answer. If anyone has any advice it would be great. Relevant code is included below. So, if I type "brother(baby,dad)." I get true and false as possible answers when all I want is false. However, "brother(dad,baby)." only returns true. But I am rambling now. Sorry if any of the code is confusing with the baby dad stuff. Thanks!
/*facts for relationships*/
female(widow).
female(redhair).
spouse(i,widow).
spouse(widow,i).
spouse(dad,redhair).
spouse(redhair,dad).
child(i,dad).
child(redhair,widow).
child(baby,i).
child(onrun,dad).
male(onrun).
male(baby).
male(dad).
male(i).
/*rules*/
daughter(D,P):-
female(D), (child(D,P);(spouse(P,S),child(D,S))).
son(D,P):-
male(D), (child(D,P);(spouse(P,S),child(D,S))).
mother(X,Y):-
female(X),
child(Y,X).
father(X,Y):-
male(X),
child(Y,X).
son_in_law(C,P):-
male(C),spouse(C,S),
(child(S,P);(spouse(P,W),child(S,W))).
daughter_in_law(C,P):-
female(C),spouse(C,S),
(child(S,P);(spouse(P,W),child(S,W))).
brother(S1,S2) :- male(S1),
(child(S1,P) = child(S2,P2));
(child(S1,P),child(S2,P2),spouse(P,P2));
((child(S1,P),son_in_law(S2,P));(child(S2,P),son_in_law(S1,P))).