CS 154 Lecture 15 CookLevin Theorem SAT 3

  • Slides: 25
Download presentation
CS 154, Lecture 15: Cook-Levin Theorem SAT, 3 SAT

CS 154, Lecture 15: Cook-Levin Theorem SAT, 3 SAT

Definition: A language B is NP-complete if: 1. B NP 2. Every A in

Definition: A language B is NP-complete if: 1. B NP 2. Every A in NP is poly-time reducible to B That is, A ≤P B When this is true, we say “B is NP-hard” On homework, you showed A language L is recognizable iff L ≤m ATM is “complete for recognizable languages ”: ATM is recognizable, and for all recognizable L, L ≤m ATM

Suppose L is NP-Complete… NP P L If L P, then P = NP

Suppose L is NP-Complete… NP P L If L P, then P = NP If L ∉ P, then P ≠ NP

Suppose L is NP-Complete… Then assuming the conjecture P NP, L is not decidable

Suppose L is NP-Complete… Then assuming the conjecture P NP, L is not decidable in nk time, for every k

The Cook-Levin Theorem: SAT and 3 SAT are NP-complete 1. 3 SAT NP A

The Cook-Levin Theorem: SAT and 3 SAT are NP-complete 1. 3 SAT NP A satisfying assignment is a “proof” that a 3 cnf formula is satisfiable 2. 3 SAT is NP-hard Every language in NP can be polynomial-time reduced to 3 SAT (complex logical formula) Corollary: 3 SAT P if and only if P = NP

Theorem (Cook-Levin): 3 SAT is NP-complete Proof Idea: (1) 3 SAT NP (done) (2)

Theorem (Cook-Levin): 3 SAT is NP-complete Proof Idea: (1) 3 SAT NP (done) (2) Every language A in NP is polynomial time reducible to 3 SAT (this is the challenge) We give a poly-time reduction from A to SAT The reduction converts a string w into a 3 cnf formula such that w A iff 3 SAT For any A NP, let N be a nondeterministic TM deciding A in nk time will simulate N on w

Nondeterministic Computation Deterministic Computation nk exp(nk)

Nondeterministic Computation Deterministic Computation nk exp(nk)

Let L(N) NTIME(nk). A tableau for N on w is an nk table whose

Let L(N) NTIME(nk). A tableau for N on w is an nk table whose rows are the configurations of some possible computation history of N on w

A tableau is accepting if the last row of the tableau is an accepting

A tableau is accepting if the last row of the tableau is an accepting configuration N accepts w if and only if there is an accepting tableau for N on w Given w, we’ll construct a 3 cnf formula with O(|w|2 k) clauses, describing logical constraints that any accepting tableau for N on w must satisfy The 3 cnf formula will be satisfiable if and only if there is an accepting tableau for N on w

