# Midterm Exam, Spring 2010

### Directions:

• Answer the problems on the exam pages.
• There are five short problems, for ten points each, and three long problems for 25 points each. Attempt all the short problems and only two of the long ones -- the maximum score is thus 100. If you attempt all three long problems I will take the scores of the best two. Actual scale was A = 80, B = 50.
• If you need extra space use the back of a page.
• No books, notes, calculators, or collaboration.

```  Q1: 10 points
Q2: 10 points
Q3: 10 points
Q4: 10 points
Q5: 10 points
Q6: 25 points
Q7: 25 points
Q8: 25 points

Total: max 100 points
```

• Question 1 (10): A two-dimensional Turing machine has a finite state set Q and a memory with a cell C(i,j) for each pair of non-negative integers i and j, where each cell holds an element of the tape alphabet Γ. Its transition function is δ: (Q × Γ) → (Q × Γ × {L,R,U,D}), so that based on the current state and the one cell that it sees it decides a new state, a new letter to write in this cell, and whether to move up, down, left, or right. We start the machine with the input word w in cells C(0,1) through C(0,n), and the blank character in all other cells. Two of the states in Q are halt states, one accepting and one rejecting.

Let P2 be the class of languages that can be decided in polynomial time by a two-dimensional Turing machine. Prove that P2 = P.

• Question 2 (10): Let M be a deterministic single-tape "Turing machine" with the following strange properties. The tape alphabet Γ = {a1, a2,...} is (countably) infinite rather than finite. The function δ from (Q × Γ) to (Q × Γ × {L,R}), is such that for any positive integer n and any state q ∈ Q, δ(q, an) can be computed by an always-halting ordinary Turing machine. Let X be the set of strings w such that M(w) = 1, and assume that M always halts. Prove that X is decidable in the ordinary sense.

• Question 3 (10): Let n be a positive integer. An n × n array of numbers, each number in the set {1,...,n}, is a Latin square if every row and column contains all n possible numbers. (The popular Sudoku and Kenken puzzles ask you to form Latin squares with certain additional properties.) Let PARTIAL-LATIN (or PL) be the set of partially filled n × n arrays (for any possible n) that can possibly be completed to a Latin square. Let UNIQUE-PARTIAL-LATIN (or UPL) be the set of partially filled n × n arrays that can be completed to a Latin square in exactly one way.

Prove that PL is in the class NP and that UPL is in the class PH. What is the size of your input string, as a function of n?

• Question 4 (10): The language MOD-POWER consists of those strings ambxcidy such that the integers xi and y are congruent modulo m. (Recall that this means that m divides the integer xi - y, or that the remainders xi%m and y%m, in Java notation, are equal.) Prove that MOD-POWER is in the complexity class L = DSPACE(log n). (Hint: Doing all your arithmetic modulo m saves space.)

• Question 5 (10): The COMPETITIVE FACILITY LOCATION (or CFL) problem takes as input an undirected graph G, with a positive integer weight for each vertex, and a positive integer t called the target. The vertices represent possible locations for facilities, the weight of a vertex represents the value of a facility at that location, and an edge (u,v) means that vertices u and v cannot both have a facility. Two players will take turns each placing a facility on a vertex, where they may choose any vertex that does not have an edge to a vertex with an existing facility.

The input (G,t) is in the language CFL if and only if there is a strategy for the first player that lets her place facilities with total weight at least t, no matter how the second player plays. Prove that the language CFL is in the class ATIME(p(n)) for some polynomial p. In what deterministic complexity class can you place this language?

• Question 6 (25): A simple path in a directed graph is a path that never visits any vertex more than once. Here are two problems involving directed graphs. LONG-PATH is the set of pairs (G,k) such that G is a directed graph and there exists a path of length at least k in G. LONG-SIMPLE-PATH is the set of pairs (G,k) such that G is a directed graph and there exists a simple path of length at least k in G.

• (a,5) Prove that LONG-SIMPLE-PATH is in the class NP. (What happens if k is very large?)

• (b,10) Prove that LONG-SIMPLE-PATH is NP-hard and thus NP-complete.

• (c,10) Prove that if the number k is given in unary, LONG-PATH is in the class NL.

• Question 7 (25): These questions all involve the language TQBF, the set of all true quantified boolean formulas. A quantified boolean formula has the form:

Q1x1:Q2x2:... Qmxm: φ(x1,...,xm),

where each Qi is a quantifier (∃ or ∀), each xi is a boolean variable, and φ is a formula using boolean variables, constants 0 and 1, and operators ∧, ∨, and ¬.

• (a,5) Explain why the language TQBF is hard for the class PSPACE under poly-time reductions.

• (b,10) Prove that the complexity classes PTQBF and NPTQBF are equal. These classes are defined in terms of ordinary oracle machines, where the oracle query tape may be used as read/write space.

• (c,10) Let M be a polynomial-time nondeterministic oracle machine with oracle for the language SAT. (Thus L(M) is an arbitrary language in the class NPSAT.) Prove that L(M) ≤p TQBF, describing the polynomial-time reduction.

• Question 8 (25): Recall that if A and B are n × n boolean matrices, their product AB is defined to be the n × n matrix C such that each entry Ci,j is the OR, over all k from 1 to n, of Ai,k ∧ Bk,j. If A is an n × n boolean matrix, the k'th power of A, called Ak, is defined by the rule A0 = I (the identity matrix) and Ak+1 = AkA.

• (a,10) Let G be a directed graph and let A be the adjacency matrix of G, except that each entry Ai,i is 1. Prove that for any non-negative integer k, there is a path in G of length at most k from vertex i to vertex j if and only if Aki,j = 1. (Here Aki,j is the (i,j) entry of the matrix Ak.)

• (b,5) Let BOOLEAN-MATRIX-POWER (BMP) be the language {(A,k,i,j): Aki,j = 1}. Assume, if you like, that k is given in unary. Prove, using part (a) as needed, that BMP is in the class NL.

• (c,10) Prove that BMP is NL-hard (under logspace reductions) and is thus NL-complete.