When I first read it I thought it all looked correct but the fact that you gave just the right amount of detail I tried to reproduce your problem and upon doing so immediately identified your problem and how to solve it.
You are working in a directory, for this example I will C:/Users/Groot/Documents
.
Now in that directory you create a file test.pl
File: test.pl
isvaluable(gold).
Then you start up SWI-Prolog
Welcome to SWI-Prolog (threaded, 64 bits, version 8.3.8)
SWI-Prolog comes with ABSOLUTELY NO WARRANTY. This is free software.
Please run ?- license. for legal details.
For online help and background, visit https://www.swi-prolog.org
For built-in help, use ?- help(Topic). or ?- apropos(Word).
?-
use chdir/1 to change the directory within the top level.
?- chdir('C:/Users/Groot/Documents').
true.
and to verify the directory is correct I will add a step to check it
?- pwd.
% c:/users/groot/documents/
true.
then you loaded the facts using
[facts].
and received an error
?- [facts].
ERROR: source_sink `facts' does not exist
ERROR: In:
ERROR: [22] throw(error(existence_error(source_sink,facts),_26960))
ERROR: [18] '$resolve_source_path'(facts,_26992,[expand(false),...]) at c:/program files/swipl/boot/init.pl:2313
ERROR: [17] '$load_file'(facts,user,[expand(false),...]) at c:/program files/swipl/boot/init.pl:2287
ERROR: [9] toplevel_call(user:user: ...) at c:/program files/swipl/boot/toplevel.pl:1113
ERROR:
ERROR: Note: some frames are missing due to last-call optimization.
ERROR: Re-run your program in debug mode (:- debug.) to get more detail.
which is not the same as the one you received.
However if instead the consult is done as
?- [test].
true.
because test
is the name of file (test.pl
) without the filetype then
?- isvaluable(Valuable).
Valuable = gold.
it works as expected.
While the use of chdir/1 will work, in Prolog the customary way to change the working directory is to use working_directory/2, e.g.
?- working_directory(_,'C:/Users/Groot/Documents').
true.