Prolog编译错误“;对谓词的未定义引用;
我们刚刚开始在我的一门编程课上学习Prolog。我得到了一些错误,我不完全确定是什么原因造成的。这是家庭作业,所以我不期待任何书面答案,但任何提示将不胜感激 这是我的密码:Prolog编译错误“;对谓词的未定义引用;,prolog,Prolog,我们刚刚开始在我的一门编程课上学习Prolog。我得到了一些错误,我不完全确定是什么原因造成的。这是家庭作业,所以我不期待任何书面答案,但任何提示将不胜感激 这是我的密码: /* Database for family. It consists of facts and rules. */ /* Facts */ male(mark). /* Question 1.1 */ male(tom). male(eric). male(josh). male(austin). /* Quest
/* Database for family. It consists of facts and rules. */
/* Facts */
male(mark).
/* Question 1.1 */
male(tom).
male(eric).
male(josh).
male(austin).
/* Question 1.1 */
female(jen).
female(beth).
female(lisa).
female(alice).
female(alex).
father_of(mark, beth). /* mark is the father of beth */
/* Question 1.1
father_of(josh, eric).
father_of(eric, mark).
father_of(eric, jen).
father_of(austin, alice).
mother_of(jen, tom). /* jen is the mother of tom */
/* Question 1.1
mother_of(lisa, eric).
mother_of(alex, alice).
mother_of(alice, jen).
mother_of(alice, mark).
/* Rules */
is_male(X) :-
male(X);
father_of(X, _).
/* Question 1.2 */
is_female(X) :-
female(X);
mother_of(X, _).
/* Question 1.3 */
grandfather_of(X, Z) :-
father_of(X, Y),
(mother_of(Y, Z); father_of(Y, Z)).
grandmother_of(X, Z) :-
mother_of(X, Y),
(mother_of(Y, Z); father_of(Y, Z)).
我收到的错误是:
/tmp/gplc0GI9tg.o:在函数“Lpred7_1”中:
(.text+0x2d1):对谓词(母亲/2)”的未定义引用
/tmp/gplc0GI9tg.o:在函数中
谓词(祖父/2)':
(.text+0x35d):对谓词(母亲/2)”的未定义引用
/tmp/gplc0GI9tg.o:函数中的谓词
(.text+0x3a8):对谓词(母亲/2)”的未定义引用
/tmp/gplc0GI9tg.o:函数中的谓词
(.text+0x3ed):对“谓词(2之母)”的未定义引用
collect2:错误:ld返回了1个退出状态
编译失败查看您的代码片段,以下几行是错误的:
/* Question 1.1
father_of(josh, eric).
同样的事情,不久之后:
/* Question 1.1
mother_of(lisa, eric).
我想你想在写下以下事实之前结束各自的评论
最佳实践:只要行末评论足够,就使用行末评论(以%
开头)。检查您的评论的开始和结束位置…@Stevem感谢您的反馈!