This is a series of problems on the use of Turing Machines to explore decidability.
Try to solve each problem on your own, before revealing the solution.
1 Proof by Construction
Some problems, usually ones that ask you to prove a positive result, are done describing the construction of a TM to solve a desired problem.
1.1 Does it Move?
We’ve discussed the common variant of allowing Turing Machines an option of keeping the head in the same place after a transition instead of always moving one space to the left or right.
Let fixed(T) be the property that one of these extended Turing machines T never moves its head to the left or to the right, on any input that it accepts.
Prove that this property is recursive.
Note: You cannot do this simply by inspecting the finite state control of the TM and seeing whether it has any transitions marked L or R. You have to consider the possibility that any such transitions might not actually be triggered by any possible input.
Answer
For any TM $T$, form a new machine $T’$ by removing any transitions with L or R moves, so that that $T’$ halts, failing, on any such transition.
If a Turing machine never moves its head, then it reads and writes to only a single cell of its tape. We can form a new machine $T’‘$ from $T’$, in which, instead of reading and writing from the tape, we store a symbol “in the state”.
If $T’’$ accepts a non-empty language, then $T$ would accept that language without moving its head.
$T’’$ now does not use its tape in any way except to read the first symbol of input. (If a TM accepts a language without moving its head, that language can consist only of strings of a length 0 or 1.)
But that means that its finite controller is just an ordinary DFA, and we can determine whether it accepts a non-empty language in finite time. (Try to trace a path from the starting state to any accepting state. Since there are only a finite number of states and edges/transitions, this can be done by any basic graph traversal algorithm.)
1.2 The Bounded UTM
A Universal Turing machine (UTM) accepts a code for a Turing machine M and a string w, encoded as M111w.
Now consider a variation on the UTM that accepts input of the form M111w111s, where s is an integer (in unary form, a string of zeros) representing a number of steps. Can you construct a TM, a “bounded UTM”, that accepts strings of that form if and only if the TM $M$ accepts the input $w$ in $s$ or fewer steps?
Answer
The UTM described in the text is already a multi-tape TM. Let’s add one more tape, which I’ll call the step-counter tape.
Our new TM starts by moving to the second 111 fence of its input, erasing the 111, then copying all zeros after that to the step-counter tape, erasing them from the input tape as we go.
Leave the head of the step-counter tape on the rightmost copied zero.
Move the input tape’s head back to the leftmost character of the input. That input tape has now been reduced to the form M111w, the conventional input format for the UTM.
We then enter a copy of the UTM, with a slight modification.
The UTM works by repeatedly simulating the transitions of the encoded machine $M$.
We add to the UTM transition that starts a simulated transition a transition on the new step-counter tape: $0; \sqcup; L$. On the step counter tape, we must be looking at a zero. If so, we move left one step on the step-counter tape. If we aren’t looking at a zero, there is no legal transition and the UTM will halt, not in an accepting state.
To all other transitions of the UTM, we add the transitions $0; 0; S$ and $\sqcup; \sqcup; S$ on the step-counter tape. These say that, whatever we are looking at on the step-counter tape (must be either zero or a blank), we leave it unchanged and do not move the head. So the step-counter tape only affects the execution of the UTM at the start of a simulated transition.
The net effect is that, if the UTM halts in an accepting state within the first $s$ simulated transitions of $M$, then our bounded UTM accepts and halts. If the UTM halts in a non-accepting state withn the first $s$ simulated transitions, our bounded UTM also halts in a non-accepting state. And if the UTM would try to start an $s+1$st transition, our bounded UTM will halt in a non-accepting state.
2 Reductions
Negative results, showing that a problem P is not recursive or not RE, are often achieved by reducing a known non-recursive or non-RE problem to P, so that if P could be solved, then the other problem would be solved as well, thereby raising a contradiction.
2.1 The Halting Problem is not Recursive
The halting problem is the problem of determining, given a pair $(T,w)$ consisting of a Turing machine $T$ and a string $w$, whether $T$ halts when presented $w$ as input, regardless of whether $T$ accepts $w$ or not.
Prove that the halting problem is not recursive i.e., there is no algorithm that can determine whether an arbitrary $T$ halts on an arbitrary $w$.
Answer
We know that $L_u$ is not recursive. There is no algorithm to determine whether an arbitrary pair $(T,w)$ represents a TM that accepts the string $w$.
Suppose, by way of contradiction, that the halting problem is recursive.
Then, if we wanted to determine whether a Turing machne $T$ accepts $w$, we could do the following:
Determine whether $T$ halts on input $w$. (We’ve just assumed that an algorithm exists that can do this.)
If it does, execute $T$ on $w$ and see whether, when $T$ halts, it does so in an accepting state. If so, accept $(T,w)$.
If $T$ does not halt on $w$, reject $(T,w)$.
In this manner, we could test whether $T$ accepts $w$ by using our assumed algorithm for determining halting. We have “reduced $L_u$ to the halting problem”.
So, if the halting problem is recursive, then so is $L_u$. But we know that $L_u$ is not recursive, so the assumption that the halting problem was recursive must be false.
2.2 The Halting Problem is RE
The previous problem establishes that we cannot decide whether a TM halts on a given input. Now consider the weaker problem of whether we can list (given infinite time) the $(T,w)$ pairs such that $T$ halts on input $w$.
Prove that the halting problem is recursively enumerable, i.e., there is a Turing machine that enumerates all such (T,w) pairs.
Answer
For this we can use our bounded UTM from the earlier problem.
The input to the bounded UTM is simply a binary integer, though only numbers of the form T111w111s, where $T$, $w$, and $s$ are strings of zeros, are valid inputs.
Construct a simple two-stage TM $T$ that
Makes one pass over its input and checks see if it is in the required T111w111sform, halting (not accepting) if it is not.
If the input is in the required form, reposition the tape head at the leftmost non-blank symbol. Then enter the bounded UTM we described earlier.
Now enumerate the integers, starting at 0, running $T$ on each. If $T$ halts in an accepting state, we list the $(T,w)$ of our T111w111s encoding as an accepted pair.
Since the bounded UTM takes a finite number of steps on each input, this process never “hangs” on any single input and will eventually list any $(T,w)$ pair such that $T$ halts when presented $w$ as an input.
3 Rice’s Theorem
Rice’s theorem is a powerful tool for proving negative results about sets of languages.
Rice’s Theorem states that all non-trivial properties of the RE languages are undecidable.
To use it we must do two things:
Express the problem as a property of the RE languages.
Show that the property is not trivial: the set is neither empty nor universal.
3.1 Does a TM Accept a Regular Langauge?
Use Rice’s Theorem to prove that it is undecidable whether an arbitrary TM accepts a regular language.
Note that if we start with a regular language, we can pretty easily construct a TM to recognize it. But this problem works in the other direction: Given a TM, can we tell if it accepts a regular language?
Because TMs can be arbitrarily (over-)complicated, it’s much harder to work the problem in this direction.)
Answer
First, we have to re-formulate this question as a property of the RE langauges.
Are the regular languages RE? We might suspect that they are simply because we “know” that TMs are more powerful than FAs and therefore the regular languages are a subset of the RE languages.
But we can show this more directly: We have previously established that it is possible to enumerate all possible regular languages by structural induction over the regular expression operators:
List all RE’s over a fixed alphabet that have 0 operators.
List all RE’s over that same alphabet that have 1 operator. Since the only operators are concatentation, alternation (+), and closure (*), this is clearly a finite list.
List all RE’s with $k$ operators by
For each previously listed RE $R$ with $k-1$ operators, $R*$ is an RE with $k$ operators.
For each previously listed RE $R$ with $i < k$ operators and for each each previously listed RE $S$ with $k-i$ operators, $R+S$ and $RS$ are REs with $k$ operators.
In this manner, it is possible to enumerate all of the regular expressions and therefore all of the regular languages. So the regular languages are RE.
Now consider the triviality of this property.
Is the set of Turing machines that accept a regular language empty?
No. Consider the regular language ${}$. A TM that halts immediately in an accepting state accepts this language.
Is the set of Turing machines that accept a regular language the set all Turing machines?
No. consider the TM that accepts $0^i1^i$, which we know is not regular and therefore not in this set.
Since the set of Regular Languages is RE but the property is non-trivial, Rice’s theorem applies and the problem is undecidable.