An engineer and a mathematician are out for a walk and spot a house on fire. There is a garden hose lying in the yard; the engineer quickly hooks it up and puts out the fire.
They continue walking and see a home where a couple is washing a car in their driveway.
The mathematician detaches their hose and sets their house on fire, thus reducing the situation to a previously solved problem.
We proved that is undecidable using a tricky proof by contradiction. If we want to prove that other languages are undecidable, we can try to find similar tricks. But a simpler strategy is to leverage what we have already proved, a method known as reduction.
Given problems and , we say that reduces to , written
if a solution to would let us solve as well.
The notation is odd at first glance. The best way to think about is that it refers to difficulty; is easier (or at least, no harder) than if solving also tells us how to solve .
Not surprisingly, any formal language that is harder to decide than an undecidable language is also undecidable.
The language
is semidecidable, but not decidable.
Proof of Semidecidability: To show that is semidecidable, we can just give the algorithm for a semidecider, namely:
def semidecide_Halt(M, w):
simulate(M, w)
return TrueThat is, a semidecider for can simulate the given machine on the given input. If this halts then (whether it accepts or rejects) the semidecider accepts the pair. If the machine runs forever on that input, the semidecider returns no answer.
Proof of Undecidability: We will show that , i.e. that if we could decide then we could decide . Since we know is not decidable, it follows that is not decidable either.
In other words, as soon as we prove that is at least as hard as the undecidable , we know that is undecidable too.
Here is why :
Suppose we could build a decider decide_Halt for
.
Then we could build a decider decide_Atm for
as follows:
def decide_Atm(M, w):
if decide_Halt(M, w):
return simulate(M, w)
else:
return FalseThat is, to correctly predict whether will accept , we first check whether will halt on . If so, we can run on and be sure we will see it accept or reject in a finite amount of time. If not, we know does not accept and can report that immediately.
A typical decidability reduction proof that goes as follows:
Assume there is a decider for .
[Show an algorithm for deciding .]
Therefore reduces to . QED.
The direction is important. We assume the right-hand-side is decidable, and show that, if so, the left-hand-side is decidable.
A successful proof guarantees that
“if is decidable, then then is decidable.”
This direction is easiest to prove, but the logically equivalent contrapositive is more useful, namely
“if is not decidable, then is not decidable.”
This means that if we do a reduction proof where is a language like that we already know is not decidable, then our reduction proof guarantees that is not decidable.
For example, in the example above we proved that (i.e., if is not decidable, then is not decidable). It immediately follows that is not decidable. So then if we manage to prove for some other language , it will immediately follow that is not decidable either. In this way, we can use reduction to prove that more and more languages are not decidable.
We can show is undecidable by proving .
Proof 1
Suppose there were a decider decide_Aprime for
.
Then we could decide as follows:
Suppose we want to know if .\
Construct a TM that is exactly like plus enough extra dummy/unreachable/useless states so that it has a prime number of states.
We haven’t changed the essential functionality of the TM, so , and accepts iff accepts .
We can run decide_Aprime on and to find out
whether accepts and has a prime number of states.
Since has a prime number of states by construction, the result (true or false) tells us whether accepts , and hence whether accepts .
Proof 2
Suppose there were a decider decide_Aprime for
.
Then we could decide as follows:
Suppose we want to know if .
Let be the number of states in .
Construct TMs such that is just like but with extra dummy/unreachable states.
A bit of number theory (for any , there is a prime number between and ) guarantees that at least one of the ’s has a prime number of states.
Run decide_Aprime on and for all .
If at least one answer is “yes” then accepts . Otherwise, does not accept .
A typical semidecidability reduction proof that goes as follows:
Assume there is a semidecider for .
[Show an algorithm for semideciding .]
Therefore reduces to . QED.
A successful proof guarantees that
“if is not semidecidable, then is not semidecidable.”
This means that if we do a reduction proof where is a language like that we already know is not semidecidable, then our reduction proof guarantees that is not semidecidable.
Irritatingly, the notation and terminology ” reduces to ” can either mean “if is decidable then so is ” or “if is semidecidable then so is ,” and these are not equivalent statements. Context usually tells us which meaning is intended.