© The McGraw-Hill Companies, Inc., 2005 8 - 1 Chapter 8 The Theory of NP-Completeness.

Slides:



Advertisements
Similar presentations
NP-Hard Nattee Niparnan.
Advertisements

Chapter 11 Limitations of Algorithm Power Copyright © 2007 Pearson Addison-Wesley. All rights reserved.
JAYASRI JETTI CHINMAYA KRISHNA SURYADEVARA
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 
CSC5160 Topics in Algorithms Tutorial 2 Introduction to NP-Complete Problems Feb Jerry Le
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
88- 1 Chapter 8 The Theory of NP-Completeness P: the class of problems which can be solved by a deterministic polynomial algorithm. NP : the class.
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.
P, NP, and NP-Complete Suzan Köknar-Tezel.
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.
1 UNIT -6 P, NP, and NP-Complete. 2 Tractability u Some problems are intractable: as they grow large, we are unable to solve them in reasonable time u.
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.
Chapter 11 Limitations of Algorithm Power. Lower Bounds Lower bound: an estimate on a minimum amount of work needed to solve a given problem Examples:
CSCE350 Algorithms and Data Structure
A. Levitin “Introduction to the Design & Analysis of Algorithms,” 3rd ed., Ch. 11 ©2012 Pearson Education, Inc. Upper Saddle River, NJ. All Rights Reserved.
Computational Complexity Polynomial time O(n k ) input size n, k constant Tractable problems solvable in polynomial time(Opposite Intractable) Ex: sorting,
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.
Tonga Institute of Higher Education Design and Analysis of Algorithms IT 254 Lecture 8: Complexity Theory.
The Complexity of Optimization Problems. Summary -Complexity of algorithms and problems -Complexity classes: P and NP -Reducibility -Karp reducibility.
Summary  NP-hard and NP-complete  NP-completeness proof  Polynomial time reduction  List of NP-complete problems  Knapsack problem  Isomprphisim.
P and NP. Computational Complexity Recall from our sorting examples at the start of class that we could prove that any sort would have to do at least.
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.
The Theory of Complexity for Nonpreemptive Scheduling 1.
1 The Theory of NP-Completeness 2 Cook ’ s Theorem (1971) Prof. Cook Toronto U. Receiving Turing Award (1982) Discussing difficult problems: worst case.
1 How to prove that a problem is NPC. 2 Cook Cook showed the first NPC problem: SAT Cook received Turing Award in 1982.
NP-Complete Problems. Running Time v.s. Input Size Concern with problems whose complexity may be described by exponential functions. Tractable problems.
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.
Lecture 6 NP Class. P = ? NP = ? PSPACE They are central problems in computational complexity.
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.
CSE 589 Part V One of the symptoms of an approaching nervous breakdown is the belief that one’s work is terribly important. Bertrand Russell.
“One ring to rule them all” Analogy (sort of) Lord of The Rings Computational Complexity “One problem to solve them all” “my preciousss…”
LIMITATIONS OF ALGORITHM POWER
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.
Chapter 11 Introduction to Computational Complexity Copyright © 2011 The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 1.
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.
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.
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.
The Theory of NP-Completeness
Chapter 10 NP-Complete Problems.
Hard Problems Some problems are hard to solve.
Hard Problems Introduction to NP
ICS 353: Design and Analysis of Algorithms
The Theory of NP-Completeness
Chapter 34: NP-Completeness
Chapter 11 Limitations of Algorithm Power
NP-Complete Problems.
CS 3343: Analysis of Algorithms
The Theory of NP-Completeness
Our old list of problems
Presentation transcript:

© The McGraw-Hill Companies, Inc., Chapter 8 The Theory of NP-Completeness

© The McGraw-Hill Companies, Inc., P: the class of problems which can be solved by a deterministic polynomial algorithm. NP : the class of decision problem which can be solved by a non-deterministic polynomial algorithm. NP-hard: the class of problems to which every NP problem reduces. NP-complete (NPC): the class of problems which are NP-hard and belong to NP.

© The McGraw-Hill Companies, Inc., Some Concepts of NPC Definition of reduction: Problem A reduces to problem B (A  B) iff A can be solved by a deterministic polynomial time algorithm using a deterministic algorithm that solves B in polynomial time. Up to now, none of the NPC problems can be solved by a deterministic polynomial time algorithm in the worst case. There does not seem to be any polynomial time algorithm to solve the NPC problems.

