Introduction to Computational Complexity

Similar documents
Essential facts about NP-completeness:

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

NP-Completeness I. Lecture Overview Introduction: Reduction and Expressiveness

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

1.1 P, NP, and NP-complete

SAT, NP, NP-Completeness

1. Introduction Recap

NP-Completeness Review

Design and Analysis of Algorithms

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

Polynomial-time reductions. We have seen several reductions:

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

NP-Complete Reductions 1

6.080 / Great Ideas in Theoretical Computer Science Spring 2008

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

Notes for Lecture 21

NP and NP Completeness

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

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

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

1 Primals and Duals: Zero Sum Games

Chapter 34: NP-Completeness

NP and Computational Intractability

1 Reductions and Expressiveness

Introduction to Complexity Theory

Admin NP-COMPLETE PROBLEMS. Run-time analysis. Tractable vs. intractable problems 5/2/13. What is a tractable problem?

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

CS173 Strong Induction and Functions. Tandy Warnow

NP-problems continued

CS21 Decidability and Tractability

CS 583: Algorithms. NP Completeness Ch 34. Intractability

Show that the following problems are NP-complete

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

CS 5114: Theory of Algorithms

CS 561, Lecture 12. Jared Saia University of New Mexico

CS 350 Algorithms and Complexity

NP-Completeness Part II

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

NP-Completeness and Boolean Satisfiability

SAT, Coloring, Hamiltonian Cycle, TSP

CMSC 441: Algorithms. NP Completeness

Polynomial-time Reductions

NP-problems continued

Review of unsolvability

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

CSC 1700 Analysis of Algorithms: P and NP Problems

Lecture 25: Cook s Theorem (1997) Steven Skiena. skiena

Limitations of Algorithm Power

CS 350 Algorithms and Complexity

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

Formal definition of P

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

Correctness of Dijkstra s algorithm

Lecture 15 - NP Completeness 1

VIII. NP-completeness

CS173 Lecture B, November 3, 2015

CSC 373: Algorithm Design and Analysis Lecture 15

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

SAT-Solvers: propositional logic in action

Introduction. Pvs.NPExample

CSCI3390-Lecture 18: Why is the P =?NP Problem Such a Big Deal?

COMP Analysis of Algorithms & Data Structures

COP 4531 Complexity & Analysis of Data Structures & Algorithms

Complexity, P and NP

Class Note #20. In today s class, the following four concepts were introduced: decision

Agenda. What is a complexity class? What are the important complexity classes? How do you prove an algorithm is in a certain class

CS/COE

U.C. Berkeley CS278: Computational Complexity Professor Luca Trevisan August 30, Notes for Lecture 1

Computational Complexity

NP-Completeness. Subhash Suri. May 15, 2018

No Harder Than. We want these transformations to effectively be a problem-hardness version of #, which we will call No Harder Than.

Algorithms and Theory of Computation. Lecture 22: NP-Completeness (2)

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

NP-Complete Problems. Complexity Class P. .. Cal Poly CSC 349: Design and Analyis of Algorithms Alexander Dekhtyar..

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

Lecture 4: NP and computational intractability

Week 3: Reductions and Completeness

Automata Theory CS Complexity Theory I: Polynomial Time

NP and Computational Intractability

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

CSCI3390-Lecture 17: A sampler of NP-complete problems

CS154, Lecture 15: Cook-Levin Theorem SAT, 3SAT

1 Computational problems

Algorithm Design and Analysis

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

1 More finite deterministic automata

CS173 Lecture B, September 10, 2015

NP-Hardness reductions

1 Propositional Logic

Complexity Theory: The P vs NP question

CSE 135: Introduction to Theory of Computation NP-completeness

CS Fall 2011 P and NP Carola Wenk

15-451/651: Design & Analysis of Algorithms October 31, 2013 Lecture #20 last changed: October 31, 2013

Intro to Theory of Computation

NP Complete Problems. COMP 215 Lecture 20

NP-Complete problems

Algorithms and Theory of Computation. Lecture 19: Class P and NP, Reduction

