Question text is in black, solutions in blue.

- Answer the problems on the exam pages.
- There are seven problems for 120 total points. Probable scale is around A=100, C=70 but will be determined after I grade the exam.
- If you need extra space use the back of a page.
- No books, notes, calculators, or collaboration.
- The first five 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: 30 points Q7: 40 points Total: 120 points

**Question 1 (10):***True or false with justification:*Define a**bizarro Turing machine**to be like an ordinary deterministic one-tape Turing machine except that the tape alphabet Γ is countably infinite, so that Γ = {a_{1}, a_{2}, a_{3},...}. The input alphabet Σ is still finite. The transition function δ from (Q × Γ) to (Q × Γ × {L, R}) can no longer be given by a finite lookup table, but it is computable by an ordinary Turing machine (that always halts).Given this definition, there exists a bizarro Turing machine B whose language L(B) = {w ∈ Σ

^{*}: B halts in its accepting state on input w} is not TR.FALSE. You can simulate a bizarro TM (BTM) with an ordinary TM. Store the tape contents of the BTM as a string, for example, a

_{i}a_{j}a_{k}can be stored as a^{i}ba^{j}ba^{k}or $(i in binary)$(j in binary)$(k in binary)$. Implement each step of the BTM by locating the head, calculating the next move, overwriting the string corresponding to the BTM character to be changed, and shifting the part of the ordinary TM's tape to the right as much as necessary to fit the string for the new BTM character. The computation of the correct move given the BTM's state and character seen can be done on another tape and is guaranteed to halt by the assumption. So any finite number of BTM steps can be simulated by the ordinary TM in finite time. The simulator must convert the BTM's input into the new format before starting -- this can clearly be done by an ordinary TM.So w is in L(B) if and only if B halts on input w, if and only if the simulator halts on input w. Thus L(B) is the language of the simulator and must be a TR language.

**Question 2 (10):***True or false with justification:*It is possible to have a countably infinite family S_{1}, S_{2}, S_{3},... of countably infinite sets, such that for any positive integers i and j where i ≠ j, the intersection S_{i}∩ S_{j}is a nonempty finite set. (Recall that a set is countably infinite if and only if it can be put into one-to-one correspondence with the positive integers.)TRUE. Let S

_{1}be {a_{11}, a_{12}, a_{13},...}, S_{2}be {a_{11}, a_{21}, a_{22}, a_{23},...}, S_{3}be {a_{11}, a_{21}, a_{31}, a_{32}, a_{33},...}, and in general S_{i}= {a_{11},..., a_{(i-1)1}, a_{i1}, a_{i2}, a_{i3},...}. Then if i < j, the intersection S_{i}∩ S_{j}is just {a_{11},..., a_{i1}} which is clearly nonempty and finite.**Question 3 (10):***True or false with justification:*For every ordinary Turing machine M with input alphabet Σ and every string w in Σ^{*}, the set of accepting computation histories of M on w is a regular language.TRUE. There are two cases. If M accepts w, there is exactly one accepting computation history, and any one-element language is regular. If M does not accept w, there are no accepting computation histories, and the empty language is regular. It is undecidable

*which*regular language we have, but either way we have a regular language.**Question 4 (10):***True or false with justification:*If f is a one-to-one function from {0, 1}^{*}to {0, 1}^{*}, and n is a positive integer, then there must exist a string w of length n such that the length of f(w) is at least n.TRUE. This came up in Section 6.4 of Sipser. There are 2

^{n}binary strings of length n, but only 1 + 2 + ... + 2^{n-1}= 2^{n}- 1 binary strings of length strictly less than n. By the Pigeonhole Principle, we cannot map a larger finite set one-to-one to a smaller set. If the range of the function does not consist entire of strings shorter than n, there must be an element of the range with length n or greater.**Question 5 (10):***True or false with justification:*Recall that an LBA is a deterministic one-tape Turing machine that never leaves the portion of its tape that originally contained its input. Define ALL_{LBA}to be the set {<M>: M is an LBA with input alphabet Σ and L(M) = Σ^{*}}. Then the language ALL_{LBA}is not TD.TRUE. We know that E

_{LBA}= {<M>: M is an LBA and L(M) = ∅} is not TD. We show that E_{LBA}≤_{m}ALL_{LBA}.Given an LBA M, we want an LBA f(M) such that L(f(M)) = Σ

^{*}- L(M). This will mean that <M> is in E_{LBA}if and only if <f(M)> is in ALL_{LBA}, and thus that f is the desired reduction.Let Q be the state set of M and let q be the size of Q. Let Γ be the tape alphabet of M and let k be the size of Γ. On input w of size n, f(M) will simulate M for at least qnk

