Search code examples
prologiso-prolog

Swi prolog Error: Showing true but not false


Just installed SWI-Prolog on my W8 machine and it's throwing an error.

Here's the error:

ERROR: toplevel: Undefined procedure: mark/0 (DWIM could not correct goal)

Let's say my prolog source file contains one fact:

 Prolog source...

 it_is_monday.   //The fact

So I compile the buffer, and get:

.../documents/prolog/prologSource compiled 0.00 sec, 2 clauses

Now when I input

it_is_monday. 

The output as expected is true. However when I input say,

some_other_statement.

I get the error posted above as opposed to false. Can anyone tell me what's going on here?

Solution: Different prolog version.


Solution

  • There's a standard Prolog flag, unknown, that is set by default in SWI-Prolog and other modern Prolog compilers to error, meaning that an attempt to call an unknown predicate will result in an exception. This flag can be set (using the standard set_prolog_flag/2 predicate) instead to fail to get the behavior that you seem to be expecting but that's not advisable as it may make debugging harder. E.g. a simply typo in a predicate name will result in a failure which, in a complex program, could be difficult to trace down while a predicate existence error would pinpoint the culprit at the spot.