2-satisfiability
Definition2-SAT as a decision problem#✓fully proved
The 2-SAT decision problem accepts a bitstring \(x\) exactly when \(x\) decodes, under the canonical bitstring encoding, to a pair \((n, \varphi)\) of a natural number \(n\) and a CNF formula \(\varphi\) such that every clause of \(\varphi\) has at most two literals, every variable occurring in \(\varphi\) is less than \(n\), and there is a list \((a_0, \dots, a_{n-1})\) of booleans such that \(\varphi\) is satisfied by the assignment that sends each variable \(v < n\) to \(a_v\) and every other variable to false.
noncomputable def twoSatDec :
MetaMathlibExt.ComplexityTheory.DecisionProblem := fun x =>
match MetaMathlibExt.BitstringEncoding.bitDecode
(α := ℕ × Cslib.Logic.PL.CNF) x with
| some i => decide (
(∀ clause ∈ i.2, clause.length ≤ 2 ∧ ∀ l ∈ clause, l.1 < i.1) ∧
∃ assign : List Bool, assign.length = i.1 ∧
Cslib.Logic.PL.CNF.Satisfies (fun v => assign.getD v false) i.2)
| none => false
abbrev DecisionProblem := List Bool → Bool
MathlibExt/Computability/Complexity.lean:170
def bitDecode [BitstringEncoding α] (l : List Bool) : Option α := toEncoding.decode l
MathlibExt/Computability/Complexity.lean:58
abbrev CNF := List CNFClause
CSLibExt/Logics/Propositional/CNF/Basic.lean:33
def Satisfies (assignment : Nat → Bool) (formula : CNF) : Prop :=
∀ clause ∈ formula, CNFClause.Satisfies assignment clause
CSLibExt/Logics/Propositional/CNF/Semantics.lean:71
Uses 12 · Used by 1
Theorem2-SAT is in P#●ready to prove
The 2-SAT decision problem lies in the complexity class P.
public theorem_wanted two_sat_in_p :
twoSatDec ∈ MetaMathlibExt.ComplexityTheory.P
noncomputable def twoSatDec :
MetaMathlibExt.ComplexityTheory.DecisionProblem := fun x =>
match MetaMathlibExt.BitstringEncoding.bitDecode
(α := ℕ × Cslib.Logic.PL.CNF) x with
| some i => decide (
(∀ clause ∈ i.2, clause.length ≤ 2 ∧ ∀ l ∈ clause, l.1 < i.1) ∧
∃ assign : List Bool, assign.length = i.1 ∧
Cslib.Logic.PL.CNF.Satisfies (fun v => assign.getD v false) i.2)
| none => false
WantedExt/Complexity/KeyTheorems/TwoSATInPWanted.lean:44
def P : DecisionComplexityClass :=
{ L | IsPolyTime L }
MathlibExt/Computability/Complexity.lean:194
Sources
- M. Davis, G. Logemann, and D. Loveland, "A machine program for theorem-proving", Communications of the ACM 5 (1962), 394-397; B. Aspvall, M. F. Plass, and R. E. Tarjan, "A linear-time algorithm for testing the truth of certain quantified Boolean formulas", Information Processing Letters 8 (1979), 121-123.
Uses 4
Loading dependency explorer…
The dependency explorer needs JavaScript and its graph data.