Traditionally, Prolog systems used the immediate update view: new clauses became visible to predicates backtracking over dynamic predicates immediately and retracted clauses became invisible immediately.
Starting with SWI-Prolog 3.3.0 we adhere the logical update view, where backtrackable predicates that enter the definition of a predicate will not see any changes (either caused by assert1 or retract1) to the predicate. This view is the ISO standard, the most commonly used and the most `safe'.2.5Logical updates are realised by keeping reference-counts on predicates and generation information on clauses. Each change to the database causes an increment of the generation of the database. Each goal is tagged with the generation in which it was started. Each clause is flagged with the generation it was created as well as the generation it was erased. Only clauses with `created' ...`erased' interval that encloses the generation of the current goal are considered visible.