1 More NP-Complete Problems NP-Hard Problems Tautology Problem Node Cover Knapsack.

Slides:



Advertisements
Similar presentations
NP-Hard Nattee Niparnan.
Advertisements

Max Cut Problem Daniel Natapov.
Theory of Computing Lecture 18 MAS 714 Hartmut Klauck.
Lecture 23. Subset Sum is NPC
 2004 SDU Lecture17-P,NP, NPC.  2004 SDU 2 1.Decision problem and language decision problem decision problem and language 2.P and NP Definitions of.
NP-complete and NP-hard problems Transitivity of polynomial-time many-one reductions Concept of Completeness and hardness for a complexity class Definition.
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.
CSC5160 Topics in Algorithms Tutorial 2 Introduction to NP-Complete Problems Feb Jerry Le
Complexity 11-1 Complexity Andrei Bulatov NP-Completeness.
Complexity 15-1 Complexity Andrei Bulatov Hierarchy Theorem.
CS21 Decidability and Tractability
February 23, 2015CS21 Lecture 201 CS21 Decidability and Tractability Lecture 20 February 23, 2015.
1 The Satisfiability Problem Cook’s Theorem: An NP-Complete Problem Restricted SAT: CSAT, 3SAT.
1 Intractable Problems Time-Bounded Turing Machines Classes P and NP Polynomial-Time Reductions.
Computability and Complexity 15-1 Computability and Complexity Andrei Bulatov NP-Completeness.
NP-Complete Problems Reading Material: Chapter 10 Sections 1, 2, 3, and 4 only.
The Theory of NP-Completeness
NP-Complete Problems Problems in Computer Science are classified into
1 CSE 417: Algorithms and Computational Complexity Winter 2001 Lecture 23 Instructor: Paul Beame.
CSE 421 Algorithms Richard Anderson Lecture 27 NP Completeness.
Chapter 11: Limitations of Algorithmic Power
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.
Clique Cover Cook’s Theorem 3SAT and Independent Set
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.
Tonga Institute of Higher Education Design and Analysis of Algorithms IT 254 Lecture 8: Complexity Theory.
Lecture 22 More NPC problems
Theory of Computation, Feodor F. Dragan, Kent State University 1 NP-Completeness P: is the set of decision problems (or languages) that are solvable in.
INHERENT LIMITATIONS OF COMPUTER PROGRAMS CSci 4011.
NP-complete Problems SAT 3SAT Independent Set Hamiltonian Cycle
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.
NP-COMPLETENESS PRESENTED BY TUSHAR KUMAR J. RITESH BAGGA.
EMIS 8373: Integer Programming NP-Complete Problems updated 21 April 2009.
Techniques for Proving NP-Completeness Show that a special case of the problem you are interested in is NP- complete. For example: The problem of finding.
1 The Theory of NP-Completeness 2 Cook ’ s Theorem (1971) Prof. Cook Toronto U. Receiving Turing Award (1982) Discussing difficult problems: worst case.
NP-Complete Problems. Running Time v.s. Input Size Concern with problems whose complexity may be described by exponential functions. Tractable problems.
Instructor Neelima Gupta Table of Contents Class NP Class NPC Approximation Algorithms.
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.
CS6045: Advanced Algorithms NP Completeness. NP-Completeness Some problems are intractable: as they grow large, we are unable to solve them in reasonable.
Chapter 11 Introduction to Computational Complexity Copyright © 2011 The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 1.
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
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.
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.
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
More NP-Complete and NP-hard Problems
Chapter 10 NP-Complete Problems.
Richard Anderson Lecture 26 NP-Completeness
Richard Anderson Lecture 26 NP-Completeness
NP-Completeness Yin Tat Lee
ICS 353: Design and Analysis of Algorithms
Richard Anderson Lecture 25 NP-Completeness
NP-Complete Problems.
NP-Completeness Yin Tat Lee
CS154, Lecture 16: More NP-Complete Problems; PCPs
CS21 Decidability and Tractability
CSE 589 Applied Algorithms Spring 1999
More NP-Complete Problems
Presentation transcript:

1 More NP-Complete Problems NP-Hard Problems Tautology Problem Node Cover Knapsack

2 Next Steps uWe can now reduce 3SAT to a large number of problems, either directly or indirectly. uEach reduction must be polytime. uUsually we focus on length of the output from the transducer, because the construction is easy. uBut key issue: must be polytime.

3 Next Steps – (2) uAnother essential part of an NP- completeness proof is showing the problem is in NP. uSometimes, we can only show a problem NP-hard = “if the problem is in P, then P = NP,” but the problem may not be in NP.

4 Example: NP-Hard Problem uThe Tautology Problem is: given a Boolean formula, is it satisfied by all truth assignments? wExample: x + -x + yz uNot obviously in NP, but it’s complement is. wGuess a truth assignment; accept if that assignment doesn’t satisfy the formula.

5 Key Point Regarding Tautology uAn NTM can guess a truth assignment and decide whether formula F is satisfied by that assignment in polytime. uBut if the NTM accepts when it guesses a satisfying assignment, it will accept F whenever F is in SAT, not Tautology.

