Bob*_*y S 1 prolog logic-programming
假设已将以下事实输入Prolog数据库:
father(X, Y) // X is the father of Y
mother(X, Y) // X is the mother of Y
male(X) // X is a male
female(X) // X is a female
parent(X, Y) // X is a parent of Y
diff(X, Y) // X and Y are different
Run Code Online (Sandbox Code Playgroud)
(1)现在为grandpa_of(X,Y)添加一个Prolog规则,其中"X是Y的祖父"
(2)为兄弟(X,Y)添加另一条规则,其中"X是Y的兄弟姐妹"
我的想法:
问题1:
我对如何找到父母的父母感到困惑,到目前为止我都是
grandpa_of(X,Y): - 男(X),...
问题2:
兄弟(X,Y): - 父(P,X),父(P,Y),差异(X,Y)