1.1 Chapter 3: Proving NP-completeness Results Six Basic NP-Complete Problems Some Techniques for Proving NP-Completeness Some Suggested Exercises.

Slides:



Advertisements
Similar presentations
Lecture 23. Subset Sum is NPC
Advertisements

1 NP-completeness Lecture 2: Jan P The class of problems that can be solved in polynomial time. e.g. gcd, shortest path, prime, etc. There are many.
NP-Completeness: Reductions
CSC5160 Topics in Algorithms Tutorial 2 Introduction to NP-Complete Problems Feb Jerry Le
Complexity 11-1 Complexity Andrei Bulatov NP-Completeness.
February 23, 2015CS21 Lecture 201 CS21 Decidability and Tractability Lecture 20 February 23, 2015.
Computability and Complexity 15-1 Computability and Complexity Andrei Bulatov NP-Completeness.
Reduction Techniques Restriction Local Replacement Component Design Examples.
NP-Complete Problems Reading Material: Chapter 10 Sections 1, 2, 3, and 4 only.
Computability and Complexity 16-1 Computability and Complexity Andrei Bulatov NP-Completeness.
1 CSE 417: Algorithms and Computational Complexity Winter 2001 Lecture 23 Instructor: Paul Beame.
NP-Completeness (2) NP-Completeness Graphs 4/17/2017 6:25 AM x x x x x
CSE 421 Algorithms Richard Anderson Lecture 27 NP Completeness.
Clique Cover Cook’s Theorem 3SAT and Independent Set
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.
Lecture 22 More NPC problems
INHERENT LIMITATIONS OF COMPUTER PROGRAMS CSci 4011.
NP-complete Problems SAT 3SAT Independent Set Hamiltonian Cycle
1 3-COLOURING: Input: Graph G Question: Does there exist a way to 3-colour the vertices of G so that adjacent vertices are different colours? 1.What could.
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.
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.
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.
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.
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.
NP-completeness NP-complete problems. Homework Vertex Cover Instance. A graph G and an integer k. Question. Is there a vertex cover of cardinality k?
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.
NP Hard Problems Instructor Neelima Gupta Presentation Edited by Sapna Grover.
COSC 3101A - Design and Analysis of Algorithms 14 NP-Completeness.
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 Variations of the maximum leaf spanning tree problem for bipartite graphs P.C. Li and M. Toulouse Information Processing Letters 97 (2006) /03/14.
34.NP Completeness. Computer Theory Lab. Chapter 34P.2.
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.
The Theory of NP-Completeness
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
P & NP.
Richard Anderson Lectures NP-Completeness
Richard Anderson Lecture 26 NP-Completeness
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
Summary of the previous lecture
Chapter 4: Using NP-Completeness to Analyze Subproblems
Chapter 3: Proving NP-completeness Results
CS154, Lecture 16: More NP-Complete Problems; PCPs
ICS 353: Design and Analysis of Algorithms
NP-Completeness (2) NP-Completeness Graphs 11/23/2018 2:12 PM x x x x
Chapter 3: Proving NP-completeness Results
Richard Anderson Lecture 25 NP-Completeness
Richard Anderson Lecture 28 NP-Completeness
Richard Anderson Lecture 26 NP-Completeness
CS154, Lecture 16: More NP-Complete Problems; PCPs
Richard Anderson Lecture 27 Survey of NP Complete Problems
NP-Completeness (2) NP-Completeness Graphs 7/9/2019 6:12 AM x x x x x
CHAPTER 7 Time complexity
Hamiltonian Circuit (HC) problem
Presentation transcript:

1.1 Chapter 3: Proving NP-completeness Results Six Basic NP-Complete Problems Some Techniques for Proving NP-Completeness Some Suggested Exercises

1.2 Six Basic NP-Complete Problems 3-SATISFIABILITY (3SAT) 3-DIMENSIONAL MATCHING (3DM) VERTEX COVER (VC) CLIQUE HAMILTONIAN CIRCUIT (HC) PARTITION

1.3 3-Satisfiability n A restricted version of satisfiability in which all instances have exactly 3 literals per clause. 3-SATISFIABILITY (3-SAT) INSTANCE: Collection C = {c 1, c 2,…,c m } of clauses on a finite set U of variables such that {c j } = 3, for 1 ≤ j ≤ m. QUESTION: Is there a truth assignment for U that satisfies all the clauses in C?

