CSCE750 Analysis of Algorithms Fall 2017 NP-Complete Problems

Similar documents
Computability Theory

Example of a Demonstration that a Problem is NP-Complete by reduction from CNF-SAT

Complexity Classes and Polynomial-time Reductions

P and NP (Millenium problem)

NP-Completeness. Algorithms

1 Introduction. 1. Prove the problem lies in the class NP. 2. Find an NP-complete problem that reduces to it.

NP-Completeness of 3SAT, 1-IN-3SAT and MAX 2SAT

W4231: Analysis of Algorithms

NP Completeness. Andreas Klappenecker [partially based on slides by Jennifer Welch]

P -vs- NP. NP Problems. P = polynomial time. NP = non-deterministic polynomial time

8 NP-complete problem Hard problems: demo

Reductions and Satisfiability

NP-Complete Reductions 2

8.1 Polynomial-Time Reductions

9.1 Cook-Levin Theorem

Best known solution time is Ω(V!) Check every permutation of vertices to see if there is a graph edge between adjacent vertices

The Satisfiability Problem [HMU06,Chp.10b] Satisfiability (SAT) Problem Cook s Theorem: An NP-Complete Problem Restricted SAT: CSAT, k-sat, 3SAT

Unit 8: Coping with NP-Completeness. Complexity classes Reducibility and NP-completeness proofs Coping with NP-complete problems. Y.-W.

SAT-CNF Is N P-complete

8.1 Polynomial-Time Reductions

Some Hardness Proofs

NP-Hardness. We start by defining types of problem, and then move on to defining the polynomial-time reductions.

arxiv: v2 [cs.cc] 29 Mar 2010

Chapter 8. NP-complete problems

CMPSCI611: The SUBSET-SUM Problem Lecture 18

Chapter 8. NP and Computational Intractability. Slides by Kevin Wayne. Copyright 2005 Pearson-Addison Wesley. All rights reserved.

(p 300) Theorem 7.27 SAT is in P iff P=NP

P and NP CISC4080, Computer Algorithms CIS, Fordham Univ. Instructor: X. Zhang

! Greed. O(n log n) interval scheduling. ! Divide-and-conquer. O(n log n) FFT. ! Dynamic programming. O(n 2 ) edit distance.

P and NP CISC5835, Algorithms for Big Data CIS, Fordham Univ. Instructor: X. Zhang

CS 580: Algorithm Design and Analysis

NP and computational intractability. Kleinberg and Tardos, chapter 8

! Greed. O(n log n) interval scheduling. ! Divide-and-conquer. O(n log n) FFT. ! Dynamic programming. O(n 2 ) edit distance.

3/7/2018. CS 580: Algorithm Design and Analysis. 8.1 Polynomial-Time Reductions. Chapter 8. NP and Computational Intractability

Where Can We Draw The Line?

Steven Skiena. skiena

COMP260 Spring 2014 Notes: February 4th

Lecture 2: NP-Completeness

Computational problems. Lecture 2: Combinatorial search and optimisation problems. Computational problems. Examples. Example

1. Suppose you are given a magic black box that somehow answers the following decision problem in polynomial time:

Exercises Computational Complexity

Introduction to Algorithms

/633 Introduction to Algorithms Lecturer: Michael Dinitz Topic: Approximation algorithms Date: 11/27/18

1 Definition of Reduction

NP-Complete Problems

Exact Algorithms Lecture 7: FPT Hardness and the ETH

Recitation 4: Elimination algorithm, reconstituted graph, triangulation

A New Reduction from 3-SAT to Graph K- Colorability for Frequency Assignment Problem

Lecture 7: Counting classes

A Simplied NP-complete MAXSAT Problem. Abstract. It is shown that the MAX2SAT problem is NP-complete even if every variable

PCP and Hardness of Approximation

Greedy algorithms Or Do the right thing

Chapter 10 Part 1: Reduction

CS154, Lecture 18: PCPs, Hardness of Approximation, Approximation-Preserving Reductions, Interactive Proofs, Zero-Knowledge, Cold Fusion, Peace in

Lecture 20: Satisfiability Steven Skiena. Department of Computer Science State University of New York Stony Brook, NY

Fixed Parameter Algorithms

NP-complete Reductions

Partha Sarathi Mandal

Chapter 8. NP-complete problems

Decision Problems. Observation: Many polynomial algorithms. Questions: Can we solve all problems in polynomial time? Answer: No, absolutely not.

