NP-Completeness Greg Plaxton Theory in Programming Practice, Spring 2004 Department of Computer Science University of Texas at Austin
Decision Problems • A decision problem is a computational problem where the answer to any given instance of the problem is either “yes” or “no” – Instances of the problem with a “yes” answer are called positive instances – Instances of the problem with a “no” answer are called negative instances • Here are some examples: – Given a text string t and a pattern string p , does p occur in t ? – Given an instance of an LP, and a real value B , is there a feasible solution to the LP for which the value of the objective function is at least B ? – Maximum Independent Set: Given an undirected graph G and a nonnegative integer k , does G contain a set U of at least k vertices such that no two vertices in U are connected by an edge? Theory in Programming Practice, Plaxton, Spring 2004
Polynomial-Time Algorithms • A polynomial-time algorithm is an algorithm with worst-case complexity that is upper bounded by some polynomial in the input size • Virtually all of the algorithms studied in this course run in polynomial time – Can you think of an exception? Theory in Programming Practice, Plaxton, Spring 2004
The Class P • The acronym “P” stands for “polynomial time” • A decision problem is in the class P if there is a polynomial-time algorithm to determine the answer (“yes” or “no”) for any given instance Theory in Programming Practice, Plaxton, Spring 2004
The Class NP • The acronym “NP” stands for nondeterministic polynomial time • There are several equivalent ways to formally define the class NP • One approach involves the notion of nondeterministic computation, thereby justifying the choice of the acronym NP • We will instead define the class NP in terms of polynomial-time verifiability Theory in Programming Practice, Plaxton, Spring 2004
The Class NP • A decision problem X is in NP if for every positive instance I of X , there is a short and polynomial-time verifiable certificate proving that I is a positive instance – The certificate is just a string (particular to the instance I ) – By “short” we mean that the size of the certificate is bounded by some polynomial in the size of the instance I – By “polynomial-time verifiable” we mean that there is a polynomial- time algorithm that can check whether any given string is indeed a certificate proving that I is a positive instance • We will discuss the notion of “polynomial-time verifiability” in greater detail momentarily • But first let’s look at a few examples of problems in NP Theory in Programming Practice, Plaxton, Spring 2004
Examples of Problems in NP • All decision problems in P also belong to NP – We can use the empty string as the short certificate – The polynomial-time verifier can simply run the polynomial-time decision procedure for determining whether the given instance is a positive instance • Satisfiability: Given a propositional formula f (such as the input to the Davis-Putnam procedure discussed earlier in the course), is f satisfiable? • Clique: Given an undirected graph G , does G contain a clique (i.e., a completely interconnected set of vertices) of size at least k ? • Hamiltonian Cycle: Given an undirected graph G , does G contain a simple cycle visiting all the vertices? Theory in Programming Practice, Plaxton, Spring 2004
Polynomial-Time Verification • Let X be a decision problem • We say that X is polynomial-time verifiable if there exists a polynomial- time algorithm A with the following properties – The input to A consists of an instance I of X and a string s such that the length of s is bounded by some polynomial in the size of I – The output of A is either “yes” or “no” – If I is a negative instance of X , then the output of A is “no”, regardless of the value of s – If I is a positive instance of X , then there is at least one choice of s for which A outputs “yes” • We think of A as the “verifier” and s as a purported “short proof” that the given instance I is a positive instance of X Theory in Programming Practice, Plaxton, Spring 2004
The Complexity of Problems in NP • Since problems in P also belong to NP, some problems in NP are “easy” in the sense that they are known to be solvable by a polynomial-time algorithm • It is an open problem whether all problems in NP can be solved in polynomial time, i.e., whether NP is equal to P • It is widely conjectured that some problems in NP require exponential time, so that NP is not equal to P • Still, the theory of NP-completeness, to be discussed next, sheds considerable light on the structure of the class NP Theory in Programming Practice, Plaxton, Spring 2004
NP-Completeness • A decision problem X in NP is defined to be NP-complete if existence of a polynomial-time algorithm for X implies that P equals NP, i.e., that every problem in NP admits a polynomial-time algorithm • Qualitatively, such an NP-complete problem is as hard to solve (up to polynomial factors) as any problem in NP • A priori, there is no particular reason to believe that NP-complete problems exist – An alternative hypothesis might be that there is no such “hardest” problem in NP – Instead, we might imagine that there are two or more problems in NP of incomparable hardness – In fact, NP-complete problems exist, as discussed on the next slide Theory in Programming Practice, Plaxton, Spring 2004
The Cook-Levin Theorem • The satisfiability problem is NP-complete • The proof of this theorem is not outrageously long but is beyond the scope of the present course Theory in Programming Practice, Plaxton, Spring 2004
Other NP-Complete Problems • Given that Cook-Levin have done the “heavy lifting” of establishing that satisfiability is NP-complete, we can now use the following simpler approach to establish the NP-completeness of a given problem X (that actually is NP-complete) – We still need to argue that X is in NP; Cook-Levin doesn’t help us here but in practice this step tends to be easy – We then prove that a polynomial-time algorithm for X could be used as a subroutine to obtain a polynomial-time algorithm for satisfiability (or some other known NP-complete problem) • The literature contains literally thousands of examples of problems that have been proven to be NP-complete in the above manner • The maximum independent set, maximum clique, and Hamiltonian cycle problems mentioned earlier in this lecture are all examples of NP-complete problems Theory in Programming Practice, Plaxton, Spring 2004
NP-Hardness • Thus far we have restricted our discussion to decision problems • A problem X is said to be NP-hard if a polynomial-time algorithm for X implies that P equals NP – An NP-hard problem need not be a decision problem – An NP-hard decision problem need not be in NP • There is a significant body of literature devoted to the design and analysis of provably-good approximation algorithms for NP-hard problems – Interestingly, the approximation versions of NP-complete problems can differ dramatically in terms of approximability Theory in Programming Practice, Plaxton, Spring 2004
Other Complexity Classes • Complexity theorists have defined a wide variety of complexity classes • Some of these classes properly contain NP, i.e., they include problems that are harder than NP-complete problems • Some of these classes refine the class P, i.e., they define problems that are in some sense easier than the hardest problems in P (the P-complete problems) • Still, the P versus NP question is considered the central problem in complexity theory – It is felt to best represent the boundary between “tractable” and “intractable” problems Theory in Programming Practice, Plaxton, Spring 2004
Recommend
More recommend