gpt4 book ai didi

Prolog 家谱

转载 作者:行者123 更新时间:2023-12-04 06:51:41 28 4
gpt4 key购买 nike

我做到了,但它没有显示答案 当我询问兄弟,姐妹,叔叔,阿姨时

这是我写的,有什么问题吗?

/*uncle(X, Y) :– male(X), sibling(X, Z), parent(Z, Y).*/
/*uncle(X, Y) :– male(X), spouse(X, W), sibling(W, Z), parent(Z, Y).*/

uncle(X,Y) :-
parent(Z,Y), brother(X,Z).

aunt(X,Y) :-
parent(Z,Y), sister(X,Z).

sibling(X, Y) :-
parent(Z, X),
parent(Z, Y),
X \= Y.

sister(X, Y) :-
sibling(X, Y),
female(X).

brother(X, Y) :-
sibling(X, Y),
male(X).

parent(Z,Y) :- father(Z,Y).
parent(Z,Y) :- mother(Z,Y).

grandparent(C,D) :- parent(C,E), parent(E,D).

aunt(X, Y) :– female(X), sibling(X, Z), parent(Z, Y).
aunt(X, Y) :– female(X), spouse(X, W), sibling(W, Z), parent(Z, Y).

male(john).
male(bob).
male(bill).
male(ron).
male(jeff).

female(mary).
female(sue).
female(nancy).

mother(mary, sue).
mother(mary, bill).
mother(sue, nancy).
mother(sue, jeff).
mother(jane, ron).

father(john, sue).
father(john, bill).
father(bob, nancy).
father(bob, jeff).
father(bill, ron).

sibling(bob,bill).
sibling(sue,bill).
sibling(nancy,jeff).
sibling(nancy,ron).
sibling(jell,ron).

还有一件事,我如何优化兄弟的规则,使 X 不是自己的兄弟。

最佳答案

如果您试图复制图表,那么您的某些公理似乎是错误的或缺失的。

丢失的:

female(jane).

father(john, bob).

错误的:
father(john, sue).

这可能会导致同级规则发生冲突。但我对序言了解多少

关于Prolog 家谱,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/679728/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com