1 The Theory of NP-Completeness 2 Cook ’ s Theorem (1971) Prof. Cook Toronto U. Receiving Turing Award (1982) Discussing difficult problems: worst case.

Slides:



Advertisements
Similar presentations
Analysis of Algorithms
Advertisements

NP-Hard Nattee Niparnan.
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 
© The McGraw-Hill Companies, Inc., Chapter 8 The Theory of 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
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.
Analysis of Algorithms CS 477/677
Chapter 11: Limitations of Algorithmic Power
Chapter 11 Limitations of Algorithm Power Copyright © 2007 Pearson Addison-Wesley. All rights reserved.
Toward NP-Completeness: Introduction Almost all the algorithms we studies so far were bounded by some polynomial in the size of the input, so we call them.
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
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.
Complexity Classes (Ch. 34) The class P: class of problems that can be solved in time that is polynomial in the size of the input, n. if input size is.
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.
TECH Computer Science NP-Complete Problems Problems  Abstract Problems  Decision Problem, Optimal value, Optimal solution  Encodings  //Data Structure.
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.
CSCI 3160 Design and Analysis of Algorithms Tutorial 10 Chengyu Lin.
The Theory of Complexity for Nonpreemptive Scheduling 1.
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.
NP-COMPLETE PROBLEMS. Admin  Two more assignments…  No office hours on tomorrow.
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.
NP-Completeness (Nondeterministic Polynomial Completeness) Sushanth Sivaram Vallath & Z. Joseph.
CS 3343: Analysis of Algorithms Lecture 25: P and NP Some slides courtesy of Carola Wenk.
“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.
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.
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.
COMPLEXITY. Satisfiability(SAT) problem Conjunctive normal form(CNF): Let S be a Boolean expression in CNF. That is, S is the product(and) of several.
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.
COMPLEXITY. Satisfiability(SAT) problem Conjunctive normal form(CNF): Let S be a Boolean expression in CNF. That is, S is the product(and) of several.
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
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 Yin Tat Lee
ICS 353: Design and Analysis of Algorithms
Chapter 11 Limitations of Algorithm Power
NP-Complete Problems.
CS 3343: Analysis of Algorithms
NP-Completeness Reference: Computers and Intractability: A Guide to the Theory of NP-Completeness by Garey and Johnson, W.H. Freeman and Company, 1979.
The Theory of NP-Completeness
Our old list of problems
RAIK 283 Data Structures & Algorithms
Presentation transcript:

1 The Theory of NP-Completeness

2 Cook ’ s Theorem (1971) Prof. Cook Toronto U. Receiving Turing Award (1982) Discussing difficult problems: worst case lower bound seems to be in the order of an exponential function NP-complete (NPC) Problems

3 Finding lower bound by problem transformation Problem A reduces to problem B (A  B) iff A can be solved by using any algorithm which solves B. If A  B, B is more difficult (B is at least as hard as A) Since  (A)   (B) +T(tr 1 ) + T(tr 2 ), we have  (B)   (A) –(T(tr 1 ) + T(tr 2 )) We have  (B)   (A) if T(tr 1 ) + T(tr 2 )   (A)

4 The lower bound of the convex hull problem sorting  convex hull A B an instance of A: (x 1, x 2, …, x n ) ↓ transformation an instance of B: {( x 1, x 1 2 ), ( x 2, x 2 2 ), …, ( x n, x n 2 )} assume: x 1 < x 2 < … < x n

5 The lower bound of the convex hull problem If the convex hull problem can be solved, we can also solve the sorting problem, but not vice versa. We have that the convex hull problem is harder than the sorting problem. The lower bound of sorting problem is  (n log n), so the lower bound of the convex hull problem is also  (n log n).

6 NP P NPC NP: Non-deterministic Polynomial P: Polynomial NPC: Non-deterministic Polynomial Complete P=NP?

7 Nondeterministic algorithms A nondeterministic algorithm is an algorithm consisting of two phases: guessing and checking. Furthermore, it is assumed that a nondeterministic algorithm always makes a correct guessing.

8 Nondeterministic algorithms Machines for running nondeterministic algorithms do not exist and they would never exist in reality. (They can only be made by allowing unbounded parallelism in computation.) Nondeterministic algorithms are useful only because they will help us define a class of problems: NP problems

9 NP algorithm If the checking stage of a nondeterministic algorithm is of polynomial time-complexity, then this algorithm is called an NP (nondeterministic polynomial) algorithm.

10 NP problem If a decision problem can be solved by a NP algorithm, this problem is called an NP (nondeterministic polynomial) problem. NP problems : (must be decision problems)

11 Decision problems The solution is simply “ Yes ” or “ No ”. Optimization problem : harder Decision problem : easier 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 ?

12 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 ?

13 Decision vs Original Version We consider decision version problem D rather than the original problem O because we are addressing the lower bound of a problem and D ∝ O

14 To express Nondeterministic Algorithm Choice(S) : arbitrarily chooses one of the elements in set S Failure : an unsuccessful completion Success : a successful completion

