Cook–Levin Theorem CSCI 3130 Formal Languages and Automata Theory Siu On CHAN Fall 2018 Chinese University of Hong Kong 1/18
NP-completeness NP-complete P NP Theorem (Cook–Levin) Every language in NP polynomial-time reduces to SAT 2/18 • SAT • IS • Clique • • PATH • L 01 •
Cook–Levin theorem Need to fjnd a polynomial-time reduction R such that L SAT z R 3/18 Every L ∈ NP polynomial-time reduces to SAT Boolean formula ϕ z ∈ L ← → ϕ is satisfjable
NP-completeness of SAT All we know: L has a polynomial-time verifjer V S T . . . V z s 0110#10 V 4/18 Tableau of computation history of q 0 0 1 1 0 # 1 0 � 0 q 1 1 1 0 # 1 0 � z ∈ L if and only if V accepts � z , s � for some s 1 q acc 0 …
Tableau of computation history S otherwise False True k possible tableau symbols u 5/18 . T . . q 0 0 1 1 0 # 1 0 � n = length of z 0 q 1 1 1 0 # 1 0 � height of tableau is O ( n c ) for some constant c width of tableau is O ( n c ) 1 q acc 0 … � if cell ( T , S ) contains symbol u x T , S , u =
Reduction to SAT L accepting computation history satisfying assignment assignment to tableau symbols 6/18 SAT R z Boolean formula ϕ z ∈ L ← → ϕ is satisfjable Will design a formula ϕ such that variables of ϕ x T , S , u ≈ assignment to x T , S , u ↔ ↔ V accepts � z , s � for some s ϕ is satisfjable
Reduction to SAT cell . . . rows follow the transitions of V legal and accepting computation history 7/18 Will construct in O ( n 2 c ) time a formula ϕ such that ϕ ( x ) is True precisely when the assignment to { x T , S , u } represents q 0 0 1 1 0 # 1 0 � ϕ = ϕ cell ∧ ϕ init ∧ ϕ move ∧ ϕ acc 0 q 1 1 1 0 # 1 0 � ϕ cell : Exactly one symbol in each ϕ init : First row is q 0 z # s for some s ϕ move : Moves between adjacent ϕ acc : Last row contains q acc 1 q acc 0 …
8/18 . where no two symbols in one cell at least one symbol . . ϕ cell : exactly one symbol per cell ϕ cell = ϕ cell , 1 , 1 ∧ · · · ∧ ϕ cell , #rows , #cols ϕ cell , T , S = ( x T , S , 1 ∨ · · · ∨ x T , S , k ) ∧ ( x T , S , 1 ∧ x T , S , 2 ) ∧ ( x T , S , 1 ∧ x T , S , 3 ) ∧ ( x T , S , k − 1 ∧ x T , S , k )
First row is q 0 z # s for some s 9/18 ϕ init and ϕ acc ϕ init = x 1 , 1 , q 0 ∧ x 1 , 2 , z 1 ∧ · · · ∧ x 1 , n + 1 , z n ∧ x 1 , n + 2 , # Last row contains q acc somewhere ϕ acc = x # rows , 1 , q acc ∧ · · · ∧ x #rows , #cols , q acc
Legal and illegal transitions windows q 6 ab … … … aba ab q 6 … … … … a q 3 a … legal windows … … … … … … … a q 3 a a q 6 x … … … q 3 q 3 x q 3 q 3 a … illegal windows … … abx abx … … … … q 3 ab ab q 3 … … … … a q 3 a q 6 ax … … q 3 q 6 a/xL … 10/18 aa � xa �
11/18 legal b 1 b 2 b 3 a 1 a 2 a 3 ϕ move : moves between rows follow transitions of V q 0 0 1 1 0 # 1 0 � 0 q 1 1 1 0 # 1 0 � a 1 a 2 a 3 b 1 b 2 b 3 1 q acc 0 … ϕ move = ϕ move , 1 , 1 ∧ · · · ∧ ϕ move , #rows − 1 , #cols − 2 � � x T , S , a 1 ∧ x T , S + 1 , a 2 ∧ x T , S + 2 , a 3 ∧ � ϕ move , T , S = x T + 1 , S , b 1 ∧ x T + 1 , S + 1 , b 2 ∧ x T + 1 , S + 2 , b 3
NP-completeness of SAT z R Let V be a polynomial-time verifjer for L 12/18 Boolean formula ϕ z ∈ L ← → ϕ is satisfjable R = On input z , 1. Construct the formulas ϕ cell , ϕ init , ϕ move , ϕ acc 2. Output ϕ = ϕ cell ∧ ϕ init ∧ ϕ move ∧ ϕ acc R takes time O ( n 2 c ) V accepts � z , s � for some s if and only if ϕ is satisfjable
NP-completeness: More examples
Cover for triangles k -cover for triangles: k vertices that touch all triangles Has 2 -cover for triangles? Yes Has 1 -cover for triangles? No, it has two vertex-disjoint triangles TRICOVER is NP-complete 13/18 TRICOVER = {� G , k � | G has a k -cover for triangles }
Step 1: TRICOVER is in NP A F D G E C B 14/18 What is a solution for TRICOVER? 2. Otherwise, accept vertices A subset of vertices like { D , F } V = On input � G , k , S � , where S is a set of k 1. For every triple ( u , v , w ) of vertices: If ( u , v ) , ( v , w ) , ( w , u ) are all edges in G : If none of u , v , w are in S , reject Running time = O ( n 3 )
Step 2: Some NP-hard problem reduces to TRICOVER Some vertex in every triangle is covered R vertex cover in G 15/18 VC = {� G , k � | G has a vertex cover of size k } Some vertex in every edge is covered TRICOVER = {� G , k � | G has a k -cover for triangles } Idea: replace edges by triangles − → cover for triangles in G ′
16/18 VC polynomial-time reduces to TRICOVER R = On input � G , k � , where graph G has n vertices and m edges, 1. Construct the following graph G ′ : G ′ has n + m vertices: v 1 , . . . , v n are vertices from G introduce a new vertex u ij for every edge ( v i , v j ) of G For every edge ( v i , v j ) of G : include edges ( v i , v j ) , ( v i , u ij ) , ( u ij , v j ) in G ′ 2. Output � G ′ , k � Running time is O ( n + m )
Step 3: Argue correctness (forward) G has a k -vertex cover S old triangles from G are covered 17/18 � G , k � ∈ VC ⇒ � G ′ , k � ∈ TRICOVER ⇒ G ′ has a k -triangle cover S new triangles in G ′ also covered
some vertices of S Step 3: Argue correctness (backward) Some vertices in S may not come from G ! still cover the same triangle 18/18 � G , k � ∈ VC ⇐ � G ′ , k � ∈ TRICOVER ⇐ G has a k -vertex cover S ′ G ′ has a k -triangle cover S S ′ is obtained after moving Since S ′ covers all triangles But we can move them and in G ′ , it covers all edges in G
Recommend
More recommend