Documentation

CslibFrontier.Logics.Propositional.CNF.LRATKernel

An LRAT checker for kernel reduction #

Cslib.Logic.PL.CNF.checkLRATRat is the reference LRAT checker with RAT steps Cruz-Filipe et al.. The kernel can evaluate it, but it keeps its clause database and its trail of true literals in lists: looking up a hinted clause searches the list of all clauses, and testing whether a literal is false searches the trail. Cslib.Logic.PL.CNF.checkLRATKernel checks the same certificates with data the kernel reduces quickly:

The checker uses structural recursion only, and no Array. Looking up and deleting recurse on the trie, and deleting stops at the first missing subtrie. Adding a clause may build the path to its number, so it recurses on a bound on the number's length instead: the number itself.

As in checkLRATFast, the trail is indexed by literal rather than by variable: the reference checker's trail holds both polarities of a variable when the added clause contains both, which makes both literals false.

It checks RUP additions, empty-clause steps and deletions with the trie and the bitmask, and RAT additions with the check Cslib.Logic.PL.CNF.ratWith of checkLRATRat, reading the trie and visiting every clause it stores (Cslib.Logic.PL.CNF.ClauseTrie.all); within a RAT step the trail is a list. It agrees with checkLRATRat on every formula and certificate (Cslib.Logic.PL.CNF.checkLRATKernel_eq_checkLRATRat). Rewriting with that equation, Cslib.Logic.PL.CNF.not_satisfiable_of_checkLRATRat and Cslib.Algorithms.Lean.DPLL.exists_checkLRATRat_iff give its soundness and completeness. It accepts every certificate of the RUP-only checker Cslib.Logic.PL.CNF.checkLRUP (Cslib.Logic.PL.CNF.checkLRATRat_of_checkLRUP).

With PR steps, Cslib.Logic.PL.CNF.checkLPRKernel checks LPR certificates Tan et al. as Cslib.Logic.PL.CNF.checkLPR does (Cslib.Logic.PL.CNF.checkLPRKernel_eq_checkLPR): a PR step runs the check Cslib.Logic.PL.CNF.prWith on the trie, as a RAT step runs ratWith.

It is the checker for kernel reduction. In compiled and interpreted code the array-based Cslib.Logic.PL.CNF.checkLRATFast is faster, by 4.8 to 6.5 times compiled on SATLIB-scale certificates and by 1.8 to 4 times interpreted on lrat_tauto's; in the kernel this checker is the faster by far (0.67 s against 62.8 s on lrat_tauto's chain of 80 implications). The measurements are in the module docstring of checkLRATFast.

Main definitions #

Main results #

References #

The clause database #

A clause database as a binary trie keyed by clause number. The number 0 is stored at the root, and the number n + 1 in the subtrie zero if n is even and one if n is odd, under the key n / 2. So a number is found by reading the digits 1 and 2 of its bijective base-2 numeral, least significant first, and the trie has a node for every number of its paths. An absent subtrie is a leaf.

The clause stored under the number n. The number is matched against 0 and n + 1, which the kernel reduces faster than a test n = 0.

Store x under the number n, which has at most fuel digits. The recursion is on fuel, since the path to n may not exist yet.

Store x under the number n: some c adds the clause c, and none deletes it.

theorem Cslib.Logic.PL.CNF.ClauseTrie.get_insert (t : ClauseTrie) (n : ℕ) (x : Option (Clause ℕ)) (m : ℕ) :
(t.insert n x).get m = if m = n then x else t.get m

Reading a trie after storing x under n.

The trie of an association list of numbered clauses; an earlier entry shadows a later one with the same number, as in List.lookup.

Delete the clause numbered n, following the path of insert. The recursion is on the trie, and stops at a leaf, which holds no clause.

Reading a trie after deleting the clause numbered n.

Delete the clauses with the given numbers.

Whether f n c holds for every clause c stored under a number n. The numbers are rebuilt from the path: the key k of the subtrie zero is the number 2 k + 1, and of one the number 2 k + 2.

theorem Cslib.Logic.PL.CNF.ClauseTrie.all_eq_true (t : ClauseTrie) (f : ℕ → Clause ℕ → Bool) :
t.all f = true ↔ ∀ (n : ℕ) (c : Clause ℕ), t.get n = some c → f n c = true

all tests every stored clause.

Trails as bitmasks #

The bitmask with the literals of ls set, at their word codes.

The residual of a clause under the literals set in the bitmask mask, as Cslib.Logic.PL.Clause.residual under a trail.

Unit propagation along hints, as Cslib.Logic.PL.CNF.propagateHints, reading the hinted clauses from a trie and keeping the trail in a bitmask.

The checker on a clause database, with PR steps if lpr.

The LRAT checker for kernel reduction: it accepts exactly the certificates that CNF.checkLRATRat accepts (CNF.checkLRATKernel_eq_checkLRATRat), RAT steps included, with the clauses of φ numbered from 1. Clauses are looked up in a binary trie keyed by number, and the literals assumed true in a RUP step are the bits set in a natural number. It is for kernel reduction (decide); compiled and interpreted code should use the faster CNF.checkLRATFast.

The LPR checker for kernel reduction: it accepts exactly the certificates that CNF.checkLPR accepts (CNF.checkLPRKernel_eq_checkLPR), on the trie and the bitmasks of CNF.checkLRATKernel.

Agreement with the reference checker #

The kernel checker agrees with the reference checker on every formula and certificate.

The kernel LPR checker agrees with the reference LPR checker on every formula and certificate.