Question text is in black, solutions in blue.

- Answer the problems on the exam pages.
- There are eight problems for 120 total points plus 15 extra credit. Actual scale was A = 105, C = 69.
- If you need extra space use the back of a page.
- No books, notes, calculators, or collaboration.
- The first five questions are statements -- in each case say whether the statement is true or false and give a convincing justification of your answer -- a proof, counterexample, quotation from the book or from lecture, etc. You get five points for the correct boolean answer (so there is no reason not to guess if you don't know) and up to five for the justification.

Q1: 10 points Q2: 10 points Q3: 10 points Q4: 10 points Q5: 10 points Q6: 25 points Q7: 15 points Q8: 30+15 points Total: 120+15 points

Correction in orange added 20 March 2015.

If C is any class of computers, such as DFA's, CFG's, LBA's TM, strange variant TM's, etc.:

- A
_{C}= {(M, w): M is a computer in C and w ∈ L(M)} - E
_{C}= {(M): M is a computer in C and L(M) = ∅} - ALL
_{C}= {(M): M is a computer in C and L(M) = Σ^{*}} - EQ
_{C}= {(M, N): M and N are computers in C and L(M) = L(N)} - REG
_{C}= {(M): M is a computer in C and L(M) is a regular language} - COMP
_{C}= {(M, N): M and N are computers in C and L(M) is the complement of L(N)}

The language DECIDER is the set {(M): M halts (either accepts or rejects) on every input}.

Recall that if A and B are two languages, A is **mapping
reducible** to B, written A ≤_{m} B, if there exists a
function f: Σ^{*} → Σ^{*} such that
for any string w, w ∈ A ↔ f(w) ∈ B.

A language A is **Turing recognizable (TR)** if it equals L(M)
for some Turing machine M.

A is **Turing decidable** if A = L(M)
for some Turing machine M that always halts.

A function f is
**Turing computable** if there exists a Turing machine M such
that for any string w, M when started on w halts with f(w) on its
tape.

A **stupid Turing machine (STM)** has one tape which "wraps
around" -- moving left from its leftmost cell takes you to its
rightmost cell, and moving right from its leftmost cell takes you to
its leftmost cell. It begins with the input string filling the
entire tape.

A **very stupid Turing machine (VSTM)** is like an STM except
that for some of its state-letter pairs it may replace the current
cell with two cells, writing to both of them, instead of just
writing to the current cell. Thus its transition function is
δ (Q × Σ) ↔ (Q × (Σ ∪
(Σ × Σ)) × {L, R}).

The function S from **N** × **N** to **N** is
defined as follows. Consider all the k-state Turing machines with
tape alphabet {0, 1, blank} and consider all input strings in {0,
1}^{n}. S(k, n) is the number of steps taken by the
*longest* of any of the halting computations of any of these
machines on any of these inputs. (This is similar to the "busy
beaver function" but is not exactly the same thing.)

**Question 1 (10):***True or false with justification:*The language A_{STM}is Turing decidable.TRUE. The size of the tape never changes. On input w of length n, if the STM runs for more than |Q||Σ|

^{n}+ 1 steps, it must have repeated a configuration and (since it is deterministic) it must be in a loop. So an ordinary TM can simulate the STM for that many steps and reject if it hasn't halted at the end of them.**Question 2 (10):***True or false with justification:*The language A_{VSTM}is Turing decidable.FALSE.. A

_{TM}≤_{m}A_{VSTM}. We convert an arbitrary one-tape TM M into an equivalent VSTM M' by having it use the two-cell write to add a blank cell to the right end of the tape when needed. We also put markers on M' so that it will never use its wraparound. Then the reduction has (M, w) ∈ A_{TM}if and only if (M', w) ∈ A_{VSTM}.**Question 3 (10):***True or false with justification:*Any regular language is the language of some STM.TRUE. An STM can simulate a DFA by marking the first cell of its tape, simulating the DFA until it sees the first square again, then accepting if and only if the DFA is in a final state.

**Question 4 (10):***True or false with justification:*It is not true that REG_{CFG}≤_{m}REG_{TM}.FALSE. It is true that REG

_{CFL}≤_{m}REG_{TM}. Given a CFG G, our reduction function just needs to output a Turing machine M_{G}that has the same language as G. On input w, M_{G}can run the CKY algorithm, or the slower decision procedure for A_{CFG}given in Sipser, to test whether w is in L(G). Thus (G) ∈ REG_{CFG}⇔ (M_{G}) ∈ REG_{TM}.**Question 5 (10):***True or false with justification:*The set of all TR languages is countably infinite.TRUE. Every TR language is L(M) for some Turing machine M. Every TM M is represented by a finite string (M) over {0, 1}. The set of strings over any finite alphabet is in bijection with

**N**and thus is countably infinite. The (M) strings are a subset of this countably infinite set and are thus countable. It remains to show that the set of TR languages is*infinite*-- this follows, for example, from the fact that every singleton language {w} is TR.**Question 6 (25):**These questions use the definition of the language COMP_{C}above.- (a, 10) Prove that the language COMP
_{NFA}is Turing decidable.COMP

_{NFA}= {(N, N'): L(N) = Σ^{*}∖ L(N')}. We need an always-halting TM that will decide whether the languages of N and N' are complements, given input (N, N'). It will first construct DFA's D and D' with L(D) = L(N) and L(D') = L(N') by the subset construction. Then it builds another DFA D'' such that L(D'') is the symmetric difference of L(D) and L(D') -- the set of strings that are in both L(D) and L(D'), or are in neither. Finally it searches the graph of D'' to see whether there is a path from its start state, with any labels, to any final state. If so it rejects, if not it accepts. - (b, 15) Is the language COMP
_{CFG}Turing decidable? Prove your answer.It is NOT Turing decidable. Let G

_{∅}be a fixed grammar with no rules, so that L(G_{∅}) = ∅. Given any grammar G, define f(G) to be the pair (G, G_{∅}). Then G ∈ ALL_{CFG}⇔ (G, G_{∅}) ∈ COMP_{CFG}. This reduction proves that ALL_{CFG}≤_{m}COMP_{CFG}. Since ALL_{CFG}is not TD, neither is COMP_{CFG}.

- (a, 10) Prove that the language COMP
**Question 7 (15):**Prove that the function S from**N**×**N**to**N**, defined above, is not Turing computable. (Hint: Assume that it is, and from this assumption prove the statement "A_{TM}is Turing decidable", which we know to be false.)Here is a decider for A

_{TM}, given the assumption that the function S exists. On input (M, w), recode M and w if necessary so that M's tape alphabet is {0, 1, blank} and w is in {0, 1}^{*}. Then let k be the number of states in M and let n = |w|. Simulate M on w for at most S(k, n) steps. If it halts, accept or reject as it does. If it runs out of time, reject.If M halts on w, by the definition of S it must do so within S(k, n) steps. So this decider accepts (M, w) if and only if M accepts w, and thus it decides the undecidable language A

_{TM}.**Question 8 (30+15):**These questions use the definitions of the languages DECIDER and COMP_{C}from above.- (a, 10): Prove, by any valid method, that DECIDER is not
Turing decidable.
We reduce A

_{TM}to DECIDER. Given a pair (M, w), let f(M, w) be the TM N that ignores its input and then runs M on w, accepting if M accepts w and going into an infinite loop if M rejects w. If (M, w) ∈ A_{TM}, N halts on any input and thus (N) ∈ DECIDER. But if (M, w) ∉ A_{TM}, then N never halts on any input and thus N ∉ DECIDER. This f is the desired reduction, and thus DECIDER must be undecidable because A_{TM}is. - (b, 5XC): Prove, using the Recursion Theorem, that DECIDER
is not Turing decidable. (Hint: Assume that there is a decider
for DECIDER and that you can design a machine to obtain its own
description, and derive a contradiction.)
Define the following machine D. On input w, D obtains its own description (D). If w and (D) are not the same string, D accepts w. Otherwise, D uses the assumption to decide whether (D) ∈ DECIDER. If it is, D runs forever, and if it is not, D accepts.

Thus D halts on all inputs if and only if (D) ∉ DECIDER, which is a contradiction.

Many people wanted to allow the DECIDER-decider to obtain its own description, but the Recursion Theorem only says that you can design a

*new*machine to obtain its own description and then do something with it. - (c, 10): Prove that DECIDER is not Turing recognizable.
(Hint: You could show that the complement of A
_{TM}is ≤_{m}DECIDER, but it may be easier to show that ALL_{TM}≤_{m}DECIDER. You may assume without proof that ALL_{TM}is not TR.We show ALL

_{TM}≤_{m}DECIDER. Let f((M)) be (M'), so that M' is a machine that runs forever on input w if M rejects w, and accepts w if M accepts w. (It does not halt on w if M does not halt on w.) Then (M) ∈ ALL_{TM}⇔ (M') ∈ DECIDER. - (d, 10): Prove that DECIDER
≤
_{m}COMP_{TM}. What can you conclude about COMP_{TM}from this result?Given any Turing machine M, let f(M) = (M, M') where M' is a machine that accepts a string w if and only if M halts and rejects it. If (M) ∈ DECIDER, (M, M') is in COMP

_{TM}because every string is either accepted or rejected by M, but not both, so that L(M) and L(M') are complements. If (M) ∉ DECIDER, then there exists a string w such that M does not halt on w, and this w is in neither L(M) nor L(M'), so that L(M) and L(M') are not complements.Together with (c), this proves that COMP

_{TM}is not TR. Together with (e), it proves that COMP_{TM}is Π_{2}hard. - (e, 10XC): Recall that a language A is in the class
Π
_{2}if there is some Turing decidable language B such that for any string w, w ∈ A if and only if ∀x:∃y: (w, x, y) ∈ B. Prove that if A is any language in Π_{2}, then A ≤_{m}DECIDER.Let A satisfy the statement ∀w: [w ∈ A ⇔ ∀x:∃y: (w, x, y) ∈ B] for some TD language B.

Given any string w, let M be a TM that on input x, looks for a y such that (w, x, y) is in B, by trying all y's in parallel by dovetailing. (For example, for each n in succession it could run the test for each of the first n y's, for n steps each.)

Now w ∈ A ⇔ ∀x:∃y: (w, x, y) ∈ B ⇔ ∀x: halts on input x ⇔ (M) ∈ DECIDER.

(An alternate proof is to observe that we proved A ≤

_{m}ALL_{TM}on the homework, and then use part (d) and the transitivity of ≤_{m}.)

- (a, 10): Prove, by any valid method, that DECIDER is not
Turing decidable.

Last modifie 20 March 2015