Recap from Last Time

2 P vs. NP and Diagonalization

Transcription:

Introduction to Computational Complexity Tandy Warnow October 30, 2018

CS 173, Introduction to Computational Complexity Tandy Warnow

Overview Topics: Solving problems using oracles Proving the answer to a decision problem is YES The SAT problem N P co-n P P N P-hard and N P-complete

SAT SAT (Satisfiability) is a decision problem. Input: Boolean formula Output: YES (if there is an assignment of T/F to the variables that makes the expression True) or NO (if no such assignment exists) What is the construction problem?

SAT Suppose you have an ORACLE that correctly answers the decision problem. Can you use it to find a satisfying assignment (when the formula is satisfiable)? How many calls to the ORACLE do we need?

Conjunctive Normal Form (CNF) Propositional formulas that are the and of a collection of clauses, where each clause is the or of literals. A literal is a variable, which can be negated See the webpage at wikipedia, for example... https://en.wikipedia.org/wiki/conjunctive_normal_form 2-CNF: all the clauses have at most two literals 3-CNF: all the clauses have at most three literals Can we determine in polynomial time if a 2-CNF formula is satisfiable? What about 3-CNF?

Using Oracles Recall the definitions of the decision problem, k-colorability (i.e., does the given graph have a proper vertex coloring with at most k colors?). Suppose we have an Oracle that solves 3-coloring. Can we use it to solve 4-colorability? Suppose we have an oracle that solves 4-coloring. Can we use it to solve 3-coloring?

Decision Problems A decision problem returns YES or NO on every input. Hence, a decision problem is usually described by a YES/NO question. 2-colorability (Can the input graph be vertex-colored with red and blue, so that no edge connects vertices of the same color?) 3-colorability (Can the input graph be vertex-colored with red, blue, and green, so that no edge connects vertices of the same color?) 2-SAT (Is the input 2CNF formula satisfiable?) 3-SAT (Is the input 3CNF formula satisfiable?) Hamiltonian Graph (Does the input graph have a cycle that visits every vertex exactly once?) Eulerian Graph (Does the input graph have a cycle that visits every edge exactly once?)

3-colorability Suppose I want to figure out if a graph G = (V, E) has a proper 3-coloring of the vertices. My friend says it does but I m not sure, and my graph is too big for me to look at all the possible colorings. Question to class: How many possible colorings are there, as a function of the number of vertices? How can my friend convince me?

3-colorability: proving YES The proof that G = (V, E) has a 3-coloring is simple: show the assignment of colors to the vertices verify no two adjacent vertices have the same color Note: The time to prove YES is polynomial once the coloring is found This is not relevant to the case where the graph cannot be 3-colored.

3-colorability: proving NO Now suppose I have another large graph G = (V, E), and my friend says it doesn t have a proper 3-coloring of its vertices. How can my friend convince me that she is right? Certainly she can list all the possible colorings and we can check them all (exhaustive search) to see if any of them are proper. This would work, but it is really expensive. Question to class: how expensive?

Decision Problems Remember that a decision problem returns YES or NO for every input. The YES-instances are the inputs for which the answers are YES. The NO-instances are the inputs for which the answers are NO.

N P N P = Non-deterministic Polynomial Time Definition: N P is the set of decision problems for which you can prove YES-instances are YES-instances in polynomial time.

N P Which of these decision problems are in N P? 2-colorability (Can the input graph be vertex-colored with red and blue, so that no edge connects vertices of the same color?) 3-colorability (Can the input graph be vertex-colored with red, blue, and green, so that no edge connects vertices of the same color?) 2-SAT (Is the input 2CNF formula satisfiable?) 3-SAT (Is the input 3CNF formula satisfiable?) Hamiltonian Graph (Does the input graph have a cycle (or path) that visits every vertex exactly once?) Eulerian Graph (Does the input graph have a circuit (or path) that visits every edge exactly once?)

co-n P co-n P is the set of decision problems where there are polynomial time proofs that NO-INSTANCES are NO-INSTANCES. We won t discuss co-n P very much.

