“The only way to parse Perl 5 is to run it or to simulate it using a language of equivalent power… There is no guarantee a Perl 5 program will ever finish running and no guarantee it will ever finish parsing itself… In this article I will use Rice’s Theorem to prove that Perl is unparseable.”
—Jeffrey Kegler
For many examples where the language is a set of Turing Machines (code), there is a very easy shortcut to show the language is not decidable. But to explain that shortcut, known as Rice’s Theorem, we need to define some more terminology.
A property of a Turing Machine is said to be functional if it depends only on the language of the Turing Machine, and not on the details of the implementation (states and transitions).
That is, the property is functional if whenever two machines accept the same language either both machines have the property or neither does.
00011 (i.e., whether 00011 is in the
language) is a functional property00011 is not a functional property.
“The TM that rejects every input” and “the TM that infinite-loops on
every input” have the same language (the empty set), but only one of
these TMs rejects 00011.
A property of Turing Machines is said to be nontrivial if there’s at least one TM with the property and at least one TM lacking the property.
It is trivial if all TMs have the property or TMs lack the property.
00011 is a nontrivial property. Some TMs
accept 00011 and others don’t.No functional and nontrivial property of Turing Machines is decidable.
None of the following languages is decidable:
Proof: by Rice’s Theorem.
Rice’s Theorem is so easy to apply, it can be tempting to overuse it.
Rice’s Theorem doesn’t apply to languages like the following:
This is a set of pairs, not a set of TMs.
This is another set of pairs of TMs, not a set of TMs.
This is a set of TMs, but not a functional property.
This is a set of TMs, but not a functional property.
Rice’s Theorem tells us the following languages are not decidable, but doesn’t say anything about whether they might be semidecidable or not.
Two of these undecidable languages are semidecidable and the rest are not semidecidable, but we can’t prove this with Rice’s Theorem.
No functional and nontrivial property of Turing Machines is decidable.
Proof:
Let be a set of TMs having some nontrivial, functional property.
To show: .
Without loss of generality, where is some always-reject TM. If , then we restart the proof to show is not decidable. It will then follow that is not decidable.
Let be some TM with the property. contains TMs having some nontrivial property, so there’s at least one TM in .
Let be the function that turns into (code for) a TM that takes an input and accepts if accepts and accepts .
So if and only if , as required.
