Presentation is loading. Please wait.

Presentation is loading. Please wait.

Cook-Levin Theorem Proof and Illustration Kwak, Nam-ju Applied Algorithm Laboratory KAIST 1 Applied Algorithm Lab. KAIST WSAC2010 Talk 11st, January, 2010.

Similar presentations


Presentation on theme: "Cook-Levin Theorem Proof and Illustration Kwak, Nam-ju Applied Algorithm Laboratory KAIST 1 Applied Algorithm Lab. KAIST WSAC2010 Talk 11st, January, 2010."— Presentation transcript:

1 Cook-Levin Theorem Proof and Illustration Kwak, Nam-ju Applied Algorithm Laboratory KAIST 1 Applied Algorithm Lab. KAIST WSAC2010 Talk 11st, January, 2010

2 Contents NP NP-complete SAT Problem A Characteristic of NP-complete Cook-Levin Theorem Proof of Cook-Levin Theorem Illustration Corollary: 3SAT ∈ NPC 2 Applied Algorithm Lab. KAIST

3 NP Definition  NP is the class of languages that have polynomial time verifiers. Definition (informal)  A verifier V for a language A is an algorithm which accepts a given input w to A if a corresponding certificate or a proof c exists. 3 Applied Algorithm Lab. KAIST

4 NP Theorem  A language is in NP iff it is decided by some nondeterministic polynomial time Turing machine. 4 Applied Algorithm Lab. KAIST

5 NP-complete Definition  A language B is NP-complete if B ∈ NP, and ∀ A ∈ NP, A≤ P B. 5 Applied Algorithm Lab. KAIST

6 NP-complete Examples  SAT, 3SAT, CLIQUE, VERTEX-COVER, HAMPATH, SUBSET-SUM, and etc. 6 Applied Algorithm Lab. KAIST

7 SAT Problem Definition  Boolean variables: variables that can take on the values TRUE and FALSE  Boolean operations: AND, OR, and NOT  Boolean formula: an expression involving Boolean variable and operations Applied Algorithm Lab. KAIST 7

8 SAT Problem Definition  satisfiable: if some assignment of 0s and 1s to the variables make the formula evaluate to 1 Example of a satisfiable Boolean formula  φ=(¬x ∧ y) ∨ (x ∧ ¬z)  x=0, y=1, and z=0 Applied Algorithm Lab. KAIST 8

9 SAT Problem Definition (SAT Problem)  SAT = { |φ is a satisfiable Boolean formula}. Given a Boolean formula, is it satisfiable? Applied Algorithm Lab. KAIST 9

10 A Characteristic of NP-complete Theorem  If B ∈ NPC and B≤ P C for C ∈ NP, then C ∈ NPC. Is there a fundamental problem for the chain of polynomial time reducibility?  P1≤ P P2≤ P … ≤ P Pn≤ P (?) 10 Applied Algorithm Lab. KAIST

11 Cook-Levin Theorem  SAT ∈ NPC P1≤ P P2≤ P … ≤ P Pn≤ P SAT 11 Applied Algorithm Lab. KAIST

12 Proof of Cook-Levin Theorem What to prove is …  SAT ∈ NP (very clear, not treated here)  ∀ A ∈ NP, A≤ P SAT We would show that for each language A ∈ NP with a given input w to it, it is possible to produce a Boolean formula which is satisfiable if w ∈ A. Definition  A≤ P B if ∃ f such that w ∈ A ⇔ f(w) ∈ B and f is polynomial time computable. Applied Algorithm Lab. KAIST 12

13 Proof of Cook-Levin Theorem Applied Algorithm Lab. KAIST 13 NP A Pick one. input w SAT Input Boolean formula φ φ ∈ SAT or not?w ∈ A or not? Let’s construct this Boolean formula!!

14 Proof of Cook-Levin Theorem Proof idea  For each language A in NP, with a given input w for A, produce a Boolean formula φ that simulates the deciding NP Turing machine for A on input w.  Check if the Boolean formula is satisfiable. 14 Applied Algorithm Lab. KAIST

