Search and Optimization Problems. CSE 548: (Design and) Analysis of Algorithms. Hard Problems: Where you find yourself...

Similar documents
CSE 548: (Design and) Analysis of Algorithms

Summer School on Introduction to Algorithms and Optimization Techniques July 4-12, 2017 Organized by ACMU, ISI and IEEE CEDA.

NP Completeness and Approximation Algorithms

Introduction to Complexity Theory

NP Complete Problems. COMP 215 Lecture 20

Design and Analysis of Algorithms

Theory of Computation CS3102 Spring 2014 A tale of computers, math, problem solving, life, love and tragic death

NP Completeness. CS 374: Algorithms & Models of Computation, Spring Lecture 23. November 19, 2015

Polynomial-time Reductions

Introduction. Pvs.NPExample

Correctness of Dijkstra s algorithm

Notes for Lecture 21

1.1 P, NP, and NP-complete

Essential facts about NP-completeness:

COMP Analysis of Algorithms & Data Structures

CS 5114: Theory of Algorithms. Tractable Problems. Tractable Problems (cont) Decision Problems. Clifford A. Shaffer. Spring 2014

an efficient procedure for the decision problem. We illustrate this phenomenon for the Satisfiability problem.

Non-Deterministic Time

SAT, Coloring, Hamiltonian Cycle, TSP

P is the class of problems for which there are algorithms that solve the problem in time O(n k ) for some constant k.

NP-Completeness. Subhash Suri. May 15, 2018

Show that the following problems are NP-complete

CS 583: Algorithms. NP Completeness Ch 34. Intractability

CS 5114: Theory of Algorithms

Complexity Theory VU , SS The Polynomial Hierarchy. Reinhard Pichler

Outline. Complexity Theory EXACT TSP. The Class DP. Definition. Problem EXACT TSP. Complexity of EXACT TSP. Proposition VU 181.

P P P NP-Hard: L is NP-hard if for all L NP, L L. Thus, if we could solve L in polynomial. Cook's Theorem and Reductions

NP and NP Completeness

SAT, NP, NP-Completeness

NP-Completeness. f(n) \ n n sec sec sec. n sec 24.3 sec 5.2 mins. 2 n sec 17.9 mins 35.

CMSC 441: Algorithms. NP Completeness

Easy Problems vs. Hard Problems. CSE 421 Introduction to Algorithms Winter Is P a good definition of efficient? The class P

Lecture 4: NP and computational intractability

NP-Completeness Review

Computational Complexity. IE 496 Lecture 6. Dr. Ted Ralphs

Computational Complexity and Intractability: An Introduction to the Theory of NP. Chapter 9

CS Lecture 29 P, NP, and NP-Completeness. k ) for all k. Fall The class P. The class NP

Lecture Notes 4. Issued 8 March 2018

Intro to Theory of Computation

Limitations of Algorithm Power

CS/COE

Turing Machines and Time Complexity

6.045: Automata, Computability, and Complexity (GITCS) Class 15 Nancy Lynch

Lecture 18: P & NP. Revised, May 1, CLRS, pp

CS5371 Theory of Computation. Lecture 19: Complexity IV (More on NP, NP-Complete)

CS311 Computational Structures. NP-completeness. Lecture 18. Andrew P. Black Andrew Tolmach. Thursday, 2 December 2010

COP 4531 Complexity & Analysis of Data Structures & Algorithms

NP-Complete Problems. More reductions

Polynomial-time reductions. We have seen several reductions:

The Class NP. NP is the problems that can be solved in polynomial time by a nondeterministic machine.

NP-Completeness. Until now we have been designing algorithms for specific problems

NP-Completeness. Andreas Klappenecker. [based on slides by Prof. Welch]

Computer Science 385 Analysis of Algorithms Siena College Spring Topic Notes: Limitations of Algorithms

Complexity Theory. Knowledge Representation and Reasoning. November 2, 2005

Chapter 2. Reductions and NP. 2.1 Reductions Continued The Satisfiability Problem (SAT) SAT 3SAT. CS 573: Algorithms, Fall 2013 August 29, 2013

Complexity, P and NP

