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

Similar documents
NP Completeness and Approximation Algorithms

NP Complete Problems. COMP 215 Lecture 20

Design and Analysis of Algorithms

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

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

NP-Complete Reductions 1

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

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

CS 583: Algorithms. NP Completeness Ch 34. Intractability

Chapter 34: NP-Completeness

Lecture 19: Finish NP-Completeness, conp and Friends

Correctness of Dijkstra s algorithm

Automata Theory CS S-18 Complexity Theory II: Class NP

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

CS154, Lecture 13: P vs NP

Introduction. Pvs.NPExample

Theory of Computation Time Complexity

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

Show that the following problems are NP-complete

BBM402-Lecture 11: The Class NP

SAT, NP, NP-Completeness

NP-Complete Problems. More reductions

CSE 105 Theory of Computation

Introduction to Complexity Theory

Polynomial-time Reductions

Polynomial-Time Reductions

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

CS154, Lecture 13: P vs NP

CSE 135: Introduction to Theory of Computation NP-completeness

Intro to Theory of Computation

NP-Completeness. Subhash Suri. May 15, 2018

COMP Analysis of Algorithms & Data Structures

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

NP and Computational Intractability

Turing Machines and Time Complexity

Data Structures in Java

CSE 105 THEORY OF COMPUTATION

Chapter 7: Time Complexity

NP and Computational Intractability

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

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

NP-Completeness Part II

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

Algorithm Design and Analysis

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

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

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

Lecture 17: Cook-Levin Theorem, NP-Complete Problems

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

Complexity, P and NP

Limitations of Algorithm Power

CSE 3500 Algorithms and Complexity Fall 2016 Lecture 25: November 29, 2016

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

NP-Complete Reductions 2

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

The Cook-Levin Theorem

CSE 105 THEORY OF COMPUTATION

Lecture 4: NP and computational intractability

Non-Deterministic Time

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

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

Introduction to Computational Complexity

Theory of Computation Chapter 9

NP and NP Completeness

Automata Theory CS Complexity Theory I: Polynomial Time

SAT, Coloring, Hamiltonian Cycle, TSP

Essential facts about NP-completeness:

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

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

More NP-Complete Problems

Applied Computer Science II Chapter 7: Time Complexity. Prof. Dr. Luc De Raedt. Institut für Informatik Albert-Ludwigs Universität Freiburg Germany

Announcements. Friday Four Square! Problem Set 8 due right now. Problem Set 9 out, due next Friday at 2:15PM. Did you lose a phone in my office?

3130CIT Theory of Computation

1. Introduction Recap

On the Computational Hardness of Graph Coloring

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

Computational Intractability 2010/4/15. Lecture 2

CS 6505, Complexity and Algorithms Week 7: NP Completeness

1.1 P, NP, and NP-complete

Week 3: Reductions and Completeness

Complexity (Pre Lecture)

NP-Completeness. NP-Completeness 1

Lecture Notes 4. Issued 8 March 2018

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

COP 4531 Complexity & Analysis of Data Structures & Algorithms

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

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.

NP-COMPLETE PROBLEMS. 1. Characterizing NP. Proof

Finish K-Complexity, Start Time Complexity

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

NP-Completeness. Sections 28.5, 28.6

CSE 548: (Design and) Analysis of Algorithms

NP-completeness was introduced by Stephen Cook in 1971 in a foundational paper.

Computational Complexity

NP Completeness. Richard Karp, 1972.

Lecture 16: Time Complexity and P vs NP

CSCI3390-Second Test with Solutions

Transcription:

Theory of Computation CS3102 Spring 2014 A tale of computers, math, problem solving, life, love and tragic death Nathan Brunelle Department of Computer Science University of Virginia www.cs.virginia.edu/~njb2b/theory

Our Favorite NP Complete Problem Satisfiability (SAT): Given a Boolean expression in conjuctive normal form, is there some assignment of T/F to its variables such that the expression resolves to True? Note: we may restrict each disjunction to have 3 variables (3-SAT) Examples: a b c a d c (d b e) Satisfied if: a = F, b = F, c = T, d = T a b a b ( a b) (a b) Can t be Satisfied!

The Cook/Levin Theorem Theorem [Cook/Levin, 1971]: SAT is NP-complete. Proof idea: given a non-deterministic polynomial time TM M and input w, construct a CNF formula that is satisfiable iff M accepts w. Create boolean variables: q[i,k] at step i, M is in state k h[i,k] at step i, M s RW head scans tape cell k s[i,j,k] at step i, M s tape cell j contains symbol S k Stephen Cook Leonid Levin Q k M halts in polynomial time p(n) total # of variables is polynomial in p(n)

Add clauses to the formula to enforce necessary restrictions on how M operates / runs: At each time i: The Cook/Levin Theorem M is in exactly 1 state r/w head scans exactly 1 cell All cells contain exactly 1 symbol At time 0 M is in its initial state At time P(n) M is in a final state Transitions from step i to i+1 all obey M's transition function Resulting formula is satisfiable iff M accepts w! Stephen Cook Leonid Levin Q k

