In the book "Expert systems in prolog" I've hit a roadblock. The book defines a simple shell as follows:
solve :-
abolish(known, 3),
define(known, 3),
top_goal(X),
write('The answer is '),
write(X),
nl.
solve :-
write('No answer found.'),
nl.
However, the predicate define
doesn't seem to be a built-in predicate in SWI-Prolog. The purpose of define is to ensure the predicate known/3
is defined in the system after abolish is called to remove any previous definitions of known/3
. known/3
itself is used to mark if an attribute/value pair is in the database or not. I've tried using assert/1
:
assert(known(Y,A,V)).
But I'm not sure if that's correct.
Also, in
write('The answer is '), write(X), nl.
The listener reports that there's a syntax error and that an operator was expected. Yet, in the second definition of solve, there's no issue.
What would be the equivalent for SWI-Prolog, and how can I fix my syntax error? Thanks for your help!