HOMEWORK 5 SOLUTIONS, CPSC 421/501, FALL 2015 JOEL FRIEDMAN Copyright: Copyright Joel Friedman 2015. Not to be copied, used, or revised without explicit written permission from the copyright owner. 1 TRIPLE-PARTITION is in NP because you can guess into which of A, B, C to put 1, then 2, etc., and then you can test (in polynomial time) if the sum of the ni with i ranging over A, B, C are equal. To see that any language in NP can be reduced to TRIPLE-PARTITION, we reduce PARTITION to TRIPLE-PARTITION. Namely, given an instance m1 , . . . , mk of PARTITION, let mk+1 = (m1 + · · · + mk )/2 and consider the problem m1 , . . . , mk , mk+1 as an instance of TRIPLE-PARTITION (if mk+1 is not an integer then m1 , . . . , mk cannot lie in partition, so just write some non-element of TRIPLE-PARTITION, such as the sequence 1, 1). If m1 , . . . , mk is in PARTITION, then mk+1 must be an integer, equal to either partition of m1 , . . . , mk into two subsequences summing to mk+1 ; hence, by putting k + 1 alone into A, and using the partition of m1 , . . . , mk to determine B and C, we have that m1 , . . . , mk , mk+1 is in TRIPLE-PARTITION. Conversely, if m1 , . . . , mk+1 is in TRIPLE-PARTITION then m1 + · · · + mk + mk+1 = 3mk+1 , and so any triple partition of m1 , . . . , mk+1 must have mk+1 in its own partition, and the rest of m1 , . . . , mk parititioned into two other sets whose sum in each is mk . It follows that the transformation from m1 , . . . , mk to m1 , . . . , mk+1 (or to 1, 1 if m1 +· · ·+mk is an odd number and hence mk+1 is not an integer)—which is clearly computatable in polynomial time, reduces PARTITION to TRIPLE-PARTITION. Since PARTITION is NP-complete, it follows than any language in NP can be reduced to TRIPLE-PARTITION. Hence TRIPLE-PARTITION is NP-complete. 2 Clearly we can guess a 3-colouring of a graph and check if it is a proper colouring in polynomial time. Hence 3COLOR is in NP. We will reduce 3SAT to 3COLOR. Consider a 3CNF Boolean formula, f , and form a graph from f consisting of (1) the palette on page 325; Research supported in part by an NSERC grant. 1 2 JOEL FRIEDMAN (2) a variable (two vertices and an edge) subgraph, with vertices vi , vi0 for each variable xi of f ; (3) for each clause xi ∨ xj ∨ xk we introduce the following new vertices: let y1 , y2 , y3 be a triangle (i.e., be a complete graph) as in the top part of the OR-gadget on page 325, and connect y1 to vi and y2 to vj (as suggested by the bottom half of the OR-gadget, so y3 is the top vertex in the ORgadget); also (not shown in the OR-gadget), connect y3 to the gray color in the palette; then y3 must be F if both vi and vj are F, but otherwise y3 can be F or T; creating another such gadget between y3 and vk we get a new “top” vertex y6 (with lower vertices y5 and y4 ), such that y6 must be F if vi , vj , vk are all F; otherwise y6 can attain the value T; finally connect y6 to the F vertex; in this way, this new part of the graph is 3-colourable iff at least one of vi , vj , vk has the colour T; (4) for each clause xi ∨ xj ∨ ¬xk , do the same except use v1 , v2 , v30 ; (5) for each clause with three variables and any negation pattern do the same with vi or vi0 according to whether or not xi is negated, vj or vj0 and vk or vk0 similarly. In this way, f is satisfiable iff the above graph can be 3-coloured. This this construction is clearly polynomial time in the number of variables and number of clauses of f , with both these numbers bounded by the length of the description of f , the above construction can be performed in polynomial time in the length of hf i. This give a polynomial time reduction from 3SAT to 3COLOR. Hence 3COLOR is NP-complete. 3 Clearly SQRT-CLIQUE is in NP since we can guess the vertices that are in the clique and check whether or not it is a clique in polynomial time. We can reduce CLIQUE to SQRT-CLIQUE as follows: given a description of a graph G = (V, E) and an integer k, consider the question of whether or not there is a clique of size k in G. For simplicity we may assume that k ≥ 2. We may therefore discard any isolated vertices in G and obtain a new G whose description is shorter than that of G and whose description is at least as great as |V |. If k 2 = |V |, then this problem is equivalent to whether or not G is instance of SQRT-CLIQUE. If k 2 6= |V |, let V 0 and V 00 be sets disjoint from V , and consider the graph G0 = (V ∪ V 0 ∪ V 00 , E ∪ E 00 ), where E 00 contains an edge from each element of V 00 to every other vertex in the graph. Then G has a clique of size k iff G0 has a clique of size k + |V 00 |, since V 00 is connected to every vertex, and V 0 are otherwise isolated vertices in G0 . So let k 00 be the smallest integer such that (k + k 00 )2 ≥ |V | + k 00 , and let k 0 be the integer with (k + k 00 )2 = |V | + k 00 + k 0 (since k ≥ 2, any clique of size k + k 00 cannot involve any verticies of V 0 since they are isolated from all vertices except those of V 00 ). It is easy to see that k 00 and k 0 are polynomial in n = |V |, and clearly G0 is an instance of SQRT-CLIQUE iff G has a clique of size k. Hence by finding k 00 and k 0 as above, and forming G0 , whose description is of size polynomial in |V |, with |V | being less than the length of hG, ki. This gives a polynomial time reduction from CLIQUE to SQRT-CLIQUE. It follows that any language in NP can be reduced to SQRT-CLIQUE. Hence SQRT-CLIQUE is NP-complete. HOMEWORK 5 SOLUTIONS, CPSC 421/501, FALL 2015 3 Department of Computer Science, University of British Columbia, Vancouver, BC V6T 1Z4, CANADA, and Department of Mathematics, University of British Columbia, Vancouver, BC V6T 1Z2, CANADA. E-mail address: jf@cs.ubc.ca or jf@math.ubc.ca URL: http://www.math.ubc.ca/~jf