I am new to Prolog, but I am stuck at this supposedly simple command. I have loaded a knowledge base with no errors, and whenever I try do assert (and even help) I get the following message:
uncaught exception: error(existence_error(procedure,assert/1),top_level/0)
{2}
What am I exactly missing? Appreciated.
Use
assertz/1
orasserta/1
instead. GNU-Prolog does not provideassert/1
because onlyasserta/1
andassertz/1
are defined in the standard.Note that while
asserta/1
always had one clear interpretation meaning add the clause at the beginning, the meaning ofassertz/1
was more difficult to resolve since "add a clause at the end" does not completely determine the semantics of goals that have been invoked prior to asserting the clause.With ISO-Prolog, goals that have been invoked prior to
assertz/1
(but alsoretract/1
) remain unaffected. This is known as the logical update view. To quote the standard (ISO/IEC 13211-1:1995):Note that in DECsystem 10 Prolog, the manual made a big difference between
assert/1
andassertz/1
. In the following quote from the DECsystem 10 User guide of 1978, the term implementation defined can only mean what is known in the standard as implementation dependent (meaning essentially undefined).Also today there are systems where
assert/1
andassertz/1
differ. E.g., xsb.