Guess and Verify Approach Note: SAT NP. Idea: Nondeterministically guess each Boolean variable value, and then verify the guessed solution. polynomial-time nondeterministic algorithm NP This guess & verify approach is general. Idea: Guessing is usually trivially fast ( NP) NP can be characterized by the verify property: NP set of problems for which proposed solutions can be quickly verified set of languages for which string membership can be quickly tested.

Denied tenure at Berkeley (1970) Invented NP completeness (1971) Won Turing Award (1982) Student of Andrei Kolmogorov Seminal paper obscured by Russian, style, and Cold War Historical Note The Cook/Levin theorem was independently proved by Stephen Cook and Leonid Levin

An NP-Complete Encyclopedia Classic book: Garey & Johnson, 1979 Definitive guide to NP-completeness Lists hundreds of NP-complete problems Gives reduction types and refs Michael Garey David Johnson

NP-Completeness Proof Method To show that Q is NP-Complete: 1) Show that Q is in NP Usually by guess and verify 2) Pick an instance, R, of your favorite NP- Complete problem (ex: 3-SAT) 3) Show a polynomial algorithm to transform R into an instance of Q

Reducing Reduction Proofs Conjecture: A has some property Y. Proof by reduction from B to A: Assume A has Y. Then, we know there is an M that decides A. We already know B does not have property Y. Show how to build S that solves B using M. Since we know B does not have Y, but having S would imply B has Y, S cannot exist. Therefore, M cannot exist, and A does not have Y.

Undecidability Proofs Conjecture: A has some property Y. Proof by reduction from B to A: Assume A has Y. Then, we know an M exists. We already know B does not have property Y. Show how to build S that solves B using M. Since we know B does not have Y, but having S would imply B has Y, S cannot exist. Therefore, M cannot exist, and A does not have Y. Undecidability: Y = can be decided by a TM B = a known undecidable problem (e.g., A TM, HALT TM, EQ TM, ) M = a TM that decides A

NP-Hardness Proofs Conjecture: A has some property Y. Proof by reduction from B to A: Assume A has Y. Then, we know an M exists. We already know B does not have property Y. Show how to build S that solves B using M. Since we know B does not have Y, but having S would imply B has Y, S cannot exist. Therefore, M cannot exist, and A does not have Y. NP-Hardness: Y = is NP-Hard B = a known NP-Hard problem (e.g., 3-SAT, SUBSET-SUM, ) M = a TM that decides A in polynomial-time

Example Suppose we know A TM is undecidable, but do not yet know if EQ TM is. EQ TM = { <M 1, M 2 > M 1 and M 2 are TMs where L(M 1 ) = L(M 2 ) } A TM = { <M>, w M is TM, w is string, w in L(M) } Conjecture: EQ TM is undecidable. What do we need to do to prove conjecture? Reduce from A TM to EQ TM : show that a solver for EQ TM could be used to solve A TM. Pitfall #1: Make sure you do reduction in right direction. Showing how to solve B using M A, shows A is as hard as B.

B = A = Building Solvers A TM = { <M, w> M is TM, w is string, w in L(M) } EQ TM = { <M 1, M 2 > M 1 and M 2 are TMs where L(M 1 ) = L(M 2 ) } Conjecture: EQ TM is undecidable. Reduce from EQ TM to A TM : show that M EQ, a solver for EQ TM can be used to solve A TM. M B (<M, w>): machine that decides A TM Simulate M EQ on <M 1, M 2 >: M 1 = a TM that simulates M running on w M 2 = a TM that always accepts If it accepts, accept; if it rejects, reject. Pitfall #2: Get the inputs to the solver to match correctly. To solve B using M A, must transform inputs to B into inputs to A.

Legal Transformations Undecidability proofs: your transformation can do anything a TM can do, but must be guaranteed to terminate E.g., cannot include, simulate M and if it halts, accept NP-Hardness proofs: your transformation must finish in polynomial time E.g., cannot include, do an exponential search to find the answer, and output that

Problem Transformations Idea: To solve a problem, efficiently transform to another problem, and then use a solver for the other problem: Satisfiability (x+y)(x'+y') SAT solution x=1, y=0 Colorability Colorability solver

Reduction Types Many-one reduction: converts an instance of one problem to a single instance of another problem. A w ƒ Turing reduction: solves a problem A by multiple calls to an oracle for problem B. A B ƒ(w) B A M B A T B

Polynomial-Time Reduction Types Polynomial-time many-one reduction: transforms in polynomial time an instance of problem A to an instance of problem B. Karp reduction (transformation) A w ƒ B ƒ(w) Polynomial-time Turing reduction: solves problem A by polynomially-many calls to oracle for B. Cook reduction A Open: do polynomial-time-bounded many-one and Turing reductions yield the same complexity classes? (NP, co-np, NP-complete, co-np-complete, etc.) B Richard Karp Stephen Cook

