NP-completeness (review) have no feasible solutions NP ❀ have P feasible solutions solvable NP- problems complete L ∈ NPC ⇔ L ∈ NP and L ∈ NP -hard Today: Proving NP -completeness • L ∈ N P : show that there is a “short” † certificate of membership in L (“id card”). • L ∈ N P -hard: show that there is an “efficient” † reduction from a known NP -hard problem L np to L . † polynomial (length, time ...) Autumn 2012 1 of 23
Skills to learn • Transforming problems into each other. Insight to gain • Seeing unity in the midst of diversity: A variety of graph-theoretical, numerical, set & other problems are just variants of one another. But before we can use reductions we need the first N P -hard problem . L 0 L 1 L 2 NP L n S ATISFIABILITY (SAT) Example I = C ∪ U � � ( x 1 ∨ ¬ x 2 ) , ( ¬ x 1 ∨ ¬ x 2 ) , ( x 1 ∨ x 2 ) C = U = { x 1 , x 2 } T = x 1 �→ TRUE , x 2 �→ FALSE is a satisfying truth assignment. Hence the given instance I is satisfiable , i.e. I ∈ SAT. Autumn 2012 2 of 23
Further (basic) reductions BOUNDED HALTING SATISFIABILITY (SAT) 3SAT 3-DIMENSIONAL VERTEX COVER (VC) MATCHING (3DM) HAMILTONICITY CLIQUE PARTITION Polynomial-time reductions (review) L 1 ∝ L 2 means that • R : � ∗ → � ∗ such that x ∈ L 1 ⇒ f R ( x ) ∈ L 2 and x �∈ L 1 ⇒ f R ( x ) �∈ L 2 L 1 L 2 Σ * Σ * • R ∈ P f , i.e. R ( x ) is polynomial computable Autumn 2012 3 of 23
S ATISFIABILITY ∝ 3- SATISFIABILITY SAT 3SAT Clauses with any Clauses with �− → number of literals exactly 3 literals ′ is the • C j is the j ’th SAT-clause, and C j corresponding 3SAT-clauses. ′ . • y j are new, fresh variables, only used in C j ′ C j C j ( x 1 ∨ x 2 ∨ x 3 ) �− → ( x 1 ∨ x 2 ∨ x 3 ) ( x 1 ∨ x 2 ) �− → ( x 1 ∨ x 2 ∨ y j ) , ( x 1 ∨ x 2 ∨ ¬ y j ) ( x 1 ∨ y 1 j ∨ y 2 j ) , ( x 1 ∨ ¬ y 1 j ∨ y 2 �− → ( x 1 ) j ) , ( x 1 ∨ y 1 j ∨ ¬ y 2 j ) , ( x 1 ∨ ¬ y 1 j ∨ ¬ y 2 j ) ( x 1 ∨ x 2 ∨ y 1 j ) , ( ¬ y 1 j ∨ x 3 ∨ y 2 ( x 1 ∨ · · · ∨ x 8 ) �− → j ) , ( ¬ y 2 j ∨ x 4 ∨ y 3 j ) , ( ¬ y 3 j ∨ x 5 ∨ y 4 j ) , ( ¬ y 4 j ∨ x 6 ∨ y 5 j ) , ( ¬ y 5 j ∨ x 7 ∨ x 8 ) Question: Why is this a proper reduction? Autumn 2012 4 of 23
3- DIMENSIONAL MATCHING (3DM) Instance: A set M of triples ( a, b, c ) such that a ∈ A , b ∈ B , c ∈ C . All 3 sets have the same size q ( | A | = | B | = | C | = q ). Question: Is there a matching in M , i.e. a subset M ′ ⊆ M such that every element of A , B and C is part of exactly 1 triple in M ′ ? Example y 1 x 1 z 1 y 2 x 2 z 2 y 3 x 3 z 3 � M = ( x 1 , y 1 , z 1 ) , ( x 1 , y 2 , z 2 ) , � ( x 2 , y 2 , z 2 ) , ( x 3 , y 3 , z 3 ) , ( x 3 , y 2 , z 1 ) We will use sets with 3 elements to visualize triples: y 1 z 1 x 1 Autumn 2012 5 of 23
Reductions are like translations from one language to another. The same properties must be expressed. 3SAT ∝ 3DM 3SAT 3DM → variables x j 3 , a j �− 3 , b 2 j , c 1 variables x 1 , · · · , x n k → variables x j 1 , ¬ x j �− literals x 1 , ¬ x 1 1 ( x j �− → triples 1 , b 1 j , b 2 clauses j ) ( ¬ x j 3 , b 1 j , b 2 C j = ( x 1 ∨ ¬ x 2 ∨ ¬ x 3 ) j ) “There exists a sat. ”There is a �− → matching” truth assignment” “There is a truth assignment T ” • ∃ T : { x 1 , · · · , x n } → { TRUE , FALSE } • T ( x i ) = TRUE ⇔ T ( ¬ x i ) = FALSE The second property is easily translated to the 3DM-world: ¬ x i x i a i �− → T ( X i ) = TRUE x i is not “married” Autumn 2012 6 of 23
A literal x i can be used in many clauses. In 3DM we must have as many copies of x i as there are clauses: x 1 i ¬ x 4 ¬ x 1 i i x 4 x 2 i i ¬ x 3 ¬ x 2 i i x 3 i • Either all the black triples must be chosen (“married”) or all the red ones! • If T ( x i ) = TRUE then we choose all the red triples, and the black copies of x i are free to be used later in the reduction. And vice versa. • We make one such truth setting component for each variable x i in 3SAT. Autumn 2012 7 of 23
“ T is satisfying” We translate each clause (example: C j = ( x 1 ∨ ¬ x 2 ∨ ¬ x 3) ) into 3 triples: x j ¬ x j ¬ x j 1 2 3 b 1 b 2 j j • b 1 j and b 2 j can be married if and only if at least one of the literals in C j is not married in the truth setting component. • If we have a satisifiable 3SAT-instance , then all b 1 j and b 2 j -variables ( 1 ≤ j ≤ m ) can be married. • If we have a negative 3SAT-instance , then some b 1 j and b 2 j -variables will not be married. Autumn 2012 8 of 23
Cleaning up (“Garbage collection”) There are many x j i who are neither married in the truth settting components nor in the “clause-satisfying” part. We introduce a number of fresh c -variables who can marry “everybody”: x m ¬ x 1 n 1 · · · x 1 ¬ x m 1 n c 1 c 2 k k • There are m × n unmarried x -variables after the truth setting part. • If all m clauses are satisfiable then there will remain ( m × n ) − m = m ( n − 1) unmarried x -variables. • So we let 1 ≤ k ≤ m ( n − 1) . Autumn 2012 9 of 23
P ARTITION Instance: A finite set A and sizes s ( a ) ∈ Z + for each a ∈ A . Question: Can we partition the set into two sets that have equal size, i.e. is there a subset A ′ ⊆ A such that � � s ( a ) = s ( a ) a ∈ A ′ a ∈ A \ A ′ 3DM ∝ P ARTITION We first reduce 3DM to S UBSET S UM where we are given A , as in P ARTITION , but also a number B , and where we are asked if it is possible to choose a subset of A with sizes that add up to B . 3DM S UBSET S UM sets and �− → triples (subsets) numbers “There is “There is a matching M ′ ” �− → a subset with total size B ” Autumn 2012 10 of 23
Difficulty: We need to translate from subsets with 3 elements (triples) to numbers. Solution: Use the characteristic function of a set! Example Given set U = { x 1 , x 2 , . . . , x n } and subset S = { x 1 , x 3 , x 4 } . The characteristic function of S is a binary number with n digits and bit 1, 3 and 4 set to 1: 101100 · · · 0 . � �� � n → There is a subset M ′ There is a matching M ′ ← � sizes = B M ′ n � �� � It is natural to set B = 111 · · · 11 , since each element in the universe is used in exactly one of the triples in the matching. Technicality: Carry bits! 01 b + 10 b = 11 b , but also 01 b + 01 b + 01 b = 11 b . Autumn 2012 11 of 23
3DM-instance: M ⊆ W × X × Y W = { w 1 , w 2 , · · · , w q } Y = { y 1 , y 2 , · · · , y q } Z = { z 1 , z 2 , · · · , z q } M = { m 1 , m 2 , · · · , m k } • For each triple m i ∈ M we construct a binary number: (log 2 k ) + 1 ... ... ... 1 0 0 0 0 1 0 1 0 0 0 0 w 1 w 2 w q x 1 x 2 x q y 1 y 2 y q • This P ARTITION /S UBSET S UM number corresponds to the triple ( w 1 , x 2 , y 1 ) . • By adding log 2 k zeros between every “characteristic digit”, we eliminate potential summation problems due to overflow / carry bits. • We make B as follows: ... ... ... 1 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 w 1 w 2 w q x 1 x 2 x q y 1 y 2 y q Autumn 2012 12 of 23
S UBSET S UM ∝ P ARTITION • We introduce two new elements b 1 and b 2 . • We choose s ( b 1 ) and s ( b 2 ) so big that every partition into to equal halves must have s ( b 1 ) in one half and s ( b 2 ) in the other. S ( b 2 ) S ( b 1 ) � S ( a ) − B B • We let s ( b 1 ) + B = s ( b 2 ) + ( � s ( a ) − B ) . • We can pick a subset of A which adds up to B if and only if we can split A ∪ { b 1 , b 2 } into two equal halves. Autumn 2012 13 of 23
V ERTEX C OVER (VC) Instance: A graph G with a set of vertices V and a set of edges E , and an integer K ≤ | V | . Question: Is there a vertex cover of G of size ≤ K ? “Can we place guards on at most K of the intersections (vertices) such that all the streets (edges) are surveyed?” G Autumn 2012 14 of 23
3SAT ∝ VC 3SAT V ERTEX C OVER �− → literals vertices �− → clauses subgraphs “There exists a sat. ”There is a VC �− → of size K ” truth assignment” literals �− → vertices ¬ u i u i • A guard must be placed in either u i or ¬ u i for the street between u i and ¬ u i to be surveyed. • If we only allow | V | guards to be used for all | V | streets of this kind, then we cannot place guards at both ends. • Placing a guard on u i corresponds to the 3SAT-literal u i being TRUE . • Placing a guard on ¬ u i corresponds to the 3SAT-literal ¬ u i being TRUE (and the u i -variable being assigned to FALSE ). Autumn 2012 15 of 23
clause �− → subgraph For clause C j = ( x 1 ∨ ¬ x 2 ∨ ¬ x 3 ) we make the following subgraph: ¬ x 3 ¬ x 3 x 1 ¬ x 2 ¬ x 2 x 1 • We need guards on two of three nodes in the triangle to cover all three (blue) edges. • If we are allowed to place only two guards per triangle, then we cannot cover all three outgoing edges. • All 6 edges can be covered if and only if at least one edge (red) is covered from the outside vertex. • By connecting the subgraph to the “truth-setting” components, this translates to one of the literals being TRUE (guarded)! Autumn 2012 16 of 23
Recommend
More recommend