1.4 3-Satisfiability Theorem 3.1: 3-SAT is NP-Complete. 1) 3-SAT  NP 2) SAT  3-SAT I is satisfiable iff I’ is A I = U,C SAT instance I’ = U’,C’ 3-SAT instance

1.5 3-Satisfiability Each clause c j in I => a set C j ’ of clauses with new variables U j ’ Let c j = {z 1, z 2,…,z k } where z i ’s are literals derived from variables in U Case 1) k=1c j = {z 1 } U j ’ = {y j 1, y j 2 } C j ’ = { {z 1, y j 1, y j 2 }, {z 1, y j 1, y j 2 }, {z 1, y j 1, y j 2 }, {z 1, y j 1, y j 2 } } Case 2) k=2c j = {z 1, z 2 } U j ’ = {y j 1 } C j ’ = { {z 1, z 2, y j 1 }, {z 1, z 2, y j 1 } }

1.6 3-Satisfiability Case 3) k=3c j = {z 1, z 2, z 3 } U j ’ = {} C j ’ = { {z 1, z 2, z 3 } } Case 4) k>=4 c j = {z 1, z 2,…,z k } U j ’ = {y j i | 1 ≤ i ≤ k-3} C j ’ = { {z 1, z 2, y j 1 } } U {y j i, z i+2, y j i+1 } | 1 ≤ i ≤ k-4} U {y j k-3, z k-1, z k } } Example: c j = {z 1, z 2, z 3, z 4, z 5, z 6 } U j ’ = { {z 1, z 2, a}, {a, z 3, b}, {b, z 4, c}, {c, z 5, z 6 } }

1.7 3-Satisfiability Finally, let: U’ = U  { U j ’ | 1 ≤ j ≤ m } C’ = { C j ’ | 1 ≤ j ≤ m } Claim: 1) I = U,C is satisfiable iff I’ = U’,C’ is satisfiable. 2) I’ can be computed in polynomial time. Let m = |C|, n = |U| case 1) creates 4 clauses case 2) creates 2 clauses case 3) creates 1 clause case 4) creates k-1 clauses, where k is the number of literals in the clause This gives a total of at most k-1 new clauses in I’ for each clause in I Therefore, there is a total of m*(k-1) clauses in I’ Since k<=2n, it follows that there are at most 2nm clauses in I’, which is O(mn)

1.8 Some More New Problems Not All Equal 3-SAT INSTANCE: Collection C = {c 1, c 2,…,c m } of clauses on a finite set U of variables such that {c j } = 3, for 1 ≤ j ≤ m. QUESTION: Is there a truth assignment for U such that each clause in C has at least one true literal and at least one false literal? Examples: { (a, b, c), (a, b, c), (a, b, c) } a = T, b = T, c = F { (a, b, c), (a, b, c), (a, b, c),Not even satistfiable (a, b, c), (a, b, c), (a, b, c) (a, b, c), (a, b, c) } { (a, b, c), (a, b, c), (a, b, c),Satistfiable, but not with (a, b, c), (a, b, c), (a, b, c)at least one literal true and false (a, b, c) }per clause

1.9 More Problems, cont. Hypergraph 2-Colorability (H2C) INSTANCE: Hypergraph H = (V, E), where 2 ≤ |e i | ≤ 3, for all e i  E. QUESTION: Is H 2-colorable? In other words, is there a function f : V  {0, 1} such that for all e i  E there exist vertices u,v  e i such that f(u)  f(v)? Examples: NoYesNo

1.10 H2C is NP-Complete Fact: Not All Equal 3-SAT is NP-complete Theorem: H2C is NP-complete 1) H2C  NP 2) Not All Equal 3-SAT  H2C A I = U,C 3-SAT instance H = (V, E) H2C instance

1.11 H2C is NP-Complete, cont. Suppose I = U,C where: U = {u 0, u 1,…,u n-1 } C = {c 0, c 1,…,c m-1 } Construct H = (V, E) where: V = { v i 1 | u i  U}  {v i 2 | u i  U} v i 1 corresponds to u i v i 2 corresponds to the complement of u i E = E 1  E 2 where E 1 = { (v 1, v 2, v 3 ) | c i  C, c i = (z 1, z 2, z 3 ) and v 1, v 2, v 3 are the vertices corresponding to the literals z 1, z 2 and z 3, respectively} E 2 = { (v i 1, v i 2 ) | 0 ≤ i ≤ n-1}

