编译这个时候我已经得到两个错误消息:Prolog的家谱编译错误
"Clauses of (-)/1 are not together in source-file" and
"Singleton variables: [X]"
...我已经得到了错误的这两个例子是...
我我已经尝试删除源代码中的一些事实,以便事实不会发生冲突,并且我试图将人们定义为原子而不是子句......他们都不像我希望的那样工作,任何想法?
male(X).
female(X).
parent(X,Y).
father(X,Y):- male(X), parent(X,Y).
mother(X,Y):- female(X), parent(X,Y).
descendant(X,Y):- parent(Y,X).
sibling(X,Y):- descendant(X,Z), descendant(Y,Z).
brother(X,Y):- male(X), sibling(X,Y).
sister(X,Y):- female(X), sibling(X,Y).
grandparent(X,Y):- parent(X,Z), parent(Z,Y).
paternalgrandparent(X,Y):- father(X,Z), father(Z,Y).
ancestor(X,Y):- parent(X,Y).
ancestor(X,Y):- ancestor(X,Z), parent(Z,Y).
male(edward).
male(sean).
male(kevin).
female(vicky).
male(malcolm).
male(claude).
male(matthew).
female(stephania).
male(kurt).
male(david).
male(mark).
male(raymond).
female(therese).
female(nadine).
female(nathalie).
male(richard).
female(mary).
male(john).
female(lilian).
female(inez).
male(william).
female(rose).
male(richie).
female(alice).
brother(edward,vicky).
brother(kevin,sean).
brother(sean,vicky).
sister(vicky,edward).
brother(malcolm,claude).
brother(claude,malcolm).
brother(matthew,stephania).
brother(kurt,matthew).
sister(stephania,kurt).
brother(david,mark).
brother(mark,david).
sister(therese,nadine).
sister(nadine,therese).
sister(lilian,inez).
sister(inez,lilian).
father(david,edward).
mother(therese,edward).
father(mark,malcolm).
mother(nathalie,malcolm).
father(raymond,matthew).
mother(nadine,matthew).
father(richard,david).
mother(mary,david).
father(john,therese).
mother(lilian,therese).
paternalgrandparent(richard,edward).
grandparent(mary,edward).
grandparent(lilian,edward).
grandparent(john,edward).
paternalgrandparent(richard,malcolm).
grandparent(mary,malcolm).
grandparent(lilian,matthew).
grandparent(john,matthew).
father(william,richard).
mother(rose,richard).
paternalgrandparent(william,david).
grandparent(rose,david).
father(richie,william).
mother(alice,william).
paternalgrandparent(richie,richard).
grandparent(alice,richard).
ancestor(richie,william).
ancestor(alice,william).
ancestor(william,richard).
ancestor(rose,richard).
ancestor(richard,david).
ancestor(mary,david).
ancestor(david,edward).
ancestor(therese,edward).
ancestor(lilian,therese).
ancestor(john,therese).
ancestor(lilian,nadine).
ancestor(john,nadine).
ancestor(richard,mark).
ancestor(mary,mark).
在Stack Overflow上格式化程序的最简单方法是选择要格式化的部分,然后单击顶部编辑器工具栏上的大括号按钮{}。 – dasblinkenlight 2013-04-23 14:47:23
感谢球员你的答案真的帮助我,但我显然有另一个问题... 我不断提出疑问,但即使对于虚假陈述我得到一个“真正的”返回...即使原子不存在(提出查询“祖先(利奥,爱德华),并得到真实”......任何想法为什么发生这种情况? – 2013-04-23 16:04:48
如果这是类似雅虎的答案,我宁愿等到它去投票,因为这两个答案帮助我.. 此外,后续问题是关于这个程序,而不是另一个,所以我认为这将是一个好主意,以获得有关此计划在同一页面处理的问题... – 2013-04-23 16:25:41