The following problem is Turing recognizable but not decidable: \[ \probHALT = \setbuild{\encoding{M, w}}{M \text{ is a Turing machine that halts on } w} \]
Simple example of a Turing reduction:
showing that the no-input Halting problem is undecidable
\[ \probHALT_\emptystring = \setbuild{\encoding{M}}{M \text{ is a Turing machine and } M(\emptystring)} \]
\(\probHALT_\emptystring\) is obviously reducible to \(\probHALT\) since it is just a special case!
We could decide if \(\encoding{M} \in \probHALT_\emptystring\) by checking if \(\encoding{M, \emptystring} \in \probHALT\).
But \(\probHALT_\emptystring\) could easier…
Simple example of a Turing reduction:
showing that the no-input Halting problem is undecidable
\[ \probHALT_\emptystring = \setbuild{\encoding{M}}{M \text{ is a Turing machine and } M(\emptystring)} \]
Theorem: \(\probHALT_\emptystring\) is undecidable.
Proof:
Suppose that \(\probHALT_\emptystring\) is decidable by an algorithm:
def H_𝜀(M): raise NotImplementedError()
We can use this to decide \(\probHALT\) as follows:
def H(M, w):
# Create a new algorithm T_Mw that ignores its input
# and has the original input w "hardcoded".
def T_Mw(_): # This is algorithm is never actually run!!!
return M(w)
return H_𝜀(T_Mw) # ... but instead is analyzed by H_𝜀.
M(w)
halts, then:
T_Mw
halts on all inputs (including \(\emptystring\)).H_𝜀(T_Mw)
returns True
.M(w)
loops (doesn’t halt), then:
T_Mw
loops on any input.H_𝜀(T_Mw)
returns False
.H
decides \(\probHALT\), which is a contradiction.The previous argument follows a pattern we will use to show that many other questions we might ask about an algorithm’s eventual behavior are undecidable.
We prove that an algorithm \(A\) deciding that other question cannot exist by showing it can be used to solve the Halting problem.
Specifically, we will use it to solve \(\probHALTe\), which is slightly more convenient.
The steps are:
The resulting \(A\) will return true if and only if \(M(\emptystring)\) halts, thus deciding \(\probHALTe\).
Let’s apply this recipe to the following problem:
\[ \probAccepts = \setbuild{\encoding{M, w}}{M \text{ is a Turing machine that accepts } w} \]
Theorem: \(\probAccepts\) is undecidable.
Proof:
Suppose that \(\probAccepts\) is decidable by alg. A
:
def A(M, w): raise NotImplementedError()
We can use A
to decide \(\probHALTe\) as follows:
def H_𝜀(M):
# Create a new algorithm T_M that accepts any input
# if and only if M halts on the empty string.
def T_M(w): # Input is ignored!
M('')
return True
return A(T_M, '011') # Analyze T_M using hypothetical decider A
M('')
halts, then:
T_M
returns True
on all inputs.A(T_M, w)
and H_𝜀
return True
.M('')
loops (does not halt), then:
T_M
never reaches the return
.A(T_M, w)
and H_𝜀
return False
.H_𝜀
decides \(\probHALTe\),\[ \probEmpty = \setbuild{\encoding{M}}{M \text{ is a Turing machine and } L(M) = \emptyset} \]
In other words: \(M\) accepts no inputs.
Theorem: \(\probEmpty\) is undecidable.
Proof:
Suppose that \(\probEmpty\) is decidable by algorithm E
:
def E(M): raise NotImplementedError()
We can use E
to decide \(\probHALTe\) as follows:
def H_𝜀(M):
# Create a new algorithm that accepts a string
# if and only if M halts on the empty string.
def T_M(w):
M('')
return True
return not E(T_M) # Analyze T_M using hypothetical decider E
M('')
halts, then:
T_M
returns True
on all inputs.E(T_M, w)
returns False
andH_𝜀
returns True
.M('')
loops (does not halt), then:
T_M
never reaches the return
.E(T_M, w)
returns True
andH_𝜀
returns False
.H_𝜀
decides \(\probHALTe\),Could we instead make T_M
return False
and H_𝜀
return E(T_M)
?
\[ \probRejects = \setbuild{\encoding{M}}{M \text{ is a Turing machine that rejects at least one input}} \]
Theorem: \(\probRejects\) is undecidable.
Proof:
Suppose that \(\probRejects\) is decidable by algorithm R
:
def R(M): raise NotImplementedError()
We can use R
to decide \(\probHALTe\) as follows:
def H_𝜀(M):
# Create a new algorithm that rejects a string
# if and only if M halts on the empty string.
def T_M(w):
M('')
return False
return R(T_M) # Analyze T_M using hypothetical decider R
M('')
halts, then:
T_M
returns False
on all inputs.R(T_M, w)
returns True
andH_𝜀
returns True
.M('')
does not halt, then:
T_M
never reaches the return
.R(T_M, w)
returns False
andH_𝜀
returns False
.H_𝜀
decides \(\probHALTe\),return
without a subroutine call?f
?Which of the following problems is decidable about a problem \(P\) and input \(x\)?