!TITLE Modification of the Program !KEY The predicates defined in this section allow modification of the program as it is actually running. Clauses can be added to the program ("asserted") or removed from the program ("retracted"). Some of the predicates make use of an implementation-defined identifier which uniquely identifies every clause in the interpreted program. This identifier makes it possible to access clauses directly, instead of requiring a search through the program every time. However such faciities are intended for more complex use of the database and are not required (and undoubtably should be avoided) by novice users. assert(C) The current instance of C is interpreted as a clause and is added to the current interpreted program (with new private variables replacing any uninstantiated variables). The position of the new clause within the procedure concerned is implementation-defined. C must be instantiated to a non-variable. assert(Clause,Ref) Equivalent to assert(_) where Ref is the implementation-defined identifier of the clause asserted. asserta(C) Like assert(_), except that the new clause becomes the first clause for the procedure concerned. asserta(Clause,Ref) Equivalent to asserta(_) where Ref is the implementation-defined identifier of the clause asserted. assertz(C) Like assert(_), except that the new clause becomes the last clause for the procedure concerned. assertz(Clause,Ref) Equivalent to assertz(_) where Ref is the implementation-defined identifier of the clause asserted. clause(P,Q) P must be bound to a non-variable term, and the current interpreted program is searched for a clause whose head matches P. The head and body of those clauses are unified with P and Q respectively. If one of the clauses is a unit clause, Q will be unified with 'true'. clause(Head,Body,R) Equivalent to clause(_) where Ref is the implementation-defined term which uniquely identifies the clause concerned. If Ref is not given at the time of the call, Head must be instantiated to a non-variable term. Thus this predicate can have two different modes of use, depending on whether the identifier of the clause is known or unknown. retract(C) The first clause in the current interpreted program that matches C is erased. C must be initially instantiated to a non-variable. The predicate may be used in a non-determinate fashion, i.e. it will successively retract clauses matching the argument through backtracking. abolish(N,A) Completely remove all clauses for the procedure with name N (which should be an atom), and arity A (which should be an integer). The space occupied retracted or abolished clauses will be recovered when instances of the clause are no longer in use. See also erase (Section 2.10) which allows a clause to be directly erased via its implementation-defined identifier (note however that this is a lower level facility that is not recommended for novice users).