Download presentation
Presentation is loading. Please wait.
Published byBruno Boyd Modified over 9 years ago
1
1.1 Chapter 3: Proving NP-completeness Results Six Basic NP-Complete Problems Some Techniques for Proving NP-Completeness Some Suggested Exercises
2
1.2 Six Basic NP-Complete Problems 3-SATISFIABILITY (3SAT) 3-DIMENSIONAL MATCHING (3DM) VERTEX COVER (VC) CLIQUE HAMILTONIAN CIRCUIT (HC) PARTITION
3
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?
4
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
5
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 } }
6
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 } }
7
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)
8
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
9
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 0 1 0 0 1 0
10
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
11
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}
12
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 ) }
13
1.13 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’.
14
1.14 3-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.
15
1.15 3-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
16
1.16 3-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
17
1.17 3-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
18
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.
19
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.
20
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.
21
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
22
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.
23
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}
24
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.
25
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.
26
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…
27
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
28
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
29
1.29 Techniques for Proving NP-Completeness There are several “general” types of transformations: Restriction Local Replacement Component Design
30
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
31
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.
32
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:
33
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.
34
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.
35
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
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.