© The McGraw-Hill Companies, Inc., The theory of NP-completeness always considers the worst case. The lower bound of any NPC problem seems to be in the order of an exponential function. Not all NP problems are difficult (e.g. the MST problem is an NP problem). If A, B  NPC, then A  B and B  A. Theory of NP-completeness If any NPC problem can be solved in polynomial time, then all NP problems can be solved in polynomial time (NP = P).

© The McGraw-Hill Companies, Inc., Decision Problems The solution is simply “ Yes ” or “ No ”. Optimization problems are more difficult. e.g. the traveling salesperson problem Optimization version: Find the shortest tour Decision version: Is there a tour whose total length is less than or equal to a constant c ?

© The McGraw-Hill Companies, Inc., The Satisfiability Problem The satisfiability problem A logical formula: x 1 v x 2 v x 3 & - x 1 & - x 2 the assignment : x 1 ← F, x 2 ← F, x 3 ← T will make the above formula true. (-x 1, -x 2, x 3 ) represents x 1 ← F, x 2 ← F, x 3 ← T

© The McGraw-Hill Companies, Inc., If there is at least one assignment which satisfies a formula, then we say that this formula is satisfiable; otherwise, it is unsatisfiable. An unsatisfiable formula: x 1 v x 2 & x 1 v -x 2 & -x 1 v x 2 & -x 1 v -x 2

© The McGraw-Hill Companies, Inc., Definition of the satisfiability problem: Given a Boolean formula, determine whether this formula is satisfiable or not. A literal: x i or -x i A clause: x 1 v x 2 v -x 3  C i A formula: conjunctive normal form C 1 & C 2 & … & C m

© The McGraw-Hill Companies, Inc., Resolution Principle C 1 : x 1 v x 2 C 2 : -x 1 v x 3  C 3 : x 2 v x 3 From C 1 & C 2, we can obtain C 3, and C 3 can be added to the formula. We have a new formula: C 1 & C 2 & C 3. The Resolution Principle x1x1 x2x2 x3x3 C 1 & C 2 C3C

© The McGraw-Hill Companies, Inc., Another example of resolution principle C 1 : -x 1 v -x 2 v x 3 C 2 : x 1 v x 4  C 3 : -x 2 v x 3 v x 4 If no new clauses can be deduced, then it is satisfiable. -x 1 v -x 2 v x 3 (1) x 1 (2) x 2 (3) (1) & (2) -x 2 v x 3 (4) (4) & (3) x 3 (5) (1) & (3) -x 1 v x 3 (6) Thus this set of clauses is satisfiable.

© The McGraw-Hill Companies, Inc., If an empty clause is deduced, then it is unsatisfiable. - x 1 v -x 2 v x 3 (1) x 1 v -x 2 (2) x 2 (3) - x 3 (4)  deduce (1) & (2) -x 2 v x 3 (5) (4) & (5) -x 2 (6) (6) & (3) □ (7) Not satisfiable.

© The McGraw-Hill Companies, Inc., x1  -x2  x3(1) x1  x4(2) x2  -x1.(3) Satisfiable A semantic tree.

© The McGraw-Hill Companies, Inc., A semantic tree. x1(1) -x1(2) Unsatisfiable

© The McGraw-Hill Companies, Inc., In a semantic tree, each path from the root to a leaf node represents a class of assignments. If each leaf node is attached with a clause, then it is unsatisfiable. Unsatisfiable

© The McGraw-Hill Companies, Inc., Nondeterministic Algorithms A nondeterministic algorithm consists of phase 1: guessing and phase 2: checking If the checking phase of a nondeterministic algorithm is of polynomial time complexity, then this algorithm is called an NP (nondeterministic polynomial) algorithm. NP problems: (must be decision problems) e.g. searching MST sorting satisfiability problem (SAT) traveling salesperson problem (TSP)

© The McGraw-Hill Companies, Inc., Decision Problems Decision version of sorting: Given a 1, a 2, …, a n and c, is there a permutation of a i s ( a 1, a 2, …,a n ) such that ∣ a 2 – a 1 ∣ + ∣ a 3 – a 2 ∣ + … + ∣ a n – a n-1 ∣< c ? Not all decision problems are NP problems. E.g. halting problem: Given a program with a certain input data, will the program terminate or not? NP-hard Undecidable

