练习如下:
在Prolog中代表以下内容:
我写的知识库代码是:
killer(Butch).
married(Mia,Marsellus).
dead(Zed).
kills(Marsellus, Y):- getsfootmassagefrom(Mia, Y).
loves(Mia, X):- goodDancer(X).
eats(Jules, X):- nutritious(X); tasty(X).
这是正确的还是在编写规则时有任何错误?
由于
答案 0 :(得分:1)
这更像是吗?
killer(butch).
killer(marcellus).
adult(mia).
adult(marcellus).
adult(jules).
loves(marcellus,mia).
loves(mia,marcellus)
loves(zed,butch).
married(X,Y):-
loves(X,Y),
adult(X).
'good dancer'(butch).
'good dancer'(zed).
'mia loves'(X):-
'good dancer'(X).
'mia footmassager'(zed).
'mia footmassager'(jules).
'mia footmassager'(butch).
'marcellus kills'(X):-
'mia footmassager'(X).
nutritious('cod liver oil').
nutritious(hummus).
tasty(hummus).
tasty(chocolate).
'jules eats'(X):-
nutritious(X),
tasty(X).