



Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!




Version: 2.
‘There must be some mistake,’ he said, ‘are you not a greater computer than the Milliard Gargantubrain at Maximegalon which can count all the atoms in a star in a millisecond?’ ‘The Milliard Gargantubrain?’ said Deep Thought with unconcealed contempt. ‘A mere abacus - mention it not.’ The Hitch Hiker’s Guide to the Galaxy, Douglas Adams.
In this lecture we will discuss the halting problem and diagonalization. This covers most of Sipser section 4.2.
There’s a widespread fascination with logical paradoxes. For example, in the Deltora Quest novel “The Lake of Tears” (author Emily Rodda), the hero Lief has just incorrectly answered the trick question posed by the giant guardian of a bridge.
“We will play a game to decide which way you will die,” said the man. “You may say one thing, and one thing only. If what you say is true, I will strangle you with my bare hands. If what you say is false, I will cut off your head.”
After some soul-searching, Lief replies “My head will be cut off.” At this point, there’s no way for the giant to make good on his threat, so the spell he’s under melts away, he changes back to his original bird form, and Lief gets to cross the bridge. The key problem for the giant is that, if he strangles Lief, then Lief’s statement will have been false. But he said he would strangle him only if his statement was true. So that does not work. And cutting off his head does not work any better. So the giant’s algorithm sounded good, but it turned out not to work properly for certain inputs. A key property of this paradox is that the input (Lief’s reply) duplicates material used in the algorithm. We’ve fed part of the algorithm back into itself.
2 The halting problem
Consider the following language
〈M, w〉
∣ M^ is a^ TM^ and^ M^ accepts^ w
We saw in the previous lecture, that one can build a universal Turing machine UTM that can simulate any Turing machine on any input. As such, using UTM, we have the following TM recognizing ATM:
Recognize-ATM( 〈M, w〉) Simulate M using UTM till it halts if M halts and accepts then accept else reject
Note, that if M goes into an in- finite loop on the input w, then the TM Recognize-ATM would run for- ever. This means that this TM is only a recognizer, not a decider. A decider for this problem would call a halt to simulations that will loop forever. So the question of whether ATM is TM decidable is equivalent to asking whether we can tell if a TM M will halt on input w. Because of this, both versions of this ques- tion are typically called the halting problem. We remind the reader that the language hierarchy looks as depicted on the right.
Regular
Context free grammar Turing decidable Turing recognizable
Not Turing recognizable.
So, let us suppose that the Halting problem (i.e., deciding if a word in is in ATM) were decidable. Namely, there is an algorithm that can solves it (for any input). this seems somewhat hard to believe since even humans can not solve this problem (and we still live under the delusion that we are smarter than computers). If we could decide the Halting problem, then we could build compilers that would auto- matically prevent programs from going into infinite loops and other very useful debugging tools. We could also solve a variety of hard mathematical problems. For example, consider the following program.
We can make an (infinite) table of how each Turing machine behaves on each input string. This table in de- picted on the right. Here, the ith row represents the ith TM Mi, where the jth entry in the row is acc if Mi accepts the jth word sj. The idea is now to define a language from the table. Consider the language Ldiag which is the language formed by taking the diagonal of this table.
s 1 s 2 s 3 s 4... M 1 acc acc rej rej... M 2 rej acc rej acc... M 3 acc rej acc acc... M 4 rej acc rej rej... .. .
Formally, the word si ∈ Ldiag if and only if Mi accepts the string si. Now, consider the complement language L = Ldiag. This language can not be recognized by an of the Turing machines on the list M 1 , M 2 ,.. .. Indeed, if Mk recognized the language L, then consider sk. There are two possibilities.
Thus, our assumption that all languages have a TM that recognizes them is false. Let us summarize this very surprising result.
Theorem 3.1 Not all languages have a TM that recognize them.
Intuitively, the above claim is a statement above infinities: There are way more languages (essentially, any real number defines a language) than TMs, as the number of TMs is count- able (i.e., as numerous as integer numbers). Since the cardinality of real numbers (i.e., ℵ) is strictly larger than the cardinality of integer numbers (i.e., ℵ 0 ), it follows that there must be an orphan language without a machine recognizing it.
A limitation of the preceding proof is that it does not identify any particular tasks that are not TM recognizable or decidable. Perhaps the problem tasks are only really obscure problems of interest only to mathematicians. Sadly, that is not true.
4 The Halting theorem
We will now show that a particular concrete problem is not TM decidable. This will let us construct particular concrete problems that are not even TM recognizable.
Theorem 4.1 (The halting theorem.) The language ATM is not TM decidable,
Proof: Assume ATM is TM decidable, and let Halt be this TM deciding ATM. That is, Halt is a TM that always halts, and works as follows
Halt
〈M, w〉
accept M accepts w reject M does not accept w.
We will now build a new TM Flipper, such that on the input 〈M 〉, it runs Halt on
the input 〈M, M 〉. If Halt
accepts than Flipper rejects, and if Halt
rejects than Flipper accepts. Formally
Flipper ( 〈M 〉) res ← Halt(〈M, M 〉) if res is accept then reject else accept The key observation is that Flipper always stops. Indeed, it uses Halt as a subroutine and Halt by our assumptions always halts. In particular, we have the following
Flipper
reject M accepts 〈M 〉 accept M does not accept 〈M 〉.
Flipper is a TM (duh!), and as such it has an encoding 〈Flipper〉. Now, consider running Flipper on itself. We get the following
Flipper
〈Flipper〉
reject Flipper accepts 0 〈Flipper〉 accept Flipper does not accept 〈Flipper〉.
This is absurd. Ridiculous even! Indeed, if Flipper accepts 〈Flipper〉, then it rejects it (by the above definition), which is impossible. As such, Indeed, if Flipper must reject (note, that Flipper always stops!) 〈Flipper〉, but then by the above definition it must accept 〈Flipper〉, which is also impossible. Thus, it must be that our assumption that Halt exists is false. We conclude that ATM is not TM decidable.
Corollary 4.2 The language ATM is TM recognizable but not TM decidable,
Let us redraw the diagonalization table from Sec- tion 3. This time, we will include only input strings that happen to be encodings of Turing ma- chines. The table on the right shows the behavior of Halt on inputs of the form 〈Mi, Mj 〉. Our con- structed TM Flipper takes two inputs that are identical 〈M, M 〉 and its output is the opposite of
Halt
M 1 rej acc rej rej... M 2 rej acc rej acc... M 3 acc acc acc rej... M 4 rej acc acc rej... .. .
So it corresponds to the negation of the entries down the diagonal of this table. Again, we essentially argued that there is no row in this infinite table that its entries are the negation of the diagonal. As such, our assumption that Halt is a decider, was false.