12/1/2009

The $1M question

The Clay Mathematics Institute Complexity Theory: Millenium Prize Problems

The P vs NP question 1. Birch and Swinnerton-Dyer 2. Lecture 28 (December 1, 2009) 3. Navier-Stokes Equations 4. P vs NP 5. Poincaré Conjecture 6. 7. Yang-Mills Theory

Princeton CS Building XKCD

PPP 1 0 1 0 0 0 0 === 0 1 1 1 1 0 1 NNN 1 0 0 1 1 1 0 PPP 1 0 1 0 0 0 0 ??? 0 1 1 1 1 1 1

The P versus NP problem

Is perhaps one of the biggest open problems in (and mathematics!) today.

(Even featured in the TV show NUMB3RS)

But what is the P-NP problem?

1 12/1/2009

Sudoku

3x3x3

Sudoku Sudoku

3x3x3 4x4x4

Sudoku Sudoku

Suppose it takes you S(n) to solve n x n x n

V(n) time to verify the solution Fact: V(n) = O(n 2 x n 2)

Question: is there some constant such that constant ... S(n) ≤ n ? 4x4x4 n x n x n

2 12/1/2009

Sudoku

The P versus NP problem P vs NP problem (informally) = Is proving a theorem much more difficult Does there exist an than checking the proof of a theorem? for n x n x n Sudoku that runs in time p(n) for some p( ) ? ... n x n x n

Hamilton Cycle

Given a graph G = (V,E), a cycle that visits the nodes exactly once

Let’s start at the beginning…

The Problem “HAM” Circuit-Satisfiability Input: A circuit C with one output Input: Graph G = (V,E) Output: YES if C is satisfiable Output: YES if G has a Hamilton cycle NO if C is not satisfiable NO if G has no Hamilton cycle

The Set “HAM” AND NOT

HAM = { graph G | G has a Hamilton cycle } AND

3 12/1/2009

Bipartite Matching

Input: A bipartite graph G = (U,V,E)

The Set “SAT” Output: YES if G has a perfect matching SAT = { all satisfiable circuits C } NO if G does not

Sudoku

Input: n x n x n sudoku instance

The Set “BI-MATCH” Output: YES if this sudoku has a solution

BI-MATCH = { all bipartite graphs that have a NO if it does not perfect matching } The Set “SUDOKU” SUDOKU = { All solvable sudoku instances }

Reducing Search to Decision Decision Versus Search Problems Given an algorithm for decision Sudoku, Search Problem devise an algorithm to find a solution YES/NO answers Find a Hamilton cycle Idea: Does G have a in G if one exists, Fill in one-by-one and Hamilton cycle? else return NO use decision algorithm Find a 3-coloring of Can G be G if one exists, else 3-colored ? return NO

4 12/1/2009

Reducing Search to Decision

Given an algorithm for decision HAM, Decision/Search Problems devise an algorithm to find a solution We’ll study decision problems because Idea: they are almost the same (asymptotically) Find the edges of the as their search counterparts cycle one by one

What is an efficient algorithm?

Is an O(n) algorithm efficient? Polynomial Time and How about O(n log n)? polynomial time The Class “P” of O(n 2) ? O(n c) for some constant c Decision Problems O(n 10 ) ? O(n log n ) ? non-polynomial O(2 n) ? time O(n!) ?

Does an algorithm running in O(n 100 ) time count as efficient? Asking for a poly-time algorithm for a We consider non-polynomial time problem sets a (very) low bar when asking to be inefficient. for efficient algorithms.

And hence a necessary condition for an The question is: can we achieve even this algorithm to be efficient is that it should for 3-coloring? run in poly-time. SAT? Sudoku?

5 12/1/2009

The Class P The Class P We say a subset of Σ* is in P if there is a program A and a polynomial p() The class of all sets L that can be recognized in polynomial time. such that for any x in Σ*,

The class of all decision problems that A(x) runs for at most p(|x|) time can be decided in polynomial time. and answers question “is x in L?” correctly.

Languages/Functions in P?

Example 1: CONN = {graph G: G is a connected graph} Why are we looking only at sets ⊆ Σ*? Algorithm A 1: What if we want to work with graphs or If G has n nodes, then run depth first search boolean formulas? from any node, and count number of distinct node you see. If you see n nodes, G ∈ CONN, else not. Θ Time: p1(|x|) = (|x|).

Languages/Functions in P?