15 Nondeterministic searching Algorithm : input: n elements and a target element x output: success if x is found among the n elements; failure, otherwise. j ← choice(1 : n) /* guess if A(j) = x then success /* check else failure A nondeterministic algorithm terminates unsuccessfully iff there exist no set of choices leading to a success signal. The time required for choice(1 : n) is O(1).

16 Relationship Between NP and P It is known P  NP. However, it is not known whether P = NP or whether P is a proper subset of NP It is believed NP is much larger than P We cannot find a polynomial-time algorithm for many NP problems. But, no NP problem is proved to have exponential lower bound. ( No NP problem has been proved to be not in P.) So, “ does P = NP ? ” is still an open question! Cook tried to answer the question by proposing NPC.

17 NP-complete (NPC) A problem A is NP-complete (NPC) if A ∈ NP and every NP problem reduces to A.

18 SAT is NP-complete Every NP problem can be solved by an NP algorithm Every NP algorithm can be transformed in polynomial time to an SAT problem Such that the SAT problem is satisfiable iff the answer for the original NP problem is “ yes ” That is, every NP problem  SAT SAT is NP-complete

19 Cook ’ s theorem (1971) NP = P iff SAT  P NP = P iff SAT  P NP = P iff the satisfiability (SAT) problem is a P problem NP = P iff the satisfiability (SAT) problem is a P problem SAT is NP-complete It is the first NP-complete problem Every NP problem reduces to SAT

20 Proof of NP-Completeness To show that A is NP-complete (I) Prove that A is an NP problem (II) Prove that  B  NPC, B  A  A  NPC Why ? Transitive property of polynomial-time reduction

21 0/1 Knapsack problem Given M (weight limit) and V, is there is a solution with value larger than V? This is an NPC problem. P1P1 P2P2 P3P3 P4P4 P5P5 P6P6 P7P7 P8P8 Value Weight

22 Traveling salesperson problem Given: A set of n planar points and a value L Find: Is there a closed tour which includes all points exactly once such that its total length is less than L? This is an NPC problem.

23 Partition problem Given: A set of positive integers S Find: Is there a partition of S 1 and S 2 such that S 1  S 2 = , S 1  S 2 =S,  i  S1 i=  i  S2 i (partition S into S 1 and S 2 such that element sum of S 1 is equal to that of S 2 ) e.g. S={1, 7, 10, 9, 5, 8, 3, 13} S 1 ={1, 10, 9, 8} S 2 ={7, 5, 3, 13} This problem is NP-complete.

24 Art gallery problem: *Given a constant C, is there a guard placement such that the number of guards is less than C and every wall is monitored? *This is an NPC problem.

25 Karp R. Karp showed several NPC problems, such as 3-STA, node (vertex) cover, and Hamiltonian cycle, etc. Karp received Turing Award in 1985

26 NP-Completeness Proof: Reduction Vertex Cover Clique3-SAT SAT Chromatic Number Dominating Set All NP problems

27 NP -Completeness “ NP -complete problems ” : the hardest problems in NP Interesting property If any one NP -complete problem can be solved in polynomial time, then every problem in NP can also be solved in polynomial time (i.e., P=NP) Many believe P ≠ NP

28 Importance of NP -Completeness NP -complete problems: considered “ intractable ” Important for algorithm designers & engineers Suppose you have a problem to solve Your colleagues have spent a lot of time to solve it exactly but in vain See whether you can prove that it is NP -complete If yes, then spend your time developing an approximation (heuristic) algorithm Many natural problems can be NP -complete

29 Some concepts Up to now, none of the NPC problems can be solved by a deterministic polynomial time algorithm in the worst case. It does not seem to have any polynomial time algorithm to solve the NPC problems. The lower bound of any NPC problem seems to be in the order of an exponential function. The theory of NP-completeness always considers the worst case.

30 Caution ! If a problem is NP-complete, its special cases may or may not be of exponential time- complexity. We consider worst case lower bound in NP-complete.

31 Some concepts Not all NP problems are difficult. (e.g. the MST problem is an NP problem.) (But NPC problem is difficult.) 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)

32 Undecidable Problems They cannot be solved by guessing and checking. They are even more difficult than NP problems. E.G.: Halting problem: Given an arbitrary program with an arbitrary input data, will the program terminate or not? It is not NP It is NP-hard (SAT  Halting problem )

33 NP : the class of decision problem which can be solved by a non-deterministic polynomial algorithm. P: the class of problems which can be solved by a deterministic polynomial algorithm. NP-hard: the class of problems to which every NP problem reduces. (It is “at least as hard as the hardest problems in NP.”)NP NP-complete: the class of problems which are NP-hard and belong to NP.

34 The satisfiability (SAT) problem Def : 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

35 The satisfiability (SAT) problem The satisfiability problem The 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

36 The satisfiability problem satisfiable unsatisfiable 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

37 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 (resolvent) If no new clauses can be deduced  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) The satisfiability problem x1 cannot satisfy c1 and c2 at the same time, so it is deleted..

38 The satisfiability problem If an empty clause is deduced  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)

39 Nondeterministic SAT Guessing for i = 1 to n do x i ← choice( true, false ) if E(x 1, x 2, …,x n ) is true Checking then success else failure

40 Transforming the NP searching algorithm to the SAT problem Does there exist a number in { x(1), x(2), …, x(n) }, which is equal to 7? Assume n = 2

41 Transforming searching to SAT 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

42 Transforming searching to SAT 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)

43 Transforming searching to SAT Satisfiable at 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)

44 Searching in CNF with inputs Searching for 7, but x(1)  7, x(2)  7 CNF :

45 Searching in CNF with inputs Apply resolution principle :

46 Searching in CNF with inputs

47 Q&A