Complexity 9 1 NPCompleteness Complexity Andrei Bulatov Complexity
Complexity 9 -1 NP-Completeness Complexity Andrei Bulatov
Complexity 9 -2 NP-Completeness Proofs To prove that a language L is NP-complete we now just have perform two steps: 1. Show that L belongs to NP 2. Find a known NP-complete problem (language) L and show L L 100 s of problems have now been shown to be NP-complete (for an earlier survey see Garey and Johnson) Note: If we can complete Step 2 but not Step 1, then we sa L is NP-hard
Complexity 9 -3 NP-Completeness of Clique Instance: A graph G and a number k. Question: Does G contain a clique of size k? Theorem Clique is NP-complete Step 1: The problem Clique is in NP: the list of vertices in the clique is the certificat
Complexity 9 -4 Step 2: To show that Clique is NP-complete we shall red Satisfiability to Clique Given a formula with clauses • For each literal X in clause create a graph vertex • Put an edge between every pair of vertices from distinc unless they are incompatible (i. e. X and X) This construction can be carried out in polynomial time The resulting graph has a clique of size k if and only if is satisfiable (assign the value true to every variable occurring in the clique)
Complexity 9 -5 Example Construction X U Y V Z Y X k 3 U Z
Complexity 9 -6 NP-Completeness of Vertex Cover¹ Instance: A graph G = (V, E), and a natural number k. Question: Is there a set M N, with M k, such that for ea edge (i, j) E, {i, j} M ? ¹Sometimes called Node Cover Step 1: The problem Vertex Cover is in NP: the list of vertices in M is the certificate
Complexity 9 -7 Step 2: To show that Vertex Cover is NP-complete we shall reduce Satisfiability to Vertex Cover Given a formula with clauses and n variab • For each variable X create two adjacent vertices to represent the literals X and X an • For each clause of size create a complete subg with vertices connected to corresponding literals • Set This construction can be carried out in polynomial time
Complexity Example Construction X Y Z U V 9 -8
Complexity • At least one of each pair 9 -9 must be in the cover • At least vertices from each complete graph must be in the cover • If the formula is satisfiable, then choose the cover by choo each literal assigned true plus all but one vertex in each (Omit a vertex which is connected to a satisfied literal. ) • Conversely, if a vertex cover exists, assign each Boolean va according to whether (true) or (false) is in M. choice of k, there must be one vertex in each clique which in M. This vertex must be adjacent to a vertex in M, hence clause is satisfied. )
Complexity Alternative Reductions We have shown that Clique and Vertex Cover are both NP-complete This means it must be possible to reduce Clique to Vertex Cover and vice versa! 9 -10
Complexity 9 -11 NP-Completeness of 3 -SAT To show that 3 -Satisfiability is NP-complete we reduce Satisfiability to 3 -Satisfiability • Replace every clause with k > 3 by • C is satisfiable if and only if C is, since at least one of other than Ys must be true
Complexity 9 -12 NP-Completeness of Subset. Sum Instance: A sequence of positive integers target integer t. Question: Is there a subset T S such that Step 1: The problem Subset. Sum is in NP: the set T is the certificate an ?
Complexity 9 -13 Step 2: To show that Subset. Sum is NP-complete we shall reduce Satisfiability to Subset. Sum Given a formula with clauses • For each variable X create 2 integers • For each clause • Choose t so that T must contain exactly one of each and at least one from each clause of length and create This construction can be carried out in polynomial time integ
Complexity 9 -14 Example Construction = = = = = t 10000 1000 100 10 10 1 1 1 0 1 0 0 0 0 0 1 0 1 0 = = = 1 1 0 0 0 1 1 1 = 11111 3 2 4
Complexity NP-Completeness of Ham. Circuit Instance: A graph G. Question: Does G contain a Hamilton circuit? Theorem Ham. Circuit is NP-complete Step 1: The problem Ham. Circuit is in NP: the Hamilton circuit is the certificate 9 -15
Complexity 9 -16 Step 2: To show that Ham. Circuit is NP-complete we shall reduce 3 -Satisfiability to Ham. Circuit Given a formula with clauses and variables What is to be encoded? • Boolean variables • a choice between two values (for each variable) • consistency: all occurrences of X must have the same • constraints on the possible values imposed by clauses
Complexity • 9 -17 the choice gadget • We assume that all gadgets are con with the rest of the graph only thro endpoints, shown as full dots; there edges connecting other vertices of to the rest of the graph • This gadget will allow the Hamilton approaching from above, to pick ei or right edge, thus communicating value
Complexity • 9 -18 the consistency gadget - This graph can be traversed by the Hamiltonian circu two ways
Complexity • - 9 -19 the constraint gadget If, using the choice and consistency devices, we have made side of the triangle is traversed by the Hamilton circuit if and corresponding literal is false; then at least one literal has to
Complexity 9 -20 Properties of the Gadgets • the choice gadget can be traversed in exactly two ways • the internal vertices of the consistency gadget (“exclusive can be traversed in exactly two ways, so that exactly one pa external vertices is involved • any Hamilton circuit traverses at most two of the edges of a constraint gadget
Complexity 9 -21 true false X Y Z 1 all these vertices are connected 2
Complexity 9 -22 NP-Completeness of TSP(D) Travelling Salesperson(D) Instance: A finite set of cities , a positive integ distance , between each pair and a integer B. Question: Is there a permutation of such that Step 1: The problem TSP(D) is in NP: a route satisfying the inequality is the certifica
Complexity 9 -23 Step 2: To show that TSP(D) is NP-complete we shall reduce Ham. Circuit to TSP(D) Given a graph G with vertex set V and edge set E • For each vertex v create a city • Set B = |V| if (u, v) E and Then • If G has a Hamilton circuit then there is a route of wei (the Hamilton circuit) • If there is a route of weight B, then in G this route go edges and therefore is a Hamilton circuit
- Slides: 23