Download presentation

Presentation is loading. Please wait.

Published bySierra Viner Modified over 2 years ago

1
MCS 312: NP Completeness and Approximation algorithms Instructor Neelima Gupta ngupta@cs.du.ac.in

2
Table of Contents 3D Matching Exact Cover

3
3-D Matching Problem Problem Definition Given Disjoint sets X, Y, Z, each of size n A set T XxYxZ of ordered triples To Find If there exists a set of n triples in T so that each element of X Y Z is contained in exactly one of these triples.

4
3-D Matching Problem Claim 3-D Matching is NP Complete Proof Part I 3-D Matching belongs to NP Given An instance of 3-D Matching A certificate containing a collection of triples T’ T It can clearly be verified in polynomial time that each element in X Y Z belongs to exactly one of the triples in T’.

5
3-D Matching Problem Part II 3-D Matching is NP-hard We prove the above by showing that 3-SAT ≤ p 3-D Matching We adopt the following approach We first design gadgets that encode the independent choices involved in the truth assignment to each variable We then add gadgets to encode constraints imposed by clauses. Given: A 3-SAT instance with n variables and k clauses

6
3-D Matching Problem Basic gadget associated with variable x i Core of the gadget as A i = {a i1,a i2,….,a i,2k } Tips of the gadget B i = {b i1,b i2,….,b i,2k } A triple t ij = (a ij,a i,j+1,b ij ) for all j = 1, 2k, where addition is modulo 2k. A triple t ij is even if j is even, and odd otherwise. Analogous for tip b ij.

7
Red nodes are the core elements Blue nodes are tips

8
Enhancing the variable gadget to model the clauses and the constraints on possible assignments imposed by them For clause C j, clause gadget is defined as follows: Two core elements P j = {p j, p j ’}. For each of the three terms in C j do the following If term = x i, define a triple (p j, p j ’,b i,2j ). If term = x i ’, define a triple (p j, p j ’,b i,2j-1 ).

9
3-D Matching Problem We understand this enhancement through an example. Consider the following clause C 1 = x 1 ’ v x 2 v x 3 ’ Interpretation: The matching should select the even tips of the first gadget, or odd tips of the second gadget, or even tips the third gadget. We first create gadgets for the three variables

10
3-D Matching Problem x1x1 x2x2 x3x3

11
We now model the assignment constraints with a clause gadget defined as follows: A set of 2 core elements P 1 = {p 1, p 1 ’} contained in the following 3 triples: (p 1, p 1 ’,b 1,1 ) (p 1, p 1 ’,b 2,2 ) (p 1, p 1 ’,b 3,1 )

12
3-D Matching Problem C 1

13
3-D Matching Problem How do we encode the idea that x i can either be set to 0 or 1 ? Either use all the even triples in gadget i, or all odd ones ! Selecting all even triples corresponds to setting x i = 0. In this case the odd tips would remain free for use. Selecting all odd triples corresponds to x i = 1. In this case, the even tips would remain free for use.

14
Enhancing the variable gadget to model the clauses and the constraints on possible assignments imposed by them For clause C j, clause gadget is defined as follows: Two core elements P j = {p j, p j ’}. For each of the three terms in C j do the following If term = x i, define a triple (p j, p j ’,b i,2j ). If term = x i ’, define a triple (p j, p j ’,b i,2j-1 ). Reserving the (2j) th and (2j-1) th tips of each variable gadget for clause gadget j ensures that the clause gadgets never compete for free tips. Since only the 3 triples defined corresponding to the 3 terms of C j cover P j, one of these must be used. This enforces the clause constraint.

15
Cleanup Gadgets We introduce (n-1)k cleanup gadgets ! The r th cleanup gadget consists of 2 core elements Q r = {q r, q r ’} Create a triple (q r, q r ’,b) for every tip b in variable gadgets.

16
3-D Matching Problem Define X,Y and Z as follows: X consists of 1.all a ij with j even ….total number nk 2.The set of all p j ….. total number k 3.The set of all q i ….. total number (n – 1) k Y consists of 1.all a ij with j odd ….total number nk 2.The set of all p j ’ ….. total number k 3.The set of all q i ’ ….. total number (n – 1) k Z consists of 1.Set of all tips b ij …. ….. total number 2 n k Can you see that X, Y and Z are of same size….what’s the size? Each triple consists of one element from each of X,Y, and Z.

17
3-D Matching Problem Y consists of 1.all a ij with j odd 2.The set of all p j ’ 3.The set of all q i ’ Z consists of 1.Set of all tips b ij Can you see that X, Y and Z are of same size Each triple consists of one element from each of X,Y, and Z.

18
3-D Matching Problem We understand the above reduction with the help of an example ! Consider an instance of 3-SAT having 4 variables : x 1,x 2 x 3, x 4 3 clauses C 1 : (x 1 v x 2 v x 3 ’) C 2 : (x 2 ’ v x 3 v x 4 ) C 3 : (x 1 ’ v x 2 v x 4 ’)

