Presentation is loading. Please wait.

Presentation is loading. Please wait.

1 The Cook-Levin Theorem Zeph Grunschlag. 2 Announcements Last HW due Thursday Please give feedback about course at oracle.seas.columbia.edu/wces oracle.seas.columbia.edu/wces.

Similar presentations


Presentation on theme: "1 The Cook-Levin Theorem Zeph Grunschlag. 2 Announcements Last HW due Thursday Please give feedback about course at oracle.seas.columbia.edu/wces oracle.seas.columbia.edu/wces."— Presentation transcript:

1 1 The Cook-Levin Theorem Zeph Grunschlag

2 2 Announcements Last HW due Thursday Please give feedback about course at oracle.seas.columbia.edu/wces oracle.seas.columbia.edu/wces

3 3 Agenda Proof from definition that CSAT is NP- complete (Cook-Levin Theorem) CSAT  P 3SAT so 3SAT is NP-complete

4 4 Notation for NTM Branching We need a way of dealing with all the possible choices that a non-deterministic TM can take at any point of the computation. Every NTM has a finite maximum on the number of choices possible, called the branching factor and denoted by b. Q: What is b for the following? 01 3 2 a|b  R bRbR LL

5 5 Notation for NTM Branching A: b= 2. This means that computation trees are binary: 01 3 2 a|b  R bRbR LL 0ababa a0baba ab0abaab1aba aba0ba abab0aabab1a aba2ba crash ababa0  crash ababa2  abab3a 

6 6 Notation for NTM Branching Given a state q and tape-symbol a in a NTM,  (q,a ) is a set of possible state-symbol-direction outputs. Order this set and let the k ’th possibility be denoted by: where q’, a’ and D are the transition’s output. When less than k possibilities were defined, just add transitions that go directly to the reject state and write blank: Q: What are below? 01 3 2 bRbRa|b  R LL

7 7 Notation for NTM Branching A: 01 3 2 bRbRa|b  R LL

8 8 Boolean Uniqueness Expression Let’s give some handy boolean expression in conjunctive normal form: The uniqueness expression U says that exactly one of its arguments is true: Herestands for the conjunction over all possible i,j. Q: Why is each a 2-clause?

9 9 Boolean Uniqueness Expression A: and are logically equivalent. Q: What is the size of U in terms of the number of variables?

10 10 Boolean Uniqueness Expression A: O (n 2 ) It will be convenient also to define U over a range of variable. For example we could express instead by:

11 11 Cook-Levin Theorem THM: Suppose we are given a NTM N and a string w of length n which is decided by N in f (n) or fewer nondeterministic steps. Then there is an explicit cnf formula  of length O (f (n) 3 ) which satisfiable iff N accepts w. In particular, when f (n) is a polynomial,  has polynomial length in terms of n so that every language in NP reduces to CSAT in polynomial time. Thus CSAT is NP-hard. Finally, as CSAT is in NP, CSAT is NP-complete.

12 12 Confusing Indices The most confusing thing about the proof of the Cook-Levin Theorem are all the indices. We use the following conventions: a –index for letters in tape alphabet q –index for NTM states i –index for tape cells t –index for computation step (time) k –index for branching choice Q: How many choices for each index?

13 13 Confusing Indices A: The number of choices are a : |  | the size of tape alphabet q : |Q  | the number of states i : f (n), since ranges from 1 to f (n) t : f (n)+1, since ranges from 0 to f (n) k : b, since ranges from 1 to branching factor b

14 14 Variables for Simulating NTM Computation T-variables will track the possible symbols on the tape cells at each step in computation T t,i,a = true iff at time t, i’ th cell reads a S-variables will track the active state at each step in computation S t,q = true iff at time t in state q

15 15 Variables for Simulating NTM Computation H-variables gives the head’s position H t,i = true iff at time t reading i’ th cell C-variables gives the nondeterministic choice at each step in computation C t,k = true iff at time t +1 take choice k

16 16 Boolean Expressions for Simulating NTM Computation Initialize the NTM. Insist that at time 0: 1) TM should be in the start state 2) Given input w = a 1 a 2 … a n, cells 1 through n should contain the a i and all the rest should be blank 3) Head should be at left-most cell i =1 Together these give:

17 17 Boolean Expressions for Simulating NTM Computation Ending configuration should accept:

18 18 Boolean Expressions for Simulating NTM Computation At each time step t : A. Machine is in a unique state: B. Each tape cell has a unique symbol:

19 19 Boolean Expressions for Simulating NTM Computation C. Head is reading unique cell: D. Unique choice considered: E. If already accepted, accept at t+1:

20 20 Boolean Expressions for Simulating NTM Computation F. If already rejected, reject at t+1: G. Cells which aren’t being read remain the same at time t+1: Q: Why can (x  y  z ) be considered a clause?

21 21 Boolean Expressions for Simulating NTM Computation A: (x  y  z ) is logically equivalent to (  x   y  z )

22 22 Boolean Expressions for Simulating NTM Computation Finally, given the branching choice k, and the current configuration, the next configuration should follow according to k’th  -function choice:

23 23 Boolean Expressions for Simulating NTM Computation Requiring all of the component cnf formulas to be true, simulates the NTM: Finally, let’s make sure that this is a poly- time reduction. The formulas are explicitly defined so running time is same as total space:

24 24 Space complexity  start --O( f (n) )  A --O( f (n) · |Q | 2 )  B --O( f (n) 2 · |  | 2 )  C --O( f (n) · f (n) 2 )  D --O( f (n) · b 2 )  E --O( f (n) )  F --O( f (n) )  G --O( f (n) 2 · |  | )  H --O( f (n) 2 · |  | · |Q | · b )  end -- O( 1 ) Total:  -- O( f (n) 3 )

25 25 Conclusion of Cook-Levin Proof Thus, any NTM that runs in time f (n) can have it’s inputs of size n converted into size O (f (n) 3 ) instances of CSAT. So if f (n) is a polynomial, the reduction runs in polynomial time on a RAM (since the cube of a polynomial is a polynomial). This proves that CSAT is NP-complete.

26 26 Reducing CSAT to 3SAT Each clause with more than 3 literals can be converted into a conjunction of clauses with at most 3 literals. EG: (a  b  c  d  e  f )  (a  b  x )  (x  c  d  e  f )  (a  b  x )  (x  c  y )  (y  d  e  f )  (a  b  x )  (x  c  y )  (y  d  z)  (z  e  f )  (a  b  x )  (  x  c  y )  (  y  d  z)  (  z  e  f ) Q: How many 3-clauses are needed to simulate an n-clause?

27 27 Reducing CSAT to 3SAT A: Each substitution got rid of one extra variable, except for first. So need n-2 = O (n) 3-clauses to simulate an n-clause. Therefore, any instance of nSAT of size k is converted to an instance of 3SAT of size O (nk ). Any instance of CSAT of size k is at worst-case, a single clause of size k so can be converted to an instance of 3SAT of size O (k 2 ). This completes the poly- time reduction from CSAT to 3SAT.

28 28 Blackboard Exercise Show that 2SAT is in P.


Download ppt "1 The Cook-Levin Theorem Zeph Grunschlag. 2 Announcements Last HW due Thursday Please give feedback about course at oracle.seas.columbia.edu/wces oracle.seas.columbia.edu/wces."

Similar presentations


Ads by Google