HAM, SUDOKU, SAT are not known to be in P Onto the new class, NP CO-HAM = { G | G does NOT have a Hamilton cycle}

CO-HAM ∈ P if and only if HAM ∈ P

6 12/1/2009

Verifying Membership NP A set L ∈ NP Is there a short “proof” I can give you for: if there exists an algorithm A and a polynomial p( ) G ∈ HAM? For all x ∈ L For all x ′ ∉ L ∈ G BI-MATCH? there exists y with For all y ′ with |y| ≤ p(|x|) |y ′| ≤ p(|x ′|) G ∈ SAT? such that A(x,y) = YES we have A(x ′,y ′) = NO ∈ G CO-HAM? in p(|x|) time in p(|x|) time

Recall the Class P NP A set L ∈ NP We say a set L ⊆ Σ* is in P if there is if there exists an algorithm A and a a program A and polynomial p( ) a polynomial p() For all x ∈ L For all x ′ ∉ L such that for any x in Σ*, there exists a y with For all y ′ with A(x) runs for at most p(|x|) time |y| ≤ p(|x|) |y ′| ≤ p(|x ′|) and answers question “is x in L?” correctly. such that A(x,y) = YES we have A(x ′,y ′) = NO

can think of A as “proving” that x is in L in p(|x|) time in p(|x|) time

The Class NP P ⊆ NP

The class of sets L for which there exist For any L in P, we can just take y to be the “short” proofs of membership empty string and satisfy the requirements. (of polynomial length) that can “quickly” verified Hence, every language in P is also in NP. (in polynomial time) .

Recall: A doesn’t have to find these proofs y; it just needs to be able to verify that y is a “correct” proof.

7 12/1/2009

Summary: P versus NP Languages/Functions in NP? Set L is in P if membership in L can be decided in poly-time. G ∈ HAM? Set L is in NP if each x in L has a short “proof G ∈ BI-MATCH? of membership” that can be verified in poly- time.

G ∈ SAT? Fact: P ⊆ NP

G ∈ CO-HAM? Question: Does NP ⊆ P ?

NP Contains Lots of Problems We Don’t Know to be in P

Classroom Scheduling Why Care? Packing objects into bins Scheduling jobs on machines Finding cheap tours visiting a subset of cities Allocating variables to registers Finding good packet routings in networks Decryption …

How can we prove that NP ⊆ P?

OK, OK, I care... I would have to show that every set in NP has a But where do I begin polynomial time algorithm… if I want to reason about How do I do that? the P=NP problem? It may take a long time! Also, what if I forgot one of the sets in NP?

8 12/1/2009

We can describe just one problem L in NP, such that if this problem L is in P, The “Hardest” Set in NP then NP ⊆ P.

It is a problem that can capture all other problems in NP.

Sudoku The “Hardest” Sets in NP Sudoku Clique Sudoku has a polynomial time SAT Independent-Set algorithm 3-Colorability HAM if and only if

P = NP These problems are all “polynomial-time equivalent”.

... I.e., each of these can be reduced to any n x n x n of the others in poly-time

“Poly-time reducible to each other”

Reducing problem Y to problem X in poly-time

F is poly-time How do you prove these computable

Answer are the hardest? Instance Instance I Y of IX = F(I Y ) of problem Y problem X

Answer

Oracle for Oracle for problem Y problem X

9 12/1/2009

Theorem [Cook/Levin]: Last lecture… 3-colorability Circuit Satisfiability SAT is one language in NP, such that if we can show SAT is in P, then we have shown NP ⊆ P. AND NOT SAT is a language in NP that can capture all other languages in NP. AND We say SAT is NP-complete.

Last lecture… Any language in NP

can be reduced SAT and 3COLOR: Two problems that seem (in polytime to) quite different, but are substantially the an instance of same. SAT hence SAT is NP-complete

Also substantially the same as CLIQUE and can be reduced (in polytime to) INDEPENDENT SET. (Homework) an instance of

If you get a polynomial-time algorithm for one, 3COLOR hence 3COLOR is NP-complete you get a polynomial-time algorithm for ALL.

Definition of P and NP

Definition of problems SAT, 3-COLOR, HAM, SUDOKU, BI-MATCH

SAT, 3-COLOR, HAM, SUDOKU all essentially equivalent.

Here’s What Solve any one in poly-time You Need to ⇒ solve all of them in poly-time Know…

10