SUBSET-SUM Instance: A set of numbers denoted S and a target number t.

Slides:



Advertisements
Similar presentations
Complexity ©D.Moshkovits 1 Where Can We Draw The Line? On the Hardness of Satisfiability Problems.
Advertisements

Complexity ©D.Moshkovitz 1 NPC More NP-Complete Problems.
Theory of Computing Lecture 18 MAS 714 Hartmut Klauck.
Lecture 23. Subset Sum is NPC
The class NP Section 7.3 Giorgi Japaridze Theory of Computability.
FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY
INHERENT LIMITATIONS OF COMPUTER PROGRAMS CSci 4011.
Complexity 11-1 Complexity Andrei Bulatov NP-Completeness.
More NP-completeness Sipser 7.5 (pages ).
CS21 Decidability and Tractability
Computability and Complexity 15-1 Computability and Complexity Andrei Bulatov NP-Completeness.
Transitivity of  poly Theorem: Let ,  ’, and  ’’ be three decision problems such that   poly  ’ and  ’  poly  ’’. Then  poly  ’’. Proof:
NP-Complete Problems Problems in Computer Science are classified into
1 Perfect Matchings in Bipartite Graphs An undirected graph G=(U  V,E) is bipartite if U  V=  and E  U  V. A 1-1 and onto function f:U  V is a perfect.
Time Complexity.
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.
CS Master – Introduction to the Theory of Computation Jan Maluszynski - HT Lecture NP-Completeness Jan Maluszynski, IDA, 2007
Complexity ©D.Moshkovitz 1 Paths On the Reasonability of Finding Paths in Graphs.
February 25, 2015CS21 Lecture 211 CS21 Decidability and Tractability Lecture 21 February 25, 2015.
INHERENT LIMITATIONS OF COMPUTER PROGRAMS CSci 4011.
1 NPC NP-Complete Problems 2 We can solve any problem(!)(?) … but perhaps not with a computer! Some problems are not computable: The Halting Problem:
Instructor Neelima Gupta Table of Contents Class NP Class NPC Approximation Algorithms.
CS6045: Advanced Algorithms NP Completeness. NP-Completeness Some problems are intractable: as they grow large, we are unable to solve them in reasonable.
NPC.
Complexity ©D.Moshkovits 1 2-Satisfiability NOTE: These slides were created by Muli Safra, from OPICS/sat/)
CSE 421 Algorithms Richard Anderson Lecture 27 NP-Completeness Proofs.
SUBSET-SUM Instance: A set of numbers denoted S and a target number t.
COSC 3101A - Design and Analysis of Algorithms 14 NP-Completeness.
 2005 SDU Lecture15 P,NP,NP-complete.  2005 SDU 2 The PATH problem PATH = { | G is a directed graph that has a directed path from s to t} s t
TU/e Algorithms (2IL15) – Lecture 10 1 NP-Completeness, II.
ICS 353: Design and Analysis of Algorithms NP-Complete Problems King Fahd University of Petroleum & Minerals Information & Computer Science Department.
NP-Completeness (2) NP-Completeness Graphs 4/13/2018 5:22 AM x x x x x
More NP-Complete and NP-hard Problems
More NP-complete 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 (2) NP-Completeness Graphs 7/23/ :02 PM x x x x
NP-Completeness Proofs
Richard Anderson Lecture 26 NP-Completeness
(xy)(yz)(xz)(zy)
Perfect Matchings in Bipartite Graphs
CS154, Lecture 16: More NP-Complete Problems; PCPs
Where Can We Draw The Line?
CS21 Decidability and Tractability
Lecture 24 NP-Complete Problems
ICS 353: Design and Analysis of Algorithms
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
Richard Anderson Lecture 28 NP-Completeness
Richard Anderson Lecture 29 NP-Completeness
Chapter 34: NP-Completeness
Additional NP-complete problems
CSC 4170 Theory of Computation The class NP Section 7.3.
More NP-Complete Problems
CSC 4170 Theory of Computation The class NP Section 7.3.
Richard Anderson Lecture 26 NP-Completeness
CS21 Decidability and Tractability
NP-Completeness Yin Tat Lee
CS154, Lecture 16: More NP-Complete Problems; PCPs
CS21 Decidability and Tractability
CSE 589 Applied Algorithms Spring 1999
Instructor: Aaron Roth
Lecture 24 Classical NP-hard Problems
Theory of Computability
NP-Completeness (2) NP-Completeness Graphs 7/9/2019 6:12 AM x x x x x
Presentation transcript:

SUBSET-SUM Instance: A set of numbers denoted S and a target number t. Problem: To decide if there exists a subset YS, s.t yYy=t. Problem definition: Subset Sum - Given a (multi)set A of integer numbers and an integer number t, does there exist a subset of A such that the sum of its elements is equal to t?