15 Proof of Cook-Levin Theorem w ∈ A? w A NP Turing machine Boolean formula φ If satisfiable, w ∈ A; otherwise, w ∉ A. given transformation SAT problem Focus on this step. 15 Applied Algorithm Lab. KAIST

16 Proof of Cook-Levin Theorem Proof idea (cont.)  If w ∈ A, there exists a series of configurations that results in the accept state, given w as the input of the Turing machine.  We would construct a Boolean formula which is satisfiable if the Turing machine accepts with the input w. 16 Applied Algorithm Lab. KAIST

17 Proof of Cook-Levin Theorem FYI: Turing machine notation example  δ(q 0,0)={(q 1,x,R)}, δ(q 1,1)={(q 1,y,R)}, δ(q 1, ⊔ )={(q accept, ⊔,L)}  This Turing machine accepts {01+}  With 0111 as an input, q ⊔ xq ⊔ xyq 1 11 ⊔ xyyq 1 1 ⊔ xyyyq 1 ⊔ xyyyq a ⊔ Applied Algorithm Lab. KAIST 17

18 Proof of Cook-Levin Theorem Proof  w: input  A: language  N: NP Turing machine that decides A Assume that N decides whether w ∈ A in n k steps, for some constant k. 18 Applied Algorithm Lab. KAIST

19 Proof of Cook-Levin Theorem Proof (cont.)  “n k ×n k -cell”tableau for N on input w #q0q0 w1w1 w2w2 …wnwn ⊔ … ⊔ # ## ## ## nknk nknk start configuration second configuration n k th configuration 19 Applied Algorithm Lab. KAIST

20 Proof of Cook-Levin Theorem Proof (cont.)  A variable could be represented as x i,j,s.  x i,j,s : true if cell[i,j] is s; otherwise, false.  cell[i,j]: the cell located on the ith row and the jth column. 20 Applied Algorithm Lab. KAIST

21 Proof of Cook-Levin Theorem Proof (cont.)  The tableau, without any restriction, can contain many invalid series of configurations.  e.g. cells containing multiple symbols, not starting with the input w and start state q 0, neighbor configurations not corresponding the transition rules, not resulting in the accept state, and etc. 21 Applied Algorithm Lab. KAIST #xw1w1 q3q3 …wnwn ⊔ … ⊔ # ## ## ## #q0q0 w1w1 w2w2 …wnwn ⊔ … ⊔ # #xxq1q1 …wnwn ⊔ … ⊔ # ## ## #q0q0 w1w1 w2w2 …wnwn ⊔ … ⊔ # #xq1q1 w2w2 …wnwn ⊔ … ⊔ # #xxq1q1 …wnwn ⊔ … ⊔ # # ⊔⊔⊔ … ⊔⊔ … ⊔ # # ⊔⊔⊔ … ⊔⊔ … ⊔ # #q0q1q0q1 w1w1 w2w2 …wnwn ⊔ … ⊔ # ## ## ##

22 Proof of Cook-Levin Theorem Proof (cont.)  Produce a Boolean formula which forces the tableau to be valid and result in the accept state. 22 Applied Algorithm Lab. KAIST

23 Proof of Cook-Levin Theorem Proof (cont.)  One cell can contain exactly one symbol among a state, a tape alphabet, and a #. (φ cell )  The first configuration should be corresponding to input w and the start state q 0. (φ start )  A configuration is derivable from the immediately previous configuration according to the transition rule of the Turing machine. (φ move )  There should exist a cell containing the accept state. (φ accept )  φ=φ cell ∧ φ start ∧ φ move ∧ φ accept 23 Applied Algorithm Lab. KAIST

