Prolog家谱问题

Prolog家谱问题,prolog,Prolog,我在Prolog中设置族谱时遇到了一个新手问题。出于某种原因,我似乎无法让“兄弟姐妹”返回真值 % male(+Person) % Specifies the Person is a male. % male(abraham). male(homer). male(bartholomew). % female(+Person) % Specifies the Person is a female. % female(mona). female(marjorie). female(lisa).

我在Prolog中设置族谱时遇到了一个新手问题。出于某种原因,我似乎无法让“兄弟姐妹”返回真值

% male(+Person)
% Specifies the Person is a male.
%
male(abraham).
male(homer).
male(bartholomew).

% female(+Person)
% Specifies the Person is a female.
%
female(mona).
female(marjorie).
female(lisa).
female(margaret).

% mother(+Parent,+Child)
% Specifies Parent is a mother of Child.
%
mother(mona,homer).
mother(marjorie,bartholomew).
mother(marjorie,lisa).
mother(marjorie,margaret).

% father(+Parent,+Child)
% Specifies Parent is a father of Child.
%
father(abraham,homer).
father(homer,bartholomew).
father(homer,lisa).
father(homer,margaret).



% sibling(+Person1,+Person2)
% Specifies Person1 is a sibling of Person2
%
sibling(X,Y) :-
       father(X,Z),
       mother(Y,Z).

提前非常感谢,这个问题让我发疯了

第一步,使用已建立的关系(母亲/2也可以):

sibling(X, Y) :- father(F, X), father(F, Y), X @< Y.
?- sibling(X,Y).
X = bartholomew,
Y = lisa ;
X = bartholomew,
Y = margaret ;
X = lisa,
Y = margaret ;
false.