assert, asserta, assertz
assert is a meta-predicate that adds its single argument, which may be a fact or a rule, to the Prolog database. The idea is that you construct or learn a new fact or rule in the course of executing your Prolog program, and you want to add it to the database. asserta ensures that the added fact/rule is added before any other facts or rules with the same functor), while assertz adds the fact after any other rules or facts with the same functor. When more than one rule/fact with the same functor is present in the database, they are tried in the order that they appear in the database, hence the need for asserta and assertz. You would use asserta in the common case where the new fact is supposed to save the effort involved in checking the fact using rules and other facts. You might use assertz, for example, if you were trying to construct a queue data structure (where items are added to the end of the queue. Examples:

?- assert(rich(mary)).

?- rich(mary).

?- assert((happy(X) :- rich(X), healthy(X))).
X = _G180

?- assert(healthy(mary)).

?- happy(X).
X = mary

Facts/rules that are loaded from a file cannot be mixed with facts/rules that are created using assert/asserta/assertz without take the special step of declaring the procedure in question to be dynamic. For example, if you have a rule to say, compute N!, with header factorial(+N, -Result), i.e with functor factorial/2 and so arity 2, and you also want to use asserta to add pre-computed values of some factorials to the Prolog database (see also memoisation), then you need to declare factorial to be dynamic, by including the following with your loaded rules for factorial:

:- dynamic factorial/2.

Programs with asserted facts and rules can be extra hard to debug.

See also retract, retractall, dynamic.