2pt 0em
play

2pt 0em CSCE423/823 Computer Science & Engineering 423/823 - PowerPoint PPT Presentation

2pt 0em CSCE423/823 Computer Science & Engineering 423/823 Introduction Proofs of NPC Design and Analysis of Algorithms Problems Lecture 08 NP-Completeness (Chapter 34) Stephen Scott (Adapted from Vinodchandran N. Variyam) 1 / 44


  1. 2pt 0em CSCE423/823 Computer Science & Engineering 423/823 Introduction Proofs of NPC Design and Analysis of Algorithms Problems Lecture 08 — NP-Completeness (Chapter 34) Stephen Scott (Adapted from Vinodchandran N. Variyam) 1 / 44

  2. Introduction CSCE423/823 So far, we have focused on problems with “e ffi cient” algorithms Introduction I.e. problems with algorithms that run in polynomial time: O ( n c ) for E ffi ciency P vs. NP some constant c NP- Completeness Side note: We call it e ffi cient even if c is large, since it is likely that Proving NP- Completeness another, even more e ffi cient, algorithm exists Reductions CIRCUIT-SAT But, for some problems, the fastest known algorithms require time Other NPC Problems that is superpolynomial Proofs of NPC Problems Includes sub-exponential time (e.g. 2 n 1 / 3 ), exponential time (e.g. 2 n ), doubly exponential time (e.g. 2 2 n ), etc. There are even problems that cannot be solved in any amount of time (e.g. the “halting problem”) 2 / 44

  3. P vs. NP CSCE423/823 Our focus will be on the complexity classes called P and NP Centers on the notion of a Turing machine (TM), which is a finite Introduction state machine with an infinitely long tape for storage E ffi ciency Anything a computer can do, a TM can do, and vice-versa P vs. NP NP- More on this in CSCE 428/828 and CSCE 424/824 Completeness Proving NP- Completeness P = “deterministic polynomial time” = the set of problems that can Reductions CIRCUIT-SAT be solved by a deterministic TM (deterministic algorithm) in Other NPC Problems polynomial time Proofs of NPC Problems NP = “nondeterministic polynomial time” = the set of problems that can be solved by a nondeterministic TM in polynomial time Can loosely think of a nondeterministic TM as one that can explore many, many possible paths of computation at once Equivalently, NP is the set of problems whose solutions, if given, can be verified in polynomial time 3 / 44

  4. P vs. NP Example CSCE423/823 Introduction Problem HAM-CYCLE: Does a graph G = ( V, E ) contain a E ffi ciency P vs. NP hamiltonian cycle , i.e. a simple cycle that visits every vertex in V NP- Completeness exactly once? Proving NP- Completeness Reductions This problem is in NP, since if we were given a specific G plus the CIRCUIT-SAT answer to the question plus a certificate , we can verify a “yes” Other NPC Problems answer in polynomial time using the certificate Proofs of NPC Problems What would be an appropriate certificate? Not known if HAM-CYCLE 2 P 4 / 44

  5. P vs. NP Example (2) CSCE423/823 Introduction E ffi ciency Problem EULER: Does a directed graph G = ( V, E ) contain an P vs. NP NP- Euler tour , i.e. a cycle that visits every edge in E exactly once and Completeness Proving NP- can visit vertices multiple times? Completeness Reductions This problem is in P, since we can answer the question in polynomial CIRCUIT-SAT Other NPC time by checking if each vertex’s in-degree equals its out-degree Problems Proofs of NPC Does that mean that the problem is also in NP? If so, what is the Problems certificate? 5 / 44

  6. NP-Completeness CSCE423/823 Any problem in P is also in NP, since if we can e ffi cently solve the Introduction problem, we get the poly-time verification for free E ffi ciency ) P ✓ NP P vs. NP NP- Completeness Not known if P ⇢ NP, i.e. unknown if there a problem in NP that’s Proving NP- Completeness not in P Reductions CIRCUIT-SAT Other NPC A subset of the problems in NP is the set of NP-complete (NPC) Problems problems Proofs of NPC Problems Every problem in NPC is at least as hard as all others in NP These problems are believed to be intractable (no e ffi cient algorithm), but not yet proven to be so .. If any NPC problem is in P, then P = NP and life is glorious ^ 6 / 44

  7. Proving NP-Completeness CSCE423/823 Thus, if we prove that a problem is NPC, we can tell our boss that Introduction we cannot find an e ffi cient algorithm and should take a di ff erent E ffi ciency approach P vs. NP NP- Completeness E.g. approximation algorithm, heuristic approach Proving NP- Completeness How do we prove that a problem A is NPC? Reductions CIRCUIT-SAT Other NPC Prove that A 2 NP by finding certificate 1 Problems Show that A is as hard as any other NP problem by showing that if we 2 Proofs of NPC Problems can e ffi ciently solve A then we can e ffi ciently solve all problems in NP First step is usually easy, but second looks di ffi cult Fortunately, part of the work has been done for us ... 7 / 44

  8. Reductions CSCE423/823 We will use the idea of a reduction of one problem to another to Introduction prove how hard it is E ffi ciency P vs. NP NP- A reduction takes an instance of one problem A and transforms it to Completeness Proving NP- an instance of another problem B in such a way that a solution to Completeness Reductions the instance of B yields a solution to the instance of A CIRCUIT-SAT Other NPC Problems Example 1: How did we solve the bipartite matching problem? Proofs of NPC Problems Example 2: How did we solve the topological sort problem? Time complexity of reduction-based algorithm for A is the time for the reduction to B plus the time to solve the instance of B 8 / 44

  9. Decision Problems CSCE423/823 Before we go further into reductions, we simplify our lives by focusing on decision problems Introduction In a decision problem, the only output of an algorithm is an answer E ffi ciency “yes” or “no” P vs. NP NP- Completeness I.e. we’re not asked for a shortest path or a hamiltonian cycle, etc. Proving NP- Completeness Reductions Not as restrictive as it may seem: Rather than asking for the weight CIRCUIT-SAT Other NPC of a shortest path from i to j , just ask if there exists a path from i Problems Proofs of NPC to j with weight at most k Problems Such decision versions of optimization problems are no harder than the original optimization problem (why?), so if we show the decision version is hard, then so is the optimization version Decision versions are especially convenient when thinking in terms of languages and the Turing machines that accept/reject them 9 / 44

  10. Reductions (2) CSCE423/823 What is a reduction in the NPC sense? Start with two problems A and B , and we want to show that Introduction problem B is at least as hard as A E ffi ciency P vs. NP Will reduce A to B via a polynomial-time reduction by NP- Completeness transforming any instance ↵ of A to some instance � of B such that Proving NP- Completeness Reductions The transformation must take polynomial time (since we’re talking 1 CIRCUIT-SAT about hardness in the sense of e ffi cient vs. ine ffi cient algorithms) Other NPC Problems The answer for ↵ is “yes” if and only if the answer for � is “yes” 2 Proofs of NPC Problems If such a reduction exists, then B is at least as hard as A since if an e ffi cient algorithm exists for B , we can solve any instance of A in polynomial time Notation: A  P B , which reads as “ A is no harder to solve than B , modulo polynomial time reductions” 10 / 44

  11. Reductions (3) CSCE423/823 Introduction E ffi ciency P vs. NP NP- Completeness Proving NP- Completeness Reductions CIRCUIT-SAT Other NPC Problems Proofs of NPC Problems 11 / 44

  12. Reductions (4) CSCE423/823 But if we want to prove that a problem B is NPC, do we have to Introduction E ffi ciency reduce to it every problem in NP? P vs. NP NP- No we don’t: Completeness Proving NP- Completeness If another problem A is known to be NPC, then we know that any Reductions problem in NP reduces to it CIRCUIT-SAT Other NPC If we reduce A to B , then any problem in NP can reduce to B via its Problems Proofs of NPC reduction to A followed by A ’s reduction to B Problems We then can call B an NP-hard problem, which is NPC if it is also in NP Still need our first NPC problem to use as a basis for our reductions 12 / 44

  13. CIRCUIT-SAT CSCE423/823 Introduction E ffi ciency P vs. NP Our first NPC problem: CIRCUIT-SAT NP- Completeness Proving NP- An instance is a boolean combinational circuit (no feedback, no Completeness Reductions memory) CIRCUIT-SAT Other NPC Problems Question: Is there a satisfying assignment , i.e. an assignment of Proofs of NPC inputs to the circuit that satisfies it (makes its output 1)? Problems 13 / 44

  14. CIRCUIT-SAT (2) CSCE423/823 Introduction E ffi ciency P vs. NP NP- Completeness Proving NP- Completeness Reductions CIRCUIT-SAT Other NPC Problems Proofs of NPC Problems Satisfiable Unsatisfiable 14 / 44

  15. CIRCUIT-SAT (3) CSCE423/823 Introduction To prove CIRCUIT-SAT to be NPC, need to show: E ffi ciency P vs. NP NP- CIRCUIT-SAT 2 NP; what is its certificate that we can confirm in 1 Completeness Proving NP- polynomial time? Completeness Reductions That any problem in NP reduces to CIRCUIT-SAT 2 CIRCUIT-SAT Other NPC We’ll skip the NP-hardness proof, save to say that it leverages the Problems Proofs of NPC existence of an algorithm that verifies certificates for some NP Problems problem 15 / 44

Recommend


More recommend