P P is the set of decision problems that can be solved in polynomial time. Which of these decision problems are in P? 2-colorability (Can the input graph be vertex-colored with red and blue, so that no edge connects vertices of the same color?) 3-colorability (Can the input graph be vertex-colored with red, blue, and green, so that no edge connects vertices of the same color?) 2-SAT (Is the input 2CNF formula satisfiable?) 3-SAT (Is the input 3CNF formula satisfiable?) Hamiltonian Graph (Does the input graph have a cycle that visits every vertex exactly once?) Eulerian Graph (Does the input graph have a cycle that visits every edge exactly once?)

P and N P Note that P N P. Hence N P contains easy problems and perhaps not so easy problems. Does N P contain problems that cannot be solved in polynomial time? If so then P N P. Otherwise, P = N P.

Reducing between Problems Suppose you have two decision problems, π and π. Suppose π P, and that A is an algorithm to solve π. We would like to use A to help solve π in polynomial time. To do this, we try to make the inputs to π look like inputs to π. What else do we need?

Figure : Steve Cook, see https://en.wikipedia.org/wiki/stephen Cook Figure : Richard Karp, inventor of Karp Reductions. See https://en.wikipedia.org/wiki/richard M. Karp.

Karp Reductions Suppose you have two decision problems, π and π. Suppose π P, and that A is a polynomial time algorithm to solve π. Suppose we have a function F that maps inputs to π to inputs to π, so that: YES-instances of π map to YES-instances of π NO-instances of π map to NO-instances of π The function F takes polynomial time to compute The size of F (I ) is polynomial in the size of I for any input I Such a function F is called a Karp reduction, after Dick Karp (Berkeley) who came up with them.

Karp Reduction If π and π are two decision problems in NP and there is a Karp reduction from π to π, we write this as and say that π reduces to π. π π, Note that if π 1 π 2 and π 2 π 3, then π 1 π 3. That is, Karp Reductions are transitive.

Karp Reductions Suppose π P, and that A is a polynomial time algorithm to solve π. Suppose π π, and that F is the Karp Reduction. Given instance I to π, Compute F (I ), which is an instance of π. Run algorithm A on F (I ) If A says YES, then return YES; otherwise return NO. So: if you can find a Karp Reduction from π to π, then if π can be solved in polynomial time then so can π!

Karp reduction We can summarize the previous discussion as follows: Theorem: If π P and π π then π P.

Karp reduction Question: If π P and π π, do we learn anything?

Karp reduction Remember the 2-colorability problem: Input: Graph G = (V, E) Question: Can we 2-color the vertices of G so that no two adjacent vertices get the same color? and consider the 3-colorability problem: Input: Graph G = (V, E) Question: Can we 3-color the vertices of G so that no two adjacent vertices get the same color? We will show that 2-colorability 3-colorability.

2-colorability 3-colorability Let F map instances of 2-colorability to instances of 3-colorability as follows. Given graph G = (V, E), let F (G) be the graph G = (V, E ) defined by V = V {v }, where v is a new vertex E = E {(v, v) : v V } It is not hard to see that F is a Karp reduction. (In particular, G can be 2-colored if and only if F (G) can be 3-colored.) Yet, 2-colorability is in P. Do we learn anything about 3-colorability?

Karp reduction When you show that a problem π reduces to π, then you learn that π is no harder than π. Therefore, knowing that π can be solved in polynomial time really tells you something - that π can be solved in polynomial time. However, if π P and π π, you don t learn anything about π. It could be that π is solvable in polynomial time, or maybe not!

Karp reduction In 1972, Dick Karp proved that every problem in N P reduces to 3-SAT using a Karp reduction. Written differently: π N P, π 3-SAT What does this mean? (See https://en.wikipedia.org/wiki/karp%27s_21_ NP-complete_problems)

Karp reduction Suppose π N P, π π. Further suppose that π P. What can you deduce from this?

Karp reduction Theorem: P = N P. Suppose π N P, π π, and π P. Then

N P-hard A problem π is said to be N P-hard if a polynomial time algorithm to solve π could be used to solve every problem in N P in polynomial time. Notes: If π satisfies π N P, π π, then π is N P-hard. If any N P-hard problem can be solved in polynomial time, then so can all problems in N P! Karp already proved that 3-SAT is N P-hard (as well as 20 other problems). Many other problems have been proven to be N P-hard. To prove that a new decision problem π is N P-hard, you just have to find a known N P-hard problem π and show that π π.

N P-complete A problem π is said to be N P-complete if and only if π N P π is N P-hard

Class Exercise Provide a Karp reduction from 3-colorability to 4-colorability.

N P-hard We use the fact that 3-colorability is N P-hard to prove that 4-colorability is N P-hard.

Does P = N P? According to Wikipedia: Nobody has yet been able to determine conclusively whether NP-complete problems are in fact solvable in polynomial time, making this one of the great unsolved problems of mathematics. The Clay Mathematics Institute is offering a US $1 million reward to anyone who has a formal proof that P = N P or that P N P.

Dealing with NP-hard problems Although we don t know if P = N P, let s assume they aren t the same... and hence that N P-hard problems are going to be hard to solve! What does this mean to you, as a programmer?

Describing a real world problem You want to partition the set of people into subsets so that every two people in any subset both like each other, and make the number of subsets as small as possible. Solution: The graph G = (V, E) is defined by V is the set of people in the class E contains (v, w) if and only if v and w like each other We are looking for a partition of V into a small number of sets so that every one of the sets is a clique. In other words, we want to write V = V 1 V 2... V k, where V i is a clique in G and where k is minimized. Does a solution always exist? Does it have to be unique? What graph problem does this look like?

A different solution You want to partition the set of people into subsets so that every two people in any subset both like each other, and make the number of subsets as small as possible. Solution: The graph G = (V, E) is defined by V is the set of people in the class E contains (v, w) if and only if v doesn t like w or w doesn t like v (i.e., they don t like each other) We are looking for a partition of V into a small number of sets so that every one of the sets is an independent set. Note - this is the same thing as finding a minimum vertex coloring.

Things to note When you formulate a real world problem as a graph problem, you have to: Describe the graph precisely. What are the vertices? What are the edges? Do the edges have weights? Use correct terminology (don t be sloppy about language). Once the graph is defined, the problem (whether a decision problem, optimization problem, or construction problem) is then defined only in terms of the graph and not in terms of the original problem. The power in making this formulation is that there are many algorithms (and software) for most natural graph problems, and so you can use those programs to solve your problem. Many graph problems are NP-hard, but sometimes you have extra structure in your problem that allows you to solve the problem in polynomial time. (For example, MIN VERTEX COLORING is NP-hard, but solvable in polynomial time on trees.)

Toy Example You work for some spy agency, and you want to listen in on all the phone calls happening in Urbana. You can put bugs in cellphones, and the bugs will let you listen to any conversation that takes place using that cellphone. You know which people call which people, and so you can try to use that information to reduce the number of bugs you need to buy and install. You assume everyone has exactly one cellphone and all calls are made using cellphones to cellphones. Formulate this as a graph problem.

Toy Example: Spy Agency What are the vertices? (Answer: Cellphones) What are the edges? (Answer: pairs of cellphones where their owners are known to call each other.) What are you looking for? Answer: the smallest number of cellphones so that all phone calls involve at least one cellphone in the set. Better answer: the smallest set V0 V of vertices so that every edge in E has at least one endpoint in V 0. Do you recognize this problem?

What do you do when a problem is NP-hard? Suppose you reduce your problem to a graph theoretic problem that a problem is NP-hard. What does this mean? What should you do?

Class Exercises Formulate each of these as a graph-theoretic problem: You want to pair people off in the class so that they will study together. You want to have as large a number of people able to be in study groups, but you have the following rules: study groups must have pairs of people who like each other, and no person can be in two study groups. You want to have a party and invite as many people as you can to it, subject to (a) they all like you, and (b) they all like each other.