© The McGraw-Hill Companies, Inc., Guessing and Checking [Horowitz 1998] Choice(S): arbitrarily chooses one of the elements in set S Failure: an unsuccessful completion Success: a successful completion Nonderministic searching algorithm: j ← choice(1 : n) /* guessing */ if A(j) = x then success /* checking */ else failure

© The McGraw-Hill Companies, Inc., A nondeterministic algorithm terminates unsuccessfully if there exists no set of choices leading to a success completion. The time required for choice(1 : n) is O(1).

© The McGraw-Hill Companies, Inc., Cook ’ s Theorem NP = P if the satisfiability problem is a P problem. SAT is NP-complete. It was the first NP-complete problem proved. Every NP problem reduces to SAT.

© The McGraw-Hill Companies, Inc., Transforming Search to SAT Does there exist a number in { x(1), x(2), …, x(n) }, which is equal to 7? Assume n = 2. nondeterministic algorithm: i = choice(1,2) if x(i)=7 then SUCCESS else FAILURE

© The McGraw-Hill Companies, Inc., i=1 v i=2 & i=1 → i≠2 & i=2 → i≠1 & x(1)=7 & i=1 → SUCCESS & x(2)=7 & i=2 → SUCCESS & x(1)≠7 & i=1 → FAILURE & x(2)≠7 & i=2 → FAILURE & FAILURE → -SUCCESS & SUCCESS (Guarantees a successful termination) & x(1)=7 (Input data) & x(2)≠7

© The McGraw-Hill Companies, Inc., CNF (conjunctive normal form) : i=1 v i=2 (1) i≠1 v i≠2 (2) x(1)≠7 v i≠1 v SUCCESS (3) x(2)≠7 v i≠2 v SUCCESS (4) x(1)=7 v i≠1 v FAILURE (5) x(2)=7 v i≠2 v FAILURE (6) -FAILURE v -SUCCESS (7) SUCCESS (8) x(1)=7 (9) x(2)≠7 (10)

© The McGraw-Hill Companies, Inc., Satisfiable with the following assignment: i=1 satisfying (1) i≠2 satisfying (2), (4) and (6) SUCCESS satisfying (3), (4) and (8) -FAILURE satisfying (7) x(1)=7 satisfying (5) and (9) x(2)≠7 satisfying (4) and (10)

© The McGraw-Hill Companies, Inc., The semantic tree

© The McGraw-Hill Companies, Inc., Searching for 7, but x(1)  7, x(2)  7 CNF (conjunctive normal form) :

© The McGraw-Hill Companies, Inc., Apply resolution principle:

© The McGraw-Hill Companies, Inc., CNF: Searching for 7, where x(1)=7, x(2)=7

© The McGraw-Hill Companies, Inc., The semantic tree It implies that both assignments (i = 1, i = 2) satisfy the clauses.

© The McGraw-Hill Companies, Inc., The Node Cover Problem Def: Given a graph G = (V, E), S is the node cover of G if S  V and for ever edge (u, v)  E, (u,v) is incident to a node in S. node cover: {1, 3} {5, 2, 4} Decision problem:  S   S   K 

© The McGraw-Hill Companies, Inc., Transforming the Node Cover Problem to SAT

© The McGraw-Hill Companies, Inc., A Graph

© The McGraw-Hill Companies, Inc., SAT is NP-complete (1) SAT is an NP problem. (2) SAT is NP-hard: Every NP problem can be transformed in polynomial time to SAT such that SAT is satisfiable if and only if the answer for the original NP problem is “ YES ”. That is, every NP problem  SAT. By (1) and (2), SAT is NP-complete.

© The McGraw-Hill Companies, Inc., Proof of NP-Completeness To show that any problem A is NP-complete: (I) Prove that A is an NP problem. (II) Prove that  B  NPC, B  A.  A  NPC. Why?

© The McGraw-Hill Companies, Inc., Satisfiability Problem (3-SAT) Def: Each clause contains exactly three literals. (I) 3-SAT is an NP problem (obviously) (II) SAT  3-SAT Proof: (1) One literal L 1 in a clause in SAT: In 3-SAT: L 1 v y 1 v y 2 L 1 v -y 1 v y 2 L 1 v y 1 v -y 2 L 1 v -y 1 v -y 2

