Presentation is loading. Please wait.

Presentation is loading. Please wait.

1 NP-Completeness Zeph Grunschlag. 2 Announcement HW9 Due Now HW Amnesty I’ll drop your lowest hw score.

Similar presentations


Presentation on theme: "1 NP-Completeness Zeph Grunschlag. 2 Announcement HW9 Due Now HW Amnesty I’ll drop your lowest hw score."— Presentation transcript:

1 1 NP-Completeness Zeph Grunschlag

2 2 Announcement HW9 Due Now HW Amnesty I’ll drop your lowest hw score.

3 3 Agenda NP-complete problems Proof that Punch-Card Puzzle is NP-complete P vs. NP question Known and unknown hierarchies Next Time: Foundational proof that 3SAT is NP-complete (Cook-Levin Theorem)

4 4 NP-Complete Problems “Magic Bullets” We have already encountered some “NP- complete” problems. The first one was the punch-card puzzle. Solving the puzzle in general in polynomial time would land you a $1,000,000 as well as yield a fast solution to thousands of other problems in NP.land you a $1,000,000 But solving any other NP-complete problem would bear the same fruits, as all NP-complete problems are polynomially equivalent to each other: if P and Q are NP-complete, then P is poly-time reducible to Q and vice versa.

5 5 NP-Complete Problems Here is a list of some NP-complete problems: 1. SAT 2. CSAT 3. 3SAT 4. Punch-Card Puzzle 5. Clique 6. Discrete Linear Algebra 7. Traveling Salesperson 8. Hamiltonian Path See many more at “An Annoted List…” or from Garey and Johnson’s book. 1“An Annoted List…”

6 6 NP-Complete Definition We already know what it means for a problem to be in NP. NP-complete problems are problems which are in NP but are also NP-hard: DEF: A language L is NP-hard if every problem L’ in NP is poly-time mapping reducible to L. If in addition, L is in NP, L is said to be NP-complete.

7 7 NP-Hard Problems A NTM Intuitively, a problem is NP-hard if it is at least as hard as any problem in NP. But we already have an archetypal hardest problem: the undecidable problem A TM. Thus A TM ought to be NP-hard. It is possible to show this using for example, the NP-hardness of SAT. However, to demonstrate directly from definition a problem that’s NP-hard, easier to use A N TM. Q: Is A NTM Turing equivalent to A TM ?

8 8 NP-Hard Problems A NTM A: A NTM and A TM are Turing equivalent 1) A solution to A NTM would automatically give a solution to A TM since all TM are automatically NTM’s. 2) Since NTM’s can be determinized algorithmically, given any description of can convert (and even in polynomial time!) to a description of equivalent which accepts iff original description accepts.

9 9 NP-Hard Problems A NTM Proof that A NTM is NP-hard: Given any language L’   * in NP, there is a NTM M’ which decides L’. Define the following mapping reduction f : Given x   *, f (x) = f can be achieved by an I/O TM which runs in polynomial time, simply by pre-appending x by the description of M’ on the tape. Furthermore, f (x) is in A NTM exactly when x is in L’. So f is a poly-time mapping reduction. Q: Is A NTM NP-complete?

10 10 NP-Hard Problems A NTM A: No! Since all NP-complete are in NP A NTM would be in NP. This is impossible as problems in NP are decidable by exhaustive (exponential) search.

11 11 Showing NP-Completeness Standard technique for showing that a problem is NP-complete. 1) Show directly that problem is in NP. 2) Show that a previously known NP- complete problem is poly-time reducible to the problem of interest. Typically, for step (2) an NP-complete SAT variant is used.

12 12 Punch-Card Puzzle is NP-Complete Let’s show that the Punch-Card Puzzle is NP-complete. We’ve already done step 1 in the previous lecture. Let’s reduce CSAT to the puzzle in poly-time: Proof that CSAT reduces to Puzzle: This is a case that the Puzzle  CSAT reduction is almost exactly the reverse of CSAT  Puzzle.

13 13 Reducing CSAT to Punch-Card Puzzle 1 st IDEA: Concentrate only on left column. 1) Each variable gives a card. 2) Each clause gives a row. When x i appears in clause j, the i th card will have no hole in the left column of row j. When  x i appears in clause j, the i th card will have no hole in the right column of row j. Therefore, i th card fills in exactly those left rows that correspond to satisfied clauses, while i th card flipped fills in left rows that correspond to negation satisfying clauses.

14 14 Reducing CSAT to Punch-Card Puzzle EG: Consider conjunction of 4 clauses:  x  y  z  x There should be 3 cards because there are 3 variables and 4 rows, because there are 4 clauses.

15 15 Reducing CSAT to Punch-Card Puzzle EG: Consider conjunction of 4 clauses:  x  y  z  x There should be 3 cards because there are 3 variables and 4 rows, because there are 4 clauses.

16 16 Reducing CSAT to Punch-Card Puzzle EG: Consider conjunction of 4 clauses:  x  y  z  x Variable x

17 17 Reducing CSAT to Punch-Card Puzzle EG: Consider conjunction of 4 clauses:  x  y  z  x Variable x Variable y

18 18 Reducing CSAT to Punch-Card Puzzle EG: Consider conjunction of 4 clauses:  x  y  z  x Variable x Variable y Variable z Q: Any problems?

19 19 Reducing CSAT to Punch-Card Puzzle A: One column can be satisfied but not both! Q: Any suggested fixes?

20 20 Reducing CSAT to Punch-Card Puzzle A: (2 nd Idea) Just add the card whose right column is completely filled in, and left column completely open: Claim: This actually works in general! In fact…

