I am trying to write the rule that D is my(me's) son-in-law if they are male and my daughter is the spouse of D. I do not get any errors when I run this on swish except for a few singleton variable warnings. Still, i'm not convinced I wrote this correctly..can someone clarify for me if this even makes sense? Thank you.
male(X).
male(me).
female(X).
child(X,Y).
spouse(X,Y).
daughter(A,me) :-
female(A), child(me, A).
mother(A,me) :-
female(A), child(me, A).
son_in_law(D,me) :-
male(D), spouse(daughter(A,me), D).
A fact is an always true predicate. So,
male(X).
means that every X
is a male. Clearly, not a correct axiom for your domain. When you get the warning about the singleton X
, you should not ignore it, but attempt to understand what it means.
Also, syntactically, nested predicates don't make sense. You should rewrite this clause
..., spouse(daughter(A,me), D).
'lifting up' the 'join' variables, for instance
..., daughter(A,me), spouse(A, D).