Lecture 23. Subset Sum is NPC

Slides:



Advertisements
Similar presentations
NP-Hard Nattee Niparnan.
Advertisements

Theory of Computing Lecture 18 MAS 714 Hartmut Klauck.
NP-Completeness: Reductions
An NP-completeness Example. The graph CLIQUE problem Undirected Graph G = (V, E) –a clique is a complete subgraph of G Subset V’ of vertices that are.
Lecture 21 NP-complete problems
© 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.
Computability and Complexity 14-1 Computability and Complexity Andrei Bulatov Cook’s Theorem.
CS21 Decidability and Tractability
Computability and Complexity 15-1 Computability and Complexity Andrei Bulatov NP-Completeness.
Computability and Complexity 16-1 Computability and Complexity Andrei Bulatov NP-Completeness.
Restricted Satisfiability (SAT) Problem
1 CSE 417: Algorithms and Computational Complexity Winter 2001 Lecture 23 Instructor: Paul Beame.
Fall 2006Costas Busch - RPI1 More NP-complete Problems.
NP-Completeness (2) NP-Completeness Graphs 4/17/2017 6:25 AM x x x x x
1 CSE 417: Algorithms and Computational Complexity Winter 2001 Lecture 24 Instructor: Paul Beame.
CSE 421 Algorithms Richard Anderson Lecture 27 NP Completeness.
Complexity ©D.Moshkovitz 1 Paths On the Reasonability of Finding Paths in Graphs.
P, NP, and NP-Complete Suzan Köknar-Tezel.
The Theory of NP-Completeness 1. What is NP-completeness? Consider the circuit satisfiability problem Difficult to answer the decision problem in polynomial.
Nattee Niparnan. Easy & Hard Problem What is “difficulty” of problem? Difficult for computer scientist to derive algorithm for the problem? Difficult.
Lecture 22 More NPC problems
INHERENT LIMITATIONS OF COMPUTER PROGRAMS CSci 4011.
NP-complete Problems SAT 3SAT Independent Set Hamiltonian Cycle
NP Complexity By Mussie Araya. What is NP Complexity? Formal Definition: NP is the set of decision problems solvable in polynomial time by a non- deterministic.
Prabhas Chongstitvatana1 NP-complete proofs The circuit satisfiability proof of NP- completeness relies on a direct proof that L  p CIRCUIT-SAT for every.
1 NP-Completeness Poly time algorithm: input size n (in some encoding), worst case running time – O(n c ) for some constant c. Three classes of problems.
CSE 024: Design & Analysis of Algorithms Chapter 9: NP Completeness Sedgewick Chp:40 David Luebke’s Course Notes / University of Virginia, Computer Science.
EMIS 8373: Integer Programming NP-Complete Problems updated 21 April 2009.
1 The Theory of NP-Completeness 2 Cook ’ s Theorem (1971) Prof. Cook Toronto U. Receiving Turing Award (1982) Discussing difficult problems: worst case.
Additional NP-complete problems
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.
1.1 Chapter 3: Proving NP-completeness Results Six Basic NP-Complete Problems Some Techniques for Proving NP-Completeness Some Suggested Exercises.
CS 3343: Analysis of Algorithms Lecture 25: P and NP Some slides courtesy of Carola Wenk.
1 Suppose I construct a TM M f which: 1. Preserves its input u. 2. Simulates a machine M b on input ε. 3. If M b hangs on input ε, force an infinite loop.
CS 461 – Nov. 30 Section 7.5 How to show a problem is NP-complete –Show it’s in NP. –Show that it corresponds to another problem already known to be NP-complete.
28.
NPC.
CSC 413/513: Intro to Algorithms
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.
NP Hard Problems Instructor Neelima Gupta Presentation Edited by Sapna Grover.
Prof. Busch - LSU1 Busch Complexity Lectures: More NP-complete Problems.
SUBSET-SUM Instance: A set of numbers denoted S and a target number t.
COSC 3101A - Design and Analysis of Algorithms 14 NP-Completeness.
34.NP Completeness. Computer Theory Lab. Chapter 34P.2.
TU/e Algorithms (2IL15) – Lecture 10 1 NP-Completeness, II.
Costas Busch - LSU 1 More NP-complete Problems. Costas Busch - LSU 2 Theorem: If: Language is NP-complete Language is in NP is polynomial time reducible.
NP-Completeness (2) NP-Completeness Graphs 4/13/2018 5:22 AM x x x x x
More NP-Complete and NP-hard Problems
Richard Anderson Lecture 26 NP-Completeness
More NP-complete Problems
NP-Completeness (2) NP-Completeness Graphs 7/23/ :02 PM x x x x
NP-Completeness Proofs
Richard Anderson Lecture 26 NP-Completeness
CS154, Lecture 16: More NP-Complete Problems; PCPs
NP-Completeness (2) NP-Completeness Graphs 11/23/2018 2:12 PM x x x x
More NP-complete Problems
Richard Anderson Lecture 25 NP-Completeness
NP-Completeness Proofs
More NP-Complete Problems
CS154, Lecture 16: More NP-Complete Problems; PCPs
CS21 Decidability and Tractability
Trevor Brown DC 2338, Office hour M3-4pm
Instructor: Aaron Roth
NP-Completeness (2) NP-Completeness Graphs 7/9/2019 6:12 AM x x x x x
Presentation transcript:

