This module implements the assert/retract family of predicates to manipulate dynamic predicates.

The predicates defined in this module allow modification of the program as it is actually running. Clauses can be added to the program (asserted) or removed from the program (retracted). For these predicates, the argument which corresponds to the clause head must be instantiated to an atom or a compound term. The argument corresponding to the clause must be instantiated either to a term Head :- Body or, if the body part is empty, to Head. An empty body part is represented as true. Note that using this library is very detrimental to global analysis, and that for most uses the predicates listed in section Fast/concurrent update of facts suffice.

Description: The current instance of Clause is interpreted as a clause and is added to the current program. The predicate concerned must be dynamic. The new clause becomes the first clause for the predicate concerned. Any uninstantiated variables in Clause will be replaced by new private variables.

The following properties hold globally:
This predicate is understood natively by CiaoPP.
(basic_props:native/1)

PREDICATE:asserta/2:

Meta-predicate with arguments: asserta(clause,?).

Usage:asserta(+Clause, -Ref)

Description: Like asserta/1. Ref is a unique identifier of the asserted clause.

The following properties hold globally:
This predicate is understood natively by CiaoPP.
(basic_props:native/1)

PREDICATE:assertz/1:

Meta-predicate with arguments: assertz(clause).

Usage:assertz(+Clause) * ISO *

Description: Like asserta/1, except that the new clause becomes the last clause for the predicate concerned.

The following properties hold globally:
This predicate is understood natively by CiaoPP.
(basic_props:native/1)

PREDICATE:assertz/2:

Meta-predicate with arguments: assertz(clause,?).

Usage:assertz(+Clause, -Ref)

Description: Like assertz/1. Ref is a unique identifier of the asserted clause.

The following properties hold globally:
This predicate is understood natively by CiaoPP.
(basic_props:native/1)

PREDICATE:assert/1:

Meta-predicate with arguments: assert(clause).

Usage:assert(+Clause)

Description: Identical to assertz/1. Included for compatibility.

The following properties hold globally:
This predicate is understood natively by CiaoPP.
(basic_props:native/1)

PREDICATE:assert/2:

Meta-predicate with arguments: assert(clause,?).

Usage:assert(+Clause, -Ref)

Description: Identical to assertz/2. Included for compatibility.

The following properties hold globally:
This predicate is understood natively by CiaoPP.
(basic_props:native/1)

PREDICATE:retract/1:

Meta-predicate with arguments: retract(clause).

Usage:retract(+Clause) * ISO *

Description: The first clause in the program that matches Clause is erased. The predicate concerned must be dynamic.
The predicate retract/1 may be used in a non-determinate fashion, i.e., it will successively retract clauses matching the argument through backtracking. If reactivated by backtracking, invocations of the predicate whose clauses are being retracted will proceed unaffected by the retracts. This is also true for invocations of clause for the same predicate. The space occupied by a retracted clause will be recovered when instances of the clause are no longer in use.

The following properties hold globally:
This predicate is understood natively by CiaoPP.
(basic_props:native/1)

PREDICATE:retractall/1:

Meta-predicate with arguments: retractall(fact).

Usage:retractall(+Head)

Description: Erase all clauses whose head matches Head, where Head must be instantiated to an atom or a compound term. The predicate concerned must be dynamic. The predicate definition is retained.

The following properties hold globally:
This predicate is understood natively by CiaoPP.
(basic_props:native/1)

PREDICATE:abolish/1:

Meta-predicate with arguments: abolish(spec).

Usage:abolish(+Spec) * ISO *

Description: Erase all clauses of the predicate specified by the predicate spec Spec. The predicate definition itself is also erased (the predicate is deemed undefined after execution of the abolish). The predicates concerned must all be user defined.

The following properties hold globally:
This predicate is understood natively by CiaoPP.
(basic_props:native/1)

PREDICATE:clause/2:

Meta-predicate with arguments: clause(fact,?).

Usage:clause(+Head, ?Body) * ISO *

Description: The clause 'Head:-Body' exists in the current program. The predicate concerned must be dynamic.

The following properties hold globally:
This predicate is understood natively by CiaoPP.
(basic_props:native/1)

PREDICATE:clause/3:

clause(Head, Body, Ref)

Like clause(Head,Body), plus the clause is uniquely identified by Ref.

Meta-predicate with arguments: clause(fact,?,?).

Usage 1:clause(+Head, ?Body, ?Ref)

Description:Head must be instantiated to an atom or a compound term.

The following properties hold globally:
This predicate is understood natively by CiaoPP.
(basic_props:native/1)

Usage 2:clause(?Head, ?Body, +Ref)

Description:Ref must be instantiated to a valid identifier.

The following properties hold globally:
This predicate is understood natively by CiaoPP.
(basic_props:native/1)

PREDICATE:current_predicate/1:

Usage:current_predicate(?Spec) * ISO *

Description: A predicate in the current module is named Spec.

The following properties hold globally:
This predicate is understood natively by CiaoPP.
(basic_props:native/1)

PREDICATE:current_predicate/2:

Usage:current_predicate(?Spec, ?Module)

Description: A predicate in Module is named Spec. Module never is an engine module.

The following properties hold globally:
This predicate is understood natively by CiaoPP.
(basic_props:native/1)

PREDICATE:dynamic/1:

dynamic Spec

Spec is of the form F/A. The predicate named F with arity A is made
dynamic in the current module at runtime (useful for predicate names generated on-the-fly). If the predicate functor name F is uninstatiated, a new, unique, predicate name is generated at runtime.

PREDICATE:data/1:

data Spec

Spec is of the form F/A. The predicate named F with arity A is made
data in the current module at runtime (useful for predicate names generated on-the-fly). If the predicate functor name F is uninstatiated, a new, unique, predicate name is generated at runtime.

PREDICATE:wellformed_body/3:

wellformed_body(BodyIn, Env, BodyOut)

BodyIn is a well-formed clause body. BodyOut is its counterpart with no single-variable meta-goals (i.e., with call(X) for X). Env denotes if global cuts are admissible in BodyIn (+ if they are, - if they are not).