- By
**Rita** - Follow User

- 236 Views
- Uploaded on

Download Presentation
## PowerPoint Slideshow about 'NP -Completeness' - Rita

Download Now**An Image/Link below is provided (as is) to download presentation**

Download Now

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.

- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -

Presentation Transcript

### NP-Completeness

Reducing CSAT to Punch-Card PuzzleNotice that we don’t need the card with filled right column. This is because could use sequence: 1, 2, 3, flip 4.

Zeph Grunschlag

Announcement

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

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)

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.

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

NP-CompleteDefinition

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.

NP-Hard ProblemsANTM

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?

NP-Hard ProblemsANTM

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.

NP-Hard ProblemsANTM

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 ANTMNP-complete?

NP-Hard ProblemsANTM

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.

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.

Punch-Card Puzzleis 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.

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.

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.

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.

Reducing CSAT to Punch-Card Puzzle

EG: Consider conjunction of 4 clauses:

f = x y z x

Variable x Variable y

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?

Reducing CSAT to Punch-Card Puzzle

A: One column can be satisfied but not both!

Q: Any suggested fixes?

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…

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.//

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.

Reducing CSAT to Punch-Card Puzzle

Let’s see how this works on a more interesting example than x y z x.

Convert

(xyy)(xzw)(yzw )

Reducing CSAT to Punch-Card Puzzle

Convert

(xyy)(xzw)(yzw )

There are 4 variables so 4 starting cards. There are 3 clauses so 3 rows.

Reducing CSAT to Punch-Card Puzzle

Convert

(xyy)(xzw)(yzw )

x y z w

Q: Is expression satisfiable?

Reducing CSAT to Punch-Card Puzzle

(xyy)(xzw)(yzw )

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:

Reducing CSAT to Punch-Card Puzzle

(xyy)(xzw)(yzw )

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:

Reducing CSAT to Punch-Card Puzzle

(xyy)(xzw)(yzw )

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:

Reducing CSAT to Punch-Card Puzzle

(xyy)(xzw)(yzw )

Notice that we don’t need the card with filled right column. This is because could use sequence: 1, 2, 3, flip 4.

Reducing CSAT to Punch-Card Puzzle

(xyy)(xzw)(yzw )

Notice that we don’t need the card with filled right column. This is because could use sequence: 1, 2, 3, flip 4.

Reducing CSAT to Punch-Card Puzzle

(xyy)(xzw)(yzw )

Notice that we don’t need the card with filled right column. This is because could use sequence: 1, 2, 3, flip 4.

(xyy)(xzw)(yzw )

Reducing CSAT to Punch-Card PuzzleNotice that we don’t need the card with filled right column. This is because could use sequence: 1, 2, 3, flip 4.

(xyy)(xzw)(yzw )

Q: What does this say about boolean expression?

Reducing CSAT to Punch-Card Puzzle

(xyy)(xzw)(yzw )

A: x = y = z = true, w = false and

x = y = z = false, w = true (antipode)

are both solutions of boolean expression!

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!

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)

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

Download Presentation

Connecting to Server..