Reputation: 11408
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 ;)?
Upvotes: 4
Views: 2486
Reputation: 18663
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.
Upvotes: 6