24 Proof of Cook-Levin Theorem Proof (cont.)  φ=φ cell ∧ φ start ∧ φ move ∧ φ accept Each cell contain at least one symbol. Each cell contain no more than one different symbol. Here, C=Q ∪ Γ ∪ {#} where Q and Γ are the state set and tape alphabet of the Turing machine N. 24 Applied Algorithm Lab. KAIST

25 Proof of Cook-Levin Theorem Proof (cont.)  φ=φ cell ∧ φ start ∧ φ move ∧ φ accept Each cell of the first row has a symbol corresponding to the start configuration where the input is w. 25 Applied Algorithm Lab. KAIST

26 Proof of Cook-Levin Theorem Proof (cont.)  φ=φ cell ∧ φ start ∧ φ move ∧ φ accept At least one cell is the accept state. 26 Applied Algorithm Lab. KAIST

27 Proof of Cook-Levin Theorem Proof (cont.)  φ=φ cell ∧ φ start ∧ φ move ∧ φ accept  φ move checks whether every 2×3 window is legal according to the transition rule of the Turing machine. 27 #…# ## ## …… #…# Applied Algorithm Lab. KAIST #q0q0 xyyyy# #zq1q1 yyyy#

28 Proof of Cook-Levin Theorem Proof (cont.)  φ=φ cell ∧ φ start ∧ φ move ∧ φ accept  For example, δ(q 1,a)={(q 1,b,R)}, δ(q 1,b)={(q 2,c,L), (q 2,a,R)} aq1q1 b q2q2 ac aaq1q1 aab #ba #ba some examples of legal 2×3 windows aba aaa aq1q1 b q1q1 aa bq1q1 b q2q2 bq2q2 some examples of illegal 2×3 windows 28 Applied Algorithm Lab. KAIST

29 Proof of Cook-Levin Theorem Proof (cont.)  φ=φ cell ∧ φ start ∧ φ move ∧ φ accept  When S i,j is the set of legal (i, j)-windows and U i,j is the set of all the (i, j)-windows,  S i,j ⊆ U i,j, |U i,j |=|C| 6 → |S i,j |≤|C| 6  |S|=|ΣS i,j |≤n 2k |C| 6  That is, the set of legal windows is finite. 29 Applied Algorithm Lab. KAIST

30 Proof of Cook-Levin Theorem Proof (cont.)  φ=φ cell ∧ φ start ∧ φ move ∧ φ accept 30 Applied Algorithm Lab. KAIST That is, for all legal (i, j)-windows, which is represented as … a1a1 a2a2 a3a3 a4a4 a5a5 a6a6

31 Proof of Cook-Levin Theorem Proof (cont.) φ=φ cell ∧ φ start ∧ φ move ∧ φ accept Now, we get φ as we wished. If φ is satisfiable, w ∈ A. That is, to see if w ∈ A, we just need to check whether φ is satisfiable or not. It is just a SAT problem. 31 Applied Algorithm Lab. KAIST

32 Proof of Cook-Levin Theorem What to prove is … (restated)  SAT ∈ NP (very clear, not treated here)  ∀ A ∈ NP, A≤ P SAT Definition (restated)  A≤ P B if ∃ f such that w ∈ A ⇔ f(w) ∈ B and f is polynomial time computable. What we’ve shown is …  w, A, and w ∈ A  f(w)=φ, B=SAT, and φ=f(w) ∈ B=SAT  w ∈ A ⇔ φ ∈ SAT  ∴ A≤ P SAT Applied Algorithm Lab. KAIST 32

33 Illustration N=(Q, Σ, Γ, δ, q 0, q accept )  Q={q 0, q 1, q accept }  Σ={0, 1}, Γ={0, 1, ⊔ }  δ(q 0,0)={(q 1,0,R)}  δ(q 1,1)={(q 1,1,R)}  δ(q 1, ⊔ )={(q accept, ⊔,L)} A=L(N)={01+}={01, 011, 0111, 01111, …} w=0111 Then, w ∈ A? 33 Applied Algorithm Lab. KAIST

34 Illustration N can decide in n 2 steps where n=|w|. Therefore n 2 is 16. C={q 0, q 1, q accept, 0, 1, ⊔, #} #q0q ⊔ … ⊔ # ## ## ## 34 16×16 tableau Applied Algorithm Lab. KAIST

35 Illustration 35 Applied Algorithm Lab. KAIST

36 Illustration 36 Applied Algorithm Lab. KAIST

37 Illustration 37 Applied Algorithm Lab. KAIST

38 Illustration For φ move, find out all the legal windows. 38 #q0q0 0 #0q1q1 q0q0 00 0q1q1 0 q0q0 01 0q1q1 1 … 0q1q1 1 01q1q1 1q1q1 1 11q1q1 q1q1 10 1q1q1 0 … 11q1q1 11 ⊔ 1q1q1 ⊔ 1 ⊔ q acc q1q1 ⊔⊔ ⊔ ⊔ q1q1 11 1q1q1 1 … ⊔⊔⊔ ⊔⊔ … … No more than n 2k |C| 6 =4 2*2 4 6 =4 10 legal windows exist. (finite) Applied Algorithm Lab. KAIST

39 Illustration 39 Applied Algorithm Lab. KAIST

40 Illustration Now, we get φ=φ cell ∧ φ start ∧ φ move ∧ φ accept. 40 Applied Algorithm Lab. KAIST ∧

41 Illustration 41 Solve a SAT problem with this Boolean formula, φ. If satisfiable, w=0111 ∈ A={01+}. (Actually, it is right.) Applied Algorithm Lab. KAIST ∧

42 Corollary: 3SAT ∈ NPC CNFs can be converted into CNFs with three literals per clause (as explained soon). At first, convert φ cell, φ start, φ move, and φ accept into CNF. Applied Algorithm Lab. KAIST 42

43 Corollary: 3SAT ∈ NPC φ cell, φ start, and φ accept are already in CNF. Applied Algorithm Lab. KAIST 43

44 Corollary: 3SAT ∈ NPC φ move is converted into CNF using the distributive laws. To CNFs have 3 literals per clause  For each clause with less than 3 literals, do literal replication.  For each clause with more than 3 literals, split it with new variables. Applied Algorithm Lab. KAIST 44

45 Corollary: 3SAT ∈ NPC Examples  (a 1 ∨ a 2 )≡(a 1 ∨ a 2 ∨ a 2 )  (a 1 ∨ a 2 ∨ a 3 ∨ a 4 )≡(a 1 ∨ a 2 ∨ z) ∧ (¬z ∨ a 3 ∨ a 4 )  (a 1 ∨ a 2 ∨ a 3 ∨ a 4 ∨ a 5 )≡ (a 1 ∨ a 2 ∨ z 1 ) ∧ (¬z 1 ∨ a 3 ∨ z 2 ) ∧ (¬z 2 ∨ a 4 ∨ a 5 ) Applied Algorithm Lab. KAIST 45

46 Corollary: 3SAT ∈ NPC Hence, a SAT problem is able to converted into a equivalent 3SAT problem (in polynomial time). That is, SAT≤ P 3SAT. Since SAT ∈ NPC, considering the definition of NPC, 3SAT ∈ NPC, too. Applied Algorithm Lab. KAIST 46

47 Conclusion Theorem (restated)  SAT ∈ NPC  3SAT ∈ NPC All the NP problems are polynomial time reducible into SAT. 47 Applied Algorithm Lab. KAIST Picture from

48 Q&A Please, ask questions, if any. 48 Applied Algorithm Lab. KAIST

49 Thank you! Contents covered are based on Introduction to the Theory of Computation, 2 nd ed. written by Michael Sipser. The slide theme and the background image are from Applied Algorithm Lab. KAIST 49


Download ppt "Cook-Levin Theorem Proof and Illustration Kwak, Nam-ju Applied Algorithm Laboratory KAIST 1 Applied Algorithm Lab. KAIST WSAC2010 Talk 11st, January, 2010."

Similar presentations


Ads by Google