If the database(prolog clause) is increased by "assertz/ensure_loaded" while searching, how dose swi-prolog keep track of which fact is done searching, and which is not?

My problem is not specific. I wrote a prolog program which calls assertz and ensure_loaded while searching, the result turns out fine, but it still confuse me how dose swiprolog do it. Shouldn’t the backtracking be affected by adding new Facts ?

How about this part of the docs: SWI-Prolog -- Transactions

Traditionally, Prolog database updates add or remove individual clauses. The Logical Update View ensures that a goal that is started on a dynamic predicate does not see modifications due to assert/1 or retract/1 during its life time. See section 4.14.5. In a multi-threaded context this assumption still holds for individual predicates: concurrent modifications to a dynamic predicate are invisible.

Is that relevant to your question, Double Dong?

Thank you Boris!
This page totally answers my question. Now it seems I didn’t read the documentation carefully. Thank you for telling me about this page.

1 Like