编译时收到两条错误消息:
"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).