Lecture 23. Subset Sum is NPC Talk at U of Maryland Lecture 23. Subset Sum is NPC The Subset Sum Problem: Given a set of positive integers S and a "target" t. Question: Is there a subset S' of S such that the sum of the elements of S' is equal to t ? For example, if S = {35,54,384,520,530,672,831,935} and t = 1757, then the answer is ‘yes’, since the subset S' = {35,520,530,672} sums to 1757. But if t = 1758, the answer is no, as can be verified by trying all 28 = 256 subsets.

Thm. SUBSET-SUM is NP-Complete Proof. 1. SUBSET-SUM is in NP. Given S', we can in polynomial time determine the sum of the elements in S', and see if that is equal to t. We also need to check that each element of S' is in S and no element occurs twice. 2. We will show 3-CNF-SAT ≤P SUBSET-SUM.

Proof continues … 3. Given a 3-CNF formula φ with variables x1, x2, ..., xn, and clauses C1, C2, ..., Ck, we need to create an instance of subset sum: namely, a set S and an integer t, such that φ is satisfiable iff there is some subset of S that sums to t. We assume no clause has both a variable and its negation and every variable appears in some clause. Our reduction constructs S by making two numbers for each clause and two numbers for each variable. We construct these numbers by specifying their base-10 digits. Each number has a digit corresponding to each variable xi and a digit corresponding to each clause Cj.

For each variable xi, we construct the two numbers vi and v'i For each variable xi, we construct the two numbers vi and v'i. Both numbers have a 1 in the digit corresponding to xi and 0's in the digits corresponding to the other variables. If the literal xi appears in Cj, then vi has a digit 1 in the digit corresponding to Cj. If the literal ~xi appears in Cj, then v'i has a digit 1 in the digit corresponding to Cj. All the other digits are 0. For each clause Cj we construct the two numbers sj and s'j. The number sj has a 1 in the digit corresponding to Cj, while the number s'j has a 2 in the digit corresponding to Cj. All the other digits are 0. Finally, we need to specify the target t. The digits of t are as follows: there should be a 1 in the digit corresponding to each variable, and a 4 in the digit corresponding to each clause.

Sample Reduction φ(x1,x2,x3,x4)=(~x1+x3+x4)(x1+~x2+~x3)(x3+x2+~x4) C1 C2 C3 x1 x2 x3 x4 C1 C2 C3 v1 = 1 0 0 0 0 1 0 v’1 = 1 0 0 0 1 0 0 v2 = 0 1 0 0 0 0 1 v’2 = 0 1 0 0 0 1 0 v3 = 0 0 1 0 1 0 1 v’3 = 0 0 1 0 0 1 0 v4 = 0 0 0 1 1 0 0 v’4 = 0 0 0 1 0 0 1 C1 C2 C3 s1 = 1 0 0 s’1 = 2 0 0 s2 = 0 1 0 s’2 = 0 2 0 s3 = 0 0 1 s’3 = 0 0 2 t = 1 1 1 1 4 4 4

Claim. φ is satisfiable if and only if the set S of all the numbers specified above has some subset that sums to the target t. To see this, suppose φ is satisfiable, and suppose (x1, ..., xn) = (y1, ..., yn) is a satisfying assignment. Then we put vi into S' if yi = 1; otherwise we put v'i into S'. Now, depending on how many literals in each clause are set to 1 by the assignment (x1, ..., xn) = (y1, ..., yn), we take some of the "slack" variables sj. If our assignment sets 3 literals true in clause Cj, we take sj. If it sets 2 literals true, we take s'j. If it sets 1 literal true, we take both sj and s'j. Thus no matter how many literals h are satisfied in a clause, the sum of the digits of sj and s'j in the position corresponding to Cj is 4-h.

It remains to see that the sum of the numbers we have chosen is t It remains to see that the sum of the numbers we have chosen is t. To see this, we compare the numbers digit-by-digit. For each variable xi, we take exactly one of vi and v'i, and each of these has a 1 in the position corresponding to xi. So when we sum up the numbers chosen, we get a 1 in a position corresponding to each variable. For each clause, we get a contribution of 1 from each variable that is set to true, giving a total of h, and then we have chosen the slack variables to sum to 4-h. So in the digit corresponding to Cj, we always get 4. Thus we hit the target t.

For the converse, let's assume that there is some subset S' that hits t. Then because the sum of the digits in any fixed position is at most 6 (1 for each literal in a clause, plus 3 for the slack variables) there can be no carries from one position to the next. So it suffices to consider each position by itself. Because the positions corresponding to the variables xi are 1, this means that we must take exactly one of each variable vi, v'i. If we choose vi, this corresponds to setting xi = 1. If we choose v'i, this corresponds to setting xi = 0.

Why is this a satisfying assignment Why is this a satisfying assignment? Because the sum matches the target in each position corresponding to a clause, and because the slack variables add up to at most 3 while the target is 4, this means that there is a 1 in at least one position corresponding to a clause, which corresponds to the corresponding literal set to 1. So there is at least 1 literal set to true in each clause, and hence the formula is satisfied. QED