Nathan Brunelle Department of Computer Science University of Virginia www.cs.virginia.edu/~njb2b/theory Theory of Computation CS3102 – Spring 2014 A tale.

Slides:



Advertisements
Similar presentations
NP-Hard Nattee Niparnan.
Advertisements

CS Department Fireside Chat All are welcome! Wed Nov 18, 5-6pm, Ols 228e/236d Kim Hazelwood and Wes Weimer Meet and ask them questions in a non-academic.
NP-Completeness Lecture for CS 302. Traveling Salesperson Problem You have to visit n cities You want to make the shortest trip How could you do this?
FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY
The Theory of NP-Completeness
1 NP-Complete Problems. 2 We discuss some hard problems:  how hard? (computational complexity)  what makes them hard?  any solutions? Definitions 
NP Completeness Tractability Polynomial time Computation vs. verification Power of non-determinism Encodings Transformation & reducibilities P vs. NP “Completeness”
CS Department Fireside Chat All are welcome! Wed Nov 18, 5-6pm, Ols 228e/236d Kim Hazelwood and Wes Weimer Meet and ask them questions in a non-academic.
CSC5160 Topics in Algorithms Tutorial 2 Introduction to NP-Complete Problems Feb Jerry Le
NP-complete and NP-hard problems Transitivity of polynomial-time many-one reductions Definition of complexity class NP –Nondeterministic computation –Problems.
Graphs 4/16/2017 8:41 PM NP-Completeness.
NP-Complete Problems Reading Material: Chapter 10 Sections 1, 2, 3, and 4 only.
1 Polynomial Time Reductions Polynomial Computable function : For any computes in polynomial time.
The Theory of NP-Completeness
NP-Complete Problems Problems in Computer Science are classified into
NP-complete and NP-hard problems
Analysis of Algorithms CS 477/677
NP-Completeness (2) NP-Completeness Graphs 4/17/2017 6:25 AM x x x x x
CSE 421 Algorithms Richard Anderson Lecture 27 NP Completeness.
CS Master – Introduction to the Theory of Computation Jan Maluszynski - HT Lecture NP-Completeness Jan Maluszynski, IDA, 2007
Chapter 11: Limitations of Algorithmic Power
Chapter 11 Limitations of Algorithm Power Copyright © 2007 Pearson Addison-Wesley. All rights reserved.
Chapter 11 Limitations of Algorithm Power Copyright © 2007 Pearson Addison-Wesley. All rights reserved.
1 The Theory of NP-Completeness 2 NP P NPC NP: Non-deterministic Polynomial P: Polynomial NPC: Non-deterministic Polynomial Complete P=NP? X = P.
The Theory of NP-Completeness 1. Nondeterministic algorithms A nondeterminstic algorithm consists of phase 1: guessing phase 2: checking If the checking.
The Theory of NP-Completeness 1. What is NP-completeness? Consider the circuit satisfiability problem Difficult to answer the decision problem in polynomial.
1 The Theory of NP-Completeness 2012/11/6 P: the class of problems which can be solved by a deterministic polynomial algorithm. NP : the class of decision.
Nattee Niparnan. Easy & Hard Problem What is “difficulty” of problem? Difficult for computer scientist to derive algorithm for the problem? Difficult.
Cs3102: Theory of Computation Class 24: NP-Completeness Spring 2010 University of Virginia David Evans.
CSCI 2670 Introduction to Theory of Computing November 29, 2005.
Week 10Complexity of Algorithms1 Hard Computational Problems Some computational problems are hard Despite a numerous attempts we do not know any efficient.
CSE 024: Design & Analysis of Algorithms Chapter 9: NP Completeness Sedgewick Chp:40 David Luebke’s Course Notes / University of Virginia, Computer Science.
1 Lower Bounds Lower bound: an estimate on a minimum amount of work needed to solve a given problem Examples: b number of comparisons needed to find the.
EMIS 8373: Integer Programming NP-Complete Problems updated 21 April 2009.
CSC401 – Analysis of Algorithms Chapter 13 NP-Completeness Objectives: Introduce the definitions of P and NP problems Introduce the definitions of NP-hard.
1 The Theory of NP-Completeness 2 Cook ’ s Theorem (1971) Prof. Cook Toronto U. Receiving Turing Award (1982) Discussing difficult problems: worst case.
Unit 9: Coping with NP-Completeness
NP-Complete Problems. Running Time v.s. Input Size Concern with problems whose complexity may be described by exponential functions. Tractable problems.
Class 24: P=NP? David Evans cs302: Theory of Computation University of Virginia Computer Science PS6 (the last one) is.
1 Chapter 34: NP-Completeness. 2 About this Tutorial What is NP ? How to check if a problem is in NP ? Cook-Levin Theorem Showing one of the most difficult.
NP-COMPLETE PROBLEMS. Admin  Two more assignments…  No office hours on tomorrow.
Lecture 6 NP Class. P = ? NP = ? PSPACE They are central problems in computational complexity.
Lecture 12 P and NP Introduction to intractability Class P and NP Class NPC (NP-complete)
Design and Analysis of Algorithms - Chapter 101 Our old list of problems b Sorting b Searching b Shortest paths in a graph b Minimum spanning tree b Primality.
CS 3343: Analysis of Algorithms Lecture 25: P and NP Some slides courtesy of Carola Wenk.
CS6045: Advanced Algorithms NP Completeness. NP-Completeness Some problems are intractable: as they grow large, we are unable to solve them in reasonable.
Lecture 25 NP Class. P = ? NP = ? PSPACE They are central problems in computational complexity.
NPC.
NP Completeness Piyush Kumar. Today Reductions Proving Lower Bounds revisited Decision and Optimization Problems SAT and 3-SAT P Vs NP Dealing with NP-Complete.
CSC 413/513: Intro to Algorithms
Young CS 331 D&A of Algo. NP-Completeness1 NP-Completeness Reference: Computers and Intractability: A Guide to the Theory of NP-Completeness by Garey and.
1 Ch 10 - NP-completeness Tractable and intractable problems Decision/Optimization problems Deterministic/NonDeterministic algorithms Classes P and NP.
CSCI 2670 Introduction to Theory of Computing December 2, 2004.
CSCI 2670 Introduction to Theory of Computing December 7, 2005.
CSE 421 Algorithms Richard Anderson Lecture 27 NP-Completeness Proofs.
The Theory of NP-Completeness 1. Nondeterministic algorithms A nondeterminstic algorithm consists of phase 1: guessing phase 2: checking If the checking.
COSC 3101A - Design and Analysis of Algorithms 14 NP-Completeness.
1 The Theory of NP-Completeness 2 Review: Finding lower bound by problem transformation Problem X reduces to problem Y (X  Y ) iff X can be solved by.
Computability Examples. Reducibility. NP completeness. Homework: Find other examples of NP complete problems.
The NP class. NP-completeness Lecture2. The NP-class The NP class is a class that contains all the problems that can be decided by a Non-Deterministic.
CSE 332: NP Completeness, Part II Richard Anderson Spring 2016.
ICS 353: Design and Analysis of Algorithms NP-Complete Problems King Fahd University of Petroleum & Minerals Information & Computer Science Department.
NP-Completeness A problem is NP-complete if: It is in NP
Chapter 10 NP-Complete Problems.
Richard Anderson Lecture 26 NP-Completeness
NP-Completeness (2) NP-Completeness Graphs 7/23/ :02 PM x x x x
ICS 353: Design and Analysis of Algorithms
NP Completeness • Tractability • Polynomial time
CSE 589 Applied Algorithms Spring 1999
Our old list of problems
Presentation transcript:

