プロローグプログラムで特定の人のいとこをすべて一覧表示しようとしていますが、動作させられないようです。私は自分のコードをチェックしたが、それは正しいようだが、私が望む出力が得られていない。プロローグファミリーツリー、いとこの問題
father(john, johnny).
father(john, peter).
father(josh, william).
father(simone, betty).
mother(mary, johnny).
mother(mary, peter).
mother(catherine, william).
mother(kate, betty).
parent(A,B) :- father(A,B).
parent(A,B) :- mother(A,B).
siblings(B,G) :- parent(P,B), parent(P,G), B\=G.
cousins(X,Y) :- parent(A,X), parent(B,Y), siblings(A,B), X\=Y.
私は2人のいとこを返すようにcousins(X, william).
を照会するとき、私はしたいが、私は唯一のリターンとして偽取得しています。私は間違って何をしていますか?
編集:HERESに私が今持っているが、わずか1人のいとこはここ
father(grandpa1, mary).
father(grandpa1, catherine).
father(grandpa2, john).
father(grandpa2, simone).
father(john, johnny).
father(john, peter).
father(josh, william).
father(simone, betty).
mother(grandma1, mary).
mother(grandma1, catherine).
mother(grandma2, john).
mother(grandma2, simone).
mother(mary, johnny).
mother(mary, peter).
mother(catherine, william).
mother(kate, betty).
parent(A,B) :- father(A,B).
parent(A,B) :- mother(A,B).
siblings(B,G) :- parent(P,B), parent(P,G), B\=G.
cousins(X,Y) :- parent(A,X), parent(B,Y), siblings(A,B), X\=Y.
ちょっとしたコメントです。 Prologは何も返さないので、 'false'が返されることはありません。目標/述語が成功するか失敗するかは、それだけです。 – Enigmativity