Download presentation

Presentation is loading. Please wait.

1
NP-Completeness Zeph Grunschlag

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

3
**Agenda NP-complete problems P vs. NP question**

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
**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. 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
**NP-Complete Problems Here is a list of some NP-complete problems: SAT**

CSAT 3SAT Punch-Card Puzzle Clique Discrete Linear Algebra Traveling Salesperson Hamiltonian Path See many more at “An Annoted List…” or from Garey and Johnson’s book.1 1Computers and Intractability: A Guide to the Theory of NP-Completeness. Michael Garey and David Johnson. W.H. Freeman & Co ISBN:

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
NP-Hard Problems ANTM 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 ATM. Thus ATM 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 ANTM. Q: Is ANTM Turing equivalent to ATM?

8
**NP-Hard Problems ANTM A: ANTM and ATM are Turing equivalent**

A solution to ANTM would automatically give a solution to ATM since all TM are automatically NTM’s. Since NTM’s can be determinized algorithmically, given any description of <NTM,input> can convert (and even in polynomial time!) to a description of equivalent <TM,input> which accepts iff original description accepts.

9
**Given x S*, f (x) = < M’ , x >**

NP-Hard Problems ANTM Proof that ANTM is NP-hard: Given any language L’ S* in NP, there is a NTM M’ which decides L’. Define the following mapping reduction f : Given x S*, f (x) = < M’ , 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 ANTM exactly when x is in L’. So f is a poly-time mapping reduction. Q: Is ANTM NP-complete?

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

11
**Showing NP-Completeness**

Standard technique for showing that a problem is NP-complete. Show directly that problem is in NP. 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
**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
**Reducing CSAT to Punch-Card Puzzle**

1st IDEA: Concentrate only on left column. Each variable gives a card. Each clause gives a row. When xi appears in clause j, the i th card will have no hole in the left column of row j. When xi 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
**Reducing CSAT to Punch-Card Puzzle**

EG: Consider conjunction of 4 clauses: f = x y z x There should be 3 cards because there are 3 variables and 4 rows, because there are 4 clauses.

15
**Reducing CSAT to Punch-Card Puzzle**

EG: Consider conjunction of 4 clauses: f = x y z x There should be 3 cards because there are 3 variables and 4 rows, because there are 4 clauses.

16
**Reducing CSAT to Punch-Card Puzzle**

EG: Consider conjunction of 4 clauses: f = x y z x Variable x

17
**Reducing CSAT to Punch-Card Puzzle**

EG: Consider conjunction of 4 clauses: f = x y z x Variable x Variable y

18
**Reducing CSAT to Punch-Card Puzzle**

EG: Consider conjunction of 4 clauses: f = x y z x Variable x Variable y Variable z Q: Any problems?

19
**Reducing CSAT to Punch-Card Puzzle**

A: One column can be satisfied but not both! Q: Any suggested fixes?

20
**Reducing CSAT to Punch-Card Puzzle**

A: (2nd 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
**Reducing CSAT to Punch-Card Puzzle**

LEMMA: Suppose a boolean expression f is transformed into a card puzzle according to 1st idea. Then if f 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 f is satisfiable. We’ve shown that if even 1 column is fillable, then f is satisfiable, which is equivalent to lemma.//

22
**Reducing CSAT to Punch-Card Puzzle**

Proof that 2nd idea works: CASE I. If f is satisfiable then the left column is fillable and adding the last card ensures that puzzle is solvable. CASE II. If f 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 f satisfiable iff the constructed puzzle is solvable which proves the reduction of CSAT to the Punch-Card Puzzle.

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
**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
**Reducing CSAT to Punch-Card Puzzle**

Convert (x y y)(x z w )(y z w ) x

26
**Reducing CSAT to Punch-Card Puzzle**

Convert (x y y)(x z w )(y z w ) x y

27
**Reducing CSAT to Punch-Card Puzzle**

Convert (x y y)(x z w )(y z w ) x y z

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
**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 2nd and 3rd cards:

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 2nd and 3rd cards: Add 2nd card:

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 2nd and 3rd cards: Add 3rd card:

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
**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
**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
**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
**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
**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
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
**Known hierarchy Let’s sum up what we actually know:**

All regular languages can be recognized in linear time 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) There are decidable languages not solvable in polynomial time (EQREX )

40
**Known hierarchy Get the following RAM hierarchy diagram: REC DEC P**

EQREX P TIME(n3) CFL REG TIME(n)

41
**Conjectured Hierarchy**

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

42
Blackboard Exercises Show that the following is NP-complete: Telling if two boolean expressions are logically non-equivalent (have different output for some input). 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). 3COLOR NP-hardness example

Similar presentations

OK

Bellwork Do the following problem on a ½ sheet of paper and turn in.

Bellwork Do the following problem on a ½ sheet of paper and turn in.

© 2018 SlidePlayer.com Inc.

All rights reserved.

Ads by Google

Transparent lcd display ppt online A ppt on refraction of light Ppt on review of literature paper Ppt on nepali culture show Ppt on product life cycle with examples Ppt on road accidents essay Compress ppt online Ppt on albert einstein life Ppt on art of war quote Ppt on bluetooth hacking device