19
Variable gadget for x 1 has the following components Core A 1 = {a 11,a 12,….,a 1,6 } Tips B 1 = {b 11,b 12,….,b 1,6 } A triple t 1j = (a 1j,a 1,j+1,b 1j ) for all j, where addition is modulo 6. Tip 1 Tip 2 Tip 3 Tip 4 Tip 5 Tip 6

20
3-D Matching Problem Gadgets for the remaining variables can similarly be drawn. We now bring the clause gadgets into picture

21
C 1 : (x 1 v x 2 v x 3 ’) x1x1 x2x2 x3x3 p1’p1’ p1p1

22
C 2 : (x 2 ’ v x 3 v x 4 ) x2x2 x3x3 x4x4 p2’p2’ p2p2

23
C 3 : (x 1 ’ v x 2 v x 4 ’) x1x1 x2x2 x4x4 p3’p3’ p3p3

24
3-D Matching Problem Part I Consider the following satisfying assignment for the given 3-SAT instance x 1 = 1 x 2 = 0 x 3 = 1 x 4 = 0 We now try to find a matching.

25
We select the odd triples of gadget for x 1 since x 1 = 1. This leaves the even tips free for use Tip 1 Tip 2 Tip 3 Tip 4 Tip 5 Tip 6

26
We select the even triples of gadget for x 2 since x 2 = 0. This leaves the odd tips free for use Tip 1 Tip 2 Tip 3 Tip 4 Tip 5 Tip 6

27
We select the odd triples of gadget for x 3 since x 3 = 1. This leaves the even tips free for use Tip 1 Tip 2 Tip 3 Tip 4 Tip 5 Tip 6

28
We select the even triples of gadget for x 4 since x 4 = 0. This leaves the odd tips free for use Tip 1 Tip 2 Tip 3 Tip 4 Tip 5 Tip 6

29
C 1 : (x 1 v x 2 v x 3 ’) x1x1 x2x2 x3x3 p1’p1’ p1p1

30
C 2 : (x 2 ’ v x 3 v x 4 ) x2x2 x3x3 x4x4 p2’p2’ p2p2

31
C 3 : (x 1 ’ v x 2 v x 4 ’) x1x1 x2x2 x4x4 p3’p3’ p3p3

32
3-D Matching Problem Claim: 3-SAT is satisfiable if and only if there exists a perfect 3-D Matching Part I Given A satisfying assignment for the 3-SAT instance To Prove There exists a perfect 3-D Matching

33
Recap Define X,Y and Z as follows: X consists of 1.all a ij with j even ….total number nk 2.The set of all p j ….. total number k 3.The set of all q i ….. total number (n – 1) k Y consists of 1.all a ij with j odd ….total number nk 2.The set of all p j ’ ….. total number k 3.The set of all q i ’ ….. total number (n – 1) k Z consists of 1.Set of all tips b ij …. ….. total number 2 n k Can you see that X, Y and Z are of same size….what’s the size? Each triple consists of one element from each of X,Y, and Z.

34
3-D Matching Problem Proof Make the corresponding choices of odd/even for each variable gadget based on the given assignment. This leaves at least one free tip for each clause gadget. Using the cleanup gadgets, we cover all the core elements in the variable, clause and cleanup gadgets, and all the tips too !

35
3-D Matching Problem Part II Given A perfect 3-D Matching in the instance constructed. Can we claim that this matching cannot possibly cover some even and some odd triples in any variable gadget, i.e., either all even or all odd triples are chosen ?

36
3-D Matching Problem Yes ! Any two consecutive triples share one of the core elements ! Therefore, any perfect matching cannot pick consecutive triples! If even triples have been chosen, set x i = 0 If odd triples have been chosen, set x i = 1

37
3-D Matching Problem Have the clauses been satisfied too ? Yes ! Since the core elements of every clause gadget have been covered, the following holds true for all clauses: At least one of the three variable gadgets corresponding to a term in any clause C j must have made the correct even/odd decision.

38
Big Thanks to Sonika Arora

Similar presentations

OK

NP-Completeness Note. Some illustrations are taken from (KT) Kleinberg and Tardos. Algorithm Design (DPV)Dasgupta, Papadimitriou, and Vazirani. Algorithms.

NP-Completeness Note. Some illustrations are taken from (KT) Kleinberg and Tardos. Algorithm Design (DPV)Dasgupta, Papadimitriou, and Vazirani. Algorithms.

© 2018 SlidePlayer.com Inc.

All rights reserved.

Ads by Google

Download ppt on ecotourism in india Ppt on cooperative society Ppt on old age homes Ppt on obesity management images Ppt on depth first search algorithms Ppt on service oriented architecture in healthcare Jit ppt on manufacturing plant Ppt on latest technology in mechanical engineering Ppt on formal education is a required Ppt on coalition government big