Applying Logical Knowledge

  Dynamic Database


Built-in predicates allow clauses to be dynamically asserted and retracted from the logicbase.

assert(X) adds the clause X to the logicbase.

retract(X) retracts the first clause that unifies with X in the logicbase.

Like the I/O predicates, assert & retract succeed when called, and simply fail on redo. The operation is NOT undone.

?- listing.
yes

?- assert(toon(daffy)).
yes

?- assert(toon(bugs)).
yes

?- listing.
user:toon(daffy).
user:toon(bugs).
yes

?- retract(toon(daffy)).
yes

?- listing.
user:toon(bugs).
yes

?- toon(X).
X = bugs ;
no

Copyright ©2005 Amzi! inc.