Copyright 2000, Kevin Wayne 1

Introduction to Algorithms. Lecture 24. Prof. Patrick Jaillet

Reductions. Linear Time Reductions. Desiderata. Reduction. Desiderata. Classify problems according to their computational requirements.

SAT Solver. CS 680 Formal Methods Jeremy Johnson

CSC 505, Fall 2000: Week 12

Engineering 9867 Advanced Computing Concepts

Greedy Algorithms 1 {K(S) K(S) C} For large values of d, brute force search is not feasible because there are 2 d {1,..., d}.

Massachusetts Institute of Technology Department of Electrical Engineering and Computer Science Algorithms For Inference Fall 2014

Introduction to Algorithms / Algorithms I Lecturer: Michael Dinitz Topic: Approximation algorithms Date: 11/18/14

NP versus PSPACE. Frank Vega. To cite this version: HAL Id: hal

Boolean Functions (Formulas) and Propositional Logic

Greedy Algorithms 1. For large values of d, brute force search is not feasible because there are 2 d

6.006 Introduction to Algorithms. Lecture 25: Complexity Prof. Erik Demaine

Hardness of Approximation for the TSP. Michael Lampis LAMSADE Université Paris Dauphine

Prove, where is known to be NP-complete. The following problems are NP-Complete:

Lecture 21: Other Reductions Steven Skiena

In this lecture we discuss the complexity of approximation problems, and show how to prove they are NP-hard.

Homework 4 Solutions

Lecture 10 October 7, 2014

P vs. NP. Simpsons: Treehouse of Horror VI

Ch9: Exact Inference: Variable Elimination. Shimi Salant, Barak Sternberg

Finite Model Generation for Isabelle/HOL Using a SAT Solver

Chapter 8. NP-complete problems. Search problems. cient algorithms. Exponential search space

University of Nevada, Las Vegas Computer Science 456/656 Fall 2016

Approximation Algorithms

1 Better Approximation of the Traveling Salesman

Linear Time Unit Propagation, Horn-SAT and 2-SAT

Lecture 1. 2 Motivation: Fast. Reliable. Cheap. Choose two.

W[1]-hardness. Dániel Marx. Recent Advances in Parameterized Complexity Tel Aviv, Israel, December 3, 2017

Localization in Graphs. Richardson, TX Azriel Rosenfeld. Center for Automation Research. College Park, MD

Inapproximability of the Perimeter Defense Problem

Binary Decision Diagrams

Reductions. designing algorithms establishing lower bounds establishing intractability classifying problems. Bird s-eye view

Lecture 13. Reading: Weiss, Ch. 9, Ch 8 CSE 100, UCSD: LEC 13. Page 1 of 29

2SAT Andreas Klappenecker

Discrete Wiskunde II. Lecture 6: Planar Graphs

Examples of P vs NP: More Problems

CSE 417 Branch & Bound (pt 4) Branch & Bound

The NP-Completeness of Some Edge-Partition Problems

Polynomial SAT-Solver Algorithm Explanation

Transcription:

CSCE750 Analysis of Algorithms Fall 2017 NP-Complete Problems This document contains slides from the lecture, formatted to be suitable for printing or individual reading, and with some supplemental explanations added. It is intended as a supplement to, rather than a replacement for, the lectures themselves you should not expect the notes to be self-contained or complete on their own. 1 Introduction The theory of NP-completeness can be used cast doubt on the existence of any polynomial-time algorithm for a given problem. CLRS 34 GJ 1 3 So far, we have concentrated mostly on designing and analyzing efficient algorithms for various problems. Algorithms are evidence of how easy those problems are. By showing that a problem is NP-complete, we are giving evidence of how hard a problem is. Practically, we can think of an NP-completeness proof as a license to stop looking for an efficient algorithm, and settle for approximation or to consider only special cases. Note: Both CLRS and GJ define things at higher level of precision than we ll examine in the lecture: models of computation, abstract vs. concrete problems, encodings, etc. 2 Illustration (from Garey and Johnson) CSCE750 Fall 2017 NP-Complete Problems 1 of 9

I can t find an efficient algorithm. I guess I m just too dumb. I can t find an efficient algorithm, because no such algorithm is possible. I can t find an efficient algorithm, but neither can any of these famous people. 3 Decision problems A decision problem is a problem in which the correct output for each instance is either Yes or No. HAM-CYCLE: Instance: An undirected graph G = (V, E). Question: Does G contain a cycle that visits every vertex exactly once? CSCE750 Fall 2017 NP-Complete Problems 2 of 9

