Documentation

CslibFrontier.Logics.Propositional.CNF.LRAT

A kernel-reducible LRUP (RUP-only LRAT) checker #

An LRAT certificate Cruz-Filipe et al. refutes a formula in conjunctive normal form by a sequence of steps, each adding a clause (by RUP or RAT), adding the empty clause, or deleting clauses. Every clause has a number: the clauses of the formula are numbered 1, 2, … in order, and every added clause carries its own number. An added RUP clause comes with hints, a list of numbers of clauses. Starting from the negation of the added clause, the hinted clauses are visited in order. Each must have all but one of its literals false, and then the remaining literal becomes true, except the last, which must have all its literals false. So the added clause follows from the hinted clauses by unit propagation: it is a RUP clause.

Cslib.Logic.PL.CNF.checkLRUP φ cert checks the RUP-only (LRUP) fragment of LRAT in the format of Lean core's Std.Tactic.BVDecide.LRAT.IntAction: literals are nonzero integers in DIMACS style, so the variable v of φ : CNF ℕ is written v + 1, and is negated by negating the integer. It accepts RUP steps, empty-clause steps and deletions, and rejects every RAT step. Full LRAT with RAT steps is checked separately by Cslib.Logic.PL.CNF.checkLRATRat (alongside the kernel trie checker Cslib.Logic.PL.CNF.checkLRATKernel and the array checker Cslib.Logic.PL.CNF.checkLRATFast). Because RAT steps simulate Extended Resolution while RUP-only certificates are polynomially equivalent to Resolution, the two checkers belong to exponentially separated proof systems.

checkLRUP is written with structural recursion on lists, so the kernel can evaluate it and decide proves that it accepts a given certificate. Lean core's Std.Tactic.BVDecide.LRAT.check checks full LRAT in the same format, but the kernel cannot evaluate it, and it is only proved sound, not complete.

A clause added by a RUP step holds under every assignment satisfying the clauses so far, so an accepted LRUP certificate shows that the formula has no model (Cslib.Logic.PL.CNF.not_satisfiable_of_checkLRUP).

Main definitions #

Main results #

References #

The literal named by a DIMACS integer: v + 1 is the variable v and -(v + 1) its negation; 0 names nothing.

The clause named by a list of DIMACS integers.

The DIMACS integer of a literal: v + 1 for the variable v, -(v + 1) for its negation.

A clause as DIMACS integers.

@[simp]

The DIMACS integer of the variable v has absolute value v + 1.

@[simp]

Reading the DIMACS integer of a literal gives it back.

@[simp]

Reading the DIMACS integers of a clause gives it back.

What is left of a clause under the literals assumed true, once its false literals are removed (Cslib.Logic.PL.Clause.residual).

  • empty : Residual

    Every literal of the clause is false.

  • unit (l : Literal ℕ) : Residual

    The literal l, possibly repeated: every literal of the clause but l is false, and l is not.

  • other : Residual

    Two different literals of the clause are not false.

The residual of a clause under the literals t assumed true: the literals of c whose negation is not in t, classified as none (empty), one literal possibly repeated (unit), or more (other). A literal repeated in the clause counts once. Unit propagation along hints (Cslib.Logic.PL.CNF.propagateWith) reads every hinted clause through this classification.

The residual of a clause is empty exactly when every literal of the clause is false.

The residual of a clause is the unit l exactly when l is a literal of the clause that is not false, and every other literal of the clause is false.

A clause whose literals other than l are false has an empty residual or the residual l.

theorem Cslib.Logic.PL.Clause.residual_congr (c : Clause ℕ) {t t' : List (Literal ℕ)} (h : ∀ (l : Literal ℕ), l ∈ t ↔ l ∈ t') :

The residual of a clause reads the assumed literals only through membership.

Unit propagation along hints, from the literals trail assumed true, reading the hinted clauses with lookup. Each hinted clause must have every literal but one false under trail, and that literal is added to trail; the run succeeds when a hinted clause has every literal false (Cslib.Logic.PL.Clause.residual). The checker reads clauses from a list of numbered clauses (Cslib.Logic.PL.CNF.propagateHints); a solver can read them from an index.

theorem Cslib.Logic.PL.CNF.propagateWith_cons_of_forall_ne {lookup : ℕ → Option (Clause ℕ)} {t : List (Literal ℕ)} {h : ℕ} {hs : List ℕ} {c : Clause ℕ} {l : Literal ℕ} (hc : lookup h = some c) (hfalse : ∀ m ∈ c, m ≠ l → Std.Sat.Literal.negate m ∈ t) (hnext : l ∈ c → Std.Sat.Literal.negate l ∉ t → propagateWith lookup (l :: t) hs = true) :
propagateWith lookup t (h :: hs) = true

One step of unit propagation along hints: if every literal of the hinted clause other than l is false, propagation succeeds, at once when l is also false or absent, and otherwise when it succeeds from the trail extended by l.