6 Co-NP uA problem/language whose complement is in NP is said to be in Co-NP. uNote: P is closed under complementation. uThus, P  Co-NP. uAlso, if P = NP, then P = NP = Co-NP.

7 Tautology is NP-Hard uWhile we can’t prove Tautology is in NP, we can prove it is NP-hard. uSuppose we had a polytime algorithm for Tautology. uTake any Boolean formula F and convert it to -(F). wObviously linear time.

8 Tautology is NP-Hard – (2) uF is satisfiable if and only -(F) is not a tautology. uUse the hypothetical polytime algorithm for Tautology to test if -(F) is a tautology. uSay “yes, F is in SAT” if -(F) is not a tautology and say “no” otherwise. uThen SAT would be in P, and P = NP.

9 Historical Comments uThere were actually two notions of “NP- complete” that differ subtlely. wAnd only if P  NP. uSteve Cook, in his 1970 paper, was really concerned with the question “why is Tautology hard?” wRemember: theorems are really logical tautologies.

10 History – (2) uCook used “if problem X is in P, then P = NP” as the definition of “X is NP- hard.” wToday called Cook completeness. uIn 1972, Richard Karp wrote a paper showing many of the key problems in Operations Research to be NP- complete.

11 History – (3) uKarp’s paper moved “NP-completeness” from a concept about theorem proving to an essential for any study of algorithms. uBut Karp used the definition of NP- completeness “exists a polytime reduction,” as we have. wCalled Karp completeness.

12 Cook Vs. Karp Completeness uIn practice, there is very little difference. uBiggest difference: for Tautology, Cook lets us flip the answer after a polytime reduction. uIn principle, Cook completeness could be much more powerful, or (if P = NP) exactly the same.

13 Cook Vs. Karp – (2) uBut there is one important reason we prefer Karp-completeness. uSuppose I had an algorithm for some NP-complete problem that ran in time O(n log n ). wA function that is bigger than any polynomial, yet smaller than the exponentials like 2 n.

14 Cook Vs. Karp – (3) uIf “NP-complete is Karp-completeness, I can conclude that all of NP can be solved in time O(n f(n) ), where f(n) is some function of the form c log k n. wStill faster than any exponential, and faster than we have a right to expect. uBut if I use Cook-completeness, I cannot say anything of this type.

15 The Node Cover Problem uGiven a graph G, we say N is a node cover for G if every edge of G has at least one end in N. uThe problem Node Cover is: given a graph G and a “budget” k, does G have a node cover of k or fewer nodes?

16 Example: Node Cover AC EF DB One possible node cover of size 3: {B, C, E}

17 NP-Completeness of Node Cover uReduction from 3SAT. uFor each clause (X+Y+Z) construct a “column” of three nodes, all connected by vertical edges. uAdd a horizontal edge between nodes that represent any variable and its negation. uBudget = twice the number of clauses.

18 Example: The Reduction to Node Cover (x + y + z)(-x + -y + -z)(x + -y +z)(-x + y + -z) x z y -x -z -y x z -x -z y Budget = 8

19 Example: Reduction – (2) uA node cover must have at least two nodes from every column, or some vertical edge is not covered. uSince the budget is twice the number of columns, there must be exactly two nodes in the cover from each column. uSatisfying assignment corresponds to the node in each column not selected.

20 Example: Reduction – (3) (x + y + z)(-x + -y + -z)(x + -y +z)(-x + y + -z) Truth assignment: x = y = T; z = F x z y -x -z -y x z -x -z y Pick a true node in each column

21 Example: Reduction – (4) (x + y + z)(-x + -y + -z)(x + -y +z)(-x + y + -z) Truth assignment: x = y = T; z = F x z y -x -z -y x z -x -z y The other nodes form a node cover

22 Proof That the Reduction Works uThe reduction is clearly polytime. uNeed to show: uIf we construct from 3SAT instance F a graph G and a budget k, then G has a node cover of size k if and only if F is satisfiable.

23 Proof: If uSuppose we have a satisfying assignment A for F. uFor each clause of F, pick one of its three literals that A makes true. uPut in the node cover the two nodes for that clause that do not correspond to the selected literal. uTotal = k nodes – meets budget.

24 Proof: If – (2) uThe selected nodes cover all vertical edges. wWhy? Any two nodes for a clause cover the triangle of vertical edges for that clause. uHorizontal edges are also covered. wA horizontal edge connects nodes for some x and -x. wOne is false in A and therefore its node must be selected for the node cover.

25 Proof: Only If uSuppose G has a node cover with at most k nodes. uOne node cannot cover the vertical edges of any column, so each column has exactly 2 nodes in the cover. uConstruct a satisfying assignment for F by making true the literal for any node not in the node cover.

26 Proof: Only If – (2) uWorry: What if there are unselected nodes corresponding to both x and -x? wThen we would not have a truth assignment. uBut there is a horizontal edge between these nodes. uThus, at least one is in the node cover.

