uncaught exception: error(existence_error(procedure,likes/0),friend/0) (Seven Languages)

女生的网名这么多〃 提交于 2019-12-10 15:59:34

问题


Currently working through the Seven Languages in Seven Weeks book, and am stuck on getting the first prolog examples to run. This concerns the same code piece as this question; however I believe my question is quite different.

I have defined likes and friend as in the book; my friends.pl:

likes(wallace, cheese).
likes(grommit, cheese).
likes(wendolene, sheep).

friend(X, Y) :- \+(X = Y), likes(X, Z), likes(Y, Z).

I am using gnu prolog (v1.4.5, on Ubuntu 18.10), and I can load the friends.pl consultfile, either via | ?- [friends.pl] or | ?- ['friends.pl'] or by calling gprolog with its --consult-file parameter: gprolog --consult-file friends.pl just fine

Asking about the likes facts or the first part of the friend rule works just fine:

| ?- likes(grommit, cheese).

yes
| ?- friend(grommit, grommit).

no

However, when I try a query which concerns the second part of the rule, I get this:

| ?- friend(grommit, wendolene).
uncaught exception: error(existence_error(procedure,likes/0),friend/0)

As I read the error message, it tells me that there is no procedure "likes" which takes 0 parameters, right? But where in my rule is such a 0-parameter procedure referenced? What am I doing wrong here? Can't believe this to be a bug in my prolog ;)?


回答1:


There have been several reports of this issue (existence errors for predicates with arity zero that are not called in the source code when a predicate with the same name exists with arity one or greater) with GNU Prolog on Ubuntu. The solution is to download the GNU Prolog sources and compile manually.



来源:https://stackoverflow.com/questions/54496409/uncaught-exception-errorexistence-errorprocedure-likes-0-friend-0-seven-la

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!