# CMPSCI 601: Theory of Computation

### David Mix Barrington

#### Solutions posted Mon 11 August 2003

Questions are in black, solutions in blue.

• Question 1 (30): Remember that the language 3-COLOR, the set of all undirected graphs that can be vertex-colored with three colors, is NP-complete. Here we consider some potential approximation schemes for this problem.

• (a,10) Suppose we had a poly-time algorithm that inputs an undirected graph and produces a coloring that used at most 5/4 times the optimal number of colors. Prove that in this case P=NP. (green text added 7 August 2003)

This algorithm can be used to decide the NP-complete language 3-COLOR. Given an undirected graph, we first apply the given algorithm and determine how many colors are used in its coloring. If there are three or fewer, we know that the input graph is 3-colorable and return "true". If it has four or more colors, we return "false". We are correct in returning "false" in this case because if the optmimal number were 3 or less, the algorithm would have used at most 3*(5/4) = 3.75 colors. Since it used four or more, there cannot have been a 3-coloring. If any NP-complete language can be decided in poly-time, then P=NP. (This decision procedure uses the poly-time given algorithm and then just counts the colors in the graph and answers, which is clear in poly-time overall.)

• (b,10) Suppose that we had a poly-time algorithm that inputs an undirected graph and produces a 3-coloring that is within one of optimal in terms of the number of correct vertices. That is, if there is a 3-coloring in which k of the n vertices are colored correctly, the algorithm produces a coloring with at least k-1 vertices colored correctly. (A vertex is colored correctly if all its neighbor's colors are different from its own color.) Prove that P=NP in this case.

Again, we will use the given algorithm to solve 3-COLOR in poly-time. Given an input graph G, let the graph H be two copies of G with no other edges. Give H to the given algorithm. (Since the size of H is only polynomially larger than that of G, the running time will still be polynomial in the size of G.) Suppose that G is 3-colorable. Then H is also 3-colorable. Since the coloring of H has only one vertex that is not colored correctly, at least one of the two copies of G must be entirely correct. We just check both of them and return "true" if either of then is correctly colored. Otherwise we return "false". It is clear that the extra work after the given algorithm is poly-time, and that we will return "true" iff G is 3-colorable. Since the NP-complete langauge 3-COLOR is in P under the assumption that this algorithm exists, P=NP in this case.

• (c,10) Suppose that we had a poly-time algorithm that inputs an n-vertex undirected graph and produces a coloring that has within sqrt(n) of the optimal number of correct vertices. That is, if there is a coloring with k vertices correct, it gets more than k - sqrt(n) vertices correct. Prove that P=NP in this case.

Let G be any input graph with n vertices and let H be the union of n separate copies of G. Clearly H is 3-colorable iff G is, and H has n2 vertices. Run the given algorithm on H to get a coloring. If G and H are 3-colorable, this coloring must have fewer than sqrt(n2) or fewer than n incorrect vertices, so at least one of the copies of G is correctly colored. Thus our decision procedure is to get this coloring, check each copy of G, and return "true" iff one of the copies is correctly colored. This is poly-time because the given algorithm takes time polynomial in n2 (hence also polynomial in n) and the extra work is clearly polynomial in the size of G. Since in this case the NP-complete language 3-COLOR is decidable in poly-time, P=NP in this case.

• Question 2 (30): Recall the ITERATED-PRODUCT problem from Question 2, HW#4:

• Input: a multiplication table for a group (a function from G times G to G obeying the group properties), and a sequence of elements of the group (a string w in G*). Note that if n is the input size, G has at most n elements and the length of w is at most n.

• Output: the product of the elements in the sequence.

Here are three questions concerning this problem:

• (a,5) Explain why, given results proved in HW#4 and in lecture, the ITERATED-PRODUCT problem is in the class AC1.

We proved on HW#4 that ITERATED-PRODUCT is in the class L. In lecture we showed that L is contained in NL (since a log-space DTM is a special case of a log-space NDTM) and that NL is contained in AC1 (because the Savitch argument puts the NL-complete problem REACH in AC1. So ITERATED-PRODUCT is in AC1.

• (b,15) Describe an AC1 circuit family for this problem directly.

Let m be the length of the string w. Make a binary tree of depth log(m) = O(log n), with m leaves. Each node of this tree will hold a partial product of some elements of w. For example, the leaves will hold w1, w2,..., wm. The next level will hold w1w2, w3w4, the next level's nodes will each hold a product of four elements of w, and so on until the root holds the final product.

At each node we must determine the required element, which is the product of the two elements at the node's children. We must thus build a circuit fragment that takes two group elements (coded as numbers from 1 to n) and gives their product. To do this we must use the multiplication table given in the read-only input, looking up the correct single entry of the table.

With a circuit, this means that we must take an OR of g2 subcircuit, where g is the size of the group. Each subcircuit returns the product of x and y, if the child nodes' elements are x and y, or returns 0 otherwise. The bitwise OR of these results thus gives us the product for the x and y that are actually the contents of the child nodes.

Since each binary multiplication is correct, the circuit gets the right answer for ITERATED-PRODUCT. Its size is polynomial because there are O(n) nodes, each with O(n) subcircuits of size O(log n). Its depth is O(log n) times the depth of the circuit at one node, and these circuits have depth O(1) each if we allow unbounded fan-in. So the whole circuit meets the conditions to put the problem in AC1.

• (c,10) Prove that the special case of ITERATED-PRODUCT, where the group has only O(1) elements, is in the class NC1.

The unbounded fan-in is used in the circuit of Problem 2-b only in taking the OR of g2 subcircuits in each node. But if g is only O(1), then g2 is also O(1) and the gates of fan-in O(1) may be replaced by O(1) gates of fan-in 2. Since the circuit still has depth O(log n) but now has fan-in two, the problem is now in NC1.

• Question 3 (25): Consider the following game played on an undirected graph G with n vertices. There are two players, and at any time each player occupies a vertex of G. On their move, a player may move from their current vertex to an adjacent vertex. There is a "victory table" V, where V is a set of pairs of vertices of G. Player 1 wins if at any time during the game, the pair (x,y) is in V where x is Player 1's position and y is player 2's position. Player 2 wins if the game continues for n moves without player 1 winning.
• (a,15) Describe a log-space alternating Turing machine M such that L(M) is the set {(G,V,x,y): Player 1 wins the game on G and V with starting position (x,y) under optimal play}.

The machine receives G, V, x, and y in its read-only input. It initializes a variable position1 to x and a variable position2 to y. It initializes a variable moveCount to 0, and then enters a loop.

Inside the loop, it checks whether (position1, position2) is in the set given by V and accepts if it does. Then if moveCount is even, player 1 names a node number z. The machine checks whether (position1, z) is in G. If it is, it changes position1 to z, if it isn't it rejects. If moveCount is odd, player2 names a node number z. Then if (position2, z) is in G the machine changes position2 to z, and if not it accepts. (Since player 2 has tried to cheat, she loses and player 1 wins in this case.)

If moveCount reaches n before the machine accepts or rejects, it then rejects (because player 1 wins in this case).

If either player has a winning strategy in the game as described above, that player can choose a series of nodes in the alternating Turing machine game, depending on her opponent's moves, that will guarantee that she wins. The ATM game thus simulates the original game.

• (b,10) Without using alternation, describe a poly-time decision procedure for this language. (Hint: make a table of all possible positions in the game.)

At any point of the game, the state is given by position1, position2, and moveCount. Following the hint, we make a table Winner indexed by all triples (position1,position2,count) of two positions and a move count. We first set Winner(x,y,n) to "player2" for all x and y. Then we set Winner(x,y,i) to "player1" for all triples where (x,y) is in V and i < n.

Now we have to fill in the other entries in the table. Starting with moveCount n-1 and working downward, we examine each position (x,y,i) that is not yet filled. If i is even, we look at all triples (z,y,i+1) where (x,z) is an edge in G. We set Winner(x,y,i) to "player1" if at least one of these is labeled "player1" or to "player2" if all the successors are labeled "player2". If i is odd, we set Winner(x,y,i) to "player2" if there is a triple (x,z,i+1) labeled "player2" and (y,z) an edge in G.

Once we have filled in the entire table, our output is Winner(x,y,0) for the particular x and y given by the input.

• Question 4 (15): Consider the following approximation algorithm for the VERTEX-COVER problem.

``````
Input: undirected graph G
for all nodes v
{mark(v) = false;}
edgeSet = empty set;
while there is an edge (x,y) with mark(x) = mark(y) = false
{edgeSet = edgeSet union {(x,y)}
mark(x) = true;
mark(y) = true;
for all nodes z adjacent to either x or y
{mark(z) = true;}
}
return edgeSet;
``````

Explain why this nondetermistic algorithm must produce a vertex cover. What is the approximation ratio of this algorithm for the MIN-VERTEX-COVER optimization problem? (It said "MAX-VERTEX-COVER" on the assignment, sorry.)

I'm afraid that I completely messed up this problem and I'll have to withdraw it. The algorithm above produces a set of edges, but a vertex cover is a set of vertices. It basically doesn't have too much to do with the vertex cover problem at all!