PATH: Instance: A weighted directed graphg, a pair of verticesu,v E(G), and a number k. Question: Does G contain a path fromutov with total weight at most k? 4 Aside: Optimization problems We can convert any optimization problem ( Find the largest..., Find the smallest..., etc) to a decision problem by including a bound on the objective function as part of the input. 5 Problems as languages We can think of a decision problem as a formal language. The input is a (binary) string s. The output is either Yes or No. The language of a problem is the set of binary input strings, under a suitable encoding, for which the correct output is Yes. 6 Example language HAM-CYCLE: Instance: An undirected graph G = (V, E). Question: Does G contain a cycle that visits every vertex exactly once? The languagel HAM-CYCLE is the set of strings describing undirected graphs that have Hamiltonian cycles. 7 Deciding a language Definition: An algorithm decides a language if it correctly determines whether its input string is a member of that language. Specifically, the algorithm should: Terminate for any input instance. Return yes if the input instance is in the language. Return no if the input instance is not in the language. CSCE750 Fall 2017 NP-Complete Problems 3 of 9

8 Verification algorithms A verification algorithm accepts two inputs: An ordinary string x (the real input) A certificatey (a proof that the correct answer for x is Yes). A verification algorithm produces one of two outputs: Yes, or No. The language verified by a verification algorithm is L = {x there exists y for which A(x, y) outputs Yes.} 9 Verification example: HAM-CYCLE We can form a verification algorithm for HAM-CYCLE that accepts two inputs: An undirected graph G = (V, E). An ordered list of vertices(v 1,...,v m ). The algorithm would: Output Yes if: the sequence (v 1,...,v m ) contains all of the vertices ofv, with no duplicates, and E contains an edge(v i,v i+1 ) for eachi = 1,...,m 1. E contains an edge(v m,v 1 ). Output No otherwise. 10 Verification example: PATH We can form a verification algorithm for PATH that accepts two inputs: A weighted directed graphg, a pair of vertices u,v E(G), and a number k. An ordered list of vertices(v 1,...,v m ). The algorithm would: Output Yes if: v 1 = u, v m = v, E contains an edge(v i,v i+1 ) for eachi = 1,...,m, and the total weight of all these edges is at most k. Output No otherwise. CSCE750 Fall 2017 NP-Complete Problems 4 of 9

11 P Intuition: P is the set of all problems that can be decided in polynomial time. Definition: P is the set of all languageslfor which there exists an algorithm A and a constant c, such that A decidesl, and the worst-case run time of A is O(n c ). 12 NP Intuition: NP is the set of all problems for which Yes answers can be verified in polynomial time. Definition: NP is the set of all languages L for which there exists a verification algorithmaand a constant c, such that A verifiesl, and the worst-case run time of A is O(n c ). non-polynomial time nondeterministic polynomial time 13 P NP Every problem inpis also innp. Why? 14 NP P? Are there problems innp that are not in P? That is: Are all problems that are polynomially verifiable also polynomially solvable? Note: IfNP P, then P = NP. 15 Reductions We can show relationships between problems using reductions: Definition: A language L 1 is polynomial-time reducible to another language L 2 if there exists a polynomial time algorithm f such that x L 1 if and only if f(x) L 2 IfL 1 is polynomial-time reducible to L 2, we writel 1 P L 2 CSCE750 Fall 2017 NP-Complete Problems 5 of 9

16 Polynomial-time reductions preserve polynomial-time solvability Lemma (34.2): If L 2 P andl 1 P L 2, then L 1 P. Intuition: L 1 P L 2 means that L 1 is no harder to solve thanl 2. 17 NP-hard Definition: A languagelis NP-hard if, for everyl NP,L P L. 18 NP-complete Definition: A language that is both NP and NP-hard is called NP-complete. Intuition: NP-complete is the set of the hardest problems innp. 19 Why is NP-complete important? Theorem 34.4: If any language in NP-complete is polynomial-time solvable, thenp = NP. 20 The Cook-Levin Theorem SAT: Instance: A Boolean formula φ consisting of variables, parentheses, and and/or/not operators. Question: Is there an assignment of True/False values to the variables that makes the formula evaluate to True? Theorem (Cook-Levin): Boolean satisfiability is NP-complete. (The surprisingly accessible proof is covered in CSCE551.) 21 NP-completeness proofs Recipe for proving a problemlis NP-complete: 1. Prove thatl NP by describing a polynomial time verification algorithm. 2. Choose a language L that we already know is NP-complete. CSCE750 Fall 2017 NP-Complete Problems 6 of 9

