- Answer the problems on the exam pages.
- There are nine problems for 125 total points. Actual scale is A = 97, C = 63.
- If you need extra space use the back of a page.
- No books, notes, calculators, or collaboration.
- The first six questions are true/false, with five points for the correct boolean answer and up to five for a correct justification of your answer -- a proof, counterexample, quotation from the book or from lecture, etc. -- note that there is no reason not to guess if you don't know.

Q1: 10 points Q2: 10 points Q3: 10 points Q4: 10 points Q5: 10 points Q6: 10 points Q7: 20 points Q8: 15 points Q9: 30 points Total: 125 points

Question text is in black, solutions in blue.

The following formal languages and other definitions are each used in one or more problems:

- A
**clocked Turing machine**is a deterministic Turing machine that has an associated polynomial p(n) with integer coefficients. When started on an input w of length n, it calculates the number p(n) and then runs for at most p(n) steps, always halting with a yes or no answer. - ALL
_{CTM}is the set of clocked Turing machines that accept every string in their input alphabet. - EMPTY
_{TM}is the set of clocked Turing machines that do not accept any string over their input alphabet. - A
_{P}is the set of triples (M, w, 1^{t}) such that M is a deterministic Turing machine, w is a string over the input alphabet of M, and M accepts w in at most t steps. - Two DFA's M = (Q, Σ, q
_{0}, F, δ) and M' = (Q', Σ, q'_{0}, F', δ') are said to be**isomorphic**if there exists a bijection f from Q to Q' such that f(q_{0}) = q'_{0}and for any state q ∈ Q and any letter a ∈ Σ, q ∈ F if and only if f(q) ∈ F' and δ'(f(q), a) = f(δ(q, a)). - The language ISO
_{DFA}is the set of pairs (M, M') such that M and M' are isomorphic DFA's, each no unreachable states. (For all languages involving DFA's, assume that we use a coding scheme such that the length of the string denoting M is some polynomial in the number of states in M.) - The language EQUIV
_{DFA}is the set of pairs (M, M') such that M and M' are DFA's over the same alphabet, and L(M) = L(M'). - The language A
_{DFA}is the set of pairs (M. w) such that M is a DFA and w ∈ L(M). - A
**cyclic alphabet Turing machine (CATM)**is a one-tape deterministic Turing machine with the property that the k letters of its tape alphabet Γ are numbered a_{0}, a_{1}, ..., a_{k-1}, and it may only overwrite a letter a_{i}with another a_{i}or an a_{(i+1)%k}, where "%" is the Java modular division operator. Note that the blank letter is an element of Γ and so is equal to a_{i}for some i. - Of course, A
_{CATM}is the set of all pairs (M, w) where M is a CATM and w ∈ L(M).

**Question 1 (10):***True or false with justification:*Assuming that P ≠ NP, there exists a context-free language that is not in P.FALSE. Every CFL is in P. Given a Chomsky Normal Form grammar for a language X, and an input w, we compute a predicate Parse(A, i, j) for every non-terminal A and numbers i and j with 1 ≤ i < j &le, n, where Parse(A, i, j) is true if and only if the nonterminal A can be expanded into the string w

_{i}...w_{j}by the rules of the grammar. Then Parse(S, 1, n) is true if and only if w is in X. We compute Parse(A, i j) by considering each rule A → BC and each number k with i < k < j, and recursively checking whether Parse(B, i, k-1) and Parse(C, k, j) are both true. (We use memoization, or dynamic programming, so that the entire calculation is in polynomial time -- there are only polynomially many combinations of A, i, and j, and each one takes only O(n) time apart from its recursive calls.) For the base case, Parse (A, i, i) is true if and only if A → w_{i}is a rule of the grammar.**Question 2 (10):***True or false with justification:*There exists a cyclic-alphabet Turing machine M such that M moves right on every step until or unless it halts and such that the language L(M) has infinitely many Myhill-Nerode equivalence classes.FALSE. If the machine always moves right, it never looks at any character it has writen, so the CATM restriction is irrelevant. It is in effect a DFA, even if it keeps going past the end of the input, because its eventual behavior depends only on its state when it finishes the input. Thus L(M) is a regular language, and by the MN theorem has only finitely many equivalence classes.

**Question 3 (10):***True or false with justification:*The language EMPTY_{TM}is mapping reducible to ALL_{CTM}, i.e., EMPTY_{CTM}≤_{m}ALL_{CTM}.TRUE. Let M be any CTM. Let f(M) be a machine that simulates M and reverses its answer, accepting whenever M rejects and vice versa. The running time of f(M) can be exactly the same as that of M, so f(M) can be made to be a CTM with the same polynomial. Clearly now L(M) = ∅ if and only if L(f(M)) = Σ

^{*}, so f is the desired reduction. We can compute f using O(log n) space, because it requires only slight adjustments to the state table of M.**Question 4 (10):***True or false with justification:*The language EQUIV_{DFA}is in the class P.TRUE. One way to see this is to use the result of Question 9b, that ISO

_{DFA}is in P, together with the state minimization algorithm. (Two DFA's have the same language if and only if their minimized versions are isomorphic.) But we can also do this directly by the product construction. Given M and M', we build a product machine M'' such that L(M'') is the symmetric difference of L(M) and L(M'). (That is, for any string w, (w ∈ L(M'')) ↔ ((w &isin L(M)) ⊕ (w ∈ L(M'))).) If M and M' each have at most n states, M'' has at most n^{2}states and the construction can be carried out in pulynomial time. Then (M, M') ∈ EQUIV_{DFA}if and only if L(M'') ≠ ∅, and we can decide emptiness for a DFA in polynomial time, for example by depth-first searching its graph from the start state, looking for a reachable final state.**Question 5 (10):***True or false with justification:*The language A_{CATM}is Turing decidable.FALSE. We can reduce A