^{n}steps or until it halts. If it runs for that many steps without halting, it is in a loop because that is the number of possible configurations of M -- there are q different states, n different head positions, and k^{n}different possible contents of the tape. So we have f(M) accept if the simulated M rejects or runs for that long, and have f(M) reject if the simulated M accepts.We are left with the technical problem of implementing f(M) as an LBA, which means keeping a "clock" on the same portion of the tape that contains the computation of M. We do this by expanding the tape alphabet of f(M) to 2(k

^{2}+ k) characters, so each square of f(M)'s tape contains an element of Γ, an element of {0, 1,..., k}, and a bit to mark where the head of one computation is while the other computation is going on. We use the elements of {0,..., k} to count up to (k+1)^{n}in base k+1. We assume that n is large enough so that (k+1)^{n}≥ qnk^{n}, otherwise we implement f(M) with a big lookup table. So f(M) alternates between implementing a step of M and incrementing the counter.**Question 6 (30):**A**Latin square**is a d by d matrix of numbers, each in the set {1, 2, 3,..., d}, such that each row and each column has each possible number exactly once. (For example, a solution to a standard Sudoku puzzle is a 9 by 9 Latin square that also has an additional property.) Let LS be the following language: A string in {a, b}^{*}is in LS if it is of the form a^{i1}ba^{i2}ba^{i3}b... a^{in}b where n is equal to d^{2}for some positive integer d, each i_{j}is in the set {1, 2, 3,..., d}, and the numbers i_{1}, i_{2},..., i_{n}form a Latin square if arranged into a d by d matrix in row-major order. Describe a deterministic k-tape Turing machine deciding the language LS, where k is a fixed positive integer of your choice.We first outline the steps of the computation and then give some detail for each:

- Read the entire input (which is kept on read-only tape 1) and count the b's to put the number n in unary on tape 2.
- Compute the first d so that d
^{2}≥ n and put d in unary on tape 3. If d^{2}> n, reject. - Check that each block of a's in the input has size in {1,..., d}, reject if any does not.
- Verify for each i and j in {1,..., d} that one of the numbers in row j is an i, that is, that one of the blocks in position (j-1)d + 1, (j-1)d + 2,..., or jd of the input has size exactly i.
- Verify for each i and j in {1,..., d} that one of the numbers in column j is an i, that is, that one of the blocks in position j, d + j, 2d + j,..., (d-1)d + j of the input has size exactly i.

We keep the variable i on tape 4 and the variable j on tape 5. On tape 6 we can keep the successive position numbers to be tested for size i. Now for some details:

- Add a b to tape 2 each time you see a b on tape 1 on a single left-to-right pass over the input.
- Implement the loop
`while (d*d < n) d++;`

, using two markers on tape 3 to count off d^{2}steps while moving right on tape 2 once each step. If you exactly count off the n b's on tape 2, go on to step 3. If you go past the b's, reject, if you come short, increase d by 1 and start over. - Measure each block of a's in the input against the string on tape 3, and reject if the block of a's is longer (or if there are two b's in a row in the input).
- For each i and j, initialize k on tape 6 to (j-1)d + 1, find the k'th block of the input, and check whether any of the next d blocks has size exactly i. If you find one, move on to the (i,j) pair -- if you don't find one, reject.
- For each i and j, initialize k to j, and check the size of that block and every d'th block thereafter to see if it has size exactly i. If you find one, move on to the next (i,j) pair -- if you reach the end of the input without finding one, reject.

If you complete all the checks in steps 1-5 without rejecting, then accept.

**Question 7 (40):**Let Z be the language {<M_{1}, M_{2}>: M_{1}and M_{2}are Turing machines and there exists a string w such that M_{1}and M_{2}both accept w and M_{1}does so in fewer steps than does M_{2}}. Here are four questions concerning Z. Your answers to some may imply answers to others --- it is fine to quote your solutions to other problems, but beware of circular reasoning!- (a, 10) Is the language Z a TR language? Prove your answer.
YES, Z is TR. Define a machine N which will, on input <M

_{1}, M_{2}>, in parallel for all strings w, run both M_{1}and M_{2}on w. (This is by dovetailing, for example, for each positive integer m it can run the machines for m steps each on the first m strings in Σ^{*}.) If for any w, both machines halt and M_{1}takes fewer steps, accept. Now Z is L(N), so Z is TR. - (b, 10) Is the language Z a TD language? Prove your answer.
NO, Z is not TD. This follows from the reduction A

_{TM}≤_{m}Z in part (c). You could also mapping-reduce or Turing-reduce any undecidable language to Z. - (c, 10) Is it true that A
_{TM}≤_{m}Z? Prove your answer by either describing a mapping reduction or proving that it cannot exist.YES, this mapping exists. Given a pair <M, w>, let f(M,w) be a pair of machines <M

_{1}, M_{2}>, where:- M
_{1}erases its input and then runs M on w, and - M
_{2}erases its input, moves right, moves left, and*then*runs M on w.

If M accepts w, both machines halt and M

_{1}halts first, so f(M, w) is in Z. If M does not accept w, then neither machine halts so f(M, w) is not in Z. So f is a mapping reduction from A_{TM}to Z. - M
- (d, 10) Is it true that
A
_{TM}≤_{m}Z? Prove your answer by either describing a mapping reduction or proving that it cannot exist.NO, this mapping does not exist. We know from (a) that Z is TR, but we know that A

_{TM}-bar is not TR. The TR languages are closed downward under ≤_{m}, so there cannot be a mapping reduction from a non-TR language to a TR language.

- (a, 10) Is the language Z a TR language? Prove your answer.

Last modified 15 April 2009