1-in-3 SAT
Abbreviation1-in-3-SAT instances#✓fully proved
A 1-in-3-SAT instance is a pair \((n, \varphi)\) of a natural number \(n\), the number of variables, and a CNF formula \(\varphi\).
Any CNF formula is allowed here; that \(\varphi\) has three literals per clause, all over the variables below \(n\), is required separately by well-formedness.
abbrev OneInThreeSatInstance := ℕ × Cslib.Logic.PL.CNF
abbrev CNF := List CNFClause
CSLibExt/Logics/Propositional/CNF/Basic.lean:33
Uses 1 · Used by 3
DefinitionWell-formed 1-in-3-SAT instances#✓fully proved
A 1-in-3-SAT instance \((n, \varphi)\) is well formed when every clause of \(\varphi\) has exactly three literals and every literal \((x, b)\) in it has variable index \(x < n\).
def WellFormed (i : OneInThreeSatInstance) : Prop :=
(∀ clause ∈ i.2, clause.length = 3 ∧ ∀ l ∈ clause, l.1 < i.1)
abbrev OneInThreeSatInstance := ℕ × Cslib.Logic.PL.CNF
WantedExt/Complexity/NPComplete/OneInThreeSatWanted.lean:47
Uses 3 · Used by 1
DefinitionFeasible 1-in-3-SAT instances#✓fully proved
A 1-in-3-SAT instance \((n, \varphi)\) is feasible when there is an assignment \(v\) of truth values to the variables \(0, \dots, n - 1\), with variables \(y \ge n\) read as false, such that every clause of \(\varphi\) has exactly one position holding a literal \((y, b)\) with \(v(y) = b\).
def OneInThreeSatFeasible
(i : OneInThreeSatInstance) : Prop :=
∃ assign : List Bool, assign.length = i.1 ∧
∀ clause ∈ i.2, ∃ k < clause.length,
Cslib.Logic.PL.CNFLiteral.Satisfies (fun x => assign.getD x false)
(clause.getD k (0, false)) ∧
∀ j < clause.length,
Cslib.Logic.PL.CNFLiteral.Satisfies (fun x => assign.getD x false)
(clause.getD j (0, false)) → j = k
abbrev OneInThreeSatInstance := ℕ × Cslib.Logic.PL.CNF
WantedExt/Complexity/NPComplete/OneInThreeSatWanted.lean:47
def Satisfies (assignment : Nat → Bool) (literal : Nat × Bool) : Prop :=
assignment literal.1 = literal.2
CSLibExt/Logics/Propositional/CNF/Semantics.lean:32
Uses 4 · Used by 1
DefinitionThe 1-in-3-SAT decision problem#✓fully proved
The 1-in-3-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 exactly three literals, every literal \((y, b)\) of \(\varphi\) has variable index \(y < n\), and some assignment \(v\) of truth values to the variables \(0, \dots, n - 1\) makes exactly one position of every clause hold a literal \((y, b)\) with \(v(y) = b\). It rejects every bitstring that does not decode.
noncomputable def oneInThreeSatDec :
MetaMathlibExt.ComplexityTheory.DecisionProblem := fun x =>
match MetaMathlibExt.BitstringEncoding.bitDecode
(α := OneInThreeSatInstance) x with
| some i => decide (WellFormed i ∧ OneInThreeSatFeasible 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 OneInThreeSatInstance := ℕ × Cslib.Logic.PL.CNF
WantedExt/Complexity/NPComplete/OneInThreeSatWanted.lean:47
def WellFormed (i : OneInThreeSatInstance) : Prop :=
(∀ clause ∈ i.2, clause.length = 3 ∧ ∀ l ∈ clause, l.1 < i.1)
WantedExt/Complexity/NPComplete/OneInThreeSatWanted.lean:50
def OneInThreeSatFeasible
(i : OneInThreeSatInstance) : Prop :=
∃ assign : List Bool, assign.length = i.1 ∧
∀ clause ∈ i.2, ∃ k < clause.length,
Cslib.Logic.PL.CNFLiteral.Satisfies (fun x => assign.getD x false)
(clause.getD k (0, false)) ∧
∀ j < clause.length,
Cslib.Logic.PL.CNFLiteral.Satisfies (fun x => assign.getD x false)
(clause.getD j (0, false)) → j = k
WantedExt/Complexity/NPComplete/OneInThreeSatWanted.lean:54
Uses 14 · Used by 1
Theorem1-IN-3-SAT is NP-complete#●ready to prove
The 1-in-3-SAT decision problem belongs to NP, and every decision problem in NP reduces to it by a polynomial-time many-one reduction.
public theorem_wanted oneInThreeSat_npComplete :
oneInThreeSatDec ∈ MetaMathlibExt.ComplexityTheory.NP ∧
∀ L : MetaMathlibExt.ComplexityTheory.DecisionProblem,
L ∈ MetaMathlibExt.ComplexityTheory.NP →
Cslib.CookLevin.PolyManyOneRed L oneInThreeSatDec
noncomputable def oneInThreeSatDec :
MetaMathlibExt.ComplexityTheory.DecisionProblem := fun x =>
match MetaMathlibExt.BitstringEncoding.bitDecode
(α := OneInThreeSatInstance) x with
| some i => decide (WellFormed i ∧ OneInThreeSatFeasible i)
| none => false
WantedExt/Complexity/NPComplete/OneInThreeSatWanted.lean:66
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), ONE-IN-THREE 3-SAT; T. J. Schaefer, "The complexity of satisfiability problems" (1978).
Uses 5
Loading dependency explorer…
The dependency explorer needs JavaScript and its graph data.