Documentation

CslibFrontier.Logics.Propositional.CNF.LRATFast

An array-based LRAT checker #

Cslib.Logic.PL.CNF.checkLRATRat is the reference LRAT checker with RAT steps: it is written for the kernel, with lists and structural recursion, so looking up a hinted clause and testing whether a literal is false each search a list. The hints of an LRAT certificate Cruz-Filipe et al. let a checker visit only the clauses they name; Cslib.Logic.PL.CNF.checkLRATFast checks the same certificates with arrays:

The assignment is indexed by literal rather than by variable because the reference checker's trail is a list of literals, which holds both polarities of a variable when the added clause contains both: such a variable makes both of its literals false. An array of Option Bool indexed by variable cannot express that state, an array of marks indexed by literal can.

RAT additions are checked by Cslib.Logic.PL.CNF.ratWith, the check of checkLRATRat, reading clauses from the array and testing every stored clause by a pass over the array. A RAT step thus takes time proportional to the size of the database, as in the algorithm of Cruz-Filipe et al., and keeps its trail in a list; solvers emit few RAT steps.

Cslib.Logic.PL.CNF.checkLPRFast checks LPR certificates Tan et al. on the same arrays, as Cslib.Logic.PL.CNF.checkLPR does (Cslib.Logic.PL.CNF.checkLPRFast_eq_checkLPR): a PR step runs Cslib.Logic.PL.CNF.prWith on the array, as a RAT step runs ratWith. If unit propagation along its RUP hints does not refute the clause, it scans the array once, testing each stored clause against the witness, and for each clause that the witness reduces but does not satisfy it may run unit propagation along the RUP hints and that clause's RAT hints. Its work thus depends on the witness, the lengths of the hints and these propagation runs, as well as on the size of the database.

The checker agrees with checkLRATRat on every formula and certificate (Cslib.Logic.PL.CNF.checkLRATFast_eq_checkLRATRat), so it is sound (Cslib.Logic.PL.CNF.not_satisfiable_of_checkLRATFast) and accepts every certificate that checkLRUP accepts. It is also complete: rewriting Cslib.Algorithms.Lean.DPLL.exists_checkLRATRat_iff with checkLRATFast_eq_checkLRATRat shows that a formula has a certificate this checker accepts exactly when it is unsatisfiable.

It is the checker for compiled and interpreted code. lrat_tauto no longer calls it, since the acceptance of its trimmed certificates is now proved (Cslib.Logic.PL.CNF.checkLRUP_renumberCert_trimCert); it is kept for compiled checking of large certificates, and the LRAT file checker Cslib.Logic.PL.CNF.checkDIMACSLRAT (lake exe lrat_check, #8790) runs it. On 2026-11-26, compiled, checkLRATKernel took 4.4 to 6.0 times as long on the CDCL solver's certificates for PHP(7, 6), PHP(8, 7) and unsatisfiable random 3-CNFs of 150 and 200 variables (on 118705 steps, 2.73 s against 0.49 s). The kernel's Array wraps a list, so the kernel cannot evaluate it efficiently: for kernel reduction, decide uses Cslib.Logic.PL.CNF.checkLRATKernel, which checks the same certificates with a binary trie and a bitmask. Each wins in its own setting. Measured on one machine with the two checkers alternating in one process (2026-11; #7225, milestone 4):

The arrays are updated in place when uniquely referenced, so that a step costs about the total length of its clause and its hinted clauses. That speed is an engineering property, measured, not a theorem here; the instruction bound on the library's word RAM is #6611. Clause numbers and variables index the arrays directly, so a certificate that adds a clause with a very large number, or mentions a very large variable, allocates an array of that length.

Main definitions #

Main results #

References #

Clause databases #

Assignments #

The checker #

The array-based LRAT checker: it accepts exactly the certificates that CNF.checkLRATRat accepts (CNF.checkLRATFast_eq_checkLRATRat), RAT steps included, with the clauses of φ numbered from 1. Clauses are looked up in an array indexed by number, and literals in an array of marks indexed by literal, reset after each step. It is for compiled and interpreted code, where it is about 2 to 7 times as fast as CNF.checkLRATKernel; in the kernel, use CNF.checkLRATKernel.

The array-based LPR checker: it accepts exactly the certificates that CNF.checkLPR accepts (CNF.checkLPRFast_eq_checkLPR), on the arrays of CNF.checkLRATFast. A PR step, like a RAT step, reads the clauses from the array and tests every stored clause by a pass over it.

Agreement with the reference checker #

The array-based checker agrees with the reference checker with RAT steps on every formula and certificate.

The array-based LPR checker agrees with the reference LPR checker on every formula and certificate.

A formula with a certificate accepted by the array-based checker is unsatisfiable.

A formula with an LPR certificate accepted by the array-based checker is unsatisfiable.