Some Algebra Problems (Algorithmic) CSE 417 Introduction to Algorithms Winter Some Problems. A Brief History of Ideas

Algorithms: COMP3121/3821/9101/9801

Computability and Complexity Theory: An Introduction

Harvard CS 121 and CSCI E-121 Lecture 22: The P vs. NP Question and NP-completeness

CS 6505, Complexity and Algorithms Week 7: NP Completeness

1 More finite deterministic automata

Algorithm Design and Analysis

CS154, Lecture 17: conp, Oracles again, Space Complexity

COMP/MATH 300 Topics for Spring 2017 June 5, Review and Regular Languages

Computational Complexity

NP-Completeness. NP-Completeness 1

CSE 135: Introduction to Theory of Computation NP-completeness

CHAPTER 3 FUNDAMENTALS OF COMPUTATIONAL COMPLEXITY. E. Amaldi Foundations of Operations Research Politecnico di Milano 1

UC Berkeley CS 170: Efficient Algorithms and Intractable Problems Handout 22 Lecturer: David Wagner April 24, Notes 22 for CS 170

CS 320, Fall Dr. Geri Georg, Instructor 320 NP 1

Classes of Problems. CS 461, Lecture 23. NP-Hard. Today s Outline. We can characterize many problems into three classes:

Complexity and NP-completeness

NP-Completeness. CptS 223 Advanced Data Structures. Larry Holder School of Electrical Engineering and Computer Science Washington State University

1. Introduction Recap

NP-completeness. Chapter 34. Sergey Bereg

1 Primals and Duals: Zero Sum Games

NP-Complete Reductions 1

DESIGN AND ANALYSIS OF ALGORITHMS. Unit 6 Chapter 17 TRACTABLE AND NON-TRACTABLE PROBLEMS

Unit 6 Chapter 17 TRACTABLE AND NON-TRACTABLE PROBLEMS

Discrete Optimization 2010 Lecture 10 P, N P, and N PCompleteness

NP-COMPLETE PROBLEMS. 1. Characterizing NP. Proof

NP-Completeness and Boolean Satisfiability

8. INTRACTABILITY I. Lecture slides by Kevin Wayne Copyright 2005 Pearson-Addison Wesley. Last updated on 2/6/18 2:16 AM

Principles of Knowledge Representation and Reasoning

Computational Complexity

Tractability. Some problems are intractable: as they grow large, we are unable to solve them in reasonable time What constitutes reasonable time?

Some Algebra Problems (Algorithmic) CSE 417 Introduction to Algorithms Winter Some Problems. A Brief History of Ideas

More on NP and Reductions

Chapter 34: NP-Completeness

Instructor N.Sadagopan Scribe: P.Renjith. Lecture- Complexity Class- P and NP

Geometric Steiner Trees

P, NP, NP-Complete, and NPhard

P and NP. Inge Li Gørtz. Thank you to Kevin Wayne, Philip Bille and Paul Fischer for inspiration to slides

NP-Hardness reductions

NP and Computational Intractability

NP-Completeness. NP-Completeness 1

NP-problems continued

P vs. NP. Data Structures and Algorithms CSE AU 1

Transcription:

Search and Optimization Problems CSE 548: (Design and) Analysis of Algorithms NP and Complexity Classes R. Sekar Many problems of our interest are search problems with exponentially (or even infinitely) many solutions Shortest of the paths between two vertices Spanning tree with minimal cost Combination of variable values that minimize an objective We should be surprised we find efficient (i.e., polynomial-time) solutions to these problems It seems like these should be the exceptions rather than the norm! What do we do when we hit upon other search problems? 1 / 38 2 / 38 Hard Problems: Where you find yourself... Search and Optimization Problems What do we do when we hit upon hard search problems? Can we prove they can t be solved efficiently? I can t find an efficient algorithm, I guess I m just too dumb. Images from Computers and Intractability by Garey and Johnson 3 / 38 4 / 38

