The Theory of NP-Completeness ∗ Peter Cappello Department of Computer Science University of California, Santa Barbara Santa Barbara, CA 93106 cappello@cs.ucsb.edu • Please read the corresponding chapter before attending this lecture. • These notes are not intended to be complete. They are supplemented with figures, and material that arises during the lecture period in response to questions. ∗ Based on Computers and Intractability , Michael R. Garey and David S. Johnson, Freeman, 1979. 1
Cook’s Theorem 1 Cook showed that SATISFIABILITY is NP-complete. The terms used to specify it are defined as follows: Let U = { u 1 , u 2 , . . . , u m } be a set of Boolean variables . A truth assignment for U is a function t : U �→ { T, F } . If t ( u ) = T , we say that u is “true” under t ; if t ( u ) = F , we say that u is “false.” If u is a variable in U , then u and u are literals over U . The literal u is true under t ⇐ ⇒ the variable u is true under t ; the literal u is true under t ⇐ ⇒ the variable u is false. A clause over U is a set of literals over U , such as { u 1 , u 3 , u 8 } . It represents the disjunction of those literals and is satisfied by a truth assignment ⇐ ⇒ at least 1 of its members is true under that assignment. The clause above is satisfied by t unless t ( u 1 ) = F , t ( u 3 ) = T , and t ( u 8 ) + F . 2
A collection C of clauses over U is satisfiable ⇐ ⇒ ∃ some truth assignment for U that satisfies all C ’s clauses. Such a truth assignment is called a satisfying truth assignment for C . The SATISFIABILITY problem is specified as follows. For example, U = { u 1 , u 2 } and C = {{ u 1 , u 2 } , { u 1 , u 2 }} provide an instance of SAT for which the answer is “Yes”. What is a satisfying assignment? OTOH, replacing C by C ′ = {{ u 1 , u 2 } , { u 1 , u 2 } , { u 1 }} yields an in- stance for which the answer is “no.” SATISFIABILITY INSTANCE: A set U of variables and a collection C of clauses over U . QUESTION: Is there a satisfying truth assignment for C ? THEOREM (Cook’s Theorem): SATISFIABILITY is NP-complete. PROOF: 3
SAT is NP-easy : It is easy to see that, given a truth assignment, it can be verified in polynomial time in the size of the problem instance ( O ( | U | + | C | ) ) whether or not C is satisfied under that assignment. SAT is NP-hard: Let L SAT denote the language of “yes” instances of SAT. We must show: ∀ L ∈ NP, L ∝ L SAT . We use a machine-based proof of this: ∀ L ∈ NP, ∃ an NDTM, M , that recognizes L in polynomial time. We show that ∀ x , input to M , there exists an instance of SAT that is “yes” ⇐ ⇒ M accepts x . Let M denote an arbitrary polynomial-time NDTM specified by: Γ , Σ , b, Q, q 0 , q Y , q N , and δ. Let L M denote the language accepted by M . 4
Let p ( n ) be a polynomial over the integers that bounds the number of steps that M takes in input of size n (i.e., the worst case over all inputs of size n ). Assume wlog that p ( n ) ≥ n, ∀ n ∈ Z + . We describe a generic polynomial transformation f L , that depends on L . The polynomial transformation f L is described in terms of M ’s param- eters, and p ( n ), the polynomial time bound. Our goal is to give f L the property: ∀ x ∈ Σ ∗ , x ∈ L ⇐ ⇒ f L ( x ) is satisfiable. If x ∈ Σ ∗ , there exists an accepting computation for M on x such that the number of steps is bounded by p ( | x | ). Such a computation cannot involve any tape cells outside the interval [ − p ( | x | ) , p ( | x | )]. Draw this. 5
The state of M ’s checking computation, at any time step in [0 , p ( | x | )], can be characterized by: • the contents of the relevant part of the tape • M ’s state • the position of the read-write head. The variables U that f L constructs are related to this characterization: Label the elements of Q as q 0 , q 1 = q Y , q 2 = q N , q 3 , . . . , q r , where r = | Q | − 1. Label the elements of Γ as s 0 = b, s 1 , s 2 , . . . , s v , where v = | Γ | − 1. We define the elements of U below, where by “at time i ,” we mean “at the completion of the i th step of the checking computation.” n = | x | . 6
Variable Range Intended meaning Q [ i, k ] 0 ≤ i ≤ p ( n ) At time i , M is in state q k . 0 ≤ k ≤ r H [ i, j ] 0 ≤ i ≤ p ( n ) At time i , the read-write head − p ( n ) ≤ j ≤ p ( n ) + 1 is scanning tape cell j . S [ i, j, k ] 0 ≤ i ≤ p ( n ) At time i , the contents of tape − p ( n ) ≤ j ≤ p ( n ) + 1 cell j is symbol s k . 0 ≤ k ≤ v Illustrate these with a machine drawing. If M halts before time step p ( n ), the halting configuration is propagated to all later times up to time step p ( n ). The tape contents consists of the input, x , in cells 1 - n . The guess, w , is in cells -1 - −| w | . 7
All other squares initially are blank. We will show that the transformation f L constructs a collection of clauses that are satisfiable ⇐ ⇒ x is accepted by the NDTM M whose checking stage has at most p ( n ) steps and whose guessed string has length at most p ( n ): x ∈ L ⇐ ⇒ M accepts x ⇐ ⇒ M accepts x with at most p ( n ) steps in its checking stage and with a guessed string w of length at most p ( n ) ⇐ ⇒ the constructed collection of clauses is satisfiable. After this is shown, we need only show that the transformation can be constructed in an amount of time that is polynomial in n , the size of the input. We proceed to give the construction of the clauses, and argue that they 8
are satisfiable ⇐ ⇒ x is accepted by M . There are 6 clause groups, whose purpose is described below. 9
Clause group Restriction imposed G 1 At step i , M is in exactly 1 state. At step i , the read-write head is scanning exactly 1 cell. G 2 At step i , each tape cell has exactly 1 symbol from Γ. G 3 At step 0, the computation is in the initial G 4 configuration of its checking state for input x . By step p ( n ), M is in q Y , accepting x . G 5 G 6 For each step i , 0 ≤ i < p ( n ), the configuration of M at time i + 1 follows by a single application of the transition function delta from the configuration at time i . 10
Group G 1 Group G 1 consists of the following clauses: { Q [ i, 0] , Q [ i, 1] , . . . , Q [ i, r ] } , 0 ≤ i ≤ p ( n ) { Q [ i, j ] , Q [ i, j ′ ] } , 0 ≤ i ≤ p ( n ) , 0 ≤ j < j ′ ≤ r The 1st p ( n ) + 1 of these clauses ensures that, for each step, M is in at least 1 state. The remaining clauses ensure that, for each step, M is in at most 1 state: Q [ i, j ] or Q [ i, j ′ ] is false ⇐ ⇒ at time i , M is in state j and is in state j ′ , for some j ′ � = j . Thus, G 1 ensures that, at step i , M is in exactly 1 state. 11
Group G 2 Group G 2 consists of the following clauses: { H [ i, − p ( n )] , H [ i, − p ( n ) + 1] , . . . , H [ i, p ( n ) + 1] } , 0 ≤ i ≤ p ( n ) { H [ i, j ] , H [ i, j ′ ] } , 0 ≤ i ≤ p ( n ) , − p ( n ) ≤ j < j ′ ≤ p ( n ) + 1 The 1st p ( n ) + 1 of these clauses ensures that, for each step, M is scanning at least 1 cell. The remaining clauses ensure that, for each step, M is scanning at most 1 cell. Thus, G 2 ensures that, at step i , the read-write head is scanning exactly 1 tape cell. 12
Group G 3 Group G 3 consists of the following clauses: { S [ i, j, 0] , S [ i, j, 1] , . . . , S [ i, j, v ] } , 0 ≤ i ≤ p ( n ), − p ( n ) ≤ j ≤ p ( n ) + 1 { S [ i, j, k ] , S [ i, j, k ′ ] } , 0 ≤ i ≤ p ( n ) , − p ( n ) ≤ j ≤ p ( n ) + 1 , 0 ≤ k < k ′ ≤ v The 1st p ( n ) + 1 of these clauses ensures that, for each step, tape cell j has at least 1 symbol from Γ. The remaining clauses ensure that, for each step, tape cell j has at most 1 symbol from Γ. Thus, G 3 ensures that, at step i , each tape cell has exactly 1 symbol from Γ. 13
Group G 4 Group G 4 consists of the following clauses: { Q [0 , 0] , H [0 , 1] , S [0 , 0 , b ] } , { S [0 , 1 , k 1 ] , S [0 , 1 , k 2 ] , . . . , S [0 , 1 , k n ] , } , { S [0 , n + 1 , 0] , S [0 , n + 2 , 0] , . . . , S [0 , p ( n ) + 1 , 0] , } , where x = s k 1 s k 2 · · · s k n Note: In the initial configuration, tape cell 0 is blank; the guessed word, w , is in [ −| w | , − 1]. Thus, G 4 ensures that, at step 0, the computation is in the initial configuration of its checking state for input x . 14
Group G 5 Group G 5 consists of the following clause: { Q [ p ( n ) , q Y ] } Thus, G 5 ensures that, by step p ( n ), M is in q Y , accepting x . Group G 6 The final group of clauses ensures that each successive configuration in the computation follows from the previous one by a single, legal step. This group consists of 2 subgroups of clauses. The first subgroup G 6 The 1st subgroup guarantees that if the read-write head is not scanning tape cell j at time i , then the symbol in cell j does not change between 15
times i and i + 1. This 1st subgroup consists of the following clauses: { S [ i, j, l ] , H [ i, j ] , S [ i + 1 , j, l ] } , 0 ≤ i < p ( n ) , − p ( n ) ≤ j ≤ p ( n ) + 1 , 0 ≤ l ≤ If the read-write head is NOT scanning cell j AND cell j has s l at time i AND it does NOT have it at time i +1, then the clause is false. Otherwise, it is true. That is, if H [ i, j ] (i.e., at time i , the read-write head is not scanning tape cell i ) AND S [ i, j, l ], then we must have S [ i + 1 , j, l ]. Thus, this subgroup of 2( p ( n )+1) 2 ( v +1) clauses perform their mission. The last subgroup G 6 The last subgroup of this last group guarantees that the changes from one configuration to the next are in accord with the transition function, δ , for 16
Recommend
More recommend