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 clause database is an
Array (Option (Clause ℕ))indexed by clause number, grown as needed; adding a clause writes it at its number, and deleting a clause writesnone; - the literals assumed true during a step are marked in an
Array Boolindexed by literal, the literal(v, b)at2 * v + 1ifband at2 * votherwise. At the end of each step the literals that step marked are unmarked, so every step starts from an empty assignment.
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):
- compiled,
checkLRATKerneltakes 6.0 to 6.5 times as long on the CDCL solver's certificates for SATLIB'suuf100touuf250(on 583226 steps, 22.4 s against 3.4 s), 4.8 to 6.1 times as long on CaDiCaL's for PHP(7, 6) to PHP(9, 8) and foruuf175touuf250(on 233006 steps, 5.4 s against 0.9 s), and 2 to 7 times as long on the trimmed certificates oflrat_tauto's benchmark families. Almost half of its time isNat.testBiton the bitmask, which is a multi-word number once there are more than about 30 variables; - interpreted,
checkLRATKerneltakes 1.8 to 4 times as long on those families; - in the kernel (
decide +kernel),checkLRATFasttook 62.8 s onlrat_tauto's certificate for the chain of 80 implications, against 0.67 s forcheckLRATKerneland 6.8 s forcheckLRUP, and exceeded 14 GB of memory on those fordist 5,iff 5,php 4andphp 5, whichcheckLRATKernelchecks in 0.9 to 8.4 s.
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 #
Cslib.Logic.PL.CNF.checkLRATFast: the array-based checker.Cslib.Logic.PL.CNF.checkLPRFast: the array-based checker with PR steps.
Main results #
Cslib.Logic.PL.CNF.checkLRATFast_eq_checkLRATRat: it agrees withcheckLRATRat.Cslib.Logic.PL.CNF.not_satisfiable_of_checkLRATFast: it is sound.Cslib.Logic.PL.CNF.checkLPRFast_eq_checkLPR,Cslib.Logic.PL.CNF.not_satisfiable_of_checkLPRFast: the same for the checker with PR steps.
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.