ERROR: No procedure usermod : select / 3 exists

150 views Asked by At

Im learning prolog and was having problems with the select/3 predicate so I made a test file for it.

The entire code i'm trying to run is the following 1 line of XSB in its own file:

find(X,B) :- select(X, [1,2,3,4,5], B).

It compiles fine but I'm getting the following error:

| ?- find(5,B).
++Error[XSB/Runtime/P]: [Existence (No procedure usermod : select / 3 exists)] []
Forward Continuation...
... machine:xsb_backtrace/1  From c:/program files (x86)/XSB/syslib/machine.xwam
... x_interp:_$call/1  From c:/program files (x86)/XSB/syslib/x_interp.xwam
... x_interp:call_query/1  From c:/program files (x86)/XSB/syslib/x_interp.xwam
... standard:call/1  From c:/program files (x86)/XSB/syslib/standard.xwam
... standard:catch/3  From c:/program files (x86)/XSB/syslib/standard.xwam
... x_interp:interpreter/0  From c:/program files (x86)/XSB/syslib/x_interp.xwam
... loader:ll_code_call/3  From c:/program files (x86)/XSB/syslib/loader.xwam
... loader:load_object_file/2  From c:/program files (x86)/XSB/syslib/loader.xwam
... standard:call/1  From c:/program files (x86)/XSB/syslib/standard.xwam
... standard:catch/3  From c:/program files (x86)/XSB/syslib/standard.xwam

AFAIK this error is usually when theres a prblem with a user defined predicate but this is a standard function and the documentation says it auto-imports so why am I getting this error?

1

There are 1 answers

1
Paulo Moura On BEST ANSWER

The select/3 predicate is a common library predicate. It seems that, despite using XSB, you're reading another Prolog system documentation. Likely, SWI-Prolog, which provides an auto-loading mechanism, which doesn't exist in XSB. But you can manually import the predicate. For example:

$ xsb
[xsb_configuration loaded]
[sysinitrc loaded]
[xsbbrat loaded]

XSB Version 3.8.0 (Three-Buck Chuck) of October 28, 2017
[i386-apple-darwin18.7.0 64 bits; mode: optimal; engine: slg-wam; scheduling: local]
[Build date: 2019-12-13]

| ?- import select/3 from lists.

yes
| ?- select(X, [1,2,3,4,5], B).

X = 1
B = [2,3,4,5];

X = 2
B = [1,3,4,5];

X = 3
B = [1,2,4,5];

X = 4
B = [1,2,3,5];

X = 5
B = [1,2,3,4];

no

To add the import to your source file, write it as a directive at the beginning of the file:

:- import select/3 from lists.