Nathan Brunelle Department of Computer Science University of Virginia Theory of Computation CS3102 – Spring 2014 A tale of computers, math, problem solving, life, love and tragic death

Our “Favorite” NP Complete Problem

Stephen CookLeonid Levin 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 M halts in polynomial time p(n)  total # of variables is polynomial in p(n) QkQk

Stephen CookLeonid Levin Add clauses to the formula to enforce necessary restrictions on how M operates / runs: At each time i: 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! QkQk The Cook/Levin Theorem

“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.

Historical Note The Cook/Levin theorem was independently proved by Stephen Cook and Leonid Levin 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

Entire paper!

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 GareyDavid 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 and M 2 are TMs where L(M 1 ) = L(M 2 ) } A TM = {, 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.

Building Solvers EQ TM = { | M 1 and M 2 are TMs where L(M 1 ) = L(M 2 ) } A TM = { | M is TM, w is string, w in L(M) } Reduce from EQ TM to A TM : show that M EQ, a solver for EQ TM can be used to solve A TM. Conjecture: EQ TM is undecidable. 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. B = A = M B ( ): machine that decides A TM Simulate M EQ on : 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.

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: (x+y)(x'+y') Colorability solver SAT solution x=1, y=0 Satisfiability Colorability

B Reduction Types Many-one reduction: converts an instance of one problem to a single instance of another problem. Turing reduction: solves a problem A by multiple calls to an “oracle” for problem B. A M BA M B A T BA T B A

Stephen Cook Richard Karp B A 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) Polynomial-time Turing reduction: solves problem A by polynomially-many calls to “oracle” for B.  “Cook” reduction Open: do polynomial-time-bounded many-one and Turing reductions yield the same complexity classes? (NP, co-NP, NP-complete, co-NP-complete, etc.)

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)

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

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') Z Y X Z' Y X' ZY'X' k-clique corresponds to 3-SAT solution: x = true, y = false, z = false Clique is in NP  clique is NP-complete. Graph clique solver

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: Graph clique solver Independent set solver Independent set  NP  NP-complete.

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”:  F T (x+y+z) Property: gadget is 3-colorable iff (x+y+z) is true x' x xx x y T z

Example: (x+y+z)(x'+y'+z)(x'+y+z') F x' y' T x z y z' F T x' x xx x y T z x+y+zx'+y'+z x'+y+z' F

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

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? U S2S2 S3S3 S1S1 S4S4 S5S5

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.

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

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^xP^x P^x' Satisfiability Decider yes no Satisfiability Decider yes no Satisfiability Decider yes no x is true x is “don’t care” P is not satisfiable x is false Iterate! Satisfiability Optimizer P