=========================================================================== CSC 363H Lecture Summary for Week 8 Fall 2007 =========================================================================== ----------- P, NP, coNP ----------- Further examples of languages in NP: - HAMPATH = { : G is an undirected graph that contains a Hamiltonian path, i.e., a path that includes every vertex exactly once } HAMPATH in P? Unknown (checking all possible paths not polytime). HAMPATH in NP? Yes: On input : 1. Check c encodes a list of vertices (v_1,v_2,...,v_n). 2. Check c contains every vertex of G exactly once, i.e., V = {v_1,v_2,...,v_n}. 3. Check G contains every edge between successive vertices in c: (v_1,v_2) in E, (v_2,v_3) in E, ..., (v_{n-1},v_n) in E. 4. Accept if all checks succeed; reject if any fail. By definition of the language, if G in HAMPATH, then verifier accepts for some value of c (a Hamiltonian path in G); if G not in HAMPATH, then verifier rejects for all values of c. Moreover, verifier runs in polytime: if G contains n vertices and m edges, runtime is at most O(n^2 m). - SUBSET-SUM = { | S = {x_1,x_2,...,x_k} and there is a set {y_1,y_2,...,y_j} such that sum y_i = t } SUBSET-SUM in P? Unknown (checking all subsets not polytime). SUBSET-SUM in NP? Yes: Verifier = "On input : 1. check that c encodes a set of numbers; 2. check that c subset of S; 3. check that SUM_{y in c} y = t; 4. accept if all checks pass, reject otherwise." Clearly runs in polytime (addition of numbers is polytime), and if in SUBSET-SUM, then there is some value of c such that verifier accepts (c = subset whose sum equals t); if not in SUBSET-SUM, then verifier rejects for all values of c (there is no subset that works). - CLIQUE = { | G is an undirected graph that contains a k-clique -- a subset of k vertices with all edges between them } CLIQUE in P? Unknown (checking all possible subsets not polytime because k not fixed, part of input). CLIQUE in NP? Yes: Verifier = "On input : 1. check that c encodes a set of k vertices; 2. check that every vertex in c belongs to G; 3. check that G contains the edge between every pair of vertices from c; 4. accept if all checks pass, reject otherwise." Verifier runs in polytime: 1. checking encodings can be done in polytime, 2. time O(kn), where n = number of vertices of G, 3. time O(k^2 n^2) (O(k^2) pairs in c, time O(n^2) for each one). If in CLIQUE, then verifier accepts when c = a k-clique of G. If not in CLIQUE, then no value of c makes verifier accept. - Contrast with TRIANGLE = { | G contains a triangle }: TRIANGLE in NP: On input , check c encodes a triangle in G. But TRIANGLE in P: As shown in Exercise 5. Notes: - ~HAMPATH, ~CLIQUE, SUBSET-~SUM don't appear to belong to NP: apparently, no way to give a short certificate of NON-membership in HAMPATH, CLIQUE, or SUBSET-SUM. - On the other hand, ~COMPOSITES = PRIMES can be shown to belong to NP (using number theory). In fact, recent research result (Agrawal, Kayal, Saxena 2002) showed that PRIMES is actually in P (for more details, see http://crypto.cs.mcgill.ca/~stiglic/PRIMES_P_FAQ.html). Definition: coNP = { ~L | L in NP } = { complements of languages in NP }. Note: coNP =/= ~NP! L in coNP iff ~L in NP but L in ~NP iff L notin NP. [Picture: P subset of NP intersect coNP, all subset of decidable; analogy with computability where decidable = recognizable intersect co-recognizable.] Open question: P ?= NP intersect coNP (No strong concensus.) Open question: NP ?= coNP (Strongly believed to be NO.) Open question: P ?= NP (Strongly believed to be NO.) Answering these questions is worth 1 million dollars! (They are some of the "Millenium Problems" recognized by the Clay Mathematics Institute.) --------------------- Polytime reducibility --------------------- Defn: Language A is "polytime reducible" to language B (written A <=p B) if there is a polytime computable function f : Sigma* -> Sigma* such that for all w in Sigma*, w in A iff f(w) in B. Almost identical to many-one reducibility, with added constraint that f can be computed in polytime. Just like <=m, think of "<=p" as comparing the difficulty of deciding the languages. So A <=p B intuitively says "A is no more difficult to solve than B" or equivalently, "B is at least as hard to solve as A". Theorem: A <=p B and B in P (or NP) -> A in P (or NP). Main proof idea: On input x (or ), compute f(x), in polytime, then run decider for B on f(x) (or verifier for B on ), in polytime. Corollary: A <=p B and A not in P (or NP) -> B not in P (or NP). Just like for decidability/recognizability, one example of a language not in P could be used to prove more, using <=p. Problem: such languages hard to find, and only known examples are outside NP... Want to focus on NP because it contains a vast majority of problems from "real life" applications.