NP-hardness of binary-index SAT
TheoremEvery clause of the Cook–Levin formula has one slot per variable#✓fully proved
Let \(E\) be an encoding of a machine \(M\), let \(x\) and \(Y\) be lists of input symbols of \(M\), let \(a\) be a symbol of its output stack, and let \(m, T \in \mathbb{N}\). Put \(H = m + (T + 1)d + 1\), where \(d\) is the window depth of \(M\). Then every clause of the Cook–Levin formula \(\Phi(E, x, Y, a, m, T)\) is a dense clause of length \((T + 1)(A + K H g)\), the number of variables of the layout of \(E\) at time bound \(T\) and height \(H\), where \(A\), \(K\) and \(g\) are the label/state block size, the number of stacks and the number of symbol codes of that layout.
theorem Phi_length {M : FinTM2} (E : Enc M) (x Ys : List (M.Γ M.k₀)) (acc : M.Γ M.k₁) (m T : ℕ) :
∀ c ∈ Phi E x Ys acc m T, c.length = E.layout.numVars T (capH m T (depth M))
structure Enc (M : FinTM2) where
/-- Number of stacks. -/
KK : ℕ
/-- Stack numbering. -/
kc : M.K → ℕ
/-- Inverse of the stack numbering. -/
kd : ℕ → M.K
kc_lt : ∀ k, kc k < KK
kd_kc : ∀ k, kd (kc k) = k
kc_kd : ∀ n < KK, kc (kd n) = n
/-- Number of (label, state) codes. -/
A0 : ℕ
⋯
CSLibExt/Computability/Complexity/CookLevin/Situation.lean:201
noncomputable def Phi (x Ys : List (M.Γ M.k₀)) (acc : M.Γ M.k₁) (m T : ℕ) : CNF :=
E.accFamily acc T (capH m T (depth M)) ++
(Shift.shFamily E.layout E.sa E.pl E.cn E.pu E.N T (capH m T (depth M)) ++
(Family.family E.layout E.la E.sa E.wa T (capH m T (depth M)) E.N ++
(Family.family E.layout E.la E.na E.wa T (capH m T (depth M)) E.N ++
E.initFamily x Ys m T (capH m T (depth M)))))
CSLibExt/Computability/Complexity/CookLevin/Assembly.lean:370
def capH (m T d : ℕ) : ℕ := m + (T + 1) * d + 1
CSLibExt/Computability/Complexity/CookLevin/Situation.lean:1420
def depth (M : FinTM2) : ℕ :=
letI := M.ΛFin
Finset.univ.sup fun l => ops (M.m l)
CSLibExt/Computability/Complexity/CookLevin/Situation.lean:231
Uses 36 · Used by 1
TheoremThe dense-to-binary translation is polynomial-time in the canonical encoding#✓fully proved
The translation of bit strings from the dense CNF encoding to the binary-index CNF encoding, as a function on all bit strings, is polynomial-time computable with respect to the canonical bitstring encoding of bit lists.
theorem isPolyTime_binConv : IsPolyTime ToBinary.binConv
def IsPolyTime {α β : Type} [BitstringEncoding α] [BitstringEncoding β]
(f : α → β) : Prop :=
IsPolyTimeWithEncoding (BitstringEncoding.toEncoding (α := α))
(BitstringEncoding.toEncoding (α := β)) f
MathlibExt/Computability/Complexity.lean:186
def binConv (w : List Bool) : List Bool := conv w.reverse false 0 0 0 []
CSLibExt/Computability/Complexity/DenseToBinaryConverter.lean:31
Uses 14 · Used by 1
TheoremEvery NP problem reduces to binary-index CNF-SAT#✓fully proved
Every decision problem \(L\) in NP has a polynomial-time many-one reduction to the language of bit strings that encode a satisfiable CNF formula in the binary-index encoding.
theorem satDec_npHard (L : DecisionProblem) (hL : L ∈ NP) :
Cslib.CookLevin.PolyManyOneRed L Cslib.CookLevin.satDec
abbrev DecisionProblem := List Bool → Bool
MathlibExt/Computability/Complexity.lean:170
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
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
noncomputable def satDec : MetaMathlibExt.ComplexityTheory.DecisionProblem :=
fun x => if x ∈ SATLang then true else false
CSLibExt/Computability/CookLevin.lean:391
Uses 54 · Used by 5
TheoremCook–Levin for binary-index CNF-SAT, given a polynomial-time verifier#✓fully proved
If the Boolean result of the SAT verifier, as a function of pairs (formula code, assignment), is computable in polynomial time, then the language of bit strings that encode a satisfiable CNF formula in the binary-index encoding is in NP, and every decision problem in NP has a polynomial-time many-one reduction to it.
theorem cook_levin_SAT_np_complete_of_isPolyTime
(h : IsPolyTime fun xw => (Cslib.CookLevin.satVerifier xw).ret) :
Cslib.CookLevin.satDec ∈ NP ∧
∀ L : DecisionProblem, L ∈ NP → Cslib.CookLevin.PolyManyOneRed L Cslib.CookLevin.satDec
def IsPolyTime {α β : Type} [BitstringEncoding α] [BitstringEncoding β]
(f : α → β) : Prop :=
IsPolyTimeWithEncoding (BitstringEncoding.toEncoding (α := α))
(BitstringEncoding.toEncoding (α := β)) f
MathlibExt/Computability/Complexity.lean:186
def satVerifier : List Bool × List Bool → TimeM Nat Bool := fun xw =>
match decodeCNF xw.1 with
| none => pure false
| some φ => checkCNF (varsOf φ) xw.2 φ
CSLibExt/Computability/SatTimeM.lean:103
noncomputable def satDec : MetaMathlibExt.ComplexityTheory.DecisionProblem :=
fun x => if x ∈ SATLang then true else false
CSLibExt/Computability/CookLevin.lean:391
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
Uses 17 · Used by 1
Loading dependency explorer…
The dependency explorer needs JavaScript and its graph data.