Download presentation

Presentation is loading. Please wait.

1
NP-Completeness CS 51 Summer 2008 TexPoint fonts used in EMF. Read the TexPoint manual before you delete this box.: A AA A A AAA

2
CS 512 Cook-Levin Any problem in NP can be – reduced in polynomial time –by a deterministic Turing Machine –to a problem of determining whether a Boolean circuit is satisfiable.

3
CS 513 Implications Deterministic poly-time algorithm for solving satisfiability implies –Deterministic poly-time algorithm for any problem in NP.

4
CS 514 Boolean Circuits Theoretical analogue of logic circuits. A Boolean circuit is a collection of –gates –inputs –wires no cycles

5
CS 515 Kinds of Gates ÇÆ : and not or

6
CS 516 Gates Wires carry 0 or 1 AND: 1 iff both 1 OR: 1 iff either 1 NOT: opposite Distinguished output gate Æ and : not Ç or

7
CS 517 Example Æ : Ç Æ x0x0 x1x1 x2x2 : Æ Output gate

8
CS 518 Example Æ : Ç Æ x0x0 x1x1 x2x2 : Æ Output gate 010 1 0 0 11 1

9
CS 519 Circuit Satisfiability A circuit is satisfiable –If there is some set of inputs –That produce a 1 The circuit-satisfiability problem tests whether a circuit is satisfiable. –CIRCUIT-SAT = { |C is a satisfiable Boolean circuit}

10
CS 5110 Circuit Satisfiability Claim: –CIRCUIT-SAT is in NP Why? We will show that circuits can simulate Turing Machines!

11
CS 5111 Circuits Let t: N ! N be a function, where t(n) ¸ n Let M be a TM that –Takes inputs over alphabet {0,1} –Runs in time t(n)

12
CS 5112 Claim Let M be a TM that –Takes inputs over alphabet {0,1} –Runs in time t(n) Each n has a Boolean Circuit with O(t 2 (n)) gates that outputs 1 on those inputs of length n accepted by M

13
CS 5113 Proof Idea Define C n to simulate M on inputs of size n Gates of C n are –Organized in rows –One for each of t(n) steps in M’s computation –Each row represents M’s configuration at that step –Each row wired to previous Technical modification –M accepts or rejects with head at leftomost

14
CS 5114 Configurations Computation changes: –current state –current head position –tape contents

15
CS 5115 Configurations Configuration: 1011 q 7 0111 means: –state is q 7 –LHS of tape is 1011, RHS of tape is 0111 –head is on RHS 0

16
CS 5116 Yields u a q i b v yields u q j a c v if –???

17
CS 5117 Yields u a q i b v yields u q j a c v if –δ(q i,b) = (q j,c,L)

18
CS 5118 Yields u a q i b v yields u q j a c v if –δ(q i,b) = (q j,c,L) u a q i b v yields u a c q j v if –???

19
CS 5119 Yields u a q i b v yields u q j a c v if –δ(q i,b) = (q j,c,L) u a q i b v yields u a c q j v if –δ(q i,b) = (q j,c,R)

20
CS 5120 Yields u a q i b v yields u q j a c v if –δ(q i,b) = (q j,c,L) u a q i b v yields u a c q j v if –δ(q i,b) = (q j,c,R) q i b v yields q j c v if –???

21
CS 5121 More Configurations Starting: q 0 w Accepting: w 0 q a w 1 Rejecting: w 0 q r w 1 Halting configurations: –w 0 q a w 1, and –w 0 q r w 1

22
CS 5122 Accepting a Language C 1 = starting configuration of M on w each C i yields C i+1 C k is an accepting configuration. A Turing machine M accepts an input w if there exits a sequence C 1, C 2, …., C k such that

23
CS 5123 Tableaux Let M be –(Q, §, ¡, ±, q 0, q a, q r ) The tableau for M on w is –a t(n) by t(n) table. –rows are configurations of M –top row is start configuration of M on w –i th row is configuration at i th step.

24
CS 5124 Tableaux Why t(n) by t(n)? –How much tape can M read in t(n) steps? –How many configurations can M assume in t(n) steps?

25
CS 5125 Entries Each entry in the tableau contains –A tape symbol (in ¡ ), or –A state (in Q) Call entry at row i, col j cell[i,j]. –cell[1,i], …, cell[1,t(n)] starting config –And cell[1,1] = q 0, the starting state Recall M modifies so –cell[1,t(n)] is either q a or q r.

26
CS 5126

27
CS 5127 Proof Content of cell is determined by neighbors in preceding row. Given –cell[i-1,j-1] –cell[i,j-1] –cell[i+1,j-1] we can determine cell[i,j] –from M's transition function.

28
CS 5128 Proof Three top tape symbols nowhere near head So middle one unchanged on next row

29
CS 5129 Constructing the Circuit Circuit C n –has several gates for each cell in the tableau –compute value at a cell from the 3 cells that affect it.

30
CS 5130 Constructing the Circuit To make the description easier, we –add ``lights'' to show the output –illustrative purposes only