1.12 H2C is NP-Complete, cont. Example: U = {u 0, u 1, u 2, u 3 } C = { (u 0, u 1, u 2 ), (u 0,u 2, u 3 ), (u 1, u 2 u 3 ) }

Dimensional Matching 3-DIMENSIONAL MATCHING (3-DM) INSTANCE: A set M  W  X  Y, where W, X and Y are disjoint sets having the same number q of elements. QUESTION: Does M contain a matching, that is, a subset M’  M sucht at |M| = q and no two elements of M’ agree in any coordinate? Example #1: q = 3 (not part of input technically) W = {a 1, a 2, a 3 } X = {b 1, b 2, b 3 } Y = {c 1, c 2, c 3 } M = { (a 1, b 2, c 1 ), (a 2, b 1, c 3 ), (a 3, b 3, c 2 ), (a 1, b 1, c 3 ), (a 2, b 2, c 1 ) } Yes! The first 3 form a matching. Note that every element in each set will appear in exactly one triple in M’.

Dimensional Matching Example #2: q = 3 (not part of input technically) W = {a 1, a 2, a 3 } X = {b 1, b 2, b 3 } Y = {c 1, c 2, c 3 } M = { (a 1, b 1, c 1 ), (a 1, b 1, c 2 ), (a 2, b 1, c 3 ), (a 3, b 1, c 1 ) } No! In fact b 1 and b 3 do not appear in any triple.

Dimensional Matching Theorem: 3DM is NP-complete. Proof: 1) 3DM  NP 2) 3-SAT  3DM A I = U,C 3-SAT instance I’ = W,X,Y,M 3DM instance

Dimensional Matching Suppose I = U,C where: U = {u 1, u 2,…,u n } C = {c 1, c 2,…,c m } Construct M as follows. M will consists of three types of “components:”  Truth Setting and fan-out  Satisfaction testing  Garbage collection

Dimensional Matching Suppose I = U,C where: U = {u 1, u 2,…,u n } C = {c 1, c 2,…,c m } Construct M as follows. M will consists of three types of “components:”  Truth Setting and fan-out  Satisfaction testing  Garbage collection

1.18 Truth Setting and Fan Out Components For each variable u i  U, create the following elements: T i t = { (u i [j], a i [j], b i [j]) | 1 ≤ j ≤ m } U T i f = { (u i [j], a i [j+1], b i [j]) | 1 ≤ j ≤ m-1 } U { (u i [m], a i [1], b i [m]) } a big “blob” for each Boolean variable (see page 51) Observation #1: Creates 2mn elements in W, mn in X and mn in Y.  u i [j] represents the fact that variable u i could occur in clause c j.  Similarly for u i [j] Observation #2: a i [j] and b i [j] both occur in exactly two triples and nowhere else. Observation #3: This tells us that in any matching M’  M we must have all white or all shaded triples, in other words, all triples from T i t or all triples from T i f  This corresponds to setting the variable false or true, respectively.

1.19 Satisfaction Testing Components For each clause c j  C, create three triples: C j = { (u i [j], s 1 [j], s 2 [j]) | u i  c j } U { (u i [j], s 1 [j], s 2 [j]) | u i  c j } Observation #4: This adds m elements to X, and m elements to Y. Observation #5: For each j, 1 ≤ j ≤ m, s 1 [j] and s 2 [j] both appear in exactly three triples and nowhere else. Observation #6: Any matching must choose exactly one triple from C j  This corresponds to making that literal true.

1.20 Garbage Collection Components For each clause c j  C, create three triples: G = { (u i [j], g 1 [k], g 2 [k]), (u i [j], g 1 [k], g 2 [k]) | 1 ≤ k ≤ m(n-1), 1 ≤ i ≤ n, 1 ≤ j ≤ m} Observation #7: This adds m(n-1) elements to X, and to Y. Observation #8: For each k, 1 ≤ k ≤ m(n-1), g 1 [k] and g 2 [k] both appear in exactly 2mn triples and nowhere else. Observation #9: Exactly m(n-1) triples from G must occur in any matching for M (why?). Observation #10: |W| = |X| = |Y| = 2mn = q.