3. Describe a polynomial time algorithm F that maps and instance x ofl to an instancef(x) of L. 4. Prove that if x L then f(x) L. 5. Prove that if x L then f(x) L. Intuition: This is essentially a proof by contradiction. We re showing that, if we have a polynomial-time algorithm to decidel, then we can use it form a polynomial-time algorithm to decidel. 22 Watch out! It is very easy to get the direction of the reduction wrong. A known NP-complete problem B problem you want to show is NP-complete The reduction must be an algorithm whose input is instance of problema, and output is an equivalent instance of problemb. 23 Example: 3-SAT Definition: A Boolean formula in conjunctive normal form is a series of clauses. Each clause is an OR of literals (that is, variables or negations of variables). The complete formula is the AND of all of the clauses. (x 1 x 2 x 3 ) ( x 2 x 3 x 4 ) ( x 1 x 2 x 5 ) 3-SAT: Instance: A CNF formula with 3 literals in each clause. Question: Is there an assignment of True/False values to the variables that makes the formula evaluate to True? Theorem: 3-SAT is NP-complete. Proof: Reduction from SAT. (CLRS 1082) CSCE750 Fall 2017 NP-Complete Problems 7 of 9

24 Example: Vertex cover VERTEX COVER: Instance: A graphgand an integerk. Question: Is there a set of K vertices ingthat touches each edge at least once? 25 VERTEX COVER is in NP Theorem: VERTEX COVER is innp. Proof: Use the set of vertices that covers the graph as the certificate. Verify that there are at most K vertices (constant time) and that each edge touches at least one of them (linear time). 26 Vertex cover is NP-hard Theorem: VERTEX COVER is NP-hard. Proof: Reduction from 3-SAT. Given an arbitrary instance φ of 3-SAT with n variables and m clauses, form an instance (G,K) of VERTEX COVER as follows. Truth-setting components: One vertex for each literal in φ, with eachxconnected to x. x 1 x 1 x 2 x 2 Idea: A vertex cover must contain at least one vertex from each pair. 27 Vertex cover (reduction continued) Clause-satisfaction components: Three vertices for each clause, connected to each other. x 2 x 3 x 4 Idea: A vertex cover must select at least two vertices from each of these triangles. 28 Vertex cover (reduction continued) Connecting edges: A edge connecting each node in each clause-satisfaction component to the corresponding truth-setting node. CSCE750 Fall 2017 NP-Complete Problems 8 of 9

Number of vertices allowed in cover: Choose K = n + 2m. 29 Vertex cover (correctness of reduction) Theorem: Ifφis satisfiable, thenghas a vertex cover of size n+2m. Proof: Given a satisfying assignment t for φ, consider this set of vertices: In truth-setting components, choose x i iftsets x i to true, or x i otherwise. In clause-satisfaction components, find the first literal set to true, and choose the other two vertices. Clearly this set has size n + 2m. Note that it covers all edges (1) within truth-setting components, (2) within clause-satisfaction components, and (3) between truth-setting and clause-satisfaction components. Therefore, it is a vertex cover for G. 30 Vertex cover (correctness of reduction) Theorem: IfGhas a vertex cover of size n+2m, thenφis satisfiable. Proof: Suppose there exists a vertex coveraofgwith sizen+2m. By construction, this cover must include one vertex in each truth-setting component, and two vertices in each clause-satisfaction component. Lettbe the truth assignment that makes x i true iff its truth-setting vertex is in the vertex cover A. For each clausec inφ, the corresponding clause-satisfaction component has exactly one vertexv that is not in the vertex cover. An edge connects v to a truth-setting vertex u. Since A is a vertex cover, and v / A, we know that u A. Therefore, the literal associated withuis satisfied int, which implies that C is satisfied. Becausetsatisfies each clause of φ, it satisfies φ. 31 More examples Additional reduction examples: CLRS 34.5 GJ Fenner s notes Erickson s notes CSCE750 Fall 2017 NP-Complete Problems 9 of 9