4.12.4 Adding Clauses to the Database

The assertion predicates are used to add clauses to the database in various ways. The relative position of the asserted clause with respect to other clauses for the same predicate is determined by the choice among assert/1, asserta/1, and assertz/1. A database reference that uniquely identifies the clause being asserted is established by providing an optional second argument to any of the assertion predicates.


clause C is asserted in an arbitrary position in its predicate


as assert/1; reference R is returned


clause C is asserted before existing clauses


as asserta/1; reference R is returned


clause C is asserted after existing clauses


as assertz/1; reference R is returned

Please note: If the term being asserted contains attributed variables (see lib-atts) or suspended goals (see ref-sem-sec), those attributes are not stored in the database. To retain the attributes, you can use copy_term/3 (see ref-lte-cpt).

Send feedback on this subject.