これをコンパイルすると、次の 2 つのエラー メッセージが表示されます。
"Clauses of (-)/1 are not together in source-file" and
"Singleton variables: [X]"
...これらの 2 つは、私が得たエラーの例です...
事実が衝突しないように、ソース コードからいくつかの事実を削除しようとしました。また、人々を句ではなくアトムとして定義しようとしましたが、どちらも期待どおりに機能しませんでした。何か案は?
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).