GNU Prolog Error

I'm new to Prolog, but I'm stuck with this supposedly simple team. I downloaded the knowledge base without errors, and whenever I try to assert (and even help), I get the following message:

uncaught exception: error(existence_error(procedure,assert/1),top_level/0) {2} 

What exactly am I missing? Appreciated.

+7
prolog iso-prolog prolog-assert gnu-prolog
source share
1 answer

Use assertz/1 or asserta/1 . GNU-Prolog does not provide assert/1 because the standard defines only asserta/1 and assertz/1 .

Please note that although asserta/1 always had one clear interpretation, meaning adding a sentence at the beginning, the value of assertz/1 was more difficult to resolve, since "add a sentence at the end" does not fully define the semantics of the goals that were called up before the statement was approved.

With ISO-Prolog, goals that were called before assertz/1 (but also retract/1 ) remain unchanged. This is called a logical update view. To quote a standard (ISO / IEC 13211-1: 1995):

7.5.4 Updating the logical database

Any change in the database that occurs as a result of the fulfillment of a goal (for example, when the subgoal activator is called assertz/1 or retract/1 ) affects only the activation, the execution of which begins later.
the change should not affect the activation that is currently in progress.

NOTE - Thus, the database is frozen at run time, and the list of sentences defining the predicate is fixed in
the moment of its execution (see 7.7.7 e).

Note that in DECsystem 10 Prolog, the manual made a big difference between assert/1 and assertz/1 . In the following quote from the 1978 DECsystem 10 User Guide, the term defined during implementation can only mean what is known in the standard as implementation dependent (which means essentially undefined).

5.5 Meta-logical

...

assert(C)

The current instance of C interpreted as a sentence and added to the current interpreted program (with new private variables
replacing any unlit variables). New position
in this procedure is defined as implementation.
C must be created for non-variable.

asserta(C)

Like assert(C) , except that the new sentence becomes the first one for the corresponding procedure.

assertz(C)

Like assert(C) , except that the new sentence becomes the last
for the appropriate procedure.

There are also systems where assert/1 and assertz/1 are different. For example, xsb .

+7
source share

All Articles