4.14.1 Managing (dynamic) predicates
AllApplicationManualNameSummaryHelp

  • Documentation
    • Reference manual
      • Built-in Predicates
        • Database
          • Managing (dynamic) predicates
            • abolish/1
            • abolish/2
            • copy_predicate_clauses/2
            • redefine_system_predicate/1
            • retract/1
            • retractall/1
            • asserta/1
            • assertz/1
            • assert/1
            • asserta/2
            • assertz/2
            • assert/2
            • Transactions
            • Impact of transactions
    • Packages
Availability:built-in
[ISO]asserta(+Term)
[ISO]assertz(+Term)
[deprecated]assert(+Term)
Assert a clause (fact or rule) into the database. The predicate asserta/1 asserts the clause as first clause of the predicate while assertz/1 assert the clause as last clause. The deprecated assert/1 is equivalent to assertz/1. If the program space for the target module is limited (see set_module/1), asserta/1 can raise a resource_error(program_space) exception. The example below adds two facts and a rule. Note the double parentheses around the rule.
?- assertz(parent('Bob', 'Jane')).
?- assertz(female('Jane')).
?- assertz((mother(Child, Mother) :-
                parent(Child, Mother),
                female(Mother))).