Hard Problems: Where you would like to be... Search and Optimization Problems I can t find an efficient algorithm, because no such algorithm is possible. Unfortunately, it is very hard to prove that efficient algorithms are impossible Second best alternative: Show that the problem is as hard as many other problems that have been worked on by a host of brilliant scientists over a very long time Much of complexity theory is concerned with categorizing hard problems into such equivalence classes Images from Computers and Intractability by Garey and Johnson 5 / 38 6 / 38 Nondeterminism and Search Problems P, NP, Co-NP, NP-hard and NP-complete 7 / 38 Nondeterminism is an oft-used abstraction in language theory Non-deterministic FSA Non-deterministic PDA So, why not non-deterministic Turing machines? Acceptance criteria is analogous to NFA and NPDA if there is a sequence of transitions to an accepting state, an NDTM will take that path. What does nondeterminism, a theoretical construct, mean in practice? You can think of it as a boundless potential to search for and identify the correct path that leads to a solution So, it does not change the class of problems that can be solved, just the time/space needed to solve. 8 / 38

Class NP: Non-deterministic Polynomial Time What are the bounds of NP? How they operate: Guess a solution verify correctness in polynomial time Polynomial time verifiability is the key property of NP. This is how you build a path from P to NP. Ideal formulation for search problems, where correct solutions are hard to find but easy to recognize. No surprise that complement of NP problems are typically not in NP. UNSAT: x P(x) where P is in CNF VALID: xp(x), where P is in DNF Only Decision problems: Problems with an yes or no answer Optimization problems are generally not in NP But we can often find optimal solutions using binary search No answers are usually not verifiable in P-time So, complement of NP problems are often not NP. UNSAT show that a CNF formula is false for all truth assignments 1 Example: Boolean formula satisfiability (SAT) Given a boolean formula in CNF, find an assignment Algorithms of {true, false} to variables that makes it true. Key point: You cannot negate nondeterministic automata. So, we are unable to convert an NDTMLecture for SAT to30: solvenp-hard UNSAT in Problem NP-time. Why not DNF? 1 Whether UNSAT NP is unknown! is harder than just 9 / 38 checking that a solution is correct. But nobody knows how to prove 10 / 38 it! solve this problem. What are the bounds of NP? A more subtle but still open Co-NP: question Problems is whether whose the complexity complement classesisnp inand NP co-np are Even if we can verify every answer quickly, there s no reason to believe we can also verify Existentially quantified vs Universally quantifiedisformulas generally believed that NP co-np, Decisionbut problems nobody that knows have a polynomially how to prove checkable it. proof when NP is good for x P(x): guess a value for x and check if P(x) holds. the answer is no NP is not good for x P(x): Guessing does not seem to help if you need to check all values of x. Negation of existential formula yields a universal formula. NP seems to be a good way to separate hard problems from even Biggest open problem: Is P = NP? harder ones! Will also imply co-np = P 30.3 NP-hard, NP-easy, and NP-complete 11 / 38 12 / 38 A problem Π is NP-hard if a polynomial-time algorithm for Π would imply a polynomial-time What we think the world looks like.