Variables of formula will encode a tableau Let C = Q Γ { #

Variables of formula will encode a tableau Let C = Q Γ { # } Each of the (nk)2 entries of a tableau is a cell containing value in C cell[i, j] = value of the cell at row i and column j = the jth symbol in the ith configuration For every i and j (1 i, j nk) and for every s C we have a Boolean variable xi, j, s in Total number of variables = |C|n 2 k, which is O(n 2 k) These xi, j, s are the variables of and represent the contents of the cells We will have: for all i, j, s, xi, j, s = 1 cell[i, j] = s

Idea: Make so that every satisfying assignment to the variables xi, j, s corresponds

Idea: Make so that every satisfying assignment to the variables xi, j, s corresponds to an accepting tableau for N on w (an assignment to all cell[i, j]’s of the tableau) The formula will be the AND of four CNF formulas: = cell start accept move cell : for all i, j, there is a unique s C with xi, j, s = 1 start : the first row of the table equals the start configuration of N on w accept : the last row of the table has an accept state move : every row is a configuration that yields the configuration on the next row

 cell : for all i, j, there is a unique s C with

cell : for all i, j, there is a unique s C with xi, j, s = 1 for all i, j at least one xi, j, s is set to 1 at most one xi, j, s is set to 1

 start : the first row of the table equals the start configuration of

start : the first row of the table equals the start configuration of N on w start = x 1, 1, # x 1, 2, q 0 x 1, 3, w 1 x 1, 4, w 2 … x 1, n+2, wn x 1, n+3, … x 1, nk-1, x 1, n k , #

 accept : the last row of the table has an accept state

accept : the last row of the table has an accept state

 move : every row is a configuration that yields the configuration on the

move : every row is a configuration that yields the configuration on the next row Key Question: If one row yields the next row, how many cells can be different between the two rows? Answer: at most three cells # b a a q 1 b c b # # b a q 2 a c c b #

 move : every row is a configuration that yields the configuration on the

move : every row is a configuration that yields the configuration on the next row Idea: check that every 2 3 “window” of cells is legal (consistent with the transition function of N)

Example: Let N = (Q, Σ, Γ, , q 0, qaccept, qreject) Suppose a,

Example: Let N = (Q, Σ, Γ, , q 0, qaccept, qreject) Suppose a, b, c Γ, q 1, q 2 Q and (q 1, a) = { (q 1, b, R)} (q 1, b) = { (q 2, c, L), (q 2, a, R) } Legal = Consistent with N’s transition function Illegal = Inconsistent with N’s transition function

Key Lemma: IF Every window of the tableau is legal, and The top row

Key Lemma: IF Every window of the tableau is legal, and The top row is the start configuration THEN Each row of the tableau is a configuration that yields the next row on the tableau Proof Sketch: (Strong) induction on the rows. The top row is a configuration. If it does not yield the next row, then there is a 2 x 3 window that is “illegal” Suppose the first 1, …, k rows are configurations which yield the next, and assume every window is legal. If row k+1 did not yield row k+2, then there must be a 2 x 3 window along those two rows which is “illegal” – contradiction.

The (i, j) window of a tableau is the tuple (a 1, …, a

The (i, j) window of a tableau is the tuple (a 1, …, a 6) C 6 such that: col. j+1 col. j+2 row i a 1 a 2 a 3 row i+1 a 4 a 5 a 6

 move : every row is a configuration that legally follows from the previous

move : every row is a configuration that legally follows from the previous configuration move = ( the (i, j) window is legal ) 1 i nk -1 1 j nk -2 (the (i, j) window is legal) = ( xi, j, a xi, j+1, a xi, j+2, a xi+1, j+1, a 5 xi+1, j+2, a ) (a 1, …, a 6) is a legal window ≡ - 1 - 4 3 2 - - 6 - - ( xi, j, a xi, j+1, a xi, j+2, a xi+1, j, a 4 xi+1, j+1, a xi+1, j+2, a ) 1 (a 1, …, a 6) is NOT a legal window 2 3 5 6

How do we get 3 SAT? We had some long clauses in there… how

How do we get 3 SAT? We had some long clauses in there… how do we convert the whole thing into a 3 -cnf formula? Everything was an AND of ORs (a CNF). We just need to make those ORs small (a 1 a 2 … at) is equivalent to (a 1 a 2 z 1) ( z 1 a 3 z 2) ( z 2 a 4 z 3) … ( zt-3 at-1 at) (SAT is polynomial time reducible to 3 SAT)

What’s the total length of ? = cell start accept move O(n 2 k)

What’s the total length of ? = cell start accept move O(n 2 k) clauses O(nk) clauses O(n 2 k) clauses

Summary. We wanted to prove: Every A in NP has a polynomial time reduction

Summary. We wanted to prove: Every A in NP has a polynomial time reduction to 3 SAT For every A in NP, we know A is decided by some nondeterministic nk-time Turing machine N We gave a generic method to reduce (N, w) to a 3 CNF formula of O(|w|2 k) clauses such that satisfying assignments to the variables of directly correspond to accepting computation histories of N on Thewformula is the AND of four 3 CNF formulas: = cell start accept move

Reading Assignment Read Luca Trevisan’s notes for an alternative proof of the Cook-Levin Theorem

Reading Assignment Read Luca Trevisan’s notes for an alternative proof of the Cook-Levin Theorem Sketch: 1. Define CIRCUIT-SAT: Given a logical circuit input a such that C(a)=1 ? C(y) , is there an 2. Show that CIRCUIT-SAT is NP-hard: The nk x nk tableau for N on w can be simulated using a logical circuit of O(n 2 k) gates 3. Reduce CIRCUIT-SAT to 3 SAT in polytime 4. Conclude 3 SAT is also NP-hard

Theorem (Cook-Levin): SAT and 3 SAT are NP-complete Corollary: SAT P if and only

Theorem (Cook-Levin): SAT and 3 SAT are NP-complete Corollary: SAT P if and only if P = NP