1.21 Another Proof for Independent Set INDEPENDENT SET (IS) INSTANCE: Graph G = (V, E) and positive integer J <= |V|. QUESTION: Does G contain an independent set of size J or more? Theorem: IS is NP-complete 1) IS  NP 2) 3DM  IS A I = M (W,X,Y) 3DM instance G = (V, E), J IS instance

1.22 H2C is NP-Complete, cont. Proof: Let M be an instance of 3DM, and construct an instance of IS as follows. V = {v i | t i  M} E = {v i, v j | i  j and t i and t j agree on some coordinate} j = q Claims: 1) The transformation can be performed in polynomial-time 2) M contains a matching if and only if G=(V,E) contains a vertex cover of size j. (only if) Let M’ = {t 0, t 1,…,t q-1 } be a matching, where M’  M. It can be easily verified that V’ = {v 0, v 1,…,v q-1 } is an independent set of size j. (if) Let V’ = {v 0, v 1,…,v q-1 } is an independent set of size j for G. Then it can be easily verified that M’ = {t 0, t 1,…,t q-1 } is a matching.

1.23 Vertex Cover, Independent Set and Clique VERTEX COVER (VC) INSTANCE: A Graph G = (V, E) and a positive integer K <= |V|. QUESTION: Is there a vertex cover of size K or less for G, that is, a subset V’  V such that |V’| <= K and, for each edge {u,v}  E, at least one of u and v belongs to V’? INDEPENDENT SET (IS) INSTANCE: Graph G = (V, E) and positive integer J <= |V|. QUESTION: Does G contain an independent set of size J or more? CLIQUE INSTANCE: A Graph G = (V, E) and a positive integer J <= |V|. QUESTION: Does G contain a clique of size J or more? Lemma 3.1: For any graph G=(V,E) and subset V’  V, the following statements are equivalent: (a) V’ is a vertex cover for G (b) V-V’ is an independent set for G (c) V-V’ is a clique in the complement G c of G, where G c =(V,E c ) with E c ={{u,v} | u,v  V and {u,v}  E}

1.24 Vertex Cover Theorem: VERTEX COVER is NP-complete Proof: 1) VC  NP 2) 3SAT  VC Suppose I = U,C is an instance of 3SAT where: U = {u 1, u 2,…,u n } C = {c 1, c 2,…,c m } We will construct a graph G=(V,E) and a positive integer K<=|V| such that G has a vertex cover of size K or less if and only if C is satistfiable. For each variable u i  U, there is a truth-setting component T i =(V i,E i ) where: V i = {u i, u i } and E i = {{u i,u i }} *Note that any vertex cover will have to contain at least on of u i and its complement.

1.25 Vertex Cover For each clause c j  C, create a satisfaction testing component S j = (V j ’, E j ’): V j ’= { a 1 [j], a 2 [j], a 3 [j] } E j ’ = { {a 1 [j], a 2 [j]}, {a 1 [j], a 3 [j]}, {a 2 [j], a 3 [j]} } *Note that any vertex cover will have to contain at least two vertices from V j ’ in order to cover the edges in E j ’. For each clause c j  C, let the three literals in c j be x j, y j, z j. Then add communication edges: E j ’’ = { {a 1 [j], x j }, {a 2 [j], y j }, {a 3 [j], z j } } Finally, let K = n + 2m. See page 55 for an example.

1.26 Vertex Cover Observations: The transformation can be performed in polynomial-time. G = (V, E) will have a vertex cover of size K or less IFF I = U,C is satisfiable. (if) Suppose I = U,C is satisfiable… (only if) Suppose G = (V, E) has a vertex cover of size K or less…

1.27 Hamiltonian Circuit (HS) HAMILTONIAN CIRCUIT (HC) INSTANCE: A Graph G = (V, E). QUESTION: Does G have a Hamiltonian circuit, that is an ordering of the vertices of G, where n = |V|, such that { v n, v 1 }  E and { v i, v i+1 }  E for all i, 1 ≤ i  n. VERTEX COVER (VC) INSTANCE: A Graph G = (V, E) and a positive integer K <= |V|. QUESTION: Is there a vertex cover of size K or less for G, that is, a subset V’  V such that |V’| <= K and, for each edge {u,v}  E, at least one of u and v belongs to V’? Theorem: HC is NP-complete Proof: 1) HC  NP 2) VC  HC