© The McGraw-Hill Companies, Inc., (2) Two literals L 1, L 2 in a clause in SAT: In 3-SAT: L 1 v L 2 v y 1 L 1 v L 2 v -y 1 (3) Three literals in a clause: remain unchanged. (4) More than 3 literals L 1, L 2, …, L k in a clause: in 3-SAT: L 1 v L 2 v y 1 L 3 v -y 1 v y 2  L k-2 v -y k-4 v y k-3 L k-1 v L k v -y k-3

© The McGraw-Hill Companies, Inc., The instance S in 3-SAT: x 1 v x 2 v y 1 x 1 v x 2 v -y 1 -x 3 v y 2 v y 3 -x 3 v -y 2 v y 3 -x 3 v y 2 v -y 3 -x 3 v -y 2 v -y 3 x 1 v -x 2 v y 4 x 3 v -y 4 v y 5 -x 4 v x 5 v -y 5 An instance S in SAT: x 1 v x 2 -x 3 x 1 v -x 2 v x 3 v -x 4 v x 5 SAT transform 3-SAT S S Example of Transforming a 3-SAT Instance to an SAT Instance

© The McGraw-Hill Companies, Inc., Chromatic Number Decision Problem (CN) Def: A coloring of a graph G = (V, E) is a functionf: V  { 1, 2, 3, …, k } such that if (u, v)  E, then f(u)  f(v). The CN problem is to determine if G has a coloring for k. E.g. Satisfiability with at most 3 literals per clause (SATY)  CN. 3-colorable f(a)=1, f(b)=2, f(c)=1 f(d)=2, f(e)=3

© The McGraw-Hill Companies, Inc., SATY  CN

© The McGraw-Hill Companies, Inc., x 1 v x 2 v x 3 (1) -x 3 v -x 4 v x 2 (2)  Example of SATY  CN True assignment: x 1 =T x 2 =F x 3 =F x 4 =T

© The McGraw-Hill Companies, Inc., Set Cover Decision Problem Def: F = { S 1, S 2, …, S k } S i = { u 1, u 2, …, u n } T is a set cover of F if T  F and S i = S i The set cover decision problem is to determine if F has a cover T containing no more than c sets. Example: c=3. F = {(a 1, a 3 ), (a 2, a 4 ), (a 2, a 3 ), (a 4 ), (a 1, a 3, a 4 )} s 1 s 2 s 3 s 4 s 5 T = { s 1, s 3, s 4 } set cover T = { s 1, s 2 } another set cover

© The McGraw-Hill Companies, Inc., Exact Cover Problem Def: To determine if F has an exact cover T, which is a cover of F and the sets in T are pairwise disjoint. CN  exact cover (No proof here.)

© The McGraw-Hill Companies, Inc., Sum of Subsets Problem Def: A set of positive numbers A = { a 1, a 2, …, a n } a constant C Determine if  A  A  a i = C e.g. A = { 7, 5, 19, 1, 12, 8, 14 } C = 21, A = { 7, 14 } C = 11, no solution Exact cover  sum of subsets.

© The McGraw-Hill Companies, Inc., Exact Cover  Sum of Subsets Proof: Instance of exact cover: F = { S 1, S 2, …, S n } Instance of sum of subsets: A = { a 1, a 2, …, a n } where

© The McGraw-Hill Companies, Inc., Partition Problem Def: Given a set of positive numbers A = { a 1,a 2, …,a n }, determine if  a partition P,   a i =  a i i  p i  p e.g. A = {3, 6, 1, 9, 4, 11} partition: {3, 1, 9, 4} and {6, 11} sum of subsets  partition

© The McGraw-Hill Companies, Inc., Bin Packing Problem Def: n items, each of size c i, c i > 0, a positive number k and bin capacity C, determine if we can assign the items into k bins such that the sum of c i ’ s assigned to each bin does not exceed C. partition  bin packing.

© The McGraw-Hill Companies, Inc., VLSI Discrete Layout Problem Given: n rectangles, each with height h i (integer) width w i and an area A, determine if there is a placement of the n rectangles within A according to the following rules: 1.Boundaries of rectangles are parallel to x axis or y axis. 2.Corners of rectangles lie on integer points. 3.No two rectangles overlap. 4.Two rectangles are separated by at least a unit distance. (See the figure on the next page.)

© The McGraw-Hill Companies, Inc., A Successful Placement bin packing  VLSI discrete layout.