21 21 Reducing CSAT to Punch-Card Puzzle LEMMA: Suppose a boolean expression  is transformed into a card puzzle according to 1 st idea. Then if  is unsatisfiable, not even 1 column can be filled. Proof of lemma: If 1 column can be filled, we can assume it’s the left column by flipping all cards if it wasn’t. By construction, each card will fill in a row exactly when its variable has the corresponding truth value. Thus filling in the left column, means that  is satisfiable. We’ve shown that if even 1 column is fillable, then  is satisfiable, which is equivalent to lemma.//

22 22 Reducing CSAT to Punch-Card Puzzle Proof that 2 nd idea works: CASE I. If  is satisfiable then the left column is fillable and adding the last card ensures that puzzle is solvable. CASE II. If  is unsatisfiable then by lemma, neither column is fillable. Adding the last card only allows the filling in of 1 of the two columns, so the puzzle remains unsolvable. Thus we have  satisfiable iff the constructed puzzle is solvable which proves the reduction of CSAT to the Punch-Card Puzzle. 

23 23 Reducing CSAT to Punch-Card Puzzle Let’s see how this works on a more interesting example than x  y  z  x. Convert (  x  y  y)  (  x  z  w )  (y  z  w )

24 24 Reducing CSAT to Punch-Card Puzzle Convert (  x  y  y)  (  x  z  w )  (y  z  w ) There are 4 variables so 4 starting cards. There are 3 clauses so 3 rows.

25 25 Reducing CSAT to Punch-Card Puzzle Convert (  x  y  y)  (  x  z  w )  (y  z  w ) x

26 26 Reducing CSAT to Punch-Card Puzzle Convert (  x  y  y)  (  x  z  w )  (y  z  w ) x y

27 27 Reducing CSAT to Punch-Card Puzzle Convert (  x  y  y)  (  x  z  w )  (y  z  w ) x y z

28 28 Reducing CSAT to Punch-Card Puzzle Convert (  x  y  y)  (  x  z  w )  (y  z  w ) x y z w Q: Is expression satisfiable?

29 29 Reducing CSAT to Punch-Card Puzzle (  x  y  y)  (  x  z  w )  (y  z  w ) A: Yes. Set y = z = true, x,w = anything. With cards this means that can fill left column by just using 2 nd and 3 rd cards:

30 30 Reducing CSAT to Punch-Card Puzzle (  x  y  y)  (  x  z  w )  (y  z  w ) A: Yes. Set y = z = true, x,w = anything. With cards this means that can fill left column by just using 2 nd and 3 rd cards: Add 2 nd card:

31 31 Reducing CSAT to Punch-Card Puzzle (  x  y  y)  (  x  z  w )  (y  z  w ) A: Yes. Set y = z = true, x,w = anything. With cards this means that can fill left column by just using 2 nd and 3 rd cards: Add 3 rd card:

32 32 Reducing CSAT to Punch-Card Puzzle (  x  y  y)  (  x  z  w )  (y  z  w ) Notice that we don’t need the card with filled right column. This is because could use sequence: 1, 2, 3, flip 4.

33 33 Reducing CSAT to Punch-Card Puzzle (  x  y  y)  (  x  z  w )  (y  z  w ) Notice that we don’t need the card with filled right column. This is because could use sequence: 1, 2, 3, flip 4.

34 34 Reducing CSAT to Punch-Card Puzzle (  x  y  y)  (  x  z  w )  (y  z  w ) Notice that we don’t need the card with filled right column. This is because could use sequence: 1, 2, 3, flip 4.

35 35 Reducing CSAT to Punch-Card Puzzle (  x  y  y)  (  x  z  w )  (y  z  w ) Notice that we don’t need the card with filled right column. This is because could use sequence: 1, 2, 3, flip 4.

36 36 Reducing CSAT to Punch-Card Puzzle (  x  y  y)  (  x  z  w )  (y  z  w ) Notice that we don’t need the card with filled right column. This is because could use sequence: 1, 2, 3, flip 4. Q: What does this say about boolean expression?

37 37 Reducing CSAT to Punch-Card Puzzle (  x  y  y)  (  x  z  w )  (y  z  w ) A: x = y = z = true, w = false and x = y = z = false, w = true (antipode) are both solutions of boolean expression!

38 38 P vs. NP Problem The most important open problem in theoretical CS is determining whether P is strictly smaller than NP. Intuitively, there seems to be no way to simulate exponentially many branches of an NTM computation in polynomial time. However, could have argued the same for NFA’s and argument would have been false!

39 39 Known hierarchy Let’s sum up what we actually know: 1. All regular languages can be recognized in linear time 2. Context free languages can be recognized in cubic time on a RAM (in fact, can prove that complexity of CFG’s is equal to complexity of matrix multiplication, so can do it in sub-cubic time) 3. There are decidable languages not solvable in polynomial time (EQ REX  )

40 40 Known hierarchy Get the following RAM hierarchy diagram: REC DEC P TIME(n) CFL TIME(n 3 ) REG EQ REX 

41 41 Conjectured Hierarchy Inside of DEC we conjecture: DEC NP P co-NP NP complete PRIME SAT

42 42 Blackboard Exercises 1. Show that the following is NP-complete: Telling if two boolean expressions are logically non-equivalent (have different output for some input). 2. Show that unless P = NP, there is no efficient algorithm for minimizing boolean expressions. (Therefore no efficient way to minimize circuits in general –result of great consequence in digital logic). 3. 3COLOR NP-hardness example


Download ppt "1 NP-Completeness Zeph Grunschlag. 2 Announcement HW9 Due Now HW Amnesty I’ll drop your lowest hw score."

Similar presentations


Ads by Google