own a dog, then it can speak fluent English has a natural corollary: No one in their r believe that I own a dog! Likewise, if IntroaP problem and NP Hard problems is NP-hard, no one in their right mind can be solved in polynomial time. NP-hard and NP-complete Finally, a problem is NP-complete if it is both NP-hard and an element of NP (o complete problems are the A problem hardest Πproblems is NP-hard in if the NP. availability If anyone of afinds polynomial a polynomial-time solution a Often, problems that are in NP co-np are in P one NP-complete problem, to Πthen will allow thatnp-problems would imply to be a solved polynomial-time in time. algorithm for ev It requires considerable insight and/or structure in the problem. to Literally thousands Π is NP-hard of problems if Π can have be solved beeninshown P-time, P to= be NP NP-complete, so a show that something is both NP and co-np algorithm for one (and therefore all) of them seems incredibly unlikely. NP-complete = NP-hard NP This can often be turned into a P-time algorithm The class Co-NP NP Examples Linear programming [1979] Obviously in NP. To see why it is in co-np, we can derive a lower bound by multiplying the constraints by a suitable (guessed) number and adding. Primality testing [2002] Obviously in co NP; See primality certificate for proof it is NP Integer factorization? More of what we think the world looks like. 13 / 38 14 / 38 3 Polynomial-time Reducibility Show that a problem A could be transformed into problem B in polynomial time Called a polynomial-time reduction of A to B The crux of proofs involving NP-completeness Implication: if B can be solved in P-time, we can solve A in P-time An NP-complete problem is one to which any problem in NP can be reduced to. Never forget the direction: To prove a problem Π is NP-complete, need to show how all other NP problems can be solved using Π, not vice-versa! 15 / 38 Wait! How can I reduce every NP to my problem? If a particular NP-problem A is given to you, then you can think of a way to reduce it to your problem B But how do you go about proving that every NP problem X can be reduced to B You don t even know X indeed, the class NP is infinite! If you already knew an NP-complete problem, your task is easy! Simply reduce this NP-complete problem to B, and by transitivity, you have a reduction of every X NP to B So, who will bell the cat? Stephen Cook [1970] and Leonid Levin [1973] managed to do this! Cook was denied reappointment/tenure in 1970 at Berkeley, but won the Turing award in 1982! 16 / 38

The first NP-complete problem: SAT How do you show reducibility of arbitrary NP-problems to SAT? You start from the definition, of course! The class NP is defined in terms of an NDTM X is in NP if there is an NDTM TX that solves X in polynomial time Use this NDTM as the basis of proof. Specifically, show that acceptance by an NDTM can be encoded in terms of a boolean formula Model TX tape contents, tape heads, and finite state at each step as a vector of boolean variables Need (p(n)) 2 variables, where p(n) is the (polynomial) runtime of TX Model each transition as a boolean formula 17 / 38 Thanks to Cook-Levin, you can say... I can t find an efficient algorithm, but neither can all these famous people. Thanks to NP-completeness results, you can say this even if you have been working on an obscure problem that no one ever looked at! 18 / 38 Figure 8.1 The optimal traveling salesman tour, shown in bold, has length 18. Traveling Salesman Problem 5 Some Hard Decision Problems 3 2 3 3 4 1 3 4 2 Given n vertices and n(n 1)/2 distances between them, is there a tour (i.e., cycle) of length b or less that passes through all vertices? components 19 / 38 of a particular graph constructed from the instance (recall Exercise 20 / 38 in Chapter 9, we ll see a different polynomial algorithm for this same special 6

Hamiltonian Cycle Balanced Cuts Simpler than TSP Is there a cycle that passes through every vertex in the graph? Earliest reference, posed in the context of chess boards and knights ( Rudrata cycle ) Longest path is another version of the same problem When posed as a decision problem, becomes the same as Hamiltonian path problem Does there exist a way to partition vertices V in a graph into two sets S and T such that there are at most b edges between S and T, and S T V /3 21 / 38 22 / 38 Integer Linear Programming (ILP) and Zero-One Equations (ZOE) ILP: Linear programing, but solutions are limited to integers Many problems are easy to solve over real numbers but much harder for integers. Examples: Knapsack solutions to equations such as x n + y n = z n ZOE: A special case of ILP, where the values are just 0 or 1. Find x such that Ax = 1 where 1 is a column matrix consisting of 1 s. 3d-Matching Figure 8.4 A more Givenelaborate triples of matchmaking compatibilities between scenario. men, Each women triple and is pets, shown as a tria shaped node joining find perfect, boy, girl, 3-way and matches. pet. Chet Alice Bob Beatrice Al Carol Armadillo Bobcat Canary 23 / 38 24 / 38

In the INDEPENDENT SET problem (recall Section 6.7) we are given a graph and an integer g, and the aim is to find g vertices that are independent, that is, no two of which have an edge between them. Can you find an independent set of three vertices in Figure 8.5? How about four vertices? We saw in Section 6.7 that this problem can be solved efficiently on trees, but for general graphs no polynomial algorithm is known. Independent set, vertex cover, and clique Easy Vs Hard Problems Figure 8.5 What is the size of the largest independent set in this graph? Independent set: Does this graph contain a set of at least k vertices with no edge between them? Vertex cover: Does this graph contain a set of at least k vertices that cover all edges? Clique: Does this graph contain at least k vertices that are fully Balanced cut connected among themselves? There are many other search problems about graphs. In VERTEX COVER, for example, the 25 / 38 input is a graph and a budget b, and the idea is to find b vertices that cover (touch) every edge. Can you cover all edges of Figure 8.5 with seven vertices? With six? (And do you see the intimate connection to the INDEPENDENT SET problem?) VERTEX COVER Intro P andis NP ahard special problems case of SET COVER, which we encountered in Chapter 5. In that problem, we are given a set E and several subsets of it, S1,..., Sm, along with a budget b. We are asked to select b of these subsets so that their union is E. VERTEX COVER is the NP-completeness: Polynomial-time Reductions 241 Hard 3SAT TSP Longest path 3d-matching Independent set ILP Hamiltonian cycle Easy 2SAT, HORN SAT MST Shortest path bipartite match Indep. set on trees Linear programming Euler path, Knights tour Min-cut NP-completeness Reductions Figure 8.7 Reductions between search problems. All of NP 26 / 38 Show that a known NP-complete problem A could be transformed I. These two translation procedures f and h imply that any algorithm for B can be converted into problem B in polynomial time into an algorithm for A by bracketing it between f and h. Instance I f Instance f(i) Algorithm for A Algorithm for B Solution S of f(i) h No solution to f(i) Solution h(s) of I No solution to I INDEPENDENT SET SAT 3SAT 3D MATCHING And now we can finally define the class of the hardest search problems. Implication: if B can be solved in P-time, we can solve A in P-time A search problem is NP-complete if all other search problems reduce to it. This is a very strong requirement indeed. For a problem to be NP-complete, it must be useful Never forget the direction: in solving every search problem in the world! It is remarkable that such problems exist. ButWe theyare do, proving and the first that column B is of NP-complete the table we saw here. earlier is filled with the most famous examples. In Section 8.3 we shall see how all these problems reduce to one another, and also why all other search problems reduce to them. VERTEX COVER CLIQUE SUBSET SUM ZOE ILP RUDRATA CYCLE The two ways to use reductions 27 / 38 So far in this book the purpose of a reduction from a problem A to a problem B has been straightforward and honorable: We know how to solve B efficiently, and we want to use this TSP 28 / 38

Reducing all of NP to SAT Reducing SAT to 3SAT We already discussed this Show how to reduce acceptance by an NDTM to the SAT problem. Exercise: Show how to transform acceptance by an FSA into an instance of SAT 3SAT: A special case of SAT where each clause has 3 literals Reduction involves transforming a disjunction with many literals into a CNF of disjunctions with 3 literals per term The transformation below at most doubles the problem size. Key Idea: Introduce additional variables: Example: l1 l2 l3 l4 can be transformed into: (l1 l2 y1) (y1 l3 l4) For this conjunction to be true, one of {l1,..., l4} must be true: So a solution to the transformed problem is a solution to the original simply discard assignments for the new variables yi. 29 / 38 30 / 38 Reducing 3SAT to Independent set Reducing Independent set to Vertex Cover Nontrivial reduction, as the problems are quite different in nature Idea: Model each of k clauses of 3SAT by a triangle in a graph Figure 8.8 The graph corresponding to (x y z) (x y z) (x y z) (x y). y y y y x z x z x z x Independent set of size k must contain one literal from each clause By setting that literal to true, we obtain a solution for 3SAT to pick only one of them for the independent set. Repeat this construction for all clauses a clause Key withpoint: two literals Avoidwill conflicts, be represented e.g., assigning simply bytrue an edge to both joining x and the literals. x (A clause with oneensure literal is using sillyedges and can between removed every variable in a preprocessing and its complement step, since the value of the variable is determined.) In the resulting graph, an independent set has to pick at most 31 / 38one literal from each group (clause). To force exactly one choice from each clause, take the goal g to be the number of clauses; in our example, g = 4. If S is an independent set then V S is a vertex cover Consider any edge e in the graph Case 1: Both ends of e are in V S Case 2: At least one end of e is S. The other end of e cannot be in S or else S won t be independent. Thus, in both cases, at least one side of e must go to V S. In other words V S is a vertex cover Thus, we have reduced independent set to vertex cover problem. 32 / 38

Reducing Independent set to Clique If S is an independent set then S is clique in G = (V, E) For any pair v1, v2 S there is no edge in E means that there is an edge between any such pair in G i.e, S is a clique in G Thus, we have reduced independent set to the clique problem, while only using polynomial time and space. NP-completeness Reductions We have discussed the left half of this picture We won t discuss the right half, since the proofs are similar in many ways, but are more involved. Figure 8.7 You Reductions can findbetween those search reductions problems. in the text book. INDEPENDENT SET All of NP SAT 3SAT 3D MATCHING VERTEX COVER CLIQUE ZOE SUBSET SUM ILP RUDRATA CYCLE 33 / 38 TSP 34 / 38 8.3 The reductions Beyond NP: PSPACE PSPACE: The class of problems that can be solved using only polynomial amount of space. It is OK to take exponential (or super-exponential) time. Key point: Unlike time, space is reusable. Result: many exponential algorithms are in PSPACE. Consider universal formulas. We can check them in polynomial space by rerunning the same computation (say, check(v)) for each v. The space used for check is recycled, but the time adds up for different v s. Note: SAT is in PSPACE Try every possible truthe assignment for variables. Thus, all NP-complete problems are in PSPACE. We shall now see that the search problems of Section 8.1 can be reduced to one another as depicted in Figure 8.7. As a consequence, they are all NP-complete. Before PSPACE-hard we tackle the specific and reductions PSPACE-complete in the tree, let s warm up by relating two versions of the Rudrata problem. RUDRATA (s, t)-path RUDRATA CYCLE Recall the RUDRATA CYCLE problem: given a graph, is there a cycle that passes through each vertex exactly once? We can also formulate the closely related RUDRATA (s, t)-path problem, PSPACE-hard: A problem Π is PSPACE-hard if for any problem Π in in which two vertices s and t are specified, and we want a path starting at s and ending at t that goes PSPACE through each there vertex is aexactly P-time once. reduction Is it possibleto that Π. RUDRATA CYCLE is easier than RUDRATA (s, t)-path? We will show by a reduction that the answer is no. The reduction maps an instance (G = (V, E), s, t) of RUDRATA (s, t)-path into an instance PSPACE-complete: PSPACE-hard problems that are in PSPACE. G = (V, E ) of RUDRATA CYCLE as follows: G is simply G with an additional vertex x and two new edges {s, x} and {x, t}. For instance: Examples: G G QBF: Quantified boolean formulae s s NFA totality: Does this NFA accept all strings? t x t Is NP PSPACE? We think so, but we can t even prove P PSPACE So V = V {x}, and E = E {{s, x}, {x, t}}. How do we recover a Rudrata (s, t)-path in G given any Rudrata cycle in G? Easy, we just delete the edges {s, x} and {x, t} from the cycle. 247 35 / 38 36 / 38

Classes EXP, EXP-hard and EXP-complete The class EXP (aka EXPTIME) consists of the class of problems that can be solved in O(2 nk ) time for some k. PSPACE EXP. Intuitively, you can t do more than EXP work using a PSPACE algorithm because you need polynomial amount of space even if the only thing you did is to count up to 2 n. As usual, EXP-hard and EXP-complete are defined using P-time reductions. Generalized versions of games such as chess and checkers are EXP-hard. We think PSPACE EXP, but can only prove P EXP. 37 / 38 Where do we stop? These classes can be extended for ever: NEXP: Nondeterministic exponential time EXPSPACE: Problems solvable with exponential space. EEXP: Problems solvable in double exp. time (O(2 2(nk ) )) for some k Examples: Equivalence of regexpr with intersection is EXPSPACE-hard. REs with negation can t be decided even in E k EXPTIME for any k. P NP PSPACE EXP NEXP EXPSPACE EEXP NEEXP EEXPSPACE We think these classes are distinct, but have proofs only for classes that are 3 places apart, e.g., P and EXP. 38 / 38