SUBSET-SUM is in NP On input S,t: Guess YS Accept iff yYy=t. The length of the certificate: O(n) (n=|S|) Time complexity: O(n)

SUBSET-SUM is NP-Complete Proof: We’ll show 3SAT  SUBSET-SUM. t

Examples SUBSET-SUM … because 2+8=10 … because 11 cannot be made out of {2,4,8}

Reducing 3SAT to SubSet Sum Proof idea Choosing the subset numbers from the set S corresponds to choosing the assignments of the variables in the 3CNF formula. The different digits of the sum correspond to the different clauses of the formula. If the target t is reached, a valid and satisfying assignment is found.

Satisfying Clauses c1 c2 …… ck yi zi digit per clause number per variable xi assigned true: yi number per variable xi assigned false: zi 1 if xi is in cj 0 otherwise 1 if xi is in cj 0 otherwise

Subset Sum + clause: 3CNF formula: Make the number table, 1 2 3 4 +x1 –x1 +x2 –x2 +x3 –x3 +x4 –x4 1 3CNF formula: Make the number table, and the ‘target sum’ t dummies + 1 3

Reducing 3SAT to SubSet Sum Let 3CNF with k clauses and  variables x1,…,x. Create a Subset-Sum instance <S,t> by: 2+2k elements of S = {y1,z1,…,y,z,g1,h1,…,gk,hk} yj indicates positive xj literals in clauses zj indicates negated xj literals in clauses gj and hj are dummies and

Subset Sum + clause: 3CNF formula: Make the number table, 1 2 3 4 +x1 –x1 +x2 –x2 +x3 –x3 +x4 –x4 1 y1 z1 y2 z2 y3 z3 y4 z4 3CNF formula: Make the number table, and the ‘target sum’ t dummies + 1 3

Subset Sum Note 1: The “1111” in the target forces a proper assignment +x1 –x1 +x2 –x2 +x3 –x3 +x4 –x4 1 Note 1: The “1111” in the target forces a proper assignment of the xi variables. Note 2: The target “3333” is only possible if each clause is satisfied. (The dummies can add maximally 2 extra.) 1 3

Subset Sum + is a satisfying assignment +x1 –x1 +x2 –x2 +x3 –x3 +x4 1 3 + is a satisfying assignment 1 3

Subset Sum + is not a satisfying assignment +x1 –x1 +x2 –x2 +x3 –x3 1 ? 2 + is not a satisfying assignment 1 3

Proof 3SAT  Subset Sum For every 3CNF , take target t=1…13…3 and the corresponding set S. If 3SAT, then the satisfying assignment defines a subset that reaches the target. Also, the target can only be obtained via a set that gives a satisfying assignment for .

Directed Hamiltonian Path Given a directed graph G, does there exist a Hamiltonian path, which visits all nodes exactly once? Two Examples: but this graph has no Hamiltonian path this graph has a Hamiltonian path

3SAT to Hamiltonian Path Proof idea: Given a 3CNF , make a graph G such that … a Hamiltonian path is possible if and only if there is a zig-zag path through G, … where the directions (zig or zag) determine the assignments (true or false) of the variables x1,…,xL of .

“Zig-Zag Graphs” s t There are 2L different Hamiltonian paths from s to the target t. For every i, “Zig” means xi=True … while “Zag” means xi=False

Accessing the Clauses stands for If  has K clauses,  = C1 Ck, then xi has K “hubs”: Idea: Make K extra nodes Cj that can only be visited via the hub- path that defines an assignment of xi which satisfies the clause (using zig/zag = T/F). stands for

Connecting the Clauses Let the clause Cj contain xi: If then xi=True=“zig” reaches node Cj If then xi=False=“zag” reaches node Cj

Proof 3SAT P HamPath Given a 3CNF (x1,…,xL) with K clauses Make graph G with a zig/zag levels for every xi Connect the clauses Cj via the proper “hubs” If SAT, then the satisfying assignment defines a Hamiltonian path, and vice versa.

Example 4 variables… 4 clauses… Clauses connected via zig-zag “hubs”

Example assignment… …satifies all four clauses; hence it defines a Hamiltonian Path

Example assignment… …does not satify first clause; hence the path misses the C1 node

More on Hamiltonian Path Useful for proving NP-completeness of “optimal routing problems” Typical example: NP-completeness of “Traveling Salesman Problem” Issue of directed versus undirected graphs

Forcing Directions Given a directed graph with s,x1,…,xk,t Replace s with sout, the t with tin ,and every xi with the triplet “xi,in—xi,mid — xi,out” Redraw the original directed edges with edges going from out-nodes to in-nodes. If and only if the directed graph has a HamPath from s to t, then so has this graph.

Example: Directions becomes becomes y y xin sout xmid xout becomes ymid yout yin xin sout xmid xout becomes ymid yout yin “Undirected HamPath” is NP-complete