NPC More NPComplete Problems Complexity D Moshk 1
NPC More NP-Complete Problems Complexity ©D. Moshk 1
Introduction • Objectives: – To introduce more NP-Complete problems. • Overview: – 3 SAT – CLIQUE & INDEPENDENT-SET – SUBSET-SUM Complexity ©D. Moshk 2
Method • How to show a problem is in NPC? – First show it’s in NP – Then show it is NP-hard by reducing some NP-Hard problem to it. Complexity ©D. Moshk 3
New Base Problems • The only NP-Complete problem we currently know of is SAT. • Unfortunately, it’s not very comfortable to work with. • Thus we’ll start by introducing several useful variants of SAT. • We’ll use them as our base problems. Complexity ©D. Moshk 4
3 SAT Instance: a 3 CNF formula Problem: To decide if the formula is satisfiable. A satifiable 3 CNF formula (x y z) An unsatifiable 3 CNF formula (x x x) ( x x x) Complexity ©D. Moshk 5
SIP 259 -260 3 SAT is NP-Complete • 3 SAT is a special case of SAT, and is therefore clearly in NP. • In order to show it’s also NP-Complete, we’ll alter the proof of SAT’s NPCompleteness, • so it produces 3 CNF formulas. Why would that be enough? Complexity ©D. Moshk 6
Revisiting SAT’s NPCompleteness Proof Given a TM and an input we’ve produced a conjunction of: Complexity ©D. Moshk 7
Transforming the Formula into a CNF Formula • All the sub-formulas, but move, form a CNF formula. • Using the distributive law we can transform move into a conjunction of clauses. • The formula stays succinct (check!). Complexity ©D. Moshk 8
CNF 3 CNF (x y) (x 1 x 2. . . xt). . . clauses with 1 or 2 literals replication (x y x) Complexity ©D. Moshk clauses with more than 3 literals split (x 1 x 2 c 11) ( c 11 x 3 c 12). . . ( c 1 t-3 xt-1 xt) 9
3 SAT is NP-Complete • Since we’ve shown a reduction from any NP problem to 3 SAT, • and 3 SAT is in NP, • 3 SAT is NP-Complete. Complexity ©D. Moshk 10
CLIQUE Instance: A graph G=(V, E) and a threshold k. Problem: To decide if there is a set of nodes C={v 1, . . . , vk} V, s. t for any u, v C: (u, v) E. Complexity ©D. Moshk 11
CLIQUE is in NP On input G=(V, E), k: • Guess C={v 1, . . . , vk} V • For any u, v C: verify (u, v) E • Reject if one of the tests fail, accept otherwise. The length of the certificate: O(n) (n=|V|) Time complexity: O(n 2) Complexity ©D. Moshk 12
SIP 251 -253 CLIQUE is NP-Complete Proof: We’ll show 3 SAT p. CLIQUE. ≤p Complexity ©D. Moshk 13
The Reduction for any clause ( ) |V| = formula’s length K= no. of clauses connected iff Complexity ©D. Moshk 14
Proof of Correctness NOT connected! 1. . . a clique of size k must contain one node from every layer. k Complexity ©D. Moshk 15
Correctness given a k-clique, assign x TRUE or FALSE according to whether x or x is in the clique; this satisfies the formula . . . given a satisfying assignment, a set comprising of one satisfied literal of each clause forms a k-clique. Complexity ©D. Moshk 16
INDEPENDENT-SET Instance: A graph G=(V, E) and a goal k. Problem: To decide if there is a set of nodes I={v 1, . . . , vk} V, s. t for any u, v I: (u, v) E. Complexity ©D. Moshk 17
INDEPENDENT-SET NP On input G=(V, E), k: • Guess I={v 1, . . . , vk} V • For any u, v C: verify (u, v) E • Reject if one of the tests fail, accept otherwise. The length of the certificate: O(n) (n=|V|) Time complexity: O(n 2) Complexity ©D. Moshk 18
INDEPENDENT-SET is NPC Proof: By the previous claim and a trivial reduction from CLIQUE. there’s a clique of size k in a graph Complexity ©D. Moshk there’s an IS of size k in its complement 19
SUBSET-SUM Instance: A multi-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. Complexity ©D. Moshk 20
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) Complexity ©D. Moshk 21
SIP 269 -271 SUBSET-SUM is NPComplete Proof: We’ll show 3 SAT p. SUBSETSUM. ≤p Complexity ©D. Moshk 22
Satisfying Clauses digit per clause c 1 c 2 …… ck number per variable xi assigned true: yi number per variable xi assigned false: zi 1 if xi is in cj 0 otherwise Complexity ©D. Moshk 23
Achieving Target digit per clause c 1 c 2 …… ck 0<d<4 target: Complexity ©D. Moshk 24
Achieving Target digit per clause c 1 c 2 …… ck 1 target: Complexity ©D. Moshk 1 3 25
Achieving Target make sure a good subset contains exactly one of yi and zi Complexity ©D. Moshk c 1 c 2 … c k y 1 1 0 0 z 1 0 0 0 …. . . yl 1 0 1 zl 1 1 0 0 1 0 0 1 3 3 3 . . . 26
Imposing Consistency c 1 c 2 … c k y 1 1 0 0 z 1 10 0 0 …. . . Complexity ©D. Moshk 1 1 yl 1 0 0 1 zl 1 0 0 1 10 1 0 0 0 0 1 3 3 3 1 . . . 27
Succinctness l k 2 l 2 k Complexity ©D. Moshk 28
Completeness • If there is a satisfying assignment, build the subset as follows: 1 in – If the i-th variable is assigned the leftmost l TRUE, take yi, else take zi. digits – Add as many auxiliary numbers as needed. satisfiability 3 in the rightmost k digits Complexity ©D. Moshk 29
Soundness • If there is a subset which sums up to the target, construct an assignment as follows: – If yi is in the subset, assign TRUE to the i-th variable. – If zi is in the subset, assign FALSE to the i-th variable. Complexity ©D. Moshk 30
Observation: No Carry • All digits are either 0 or 1. • Each column contains at most five 1’s. • Hence, a “carry” into the next column never occurs. Complexity ©D. Moshk 1 0 c 1 c 2 … c k 0 1 0 0 y 1 0 0 z 1 … 0 0 1 1 0 0 z l 1 0 0 1 3 3 3 1 1 1 yl 0 31
Consistency • Thus, to get 1 in the leftmost l digits, our subset necessarily contains either yi or zi (Not both!). Complexity ©D. Moshk 1 0 c 1 c 2 … c k 0 1 0 0 y 1 0 0 z 1 … 0 0 1 1 0 0 z l 1 0 0 1 3 3 3 1 1 1 yl 0 32
Satisfiablity • In each column, at most 2 can come from the auxiliary numbers, so all clauses are satisfied. Complexity ©D. Moshk 1 0 c 1 c 2 … c k 0 1 0 0 y 1 0 0 z 1 … 0 0 1 1 0 0 z l 1 0 0 1 3 3 3 1 1 1 yl 0 33
Summing Up 1. SUBSET-SUM is in NP 2. 3 SAT p. SUBSET-SUM 3. Thus SUBSET-SUM is NP-Complete Complexity ©D. Moshk 34
Summary • In this lecture we’ve added many new problems to our NPC “bank”. • Interestingly, NPC contains over 1000 different problems ! Complexity ©D. Moshk 35
Appendix Complexity ©D. Moshk 36
Dictionary negation: not ( ) conjunction: and ( ) literal: (negated or not) Boolean variable disjunction: or ( ) Examples: x, x clause: several literals connected with Example: (x y z) CNF (Conjunctive Normal Form): several clauses connected with Example: (x y) (x y z) 3 CNF: a CNF formula with three literals in each clause. Example: (x y z) Complexity ©D. Moshk 37
- Slides: 37