我有事实:male
,female
和child
。
例如。使用序言找到家族树的姐妹关系
/* tg and yem are mother and father. rika,kiku and susu are children*/
female(rika).
female(tg).
male(kiku).
male(susu).
male(yem).
child(rika,tg).
child(kiku,tg).
child(susu,tg).
child(rika,yem).
child(kiku,yem).
child(susu,yem).
现在我需要一个查询,提取像
sister(Sister1,Sister2):-
female(Sister1),
child(Sister1,X),child(Sister2,X),
Sister1 \= Sister2.
姐妹关系,但它会导致重复响应。我如何改进以获得单一答案?
您是指在两个姐妹之间写一个关系,或者只是两个参数中的一个应该是一个妹妹? (变量名称声称两个,实现声称只有一个) –