7.3 The Class NP What's the Class NP? NP is the class of languages decidable in Polynomial time on a Nondeterministic TM What's a Nondeterministic Time Complexity Class? NTIME(t(n)) = { L | L is a language decided by a O(t(n)) time NTM } What's a formal definition of the class NP? NP = union over k of NTIME(n^k) If a certain problem has a Polynomial-time solution on one kind of Nondeterministic computing model, what do you know about other types of reasonable Nondeterministic computing models? The problem will have a Polynomial-time solution on any reasonable Nondeterministic computing model How do you show a problem is in the class NP? 1. describe a nondeterministic algorithm that solves the problem 2. show the algorithm runs in nondeterministic polynomial time The HAMPATH Problem What's a Hamiltonian Path in a directed graph? a path that goes through each node exactly once What's the HAMPATH problem? HAMPATH = { | G is a directed graph with a Hamiltonian path from s to t } What's a Brute-force Algorithm for the HAMPATH problem? What's the running-time of the Brute-force Algorithm for HAMPATH? Can you design a Polynomial-time Algorithm for HAMPATH? HAMPATH is in NP What's a Nondeterministic-Polynomial-Time algorithm for HAMPATH? H = "On input , G is directed graph, s and t are nodes: 1. Select a list of n numbers where n is the number of nodes in G. Nondeterministically select each number to be between 1 and n. 2. If the list has any repeated numbers, reject. 3. If the first number is not s or the last is not t, reject. 4. If there is an edge in the graph for each pair of adjacent numbers in the list, accept. Otherwise, reject." Show that H is a Nondeterministic-Polynomial-Time algorithm. The CLIQUE Problem What's a Clique in an undirected graph? a subgraph with an edge between every pair of nodes What's a k-clique? a clique that contains k nodes What's the CLIQUE problem? CLIQUE = { | G is an undirected graph with a k-clique } CLIQUE is in NP What's a Nondeterministic-Polynomial-Time algorithm for CLIQUE? N = "On input , G is a graph, k is a number: 1. Nondeterministically select a subset c of k nodes from G. 2. If G has an edge between each pair of nodes in c, accept. Otherwise, reject." Show that N is a Nondeterministic-Polynomial-Time algorithm. Polynomial-Time Verifiers If you are given a HAMPATH problem and a list of nodes c that is a Hamiltonian Path from s to t in G, can you verify that G has a Hamiltonian Path from s to t in polynomial time? What's a Polynomial-Time Verifier for HAMPATH? HV = "On input <,c>, G is directed graph, s and t are nodes: 1. If c is not a list of n values, each between 1 and n, reject. 2. If the list has any repeated numbers, reject. 3. If the first number is not s or the last is not t, reject. 4. If there is an edge in the graph for each pair of adjacent numbers in the list, accept. Otherwise, reject." If you are given a CLIQUE problem and a set of nodes c that is a k-clique in G, can you verify that G has a k-clique in polynomial time? What's a Polynomial-Time Verifier for CLIQUE? V = "On input <,c>: 1. If c is not a set of k nodes from G, reject. 2. If G has an edge between each pair of nodes in c, accept. Otherwise, reject." What's a Verifier? a verifier for language A is an algorithm V, where A = { w | V accepts for some string c } What's a Certificate? extra information that allows a verifier to check that w is in A What's the certificate for HAMPATH, CLIQUE? HAMPATH: a Hamiltonian path CLIQUE: a k-clique What's another definition of the Class NP? NP is the class of languages with Polynomial-Time Verifiers The Class coNP What's the class coNP? set of languages that are complements of languages in NP Can you give Polynomial-Time Verifiers for these languages? NOT HAMPATH NOT CLIQUE Is the class coNP different from the class NP? Is the class coNP the same as the class NP? Comparing P and NP How does the class P compare to the class NP? P = languages where membership can be Decided quickly NP = languages where membership can be Verified quickly Is the class P equivalent to the class NP? Is the class P a subset of the class NP? Can you show that HAMPATH and CLIQUE are in P? Can you show that HAMPATH and CLIQUE are not in P? Can you give an example of any problem in NP but not in P?