27 Optimization Problems uNP-complete problems are always yes/no questions. uIn practice, we tend to want to solve optimization problems, where our task is to minimize (or maximize) a parameter subject to some constraints.

28 Example: Optimization Problem uPeople who care about node covers would ask: wGiven this graph, what is the smallest number of nodes I can pick to form a node cover? uIf I can solve that problem in polytime, then I can solve the yes/no version.

29 Example – Continued uPolytime algorithm: given graph G and budget k, solve the optimization problem for G. uIf the smallest node cover for G is of size k or less, answer “yes’; otherwise answer “no.”

30 Optimization Problems – (2) uOptimization problems are never, strictly speaking, in NP. wThey are not yes/no. uBut there is a Cook reduction from the yes/no version to the optimization version.

31 Optimization Problems – (3) uThat is enough to show that if the optimization version of an NP-complete problem can be solved in polytime, then P = NP. wA strong argument that you cannot solve the optimization version of an NP-complete problem in polytime.

32 The Knapsack Problem uWe shall prove NP-complete a version of Knapsack with a budget: wGiven a list L of integers and a budget k, is there a subset of L whose sum is exactly k? uLater, we’ll reduce this version of Knapsack to our earlier one: given an integer list L, can we divide it into two equal parts?

33 Knapsack is in NP uGuess a subset of the list L. uAdd ‘em up. uAccept if the sum is k.

34 Polytime Reduction of 3SAT to Knapsack uGiven 3SAT instance F, we need to construct a list L and a budget k. uSuppose F has c clauses and v variables. uL will have base-32 integers of length c+v, and there will be 3c+2v of them.

35 Picture of Integers for Literals cv i 1 1 in i-th position if this integer is for x i or -x i ’s in all positions such that this literal makes the clause true. All other positions are 0.

36 Pictures of Integers for Clauses i For the i-th clause

37 Example: Base-32 Integers (x + y + z)(x + -y + -z) uc = 2; v = 3. uAssume x, y, z are variables 1, 2, 3, respectively. uClauses are 1, 2 in order given.

38 Example: (x + y + z)(x + -y + -z) uFor x: uFor -x: uFor y: uFor -y: uFor z: uFor -z: u For first clause: 00005, 00006, u For second clause: 00050, 00060, 00070

39 The Budget uk = 8( …+32 c-1 ) + 32 c ( …+32 v-1 ) uThat is, 8 for the position of each clause and 1 for the position of each variable. uKey Point: Base-32 is high enough that there can be no carries between positions.

40 Key Point: Details uAmong all the integers, the sum of digits in the position for a variable is 2. uAnd for a clause, it is = 21. w1’s for the three literals in the clause; 5, 6, and 7 for the integers for that clause. uThus, the budget must be satisfied on a digit-by-digit basis.

41 Key Point: Concluded uThus, if a set of integers matches the budget, it must include exactly one of the integers for x and -x. uFor each clause, at least one of the integers for literals must have a 1 there, so we can choose either 5, 6, or 7 to make 8 in that position.

42 Proof the Reduction Works uEach integer can be constructed from the 3SAT instance F in time proportional to its length. wThus, reduction is O(n 2 ). uIf F is satisfiable, take a satisfying assignment A. uPick integers for those literals that A makes true.

43 Proof the Reduction Works – (2) uThe selected integers sum to between 1 and 3 in the digit for each clause. uFor each clause, choose the integer with 5, 6, or 7 in that digit to make a sum of 8. uThese selected integers sum to exactly the budget.

44 Proof: Converse uWe must also show that a sum of integers equal to the budget k implies F is satisfiable. uIn each digit for a variable x, either the integer for x or the digit for -x, but not both is selected. wlet truth assignment A make this literal true.

45 Proof: Converse – (2) uIn the digits for the clauses, a sum of 8 can only be achieved if among the integers for the variables, there is at least one 1 in that digit. uThus, truth assignment A makes each clause true, so it satisfies F.

46 The Partition-Knapsack Problem uThis problem is what we originally referred to as “knapsack.” uGiven a list of integers L, can we partition it into two disjoint sets whose sums are equal? uPartition-Knapsack is NP-complete; reduction from Knapsack.

47 Reduction of Knapsack to Partition-Knapsack uGiven instance (L, k) of Knapsack, compute the sum s of all the integers in L. wLinear in input size. uOutput is L followed by two integers: s and 2k. uExample: L = 3, 4, 5, 6; k = 7. wPartition-Knapsack instance = 3, 4, 5, 6, 14, 18. Solution

48 Proof That Reduction Works uThe sum of all integers in the output instance is 2(s+k). wThus, the two partitions must each sum to s+k. uIf the input instance has a subset of L that sums to k, then pick it plus the integer s to solve the output instance.

49 Proof: Converse uSuppose the output instance of Partition- Knapsack has a solution. uThe integers s and 2k cannot be in the same partition. wBecause their sum is more than half 2(s+k). uThus, the subset of L that is in the partition with s sums to k. wThus, it solves the Knapsack instance.