the class np

11
The class NP The class NP Section 7.3 Giorgi Japaridze Theory of Computability

Upload: amity-ramos

Post on 31-Dec-2015

26 views

Category:

Documents


0 download

DESCRIPTION

Giorgi Japaridze Theory of Computability. The class NP. Section 7.3. 7.3.a. Giorgi Japaridze Theory of Computability. The HAMPATH problem. A Hamiltonian path in a directed graph G is a directed path that goes through each - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: The class NP

The class NPThe class NP

Section 7.3

Giorgi Japaridze

Theory of Computability

Page 2: The class NP

The HAMPATH problem 7.3.a Giorgi Japaridze Theory of Computability

A Hamiltonian path in a directed graph G is a directed path that goes through each node exactly once. We consider a special case of this problem where the start nodeand target node are fixed.

HAMPATH = {<G,s,t> | G is a directed graph with a Hamiltonian path from s to t}

s

1

2

3

4

5

6

t

s

1

2

3

4

5

6

t

PATH?

HAMPATH?

HAMPATH?

Page 3: The class NP

Polynomial verifiability 7.3.b Giorgi Japaridze Theory of Computability

s t

Does this graph have aHamiltonian path?

Page 4: The class NP

The COMPOSITES problem 7.3.c Giorgi Japaridze Theory of Computability

COMPOSITES = {x | x=pq for some integers p,q>1}

15 COMPOSITES ?

17 COMPOSITES ?

77 COMPOSITES ?

10403 COMPOSITES ?

997,111,111,911,111,119,131,119,871 COMPOSITES ?

COMPOSITES is very easily seen to be verifiable in polynomial time.But only a few years ago it was proven that it is also decidable in polynomial time. The same question, however, remains open forHAMPATH --- one of the seven $1,000,000 questions!

Page 5: The class NP

Definition of a verifier7.3.d Giorgi Japaridze Theory of Computability

Definition 7.18 A verifier for a language A is an algorithm V, where A = {w | V accepts <w,c> for some string c}.We measure the time of a verifier only in terms of the length of w, so a polynomial time verifier runs in polynomial time in the length of w. A language A is polynomially verifiable if it has a polynomial time verifier. The above string c, used as additional information to verify that wA, is called a certificate, or proof, of membership in A.

What is a certificate for <G,s,t> HAMPATH?

What is a verifier for HAMPATH?

Observe that, for polynomial verifiers, the certificate has polynomial length (in the length of w) because that is all the verifier can access in its time bound.

What is a certificate for x COMPOSITES?

What is a verifier for COMPOSITES?

Page 6: The class NP

Definition of NP7.3.e Giorgi Japaridze Theory of Computability

Definition 7.19 NP is the class of languages that have polynomial time verifiers.

A very important class, because many natural and important problems are in it!

NP stand for “nondeterministic polynomial”. As it turns out (Theorem 7.20), an alternative characterization of NP is to say that this is the class of languages decidable by polynomial-time nondeterministic Turing machines. Here is such a machine for HAMPATH:

N1 = “On input <G,s,t>, where G is a directed graph with nodes s and t: 1. Write a list on m members p1,…,pm, where m is the number of nodes of G. Each number in the list is nondeterministically selected to be between 1 and m. 2. Check for repetitions in the list. If any are found, reject.

3. Check whether s=p1 and t=pm. If either fail, reject.

4. For each i between 1 and m-1, check whether (pi,pi+1) is an edge of G. If any are not, reject. Otherwise, all tests have been passed, so accept.”

Page 7: The class NP

NP in terms of nondeterministic Turing machines7.3.f Giorgi Japaridze Theory of Computability

Theorem 7.20 A language is in NP iff it is decided by some nondeterministic polynomial time Turing machine.

Proof. The idea is to show how to convert a polynomial time verifier into a polynomial time NTM, and vice versa. The NTM simulates the verifier by guessing the certificate. The verifier simulates the NTM by using the accepting branch as the certificate.

() Assume ANP. Let V be a verifier for A with VTIME(nk), which, by the definition of NP, exists. Construct N as follows: N = “On input w of length n: 1. Nondeterministically select a string c of length at most nk. 2. Run V on input <w,c>. 3. If V accepts, accept; otherwise reject.”

() Assume A is decided by a polynomial time NTM N. Construct a verifier V as follows: V = “On input <w,c>, where w and c are strings: Check whether c is (encodes) an accepting computation branch of N on input w. If yes, accept; otherwise reject.”

Page 8: The class NP

Definition of NTIME(t(n))7.3.g Giorgi Japaridze Theory of Computability

Definition 7.21 Let t(n) be a function. NTIME(t(n)) is defined as {L | L is a language decided by some O(t(n)) time NTM}.

Corollary 7.22 NP = NTIME(n1) NTIME(n2) NTIME(n3) NTIME(n4) …

Just like P, the class NP is insensitive to the choice of the reasonableunderlying computational model because all such models are polynomially equivalent. So, when describing and analyzing nondeterministic polynomial algorithms, we can follow the preceding (lazy man’s) conventions for deterministic polynomial time algorithms.

Page 9: The class NP

The CLIQUE problem7.3.h Giorgi Japaridze Theory of Computability

A k-clique in an undirected graph is a subgraph with k nodes, wherein every two nodes are connected by an edge. On the right we see a 5-clique

CLIQUE = {<G,k> | G is an undirected graph with a k-clique}

Theorem 7.24 CLIQUENP.

Proof. Here is a polynomial time verifier V for CLIQUE:V = “On input <<G,k>,c>: 1. Test whether c is a set of k nodes in G. 2. Test whether G contains all edges connecting nodes in c. 3. If both pass, accept; otherwise reject.”

Idea: The clique is the certificate.

Alternative proof. Here is a polynomial time NTM N deciding CLIQUE:N = “On input <G,k>: 1. Nondeterministically select a subset c of k nodes of G. 2. Test whether G contains all edges connecting nodes in c. 3. If yes, accept; otherwise reject.”

Page 10: The class NP

The SUBSET-SUM problem7.3.i Giorgi Japaridze Theory of Computability

SUBSET-SUM = {<S,t> | S is a multiset of integers and, for some RS, the sum of all elements of R equals t}

Theorem 7.25 SUBSET-SUMNP.

Proof. Here is a polynomial time verifier V for SUBSET-SUM:V = “On input <<S,t>,c>: 1. Test whether c is a collection of numbers that sum to t. 2. Test whether S contains all the numbers in c. 3. If both pass, accept; otherwise reject.”

Idea: The subset is the certificate.

Alternative proof. Here is a polynomial time NTM N deciding SUBSET-SUM:N = “On input <S,t>: 1. Nondeterministically select a subset c of S. 2. Test whether the elements of c sum up to t. 3. If yes, accept; otherwise reject.”

Page 11: The class NP

P vs. NP vs. coNP vs. EXPTIME7.3.j Giorgi Japaridze Theory of Computability

Definitions coNP = {L | L is the complement of some language in NP} EXPTIME = TIME(2n1) TIME(2n2) TIME(2n3) …

This is what we know:

P NP coNP EXPTIME

NP coNP ≠ EXPTIME

This is what we do not know:

P = NP?

NP = coNP?

P = NP coNP?

P: membership can be decided quicklyNP: membership can be verified quicklycoNP: membership can be refuted quicklyEXPTIME: none of the above