所以我的讲师把这段代码写成了一个问题的答案。今天我们发现男性和女性的规则都是错的,有人可以为我证实这一点吗?此外,利用这篇文章,我想问你善良的人,如果你可以发送/链接我的教程详细解释序言,如果你能做到这一点,那就太好了!非常感谢。
/* FACTS */
parents(david, george, noreen).
parents(jennifer, george, noreen).
parents(georgejr, george, noreen).
parents(scott, george, noreen).
parents(joanne, george, noreen).
parents(jessica, david, edel).
parents(clara, david, edel).
parents(michael, david, edel).
parents(laura, georgejr, susan).
parents(anna, scott, siobhan).
parents(edel, mick, peggy).
parents(maria, mick, peggy).
parents(assumpta, mick, peggy).
parents(patrick, kevin, maria).
parents(hugh, kevin, maria).
parents(helena, kevin, maria).
parents(roisin, wim, assumpta).
/* Relationships */
father(X, Y) :- parents(Y, X, _).
male(X) :- father(X, _).
mother(X, Y) :- parents(Y, _, X).
female(X) :- mother(X, _).
grandfather(X, Y) :- father(X, Z), father(Z, Y).
grandfather(X, Y) :- father(X, Z), mother(Z, Y).
grandmother(X, Y) :- mother(X, Z), mother(Z, Y).
grandmother(X, Y) :- mother(X, Z), father(Z, Y).
brother(X, Y) :- male(X), father(Z, X), father(Z, Y), X \== Y.
sister(X, Y) :- female(X), father(Z, X), father(Z, Y), X \== Y.
/* New realtionships */
parent(X,Y) :- father(X,Y); mother(X,Y).
uncle(X,Y) :- parent(Z,Y), brother(X,Z), Z \== X.
aunt(X,Y) :- parent(Z,Y), sister(X,Z), Z \== X.
sibling(X,Y) :- brother(X,Y); sister(X,Y).
cousin(X,Y) :- parent(Z,X), parent(W,Y), sibling(Z,W).