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.
Reveal
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?
Reveal
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 within 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$.
Reveal
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 machine $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.
Reveal
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.
2.3 Halting on empty input
Many problems can be proven by reduction to the halting problem.
For example, is it decidable whether an arbitrary Turing machine halts when presented with an empty input tape?
Reveal
No, it is not decidable.
Let $L_{\epsilon}$ denote the set of all (binary encodings of) TMs that halt on an empty input.
Assume BWOC, that $L_{\epsilon}$ is recursive and that we have a TM $M_{\epsilon}$ that accepts it.
Now, let’s revisit the halting problem.
Consider a new TM M` designed along the following lines:
M'(x) {
erase everything on the tape
write $M_{\epsilon}111x$ onto the tape.
run U to simulate $M_{\epsilon}$
}
Now, for some arbitrary $M_i$ and $w_j$, run $M’(M_i111w_j)$.
If $M_{\epsilon}111x$ really is decidable, then M’ will halt and tell us whether $U(M_i111w_j)$ halts, which is equivalent to asking whether $M_i$ halts on input $w_j$.
We know that the halting problem is not decidable. So out assumption that $L_{\epsilon}$ is recursive must be false.
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.
Try to use Rice’s theorem to answer the following:
3.1 Accepting an Infinite Number of Strings
Is it decidable whether an arbitrary TM accepts an infinite number of strings?
Reveal
No.
Having an infinite number of strings is clearly a language property.
It is also pretty clearly not a property held by all languages nor by no languages.
3.2 Accepting 1011
Is it decidable whether an arbitrary TM accepts a particular input, e.g., 1011?
Reveal
No.
Containing that string is clearly a language property.
It is also pretty clearly not a property held by all languages nor by no languages.
3.3 Accepting All Strings Over its Alphabet
Is it decidable whether an arbitrary TM over alphabet $\Sigma$ accepts all strings in $\Sigma *$?
Reveal
No.
Being equal to that set is clearly a language property.
It is also pretty clearly not a property held by all languages nor by no languages.
3.4 Never Moving Far
Is it decidable whether an arbitrary TM never moves more than 2 steps to the left or right of its starting position?
Reveal
In fact, this is not a property of the language but of specific Turing machines. Consequently, Rice’s theorem is of no use here.
For the record, this is actually decidable. Given a fixed number of states and a fixed number of steps we want to allow, we can enumerate all of the possible intermediate states that the TM could generate within that number of steps of the start, and see whether any of them would cause it to move further away.