1.28 Partition PARTITION INSTANCE: A finite set A and a “size” s(a)  Z + for each a  A. QUESTION: Is there a subset A’  A such that 3-DIMENSIONAL MATCHING (3-DM) INSTANCE: A set M  W  X  Y, where W, X and Y are disjoint sets having the same number q of elements. QUESTION: Does M contain a matching, that is, a subset M’  M such at |M| = q and no two elements of M’ agree in any coordinate? Theorem: Partition is NP-complete Proof: 1) PARTITION  NP 2) 3DM  PARTITION

1.29 Techniques for Proving NP-Completeness There are several “general” types of transformations: Restriction Local Replacement Component Design

1.30 Restriction Proving a problem   NP NP-complete by restriction consists of showing that  contains another known NP-complete problem  ’ as a special case. What is a “special case” of a problem?  Let I be all instances of a problem , and let I’ be all instances of a problem  ’  If I’  I then  ’ is a special case of  ’  Furthermore, if  and  ’ are both in NP, and if  is NP-complete, then so is  ’ The heart of a proof by restriction is the specification of additional restrictions to be placed on the instances of  so that the resulting problem will be identical to  ’ Note that a proof by restriction is still a transformation, i.e., it is not a different kind of NP- completeness proof

1.31 Hamiltonian Circuit (HS) DIRECTED HAMILTONIAN CIRCUIT (DHC) INSTANCE: A directed graph G = (V, E). QUESTION: Does G have a Hamiltonian circuit, that is an ordering of the vertices of G, where n = |V|, such that { v n, v 1 }  E and { v i, v i+1 }  E for all i, 1 ≤ i  n. HAMILTONIAN CIRCUIT (HC) INSTANCE: A Graph G = (V, E). QUESTION: Does G have a Hamiltonian circuit, that is an ordering of the vertices of G, where n = |V|, such that { v n, v 1 }  E and { v i, v i+1 }  E for all i, 1 ≤ i  n. Theorem: DHC is NP-complete Proof: 1) DHC  NP 2) HC  DHC, by restriction. Consider those instances of DHC where there is an edge from u to v if and only if there is an edge from v to u.

1.32 Invalid Restriction Subset Sum INSTANCE: Integers a 1, a 2,…,a n and integer B. QUESTION: Is there a sequence of 0’s and 1’s, x 1, x 2,…,x n such that: Fact: Subset Sum is NP-complete Real Subset Sum INSTANCE: Integers a 1, a 2,…,a n and integer B. QUESTION: Is there a sequence of real numbers x 1, x 2,…,x n such that:

1.33 Invalid Restriction, Cont. Claim (from a Ph.D disseration):  Subset Sum is just a special case of Real Subset Sum  Therefore, Real Subset Sum is NP-complete The proof is in error since it restricts the question, and not the instances. The problem is actually trivially solvable in polynomial time simply taking x 1 = B/a 1 and x i = 0, for all i, where 2 ≤ i ≤ n.

1.34 Local Replacement Transformations are sufficiently non-trivial to warrant spelling out details, in contrast to restriction. An instance of a known NP-complete problem is broken up into some number of structurally similar “basic units” During the transformation, each “basic unit” is replaced by a different structure, which is part of the target problems instance. Each replacement constitutes only local modification.

1.35 Partition Exact Cover by 3-Sets (X3C) INSTANCE: Set X with |X| = 3q and a collection C of 3-element subsets of X. QUESTION: Does C contain a an exact cover for X, i.e., a subcollection C’  C such that every element of X occurs in exactly one member of C’? Fact: X3C is NP-complete (by restriction from 3DM) Partition into Triangles INSTANCE: A Graph G = (V, E), with |X| = 3q. QUESTION: Is there a partition of V into q disjoint sets V 1, V 2,…,V q of three vertices each such that, for each V i = {v i[1], v i[2], v i[3] } the three edges {v i[1], v i[2] }, {v i[1], v i[3] } and {v i[2], v i[3] } all belong to E’? Theorem: Partition into Triangles is NP-complete Proof: 1) Partition into Triangles  NP 2) X3C  Partition into Triangles