Unit propagation along hints in a database of numbered clauses (Cslib.Logic.PL.CNF.propagateWith), looking up the first clause of each number (List.lookup).

theorem Cslib.Logic.PL.CNF.propagateHints_cons (db : List (ℕ × Clause ℕ)) (t : List (Literal ℕ)) (h : ℕ) (hs : List ℕ) :
propagateHints db t (h :: hs) = match List.find? (fun (x : ℕ × Clause ℕ) => x.1 == h) db with | none => false | some e => match e.2.residual t with | Clause.Residual.empty => true | Clause.Residual.unit l => propagateHints db (l :: t) hs | Clause.Residual.other => false

One step of unit propagation along hints in a database, by the residual of the hinted clause.

theorem Cslib.Logic.PL.CNF.propagateHints_cons_of_forall_ne {db : List (ℕ × Clause ℕ)} {t : List (Literal ℕ)} {h : ℕ} {hs : List ℕ} {e : ℕ × Clause ℕ} {l : Literal ℕ} (he : List.find? (fun (x : ℕ × Clause ℕ) => x.1 == h) db = some e) (hfalse : ∀ m ∈ e.2, m ≠ l → Std.Sat.Literal.negate m ∈ t) (hnext : l ∈ e.2 → Std.Sat.Literal.negate l ∉ t → propagateHints db (l :: t) hs = true) :
propagateHints db t (h :: hs) = true

One step of unit propagation along hints in a database: if every literal of the hinted clause other than l is false, propagation succeeds, at once when l is also false or absent, and otherwise when it succeeds from the trail extended by l.

The number of RUP and empty-clause hints of a certificate: the total length of the hint lists of its RUP and empty-clause steps. CNF.checkLRUP reads no other hints and rejects RAT steps.

The RUP-only (LRUP) checker on a database of numbered clauses; RAT steps are rejected.

The numbered clauses the checker starts from: clause i of φ has the number i + 1.

The LRUP (RUP-only LRAT) checker: the clauses of φ are numbered from 1, and the certificate must reach an empty-clause step through RUP steps and deletions; RAT steps are rejected (for full LRAT with RAT steps, see Cslib.Logic.PL.CNF.checkLRATRat).

theorem Cslib.Logic.PL.CNF.propagateWith_congr (lookup : ℕ → Option (Clause ℕ)) {t t' : List (Literal ℕ)} :
(∀ (l : Literal ℕ), l ∈ t ↔ l ∈ t') → ∀ (hs : List ℕ), propagateWith lookup t hs = propagateWith lookup t' hs

Unit propagation along hints reads the starting literals only through membership.

theorem Cslib.Logic.PL.CNF.propagateHints_congr (db : List (ℕ × Clause ℕ)) {t t' : List (Literal ℕ)} (h : ∀ (l : Literal ℕ), l ∈ t ↔ l ∈ t') (hs : List ℕ) :

Unit propagation along hints reads the starting literals only through membership.

Soundness #

theorem Cslib.Logic.PL.CNF.false_of_propagateWith {lookup : ℕ → Option (Clause ℕ)} {σ : ℕ → Bool} (hlookup : ∀ (h : ℕ) (c : Clause ℕ), lookup h = some c → Clause.eval σ c = true) {trail : List (Literal ℕ)} (htrail : ∀ l ∈ trail, Literal.eval σ l = true) {hs : List ℕ} (h : propagateWith lookup trail hs = true) :

If unit propagation along hints succeeds, no assignment satisfying every clause the lookup returns makes the starting literals true.

theorem Cslib.Logic.PL.CNF.false_of_propagateHints {db : List (ℕ × Clause ℕ)} {σ : ℕ → Bool} (hdb : ∀ e ∈ db, Clause.eval σ e.2 = true) {trail : List (Literal ℕ)} (htrail : ∀ l ∈ trail, Literal.eval σ l = true) {hs : List ℕ} (h : propagateHints db trail hs = true) :

If unit propagation along hints succeeds, no assignment satisfies the database and makes the starting literals true.

theorem Cslib.Logic.PL.CNF.eval_of_propagateHints {db : List (ℕ × Clause ℕ)} {σ : ℕ → Bool} (hdb : ∀ e ∈ db, Clause.eval σ e.2 = true) {c : Clause ℕ} {hs : List ℕ} (h : propagateHints db (List.map Std.Sat.Literal.negate c) hs = true) :

A RUP clause holds: if unit propagation along hints from its negation succeeds, every assignment satisfying the database satisfies it.

theorem Cslib.Logic.PL.CNF.false_of_checkLRUPAux {σ : ℕ → Bool} {db : List (ℕ × Clause ℕ)} (hdb : ∀ e ∈ db, Clause.eval σ e.2 = true) {cert : List Std.Tactic.BVDecide.LRAT.IntAction} (h : checkLRUPAux db cert = true) :

If the LRUP checker accepts on a database, no assignment satisfies the database.

A formula with an accepted LRUP (RUP-only LRAT) certificate is unsatisfiable.