我有一个关于我得到的错误的快速问题。我是prolog新手,所以请原谅,如果它是一个简单的修复。Prolog并发症错误
这里是我正在试图做的事:
Consider the database created in question 1. In implementing the following rules, you can add additional rules to make your implementation easier.
2.1 Add the following set of rules that extend the family relations among the members: (1) parent_of, (2) sibling_of, (3) uncle_of, (4) uncleOrAunt_of, (5) spouse_of, and (6) descendant_of
2.2 Add at least 10 facts into the database. These new facts should show consistent relationship among family members and must ensure (1) no conflict facts,(2) no redundant information, (3) each rule defined in question 2.1 can return a "yes" value for at least one set of parameters.
2.4 Add a rule called fullQuestions at the end of database to test all the rules that you have defined in the homework. Include sufficient write statements, so that the answers to individual questions are printed. Make sure that the compound question can terminate (will not cause a "dead loop"). Include the output as comments.
这是我走到这一步:
/* Database for family. It consists of facts and
rules. */
/* Facts */
/* female(ella).
female(jodi).
female(sonya).
/*
male(arnold).
*/
male(chris).
/*
male(louis).
male(mark).
*/
father_of(X,Y) :-
parent_of(X,Y), is_male(X).
father_of(arnold, chris). /* arnold is the father of chris */
father_of(louis, mark).
father_of(mark, arnold).
mother_of(X,Y) :-
parent_of(X,Y), is_female(X).
mother_of(ella, sonya).
mother_of(jodi, mark).
child(X, Y) :-
parent_of(Y, X).
parent_of(X, Y) :-
child(Y, X).
parent_of(jodi, ella).
parent_of(jodi, mark).
parent_of(louis, mark).
parent_of(mark, arnold).
parent_of(jose, sergio).
parent_of(ana, sergio).
parent_of(jose, gio).
parent_of(ana, gio).
parent_of(joe, jose).
parent_of(mary, jose).
/* Rules */
grandmother_of(X, Z) :-
mother_of(X, Y),
(mother_of(Y, Z); father_of(Y, Z)).
is_male(X) :-
father_of(X, _).
is_female(X) :-
mother_of(X, _).
sibling_of(X, Y) :-
parent_of(Z, X), parent_of(Z, Y).
sister(X,Y) :-
siblings(X,Y), is_female(X), X \= Y.
brother(X,Y) :-
siblings(X,Y), is_male(X), X \= Y.
uncle_of(X,Y) :-
brother(X,Z), mother_of(Z,Y).
uncle_of(X,Y) :-
brother(X,Z), father_of(Z,Y).
uncleOrAunt_of(X, Y) :-
brother(X,Z), mother_of(Z,Y).
uncleorAunt_of(X, Y) :-
brother(X,Z), father_of(Z,Y).
uncleorAunt_of(X, Y) :-
sister(X,Z), father_of(Z,Y).
uncleorAunt_of(X, Y) :-
sister(X,Z), mother_of(Z,Y).
spouse_of(X,Y) :-
child(P, X), child(P, Y).
ancestor(X , Y) :-
parent_of(X , Y).
ancestor(X , Y) :-
parent_of(X , Z) , ancestor(Z , Y).
descendant_of(X, Y) :-
ancestor(Y, X).
familyquestions :-
grandmother_of(X, arnold),
write('The grandmother of Arnold is '), write(X), nl,
father_of(Y, mark),
write(Y), write(' is the father of Mark'), nl, nl.
然而,当我尝试编译它,我得到多个错误:
/tmp/gplcExLkpg.o:在功能`谓词(姐姐/ 2)“:
(+的.text 0x7b3 ):未定义参考`谓词(兄弟姐妹/ 2) '
/tmp/gplcExLkpg.o:在功能`谓词(兄弟/ 2)':
(的.text + 0x843):未定义参考`谓语(同胞/ 2)'
collect2:错误:LD返回1个退出状态
编译失败
您在'parent_of(mary,jose),'中有一个错字。它应该以点而不是逗号结束。 – gusbro
好的,谢谢!我修好了,但现在我有两个不同的erros? –
family.pl:64-65:warning:不连续谓词parent_of/2 - 子句忽略 family.pl:75:致命错误:重新定义控件构造(',')/ 2 编译失败 –