Not-all-equal 3-SAT
AbbreviationNOT-ALL-EQUAL 3-SAT instances#✓fully proved
A NOT-ALL-EQUAL 3-SAT instance is a pair \((n, \varphi)\) of a natural number \(n\), the number of variables, and a CNF formula \(\varphi\). The formula is not required to have three literals per clause; that is part of well-formedness.
abbrev NaeThreeSatInstance := ℕ × Cslib.Logic.PL.CNF
abbrev CNF := List CNFClause
CSLibExt/Logics/Propositional/CNF/Basic.lean:33
Uses 1 · Used by 3
DefinitionWell-formed NOT-ALL-EQUAL 3-SAT instances#✓fully proved
A NOT-ALL-EQUAL 3-SAT instance \((n, \varphi)\) is well-formed when every clause of \(\varphi\) is a list of exactly three literals, repetitions allowed, and every literal \((x, b)\) in it has variable index \(x < n\).
def WellFormed (i : NaeThreeSatInstance) : Prop :=
(∀ clause ∈ i.2, clause.length = 3 ∧ ∀ l ∈ clause, l.1 < i.1)
abbrev NaeThreeSatInstance := ℕ × Cslib.Logic.PL.CNF
WantedExt/Complexity/NPComplete/NaeThreeSatWanted.lean:48
Uses 3 · Used by 1
DefinitionNot-all-equal satisfiability of an instance#✓fully proved
A NOT-ALL-EQUAL 3-SAT instance \((n, \varphi)\), with \(n \in \mathbb{N}\) and \(\varphi\) a CNF formula, is not-all-equal satisfiable when there are truth values \(a_0, \dots, a_{n-1}\) such that, for the assignment \(v\) with \(v(x) = a_x\) for \(x < n\) and \(v(x) = \mathrm{false}\) for \(x \ge n\), every clause of \(\varphi\) contains a literal satisfied by \(v\) and a literal not satisfied by \(v\).
def NaeThreeSatFeasible
(i : NaeThreeSatInstance) : Prop :=
∃ assign : List Bool, assign.length = i.1 ∧
∀ clause ∈ i.2, Cslib.Logic.PL.CNFClause.Satisfies (fun x => assign.getD x false) clause ∧
∃ l ∈ clause, ¬ Cslib.Logic.PL.CNFLiteral.Satisfies (fun x => assign.getD x false) l
abbrev NaeThreeSatInstance := ℕ × Cslib.Logic.PL.CNF
WantedExt/Complexity/NPComplete/NaeThreeSatWanted.lean:48
def Satisfies (assignment : Nat → Bool) (clause : CNFClause) : Prop :=
∃ literal ∈ clause, CNFLiteral.Satisfies assignment literal
CSLibExt/Logics/Propositional/CNF/Semantics.lean:45
def Satisfies (assignment : Nat → Bool) (literal : Nat × Bool) : Prop :=
assignment literal.1 = literal.2
CSLibExt/Logics/Propositional/CNF/Semantics.lean:32
Uses 5 · Used by 1
DefinitionNOT-ALL-EQUAL 3-SAT as a decision problem#✓fully proved
The decision problem NOT-ALL-EQUAL 3-SAT accepts a bitstring \(x\) exactly when \(x\) decodes, under the canonical bitstring encoding, to a NOT-ALL-EQUAL 3-SAT instance \((n, \varphi)\) that is well-formed and not-all-equal satisfiable. Every bitstring that decodes to no instance is rejected.
noncomputable def naeThreeSatDec :
MetaMathlibExt.ComplexityTheory.DecisionProblem := fun x =>
match MetaMathlibExt.BitstringEncoding.bitDecode
(α := NaeThreeSatInstance) x with
| some i => decide (WellFormed i ∧ NaeThreeSatFeasible 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 NaeThreeSatInstance := ℕ × Cslib.Logic.PL.CNF
WantedExt/Complexity/NPComplete/NaeThreeSatWanted.lean:48
def WellFormed (i : NaeThreeSatInstance) : Prop :=
(∀ clause ∈ i.2, clause.length = 3 ∧ ∀ l ∈ clause, l.1 < i.1)
WantedExt/Complexity/NPComplete/NaeThreeSatWanted.lean:51
def NaeThreeSatFeasible
(i : NaeThreeSatInstance) : Prop :=
∃ assign : List Bool, assign.length = i.1 ∧
∀ clause ∈ i.2, Cslib.Logic.PL.CNFClause.Satisfies (fun x => assign.getD x false) clause ∧
∃ l ∈ clause, ¬ Cslib.Logic.PL.CNFLiteral.Satisfies (fun x => assign.getD x false) l
WantedExt/Complexity/NPComplete/NaeThreeSatWanted.lean:55
Uses 14 · Used by 1
TheoremNOT-ALL-EQUAL 3-SAT is NP-complete#●ready to prove
The decision problem NOT-ALL-EQUAL 3-SAT over bitstrings belongs to NP, and every decision problem in NP has a polynomial-time many-one reduction to it.
public theorem_wanted naeThreeSat_npComplete :
naeThreeSatDec ∈ MetaMathlibExt.ComplexityTheory.NP ∧
∀ L : MetaMathlibExt.ComplexityTheory.DecisionProblem,
L ∈ MetaMathlibExt.ComplexityTheory.NP →
Cslib.CookLevin.PolyManyOneRed L naeThreeSatDec
noncomputable def naeThreeSatDec :
MetaMathlibExt.ComplexityTheory.DecisionProblem := fun x =>
match MetaMathlibExt.BitstringEncoding.bitDecode
(α := NaeThreeSatInstance) x with
| some i => decide (WellFormed i ∧ NaeThreeSatFeasible i)
| none => false
WantedExt/Complexity/NPComplete/NaeThreeSatWanted.lean:63
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), NOT-ALL-EQUAL 3-SAT; T. J. Schaefer, "The complexity of satisfiability problems" (1978).
Loading dependency explorer…
The dependency explorer needs JavaScript and its graph data.