190 likes | 349 Views
Fall 2010. The Chinese University of Hong Kong. CSCI 3130: Formal languages and automata theory. The Cook-Levin Theorem. Andrej Bogdanov http://www.cse.cuhk.edu.hk/~andrejb/csc3130. The class NP. A verifier for L is a TM V such that s is a potential solution for z
E N D
Fall 2010 The Chinese University of Hong Kong CSCI 3130: Formal languages and automata theory The Cook-Levin Theorem Andrej Bogdanov http://www.cse.cuhk.edu.hk/~andrejb/csc3130
The class NP • A verifier for L is a TM V such that • s is a potential solution for z • We say V runs in polynomial time if on every input z, it runs in time polynomial in |z| (for every s) z ∈ L V accepts 〈z, s〉 for some s NP is the class of all languages that have polynomial-time verifiers
NP-complete problems NP-complete DOM SET MIN COVER VERTEX COVER SUBSET SUM IND SET HAM CYCLE HAM PATH PARTITION CLIQUE 3SAT NP SAT P
Polynomial-time reductions • Language Lpolynomial-time reduces to L’ if there exists a polynomial-time computable map R that takes an instance x of L into instance y of L’ s.t. x ∈ L if and only if y ∈ L’ L (CLIQUE) L’ (IS) R (G, k) x y (G’, k’) x ∈ L y ∈ L’ (G has clique of size k) (G’ has IS of size k’)
NP-completeness • A language C is NP-complete if: • Cook-Levin Theorem: 1. C is in NP, and 2.For every L in NP, L reduces to C. C NP SAT is NP-complete P
SAT and 3SAT SAT = {〈f〉: fis a satisfiable Boolean formula} ((x1∨x2 ) ∧ (x1∨x2)) ∨ ((x1∨(x2 ∧ x3)) ∧x3) 3SAT = {〈f〉: fis a satisfiable 3CNF formula} (x1∨x2∨x2 ) ∧ (x2∨x3∨x4) ∧ (x2∨x3∨x5) ∧ (x1∨x5∨x5)
The Cook-Levin Theorem • To show this, we need a reduction R such that: Every L∈NP reduces to SAT R z Boolean formula f f is satisfiable z ∈ L
NP-completeness of SAT • All we know: L has a poly-time verifierV • Look at the computation tableau of V on input 〈z, s〉 S z | s V … q0 z1 # # S-th configuration symbol at time T # T … qacc # #
NP-completeness of SAT S … q0 n = length of z x1 # # # height of tableau is nc for some constantc T u width is at most nc k possible tableau symbols … qacc # # true, if the (T, S) cell of tableau contains u 1 ≤ S ≤ nc xT, S, u = 1 ≤ T ≤ nc false, if not 1 ≤ u ≤ k
NP-completeness of SAT • We will design a formula f such that: R z Boolean formula f f is satisfiable z ∈ L variables of f : xT, S, u assignment to xT, S, u way to fill up the tableau accepting computation tableau satisfying assignment f is satisfiable V accepts 〈z, s〉for some s
NP-completeness of SAT • We want to construct (in time O(n2c)) a formula f : true, if the (T, S) cell of tableau contains u 1 ≤ S ≤ nc xT, S, u = 1 ≤ T ≤ nc false, if not 1 ≤ u ≤ k true, if the xs represent a valid and accepting tableau f(x1, 1, 1, ..., xnc, nc, k) = false, if not Symbols in computation tableau come from the alphabet G∪Q∪{#} ={a1,...,ak}
NP-completeness of SAT S f = fcell ∧ f0 ∧ fmove ∧ facc … q0 z1 # # # T fcell: “Every cell contains exactly one symbol” u f0: “The first row is #q0z|s☐...☐#” for some s … qacc # # fmove: “The moves between rows follow the transitions of V” facc: “qacc appears somewhere in the last row”
NP-completeness of SAT • Desired meaning • Implementation: fcell: “Every cell contains exactly one symbol” or: “Exactly one of xS, T, 1 ∨ ... ∨ xS, T, k is true” fcell = fcell1, 1 ∧ ... ∧ fcellnc,nc where fcellT, S = (xT, S, 1 ∨ ... ∨ xT, S, k) ∧ (xT, S, 1 ∧ xT, S, 2) ∧ (xT, S, 1 ∧ xT, S, 3) ∧ ... ∧ (xT, S, k-1 ∧ xT, S, k) at least one symbol no cell containstwo or more symbols
NP-completeness of SAT • Desired meaning • Implementation: f0: “The first row is #q0z1z2...zn|s1s2...sm☐...☐# for some (possible solution) s1s2...sm” f0 = x1, 1, # ∧ x1, 2, q0 ∧ x1, 3, z1 ∧ ... ∧ x1, n+2,zn ∧ x1, n+3, | ∧ x1, nc, #
NP-completeness of SAT • Desired meaning • Implementation: facc: “qacc appears somewhere in the last row” facc = xnc, 1, qacc ∨ xnc, 2, qacc ∨ ... ∨ xnc, nc, qacc
Valid and invalid windows valid windows invalid windows … 6a3b0x0 … … 0a6b0x0…0 … 6q2a0b0 … … 0a6b0q2 …0 … 6a3q2a0 … … 0q5a6x0…0 … 6q2q2a0 … … 0q2q2x3…0 q2 a/xL … 6#3b0a0 … … 0#6b0q5 …0 … 6a3q2a0 … … 0q5a6b0…0 q5 … 6a3a0☐0 … … 0x6a0☐0…0 … 6#3q2a0 … … 0q5#6x0…0
NP-completeness of SAT • Desired meaning • Implementation: q0 b a # # a2 a3 a1 # fmove: “The moves between rows follow transitions of V” a4 a5 a6 # fmove2, 2 … qacc # # fmove = fmove1, 1 ∧ ... ∧ fmovenc-3, nc-3 ∨ fmoveT, S = (xT, S, a1 ∧ xT, S+1, a2 ∧ xT, S+2, a3 ∧ xT+1, S, a4 ∧ xT+1, S+1, a5 ∧ xT+2, S+1, a6) over all valid windows a1 a2 a3 a4 a5 a6
NP-completeness of SAT R z Boolean formula f ✔ f is satisfiable z ∈ L Let V be a poly-time verifier TM for L. R := On input z, Construct the formulas fcell,f0,fmove, andfacc Output the formula f = fcell ∧ f0 ∧ fmove ∧ facc. Then R is computable in time O(n2c) and V accepts z if and only if f is satisfiable.
NP-complete problems NP-complete DOM SET MIN COVER VERTEX COVER SUBSET SUM IND SET HAM CYCLE HAM PATH PARTITION CLIQUE 3SAT NP SAT P