LRAT certificates built step by step #
A solver that learns clauses builds its certificate as it runs. Cslib.Logic.PL.CNF.LRATLog φ is a
certificate under construction for φ: the steps so far, the numbered clauses they lead to, an
index of them by number, which Cslib.Logic.PL.CNF.LRATLog.clause? reads in constant time
instead of searching the database (Cslib.Logic.PL.CNF.LRATLog.clause?_eq), and the next unused
number, together with the facts that the checker passes the steps
(Cslib.Logic.PL.CNF.LRATLog.run) and that every clause of the database holds in every model of
φ (Cslib.Logic.PL.CNF.LRATLog.implied).
The log grows by RUP steps (Cslib.Logic.PL.CNF.LRATLog.addRup): a clause is added under the next
number with hints along which the checker's unit propagation, from the negation of the clause,
reaches a conflict. A solver that learns clauses by resolution can build those hints without
building the resolvents (Cslib.Logic.PL.CNF.RupHints): the hints refuting a clause, after a clause
R of the database, refute any clause containing its resolvent with R
(Cslib.Logic.PL.CNF.RupHints.resolve), since R then propagates the literal resolved on. Chaining
this from a conflict clause gives the hints of the clause learned from it, with no step for the
intermediate resolvents. Clauses can be deleted (Cslib.Logic.PL.CNF.LRATLog.delete), which clears
their index entries in place but still filters the database list. Closing the log with an
empty-clause step, given hints refuting the empty clause, gives a RUP-only (LRUP) certificate that
Cslib.Logic.PL.CNF.checkLRUP accepts (Cslib.Logic.PL.CNF.LRATLog.checkLRUP_finish).
Main definitions #
Cslib.Logic.PL.CNF.LRATLog: a RUP-only LRAT (LRUP) certificate under construction.Cslib.Logic.PL.CNF.LRATLog.init,Cslib.Logic.PL.CNF.LRATLog.addRup,Cslib.Logic.PL.CNF.LRATLog.delete,Cslib.Logic.PL.CNF.LRATLog.finish: starting, adding a RUP clause, deleting and closing.Cslib.Logic.PL.CNF.RupHints: hints refuting every clause containing given literals.
Main results #
Cslib.Logic.PL.CNF.LRATLog.checkLRUP_finish: a closed log is accepted byCNF.checkLRUP.Cslib.Logic.PL.CNF.RupHints.resolve: resolving with a clause of the database extends the hints.
An index in chunks: the entries by number, in arrays of 256, so that updating a shared
index copies the array of chunks and one chunk rather than every entry.
Hints built by resolution #
A hinted clause whose literals other than l are false propagates l: the shared rule
Cslib.Logic.PL.CNF.propagateHints_cons_of_forall_ne, with propagation from l succeeding.
Unit propagation along hints succeeds from more literals. A clause with no open literal
from t has none from t', and one with the single open literal l from t has its other
literals false under t', so the shared rule applies.
Resolving with a clause of the database: if C' contains every literal of the clause R
numbered r other than l, and every literal of C other than the negation of l, then the hints
refuting C, after r, refute C': the clause R propagates l, and then the negation of C
holds.
A certificate under construction for φ: the steps so far, newest first, the numbered
clauses they lead to, indexed by number, and the next unused number.
The steps so far, newest first.
The numbered clauses after the steps.
- next : ℕ
The first number not yet used.
- run (rest : List Std.Tactic.BVDecide.LRAT.IntAction) : checkLRUPAux φ.lratDB (self.steps.reverse ++ rest) = checkLRUPAux self.db rest
The LRUP checker passes the steps and reaches the database.
Every number in the database is below
next.Every clause of the database holds in every model of
φ.Every clause of the database uses variables of
φ.The clauses of the database by number,
nonepast the end.- index_eq (i : ℕ) : chunkGet self.index i = Option.map (fun (x : ℕ × Clause ℕ) => x.2) (List.find? (fun (x : ℕ × Clause ℕ) => x.1 == i) self.db)
The index names the clauses of the database.
The next number is beyond the clauses of
φ.The added clauses come newest first, before the clauses of
φ.
The empty log: the clauses of φ, numbered from 1.
Adding a RUP clause: c, over variables of φ, under the next number, hinting hints,
given that unit propagation along the hints from the negation of c reaches a conflict.
A 1024-bucket table of clause numbers for fast membership tests without allocating an
array spanning max - min (which reaches hundreds of thousands of slots on long runs when an old
clause is locked or deleted alongside recent ones).
Deleting clauses from the log. An empty list deletes nothing and adds no step. The index
entries are cleared in place (chunkClear), so deleting a number that names no clause does not
grow the index.