SWI Prolog Error and Warning Messages


Under Construction

Error and warning messages from programming systems like SWI Prolog tell you that there is (or may be) a problem, but they can be a little cryptic in terms of telling you what the problem is. The following table is intended to demystify the messages.

MessageLikely cause(s)
ERROR: Out of local stack Usually infinite recursion. Look at your recursive rules and ensure that there is some provision to stop the recursion from going on for ever.
Warning: (test.pl:1):
        Singleton variables: [Cihld]
Means that in the program file test.pl, at line 1 (that's the :1), you have used a variable name that not used anywhere else in that rule (or fact). Can mean a spelling mistake, as in this case - Cihld should presumably be Child. However, it could just be that you really only wanted to use the variable once, as with Someone, in
happy(Person) :- loves(Someone, Person).
In this case, you can get rid of the warning message by putting an underscore in front of the singleton variable:
happy(Person) :- loves(_Someone, Person).
Warning: (thing.pl:3:31):
        Redefined static procedure rich/1
means that rich was previously defined, and you have now loaded a new definition of it via a consult operation. This will have cleared out the previous definition of rich.
Warning: (/Users/billw/or.pl:6):
        Clauses of rich/1 are not together in the source-file
  
means that it expects all the clauses for a each procedure to be together, and for procedure rich this was not the case. Could have been intentional (which is not to say a good idea) or maybe you goofed up and e.g. repeated bits of code for rich in different places in your source file.
ERROR: /Users/billw/thing.pl:1:
  No permission to redefine built-in predicate `assert/1'
  Use :- redefine_system_predicate(+Head) if redefinition is intended
This means that you have tried to redefine a system predicate. It is usually a very bad idea to redefine a system predicate, as it means that any other code that calls the system predicate may end up using your definition, which might be entirely inappropriate. It is usually better to think of another name for your predicate: perhaps make_assertion instead of assert in the example above.
If you absolutely have to use the name reserved for the system predicate for some very good reason, you can do this by inserting the directive
:- redefine_system_predicate(+Head).
e.g.
:- redefine_system_predicate(assert/1).
before the point where you begin to redefine the system predicate.
ERROR: /import/diskname/1/yourlogin/filename.pl:6:
        source_sink `nlp-basis.pro' does not exist
Warning: /import/diskname/1/yourlogin/filename.pl:6:
        Goal (directive) failed: user:[nlp-basis.pro]
This is telling you something like the following: you tried to use a directive like :- ['nlp-basis.pro']. to load some extra code into Prolog, but there was no such file available. This could happen either because, although the file exists, it's in another directory, or because you mis-spelled the filename. In this case, the file is one that is often used in COMP9414 nlp assignments, and it is spelled nlpbasis.pro not nlp-basis.pro - i.e. no hyphen. Solution - fix the spelling of the filename in your code. The :6: at the end of the first and third lines of the messages is telling you that the problem was detected at line 6 of your code file. The extra "Warning" message is about the same problem.
ERROR: /import/kamen/1/billw/filename.pl:12:0:
      Syntax error: Unexpected end of file
This says that, from the point of view of the Prolog system, your code stopped abruptly at line 12, without completing the rule or fact that it was half-way through. This might be exactly what has happened, or it might be that some syntax error in your code has caused Prolog to get confused about what you are trying to do.
ERROR: /import/kamen/1/billw/filename.pl:92:0:
      Syntax error: Unexpected end of clause
This says that, from the point of view of the Prolog system, your code stopped abruptly at line 92, partway through a clause. This is similar to the previous message, but Prolog had passed the start of a clause when the problem occurred.
ERROR: /import/kamen/1/billw/filename.pl:41:
	Full stop in clause-body?  Cannot redefine ,/2
Likely to occur with other messages, e.g. singleton variable warnings. Probably means you have a punctuation error in a rule, something like this:
likes(Person1, Person2) :- friendly(Person1).
                           shared_interests(Person1, Person2),
                           pleasant(Person2).
There should be a comma, not a full stop, at the end of the first line.
ERROR: predname/1: Arguments are not sufficiently instantiated
  
You have called a predicate, predname, probably a predefined one, and you supplied an argument that was a variable that is yet bound, where it doesn't make sense to supply an unbound variable. For example, tab(N) (which prints N spaces) doesn't make sense if N is not bound to a non-negative whole number. The argument must be bound at the time the goal is evaluated - it is not good enough to supply a value via a later goal. The /1 refers to the number of arguments that predname takes, in this case 1, but will vary according to the number of arguments you provide to the particular predicate. Like the preceding example errors, this one is likely to come, in practice, with a filename:linenum:position to tell you where in your program the problem is located.
ERROR: predname/1: Type error: `character' expected, found `abc'
  
Some Prolog built-in predicates insist on a particular type of argument - maybe integer, or string, for example. In this case, the predicate predname was expecting a single character, but you provided the string 'abc'. Like preceding example errors, this one is likely to come, in practice, with a filename:linenum:position to tell you where in your program the problem is located.

I plan to add to the table as I encounter more such messages. Suggestions welcome, please send a cut-and-paste of the message, the dialogue with SWI Prolog that generated it, and the Prolog code as an attachment. This is not a free debugging service, but I'll try to include such examples in this list.


Bill Wilson's contact info
Last updated:
UNSW's CRICOS Provider No. is 00098G