Notes on Models of Computation
Chapter 12
H. Conrad Cunningham
06 April 2022
Browser Advisory: The HTML version of this textbook requires a browser that supports the display of MathML. A good choice as of April 2022 is a recent version of Firefox from Mozilla.
Note: These notes were written primarily to accompany my use of Chapter 1 of the Linz textbook An Introduction to Formal Languages and Automata [[1].
In Linz Chapter 9, we studied the Turing thesis, which concerned what Turing machines can do.
This chapter we study: What Turing machines cannot do.
This chapter considers the concepts:
Recall the following definition from Chapter 9.
Linz Definition 9.4 (Turing Computable): A function with domain is said to be Turing-computable, or just computable, if there exists some Turing machine such that
, ,
for all .
Note:
Here we work in a simplified setting: the result of a computation is either “yes” or “no”. In this context, the problem is considered either decidable or undecidable.
Problem: We have a set of related statements, each either true or false.
This problem is decidable if and only if there exists a Turing machine that gives the correct answer for every statement in the domain. Otherwise, the problem is undecidable.
Example problem statement: For a context-free grammar , the language is ambiguous. This is a true statement for some and false for others.
If we can answer this question, with either the result true or false, for every context-free grammar, then the problem is decidable. If we cannot answer the question for some context-free grammar (i.e., the Turing machine does not halt), then the problem is undecidable.
(In Linz Theorem 12.8, we see that this question is actually undecidable.)
Given the description of a Turing machine and input string , does , when started in the initial configuration , perform a computation that eventually halts?
What is the domain ?
We cannot solve this problem by simulating . That is an infinite computation if the Turing machine does not halt.
We must analyze the Turing machine description to get an answer for any machine and string . But no such algorithm exists!
Linz Definition 12.1 (Halting Problem): Let be a string that describes a Turing machine and let be a string in ’s alphabet. Assume that and are encoded as strings of 0’s and 1’s (as suggested in Linz Section 10.4). A solution to the halting problem is a Turing machine , which for any and , performs the computation
if is applied to halts, and
,
if is applied to does not halt. Here and are both final states of .
Linz Theorem 12.1 (Halting Problem is Undecidable): There does not exist any Turing machine that behaves as required by Linz Definition 12.1. Thus the halting problem is undecidable.
Proof: Assume there exists such a Turing machine that solves the halting problem.
The input to is , where is a description of Turing machine . must halt with a “yes” or “no” answer as indicated in Linz Figure 12.1.
We next modify to produce a Turing machine with the structure shown in Linz Figure 12.2.
When reaches a state where halts, it enters an infinite loop.
From we construct Turing machine , which takes an input and copies it, ending in initial state of . After that, it behaves the same as .
The behavior of is
if applied to halts, and
if applied to does not halt.
Now is itself a Turing machine, which can be also be encoded as a string .
So, let’s apply to its own description . The behavior is
if applied to halts, and
if applied to does not halt.
In the first case, goes into an infinite loop (i.e., does not halt) if halts. In the second case, halts if does not halt. This is clearly impossible!
Thus we have a contradiction. Therefore, there exists no Turing machine . The halting problem is undecidable. QED.
It may be possible to determine whether a Turing machine halts in specific cases by analyzing the machine and its input.
However, this theorem says that there exists no algorithm to solve the halting problem for all Turing machines and all possible inputs.
Linz Theorem 12.2: If the halting problem were decidable, then every recursively enumerated language would be recursive. Consequently, the halting problem is undecidable.
Proof: Let be a recursively enumerable language on , be a Turing machine that accepts , and be an encoding of as a string.
Assume the halting problem is decidable and let be a Turing machine that solves it.
Consider the following procedure.
The above is thus a membership algorithm, so must be recursive. But we know that there are recursively enumerable languages that are not recursive. So this is a contradiction.
Therefore, cannot exist and the halting problem is undecidable. QED.
In the above, the halting problem is reduced to a membership algorithm for recursively enumerable languages.
A problem is reduced to problem if the decidability of implies the decidability of . We transform a new problem into a problem whose decidability is already known.
Note: The Linz textbook gives three example reductions in Section 12.1
Linz Theorem 12.3 (Empty Unrestricted Grammars Undecidable): Let be an unrestricted grammar. Then the problem of determining whether or not
is undecidable.
Proof: See Linz Section 12.2 for the details of this reduction argument. The decidability of membership problem for recursively enumerated languages implies the problem in this theorem.
Linz Theorem 12.4 (Finiteness of Turing Machine Languages is Undecided): Let be a Turing Machine. Then the question of whether or not is finite is undecidable.
Proof: See Linz Section 12.2 for the details of this proof.
Rice’s theorem, a generalization of the above, states that any nontrivial property of a recursively enumerable language is undecidable. The adjective “nontrivial” refers to a property possessed by some but not all recursively enumerated languages.
This section is not covered in this course.
Linz Theorem 12.8: There exists no algorithm for deciding whether any given context-free grammar is ambiguous.
Proof: See Linz Section 12.4 for the details of this proof.
Linz Theorem 12.9: There exists no algorithm for deciding whether or not
for arbitrary context-free grammars and .
Proof: See Linz Section 12.4 for the details of this proof.
Keep in mind that the above and other such decidability results do not eliminate the possibility that there may be specific cases–perhaps even many interesting and important cases–for which there exist decision algorithms.
However, these theorems do say that there are no general algorithms to decide these problems. There are always some cases in which specific algorithms will fail to work.
This section is not covered in this course.