_{TM}, which we know to be TR-complete, to A_{CATM}by a mapping reduction. All we need to do is to simulate an arbitrary deterministic TM by a CATM. Let δ be the transition function of the ordinary TM M. Whenever δ(q, a_{i}) = (r, a_{j}, R), we make extra states in the CATM f(M). The CATM moves right from its original position (j-i)%k times, each time changing the letter, so that it ends up being a_{j}. In between each of these moves it moves left, without changing the letter to the right of the original position. Whenever δ(q, a_{i}) = (r, a_{j}, L), the CATM moves left that many times and changes the letter in the original position, moving right without changing the letter between each pair of moves to the left. Since this CATM simulates M exactly, and the transformation from TM to CATM is clearly computable by an always-halting TM, we have the desired reduction and we have proved that A_{CATM}is not TD.**Question 6 (30):***True or false with justification:*The language A_{DFA}is in the class L.TRUE. The input (on the read-only input tape) is a DFA M and a string w. We must simulate M on w using only O(log n) bits of read/write memory. There are at most n states of M and at most n letters in w, where n is the input size. We can thus store the current state of M and the current position in the input using at most log n bits each. So we simulate M step by step, updating the state s to δ(s, w

_{i}) where we look at M's description to compute δ and look at w to find w_{i}. At the end we have computed δ^{*}(q_{0}, w) and we check M to see whether this state is in F.**Question 7 (20):**Two questions on clocked Turing machines, as defined above:- (a,10) Prove that every language in L (where L = DSPACE(log n)) is the
language of some clocked Turing machine.
Let X be any language in the class L. There exists a TM M such that L(M) = X and for some constant c, M uses at most c log n tape cells on any input of length n. Let C be a CTM that simulates M for up to |Γ|

^{c log n}= p(n) steps -- this will be enough so that if M has not halted after this many steps it never will. - (b,10) Prove that the language EMPTY
_{CTM}is not Turing decidable.We reduce ALL

_{CFG}, a language proven to be undecidable in Sipser, to EMPTY_{CTM}by a mapping reduction, thus showing that the latter language is not TD. Recall that ALL_{CFG}is {G: L(G) = Σ^{*}}. Given G, let f(G) be a CTM with L(f(G)) = L(G). By the answer to Question 1, L(G) is in the class P, and by the answer to Question 7a (which extends from X ∈ L to X ∈ P without changes) we can construct this CTM. Then let f'(G) be a CTM that reverses the answer given by f(G), as in the answer to Question 3. Now L(G) = Σ^{*}↔ L(f(G)) = Σ^{*}↔ L(f'(G)) = ∅, so G ∈ ALL_{CFG}↔ f'(G) ∈ EMPTY_{CTM}, and f' is the desired mapping reduction.

- (a,10) Prove that every language in L (where L = DSPACE(log n)) is the
language of some clocked Turing machine.
**Question 8 (15):**Prove that the language A_{P}is complete for the class P under ≤_{L}reductions.We first show that A

_{P}is in P: Given an input (M, w, 1^{t}, a universal TM can simulate M for t steps on w, taking time polynomial in t, in the length of w, and in the description size of M (and thus polynomial in the input size).Now let X be an arbitrary language in P, and we will prove that X ≤

_{L}A_{P}. Let X = L(M) where M is a deterministic TM that always answers after at most p(n) steps on input of length n. Given any string w of length n over the correct alphabet, we let f(w) = (M, w, 1^{n}). Clearly w ∈ L(M) ↔ (M, w, 1^{p(n)}) ∈ A_{P}. It remains to show that f is logspace computable. M is fixed and so has constant size -- it may be printed using only O(1) states. The string w is just copied, using no space. The number p(n) is a sum of O(1) products of n and fixed constant integers -- a logspace TM can count the letters of w on its worktape and then compute p(n) by doing O(1) multiplications and additions -- we proved that multiplication of binary numbers is doable in log space.**Question 9 (30):**These questions concern the language ISO_{DFA}defined above:- (a,10) Prove that the language ISO
_{DFA}is in the class NP.Given M and M' as described, our certificate is a function f from Q to Q' that is a bijection, that has f(q

_{0}) = q'_{0}, that has f(q) ∈ F' ↔ q ∈ F, and that has f(δ(q, a)) = δ'(f(q), a) for any state q and any letter a. Given M, M', and f, we can easily check all these conditions in polynomial time, and by the definition (M, M') is in ISO_{DFA}if and only if an f exists that meets all these conditions. - (b,20) Either prove that ISO
_{DFA}is in the class P, or prove that ISO_{DFA}is NP-complete. (Extra credit for doing both.)ISO

_{DFA}is in P, so of course it is not NP-complete unless P = NP. Given M and M', we construct an f that meets the conditions for an isomorphism if any such f exists. We start by setting f(q_{0}) = q'_{0}. We then assign, for every q such that f(q) is known, f(δ(q, a)) to be δ'(f(q), a). These assignments must all be correct if f is to be an isomorphism. If this process ever assigns two different values to f(q) for any q, we can reject -- no isomorphism exists. If not, we will have assigned all values of f (since every state is reachable from the start state by some sequence of letter-moves) and constructed the only possible f. If this f satisfies the condition for final state sets we accept, and otherwise we reject.(I am fairly sure that ISO

_{DFA}is still in P without the condition on reachable states, but I haven't verified this.)

- (a,10) Prove that the language ISO

Last modified 20 May 2011