31
CS 5131 Constructing the Circuit To make the description easier, we –add ``lights'' to show the output –illustrative purposes only Let k = number of elements in ¡ [ Q. –each cell has k possible lights –grand total of k ¢ t 2 (n) lights –only one light can be lit, –that light indicates contents of cell.

32
CS 5132 Construction Model each light as light[i,j,s], where –1 · i,j · t(n) –s 2 ¡ –one and only one light on in each cell –if light[i,j,s] is on, then cell[i,j] = s.

33
CS 5133 Constructing the Circuit Pick light[i,j,s] in cell[i,j]. This light should be on iff cell[i,j] = s. Only three cells can affect this cell: –cell[i-1,j-1], –cell[i,j-1], and –cell[i+1,j-1]. How they affect the cell determined by transition function ±.

34
CS 5134 Construction Suppose that if –cell[i-1,j-1] = a 1, –cell[i,j-1] = b 1, and –cell[i+1,j-1] = c 1. then cell[i,j] = s, according to ±. Wire the circuit so that –light[i,j,s] = light[i-1,j-1, a 1 ] Æ light[i-1,j-1, b 1 ] Æ light[i-1,j-1, c 1 ]

35
CS 5135 Construction Wire the circuit so that –light[i,j,s] = light[i-1,j-1, a 1 ] Æ light[i-1,j-1, b 1 ] Æ light[i-1,j-1, c 1 ]

36
CS 5136 Construction In general, more than one setting (a 1,b 1,c 1 ), …, (a k,b k,c k ) of cell[i-1,j-1].cell[i,j-1],cell[i+1,j-1] can yield s. Wire the circuit so that –a i,b i,c i connected by Æ gates –different settings connected by Ç gates

37
CS 5137

38
CS 5138 First Row Hardwired for start configuration light[1,1,q 0 ] is initially on.

39
CS 5139 First Roiw light[1,2,1], …, light[1,n+1,1] connected to w 1,…w n light[1,2,0], …, light[1,n+1,0] connected to w 1,…w n by NOT gates

40
CS 5140 First Row light[1,n+2,_],…light[1,t(n),_] all on

41
CS 5141 Construction We have constructed a circuit that simulates M through its t(n) th step. Need one gate to be the output gate of the circuit M accepts w iff it is –in q a, and –at left-hand end of tape Choose light[t(n),1,q a ]. Completes proof M simulated by C n

42
CS 5142 Theorem CIRCUIT-SAT is NP-complete Is clearly in NP? (why?) We must show that any language A in NP is reducible to CIRCUIT-SAT We must give a polynomial time reduction mapping strings to circuits

43
CS 5143 Proof We must give a polynomial time reduction mapping strings to circuits –f(w) = C So that –W 2 A, C is satisfiable

44
CS 5144 Proof Let V be a poly-time verifier for A –Input –c is a certificate for x Now –Construct circuit simulating V –Fill in x inputs to circuit with w –Remaining inputs are for c Output this circuit, call it C

45
CS 5145 Proof Output this circuit, call it C –If C is satisfiable, a certificate exists, and w 2 A –If w 2 A, certificate exists, and C is satisfiable

46
CS 5146 Proof Check that circuit construction is poly time –Verifier running time is n k –Circuit size is O(n 2k ) –Circuit is simple and running time of reduction is O(n 2k )

47
CS 5147 3-SAT Boolean expression in CNF –Conjunctive normal form With no more than three literals –Literal = variable or its complement

48
CS 5148 Theorem 3-SAT is NP-Complete Obviously in NP Reduction of CIRCUIT-SAT to 3- SAT

49
CS 5149 Proof Let C be a circuit with –Inputs x 1, …, x k –Gates g 1, …,g m We build Boolean formula Á such that –x i correspond to input wires –g i correspond to gate output wires Relabel variables w 1, …, w k+m

50
CS 5150 NOT Gates For each NOT gate in C with input w i, output w j, add clauses –(w i Ç w j ) Æ ( : w i Ç w j ) Both clauses satisfied when assignment to w i and w j mirror NOT gate

51
CS 5151 AND Gates For each AND gate with inputs w i and w j, and output w k, add clauses –(w i Ç w j Ç : w k ) Æ –(w i Ç : w j Ç : w k ) Æ –( : w i Ç w j Ç : w k ) Æ –( : w i Ç : w j Ç w k ) Satisfied when assignments mirror AND

52
CS 5152 OR Gates For each OR gate with inputs w i and w j, and output w k, add clauses –(w i Ç w j Ç : w k ) Æ –(w i Ç : w j Ç w k ) Æ –( : w i Ç w j Ç w k ) Æ –( : w i Ç : w j Ç w k ) Satisfied when assignments mirror OR

53
CS 5153 Details All clauses have no more than 3 literals –If they have fewer, then repeat

54
CS 5154 Details Satisfying assignment for C yields satisfying assignment for Á by assigning g i vars according to C Satisfying assignment for Á yields satisfying assignment for C because it describes C’s computation with output 1 Reduction is poly-time

55
CS 5155 This work is licensed under a Creative Commons Attribution- ShareAlike 2.5 License.Creative Commons Attribution- ShareAlike 2.5 License

Similar presentations

© 2020 SlidePlayer.com Inc.

All rights reserved.

To make this website work, we log user data and share it with processors. To use this website, you must agree to our Privacy Policy, including cookie policy.

Ads by Google