Download presentation
Presentation is loading. Please wait.
Published byNorah Rice Modified over 9 years ago
1
INHERENT LIMITATIONS OF COMPUTER PROGRAMS CSci 4011
2
Definition: A language B is NP-complete if: 1. B NP 2. Every A in NP is poly-time reducible to B (i.e. B is NP-hard) HARDEST PROBLEMS IN NP 2. A is NP-complete and A · P B If B is NP-Complete and P NP, then There is no fast algorithm for B. Theorem: A language B is NP-complete if:
3
3SAT ≤ P NAESAT, 2CSP… We will use 3SAT to prove other problems are NP-Complete or NP-Hard. Examples include 3SAT ≤ P CLIQUE 3SAT ≤ P 0/1-ILP 3SAT ≤ P HAMPATH 3SAT ≤ P 3COLOR 3SAT ≤ P GRADUATION 3SAT ≤ P VERTEX-COVER
4
REDUCTION STRATEGIES A reduction by restriction shows that the source problem is a special case of the target problem. For example, 3SAT ≤ P CNF-SAT because every satisfiable 3CNF is also a satisfiable CNF. Example. Prove 3SAT ≤ P 4SAT by restriction. A 3CNF can be converted to an equivalent 4CNF by repeating one literal in each clause.
5
VERTEX COVER b a e c d b a e c d VERTEX-COVER = { 〈 G,k 〉 | G has a vertex cover of size at most k }
6
INDEPENDENT SET b a e c d b a e c d INDSET = { 〈 G,k 〉 | G has an independent set of size at least k } Prove that VERTEX-COVER ≤ P INDSET.
7
SUBSET SUM SUBSET-SUM = { 〈 y 1,…, y n,t 〉 | ∃ S ⊆ {1,…,n}. Σ j ∈ S y j =t } Which of the following are in SUBSET-SUM? 〈 1,3,5,7, 10 〉 〈 19,11,27,4, 13 〉 〈 19,11,27,4, 61 〉 YES NO YES
8
KNAPSACK = { 〈 (w 1,v 1 )…,(w n,v n ),W, V 〉 | ∃ S ⊆ {1…n} so that Σ i ∈ S w i ≤ W and Σ i ∈ S v i ≥ V} 15 lbs $500 ½ lb $15 3 lbs $2000 1lb, $20 50 ×
9
Theorem. SUBSET-SUM ≤ P KNAPSACK Proof. A subset sum instance is a knapsack where the weights are equal to the values: Let ƒ(y 1,…,y n,t) = 〈 y 1,y 1 )…(y n,y n ),t,t 〉 Then ∃ S. Σ i ∈ S y i = t iff ∃ S. Σ i ∈ S y i ≥ t and Σ i ∈ S y i ≤ t, so 〈 y 1 …y n,t 〉 ∈ SUBSET-SUM iff ƒ(y 1 …y n,t) ∈ KNAPSACK
10
Theorem. VERTEX-COVER ≤ P SET-COVER SET-COVER = { 〈 S 1,…,S n,k 〉 | ∀ i,S i ⊆ U and ∃ i[1…k] so that S i[1] ∪ S i[2] ∪ … ∪ S i[k] = U } Which of the following are in SET-COVER? 〈 {1}, {1,2}, {2}, {3}, 2 〉 〈 {1,4}, {1,2}, {1,3}, {4}, 2 〉 Proof. A vertex cover instance is just a set cover instance where every node is a set of edges. YES NO 〈 {1}, {2}, {1,2}, 2 〉 YES
11
REDUCTION STRATEGIES A reduction from A to B by local replacement shows how to “translate” between “units” of A and “units” of B. Example. vertex cover “units” are vertices and edges; set cover “units” are elements and sets. Example. CIRCUIT-SAT units are gates, CNFSAT units are clauses, 3SAT units are 3-literal clauses.
12
GRADUATION A transcript is a set of course numbers a student has taken A major consists of: Pairs: exactly one of which must be taken Lists: at least one course of which must be taken GRADUATION = { 〈 T,M 〉 | a subset of T satisfies M} For example: T = {1901A, 1902B, 1902A, 2011, 4041A, 4061, 4211} M = [1901A,1901B], [1902A,1902B] (4011,4041A,4041B), (4211,4707), (4061)
13
GRADUATION ∈ NP: The subset is a proof that (T,M) ∈ GRADUATION. 3SAT ≤ P GRADUATION: (x 1 ⋁ x 2 ⋁ ¬x 3 ) ∧ (¬x 1 ⋁ x 2 ⋁ x 2 ) ∧ (¬x 2 ⋁ x 3 ⋁ x 1 ) T = {101, 102, 201, 202, 301, 302} M = [101, 102], [201, 202], [301, 302] (101,201,302), (101,201,201), (101,202,301)
14
GRADUATION ∈ NP: The subset is a proof that (T,M) ∈ GRADUATION. 3SAT ≤ P GRADUATION: Let = C 1 ∧ C 2 ∧ … ∧ C m have variables x 1 …x k For each x i : add classes i01 and i02 to T. add pair (i01,i02) to M. For each C j, we add a triple to M: if x i is a literal in C j, the triple includes i01. if ¬x i is a literal in C j, the triple includes i02.
15
3SAT P SUBSET-SUM We transform a 3-cnf formula into 〈 y 1 …y n, t 〉 : 3SAT 〈 y 1 …y n,t 〉 SUBSET-SUM The transformation can be done in time polynomial in the length of
16
(x 1 ⋁ x 2 ⋁ x 2 ) ∧ (¬x 1 ⋁ x 2 ⋁ x 2 ) ∧ (x 1 ⋁ ¬x 2 ⋁ x 2 ) Each variable and each clause result in two y i ’s. Each y i will have a digit for each clause and variable. C1C1 C2C2 C3C3 y1y1 1101 y2y2 1010 y3y3 10111 y4y4 10100 y5y5 100 y6y6 100 y7y7 10 y8y8 10 y9y9 1 y 10 1 t11333 x1x1 x2x2 x1x1 x2x2 C1C1 C2C2 C3C3
17
3SAT P SUBSET-SUM Let = C 1 ∧ C 2 ∧ … C m have k variables x 1 …x k. We output y 1 … y 2k + 2m, each a k+m-digit number. for each 1 ≤ j ≤ k: for each 1 ≤ I ≤ m: the i th digit of y 2j-1 is 1 if x j ∈ C i, else 0 the i th digit of y 2j is 1 if ¬x j ∈ C i, else 0. digit j+m of y 2j, y 2j-1 is 1. For each 1 ≤ j ≤ m: y 2k+2j = y 2k+2j-1 = 10 j-1 Output t = 11..1133..3
18
REDUCTION STRATEGIES A reduction by component design constructs gadgets that simulate variables and clauses. In particular a reduction must provide: a gadget to force the solution to the target instance to choose either x or ¬x a gadget to force the solution to the target instance to choose one literal from each clause a gadget to force the solution to the target instance to satisfy every clause
19
K- CLIQUES b a e c d f g
20
3SAT P CLIQUE We transform a 3-cnf formula into 〈 G,k 〉 such that 3SAT 〈 G,k 〉 CLIQUE The transformation can be done in time polynomial in the length of
21
(x 1 x 1 x 2 ) ( x 1 x 2 x 2 ) ( x 1 x 2 x 2 ) x1x1 x1x1 x1x1 x2x2 x2x2 x2x2 x2x2 x2x2 x1x1 k = #clauses
22
(x 1 x 1 x 1 ) ( x 1 x 1 x 2 ) (x 2 x 2 x 2 ) ( x 2 x 2 x 1 ) x1x1 x1x1 x2x2 x2x2 x1x1 x1x1 x2x2 x2x2 x1x1 x2x2 x2x2 x1x1
23
3SAT P CLIQUE We transform a 3-cnf formula into 〈 G,k 〉 such that 3SAT 〈 G,k 〉 CLIQUE If has k clauses, we create a graph with k clusters of 3 nodes each. Each cluster corresponds to a clause. Each node in a cluster is labeled with a literal from the clause. We do not connect any nodes in the same cluster We connect nodes in different clusters whenever they are not contradictory
24
3SAT P CLIQUE We transform a 3-cnf formula into 〈 G,k 〉 such that 3SAT 〈 G,k 〉 CLIQUE is satisfiable iff there is an assignment that makes at least one literal true in each clause. The nodes corresponding to these k true literals do not contradict each other, so they form a k- clique in G. A k-clique in G must have one node from each cluster. Setting the corresponding literals to true will satisfy
25
3-COLORING b a e c db ac d b a e c d a bd
26
3SAT P 3COLOR We transform a 3-cnf formula into a graph G so 3SAT G 3COLOR The transformation can be done in time polynomial in the length of
27
F T ? (x 1 ⋁ x 2 ⋁ x 2 ) x2x2 x2x2 x1x1 x1x1
28
F T ? x2x2 x1x1 x1x1 x2x2 c 11 c 12 c 13 c 14 c 15 c 16 (x 1 ⋁ x 2 ⋁ x 2 )
29
F T ? x2x2 x1x1 x1x1 x2x2 c 11 c 12 c 13 c 14 c 15 c 16 c 11 c 12 c 13 c 14 c 15 c 16 ∧ (x 2 ⋁ ¬x 1 ⋁ ¬x 1 )
30
F T ? x2x2 x1x1 x1x1 x2x2 c 11 c 12 c 13 c 14 c 15 c 16 c 11 c 12 c 13 c 14 c 15 c 16 (x 1 ⋁ x 2 ⋁ x 2 ) ∧ (x 2 ⋁ ¬x 1 ⋁ ¬x 1 )
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.