我想在 Prolog 中创建与以下语句等效的知识库。
约翰喜欢各种食物。
苹果和蔬菜是食物
任何人吃的东西,没有被杀死的东西都是食物。
阿尼尔吃花生还活着
哈利吃掉了阿尼尔吃的所有东西。
所以这是从这里借来的版本之一
创建此文件后,我想找到查询“约翰喜欢花生”的答案。说likes(john, peanut).
从我这边尝试在 Prolog 中编写规则如下
alive(anil).
eats(anil,peanut).
food(apple).
food(vegitables).
food(X):-likes(john,X).
eats(X,Y),not(killed(X)):-food(Y).
eats(anil,X):-eats(harry,X).
killed(X):-not(alive(X)).
alive(X):-not(killed(X)).
但我收到如下错误和警告;
ERROR: No permission to modify static procedure `(',')/2'
Warning: Clauses of eats/2 are not together in the source-file
Warning: Current predicate: food/1
Warning: Use ':- discontiguous eats/2.' to suppress this message
Warning: Clauses of alive/1 are not together in the source-file
Warning: Current predicate: killed/1
Warning: Use ':- discontiguous alive/1.' to suppress this message