Local consistency tests for CNF satisfiability verdicts
DefinitionSATLocalWitnessescomplexity-theoryformal-verificationpropositional-logic
Choose the variable of the first literal in a CNF. Restricting it to a bit deletes satisfied clauses and removes the assigned variable from the remaining clauses. A judgment on a CNF without any literal should accept exactly when the formula has no clauses. Otherwise its judgment should equal the Boolean OR of its judgments on the two restrictions.
Definition code
import Definitions.Def_PvsNP import Mathlib set_option autoImplicit false namespace PvsNP.SATLocal.Split def fixedTrue (x : ℕ) (b : Bool) (l : Literal) : Bool := decide (l.2 = x) && l.1 == b def otherVariable (x : ℕ) (l : Literal) : Bool := decide (l.2 ≠ x) def restrictClause (x : ℕ) (b : Bool) (c : Clause) : Option Clause := if c.any (fixedTrue x b) then none else some (c.filter (otherVariable x)) def restrict (x : ℕ) (b : Bool) (F : CNF) : CNF := F.filterMap (restrictClause x b) end PvsNP.SATLocal.Split namespace PvsNP.SATLocal abbrev restrictFormula (F : CNF) (v : ℕ) (bit : Bool) : CNF := Split.restrict v bit F def vars (F : CNF) : Finset ℕ := (F.flatten.map Prod.snd).toFinset def pivot (F : CNF) : Option ℕ := (F.flatten.head?).map Prod.snd def advance (F : CNF) (bit : Bool) : CNF := (pivot F).elim F (fun v => restrictFormula F v bit) def follows (F : CNF) (path : List Bool) : CNF := path.foldl advance F def Inconsistent (J : CNF → Bool) (F : CNF) : Prop := match pivot F with | none => J F ≠ F.isEmpty | some v => J F ≠ (J (restrictFormula F v false) || J (restrictFormula F v true)) def ErrorAt (J : CNF → Bool) (F : CNF) : Prop := ¬ (Satisfiable F ↔ J F = true) end PvsNP.SATLocal
Source
The usual self-reduction for conjunctive normal form satisfiability, using the fixed Cook CNF encoding.