Boolean 3-Satisfiability (3-SAT) Def: 3-CNF: each sum term has exactly 3 literals. Ex: (x 1 +x 5 +x 7 )(x 3 +x' 4 +x' 5 ) Def: 3-SAT: given an n-variable boolean formula (in CNF), is it satisfiable? Theorem: 3-SAT is NP-complete. Proof: convert each long clause of the given formula into an equivalent set of 3-CNF clauses: Ex: (x+y+z+u+v+w) (x+y+a)(a'+z+b)(b'+u+c)(c'+v+w) Resulting formula is satisfiable iff original formula is.

1-SAT and 2-SAT Idea: Determine the boundary of intractability by varying / trivializing some of the parameters. Q: Is 1-SAT NP-complete? A: iff P=NP (look for a variable & its negation) Q: Is 2-SAT NP-complete? A:iff P=NP (cycles in the implication graph)

Classic NP Complete Problems Clique: given a graph and integer k, is there a subgraph that is a complete graph of size k? Richard Karp

Graph Cliques Graph clique problem: given a graph and an integer k, is there a subgraph in G that is a complete graph of size k? Theorem: The clique problem is NP-complete. Proof: Reduction from 3-SAT: Literals become nodes; k clauses induce node groups; Connect all inter-group compatible nodes / literals. Example: (x+y+z)(x'+y'+z)(x'+y+z') X X' Y' Z X' Graph clique solver Y Z Clique is in NP clique is NP-complete. Y Z' k-clique corresponds to 3-SAT solution: x = true, y = false, z = false

Independent Sets Independent set problem: given a graph and an integer k, is there a pairwise non-adjacent node subset of size k? Theorem: The independent set problem is NP-complete. Proof: Reduction from graph clique: Idea: independent set is an anti-clique (i.e., negated clique) finding a clique reduces to finding an independent set in the complement graph: Independent set NP NP-complete. Graph clique solver Independent set solver

Classic NP Complete Problems Graph coloring: given an integer k and a graph, is it k-colorable? (adjacent nodes get different colors)

Graph Colorability Problem: is a given graph G 3-colorable? Theorem: Graph 3-colorability is NP-complete. Proof: Reduction from 3-SAT. Idea: construct a colorability OR gate gadget : (x+y+z) x y T x "x x' z T Property: gadget is 3-colorable iff (x+y+z) is true F

Example: (x+y+z)(x'+y'+z)(x'+y+z') x'+y'+z x'+y+z' x y T z x y T F x x' "x x' y' z T F z'

Example: (x+y+z)(x'+y'+z)(x'+y+z') 3-colorability Solution: x y 3-satisfiability z Solution: x' x = true y = false y' T F z = false z'

Classic NP Complete Problems Set Cover: given a universe U, a collection of subsets S i and an integer k, can k of these subsets cover U? S 1 U S 2 S 5 S 3 S 4

Classic NP Complete Problems Hamiltonian cycle: Given an undirected graph, is there a closed path that visits every vertex exactly once?

Classic NP Complete Problems Partition: Given a set of integers, is there a way to partition is into two subsets each with the same sum?

Classic NP Complete Problems Knapsack: maximize the total value of a set of items without exceeding an overall weight constraint.

NP Complete Problems Bin packing: minimize the number of same-size bins necessary to hold a set of items of various sizes.

Other Classic NP Complete Problems Steiner Tree: span a given node subset in a weighted graph using a minimum-cost tree. 2

Other Classic NP Complete Problems Traveling salesperson: given a set of points, find the shortest tour that visits every point exactly once.

Graph Colorability Problem: given a graph G and an integer k, is G k-colorable? Note: adjacent nodes must have different colors

Decision vs. Optimization Problems Decision problem: yes or no membership answer. Ex: Given a Boolean formula, is it satisfiable? Ex: Given a graph, is it 3-colorable? Ex: Given a graph & k, does it contain a k-clique? Optimization problem: find a (minimal) solution. Ex: Given a formula, find a satisfying assignment. Ex: Given a graph, find a 3-coloring. Ex: Given a graph & k, find a k-qlique. Theorem: Solving a decision problem is not harder than solving its optimization version. Theorem: Solving an optimization problem is not (more than polynomially) harder than solving its decision version. (x+y+z) ^(x'+y'+z) ^(x'+y+z')

Decision vs. Optimization Problems Corollary: A decision problem is in P if and only if its optimization version is in P. Corollary: A decision problem is in NP if and only if its optimization version is in NP. Building an optimizer from a decider: Ex: what is a satisfying assignemnt of P=(x+y+z)(x'+y'+z)(x'+y+z')? Idea: Ask the decider 2 related yes/no questions: P P^x Iterate! P^x' Satisfiability Decider Satisfiability Decider yes no yes no x is true x is false Satisfiability Decider x is don t care P is not satisfiable yes no Satisfiability Optimizer