Maximum 2-satisfiability
AbbreviationMAX-2SAT instances#✓fully proved
A MAX-2SAT instance is a triple \((n, \varphi, K)\) of a natural number \(n\) (the number of variables), a CNF formula \(\varphi\) and a natural number \(K\) (the bound). The type does not restrict clause lengths; that clauses have at most two literals is part of well-formedness.
abbrev MaxTwoSatInstance := ℕ × Cslib.Logic.PL.CNF × ℕ
abbrev CNF := List CNFClause
CSLibExt/Logics/Propositional/CNF/Basic.lean:33
Uses 1 · Used by 3
DefinitionWell-formed MAX-2SAT instances#✓fully proved
A MAX-2SAT instance \((n, \varphi, K)\) is well formed when every clause of \(\varphi\) has at most two literals and every literal \((x, b)\) in it has variable index \(x < n\).
def WellFormed (i : MaxTwoSatInstance) : Prop :=
(∀ clause ∈ i.2.1, clause.length ≤ 2 ∧ ∀ l ∈ clause, l.1 < i.1)
abbrev MaxTwoSatInstance := ℕ × Cslib.Logic.PL.CNF × ℕ
WantedExt/Complexity/NPComplete/MaxTwoSatWanted.lean:46
Uses 3 · Used by 1
DefinitionFeasible MAX-2SAT instances#✓fully proved
A MAX-2SAT instance \((n, \varphi, K)\) is feasible when there are truth values \(a_0, \dots, a_{n-1}\) such that at least \(K\) of the clauses in the list \(\varphi\), counted with multiplicity, are satisfied by the assignment \(v\) with \(v(x) = a_x\) for \(x < n\) and \(v(x) = \mathrm{false}\) for \(x \ge n\).
def MaxTwoSatFeasible
(i : MaxTwoSatInstance) : Prop :=
∃ assign : List Bool, assign.length = i.1 ∧
∃ sub : Cslib.Logic.PL.CNF, sub.Sublist i.2.1 ∧ i.2.2 ≤ sub.length ∧
∀ clause ∈ sub, Cslib.Logic.PL.CNFClause.Satisfies
(fun x => assign.getD x false) clause
abbrev MaxTwoSatInstance := ℕ × Cslib.Logic.PL.CNF × ℕ
WantedExt/Complexity/NPComplete/MaxTwoSatWanted.lean:46
abbrev CNF := List CNFClause
CSLibExt/Logics/Propositional/CNF/Basic.lean:33
def Satisfies (assignment : Nat → Bool) (clause : CNFClause) : Prop :=
∃ literal ∈ clause, CNFLiteral.Satisfies assignment literal
CSLibExt/Logics/Propositional/CNF/Semantics.lean:45
Uses 4 · Used by 1
DefinitionMAXIMUM 2-SATISFIABILITY as a decision problem#✓fully proved
The decision problem MAXIMUM 2-SATISFIABILITY accepts a bitstring \(x\) exactly when \(x\) decodes, under the canonical bitstring encoding of MAX-2SAT instances, to an instance \((n, \varphi, K)\) that is well formed (every clause of \(\varphi\) has at most two literals, and every literal has variable index less than \(n\)) and feasible (some assignment of truth values to the \(n\) variables satisfies at least \(K\) of the clauses of \(\varphi\), counted with multiplicity). Bitstrings that do not decode, and bitstrings that decode to instances that are not well formed, are rejected.
noncomputable def maxTwoSatDec :
MetaMathlibExt.ComplexityTheory.DecisionProblem := fun x =>
match MetaMathlibExt.BitstringEncoding.bitDecode
(α := MaxTwoSatInstance) x with
| some i => decide (WellFormed i ∧ MaxTwoSatFeasible i)
| 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 MaxTwoSatInstance := ℕ × Cslib.Logic.PL.CNF × ℕ
WantedExt/Complexity/NPComplete/MaxTwoSatWanted.lean:46
def WellFormed (i : MaxTwoSatInstance) : Prop :=
(∀ clause ∈ i.2.1, clause.length ≤ 2 ∧ ∀ l ∈ clause, l.1 < i.1)
WantedExt/Complexity/NPComplete/MaxTwoSatWanted.lean:49
def MaxTwoSatFeasible
(i : MaxTwoSatInstance) : Prop :=
∃ assign : List Bool, assign.length = i.1 ∧
∃ sub : Cslib.Logic.PL.CNF, sub.Sublist i.2.1 ∧ i.2.2 ≤ sub.length ∧
∀ clause ∈ sub, Cslib.Logic.PL.CNFClause.Satisfies
(fun x => assign.getD x false) clause
WantedExt/Complexity/NPComplete/MaxTwoSatWanted.lean:53
Uses 14 · Used by 1
TheoremMAXIMUM 2-SATISFIABILITY is NP-complete#●ready to prove
The decision problem MAXIMUM 2-SATISFIABILITY over bitstrings lies in NP, and every decision problem in NP has a polynomial-time many-one reduction to it.
public theorem_wanted maxTwoSat_npComplete :
maxTwoSatDec ∈ MetaMathlibExt.ComplexityTheory.NP ∧
∀ L : MetaMathlibExt.ComplexityTheory.DecisionProblem,
L ∈ MetaMathlibExt.ComplexityTheory.NP →
Cslib.CookLevin.PolyManyOneRed L maxTwoSatDec
noncomputable def maxTwoSatDec :
MetaMathlibExt.ComplexityTheory.DecisionProblem := fun x =>
match MetaMathlibExt.BitstringEncoding.bitDecode
(α := MaxTwoSatInstance) x with
| some i => decide (WellFormed i ∧ MaxTwoSatFeasible i)
| none => false
WantedExt/Complexity/NPComplete/MaxTwoSatWanted.lean:62
def NP : DecisionComplexityClass :=
{ L | ∃ (p : Polynomial ℕ), ∃ R : (List Bool × List Bool) → Bool,
IsPolyTime R ∧
∀ x, L x ↔ ∃ w : List Bool, w.length ≤ p.eval x.length ∧ R (x, w) }
MathlibExt/Computability/Complexity.lean:200
abbrev DecisionProblem := List Bool → Bool
MathlibExt/Computability/Complexity.lean:170
def PolyManyOneRed (L₁ L₂ : MetaMathlibExt.ComplexityTheory.DecisionProblem) : Prop :=
∃ reduce : List Bool → List Bool,
MetaMathlibExt.ComplexityTheory.IsPolyTime reduce ∧ ∀ x, L₁ x = L₂ (reduce x)
CSLibExt/Computability/CookLevin.lean:396
Sources
- M. R. Garey and D. S. Johnson, Computers and Intractability: A Guide to the Theory of NP-Completeness (1979), MAXIMUM 2-SATISFIABILITY.
Loading dependency explorer…
The dependency explorer needs JavaScript and its graph data.