我有一些事实和规则,我试图使用,当我传递一个查询,它说,如果两个变量是同一代(兄弟姐妹或堂兄弟) .

%mother/father DB
mother(lisa, abe).
mother(lisa, sarah).
mother(nancy, john).
mother(mary, jill).
mother(sarah, susan).
mother(susan, jack).
mother(susan, phil).

father(tony, abe).
father(tony, sarah).
father(abe, john).
father(john, jill).
father(bill, susan).
father(rob, jack).
father(rob, phil).
father(jack, jim).

%Parent rule
parent(X,Y):-mother(X,Y).%Defines the parent rule
parent(X,Y):-father(X,Y).

%sibling rule true if X,Y share same parent
sibling(X,Y):-father(Z,X),father(Z,Y),
mother(M,X),mother(M,Y).

cousin(X,Y):-parent(P,X),parent(Q,Y),sibling(P,Q).

%returns true if X is an ancestor of Y
ancestor(X,Y):-parent(X,Y);parent(X,Z),ancestor(Z,Y).


same_generation(X,Y):-ancestor(Z,X),ancestor(A,Y),sibling(Z,A).

不幸的是,我得到的问题是,当我测试一个孩子和父母ex.same_generation(杰克,苏珊)的查询时,我得到了真(这是不正确的)!

任何帮助都会很棒!

这是家谱:enter image description here