Introduction to Computability Theory

Introduction to Computability
Theory
Lecture12: Reductions
Prof. Amos Israeli
1
Introduction
The rest of the course deals with an important
tool in Computability and Complexity
theories, namely: Reductions.
The reduction technique enables us to use the
undecidability of ATM to prove many other
languages undecidable.
2
Introduction
A reduction always involves two computational
problems. Generally speaking, the idea is to
show that a solution for some problem A
induces a solution for problem B. If we know
that B does not have a solution, we may
deduce that A is also insolvable. In this case
we say that B is reducible to A.
3
Introduction
In the context of undecidability: If we want to
prove that a certain language L is
undecidable. We assume by way of
contradiction that L is decidable, and show
that a decider for L, can be used to devise a
decider for ATM . Since ATM is undecidable, so
is the language L.
4
Introduction
Using a decider for L to construct a decider for
ATM , is called reducing L to ATM .
Note: Once we prove that a certain language L
is undecidable, we can prove that some other
language, say L’ , is undecidable, by reducing
L’ to L.
5
Schematic of a Reduction
1. We know that A is undecidable.
2. We want to prove B is undecidable.
3. We assume that B is decidable and use this
assumption to prove that A is decidable.
4. We conclude that B is undecidable.
Note: The reduction is from A to B.
6
Demonstration
1. We know that A is undecidable.
The only undecidable language we know, so
far, is ATM whose undecidability was proven
directly. (In the discussion you also proved
directly that HALTTM is undecidable). So we
pick ATM to play the role of A.
2. We want to prove B is undecidable.
7
Demonstration
2. We want to prove B is undecidable.
We pick HALTTM to play the role of B that is:
We want to prove that HALTTM is
undecidable.
3. We assume that B is decidable and use this
assumption to prove that A is decidable.
8
Demonstration
3. We assume that B is decidable and use this
assumption to prove that A is decidable.
In the following slides we assume (towards a
contradiction) that HALTTM is decidable and
use this assumption to prove that ATM is
decidable.
4. We conclude that B is undecidable.
9
The “Real” Halting Problem
Consider


HALTTM  M , w  M is a TM that halts on w
Theorem
HALTTM is undecidable.
Proof
By reducing HALTTM to ATM .
10
Discussion
Assume by way of contradiction that HALTTM is
decidable.
Recall that a decidable set has a decider R: A TM
that halts on every input and either accepts
or rejects, but never loops!.
We will use the assumed decider of HALTTM to
devise a decider for ATM .
11
Discussion
Recall the definition of ATM :


ATM  M , w  M is a TM thataccepts w
Why is it impossible to decide ATM ?
Because as long as M runs, we cannot determine
whether it will eventually halt.
Well, now we can, using the decider R for
HALTTM .
12
Proof
Assume by way of contradiction that HALTTM is
decidable and let R be a TM deciding it. In
the next slide we present TM S that uses R as
a subroutine and decides ATM . Since ATM is
undecidable this constitutes a contradiction,
so R does not exist.
13
Proof (cont.)
S=“On input M , w where M is a TM:
1. Run R on input M , w until it halts.
2. If R rejects, (i.e. M loops on w ) - reject.
(At this stage we know that R accepts, and we
conclude that M halts on input w.)
3. Simulate M on w until it halts.
4. If M accepts - accept, otherwise - reject. “
14
Another Example
In the discussion, you saw how Diagonalization
can be used to prove that HALTTM is not
decidable.
We can use this result to prove by reduction
that ATM is not decidable.
15
Another Example
Note: Since we already know that both ATM and
HALTTM are undecidable, this new proof does
not add any new information. We bring it
here only for the the sake of demonstration.
16
Demonstration
1. We know that A is undecidable.
Now we pick HALTTM to play the role of A.
2. We want to prove B is undecidable.
We pick ATM to play the role of B, that is: We
want to prove that ATM is undecidable.
3. We assume that B is decidable and use this
assumption to prove that A is decidable.
17
Demonstration
3. We assume that B is decidable and use this
assumption to prove that A is decidable.
In the following slides we assume that ATM
is decidable and use this assumption to prove
that HALTTM is decidable.
4. We conclude that B is undecidable.
18
Discussion
Let R be a decider for ATM . Given an input
for M , w , R can be run with this input :
If R accepts, it means that M , w  ATM .
This means that M accepts on input w. In
particular, M stops on input w. Therefore, a
decider for HALTTM must accept M , w too.
19
Discussion
If however R rejects on input M , w , a decider
for HALTTM cannot safely reject: M may be
halting on w to reject it. So if M rejects w, a
decider for HALTTM must accept M , w .
20
Discussion
How can we use our decider for ATM ?
The answer here is more difficult. The new
decider should first modify the input TM, M,
so the modified TM, M1 , accepts, whenever
TM M halts.
Since M is a part of the input, the modification
must be a part of the computation.
21
Discussion
Faithful to our principal “ If it ain’t broken don’t
fix it”, the modified TM keeps M as a
subroutine, and the idea is quite simple:
Let qaccept and qreject be the accepting and
rejecting states of TM M, respectively. In the
modified TM, M1 , qaccept and qreject are kept
as ordinary states.
22
Discussion
We continue the modification of M by adding a
new accepting sate nqaccept . Then we add
two new transitions: A transition from
qaccept to nqaccept , and another transition
from qreject to nqaccept .
This completes the description of M1 . It is not
hard to verify that M1 accepts iff M halts.
23
Discussion
M1
M
qaccept
qreject
24
nqaccept
Discussion
The final description of a decider S for ATM is:
S=“On input M , w where M is a TM:
1. Modify M as described to get M1 .
2. Run R, the decider of HALTTM with input
M1, w .
3. If R accepts - accept, otherwise - reject. ”
25
Discussion
It should be noted that modifying TM M to get
M1 , is part of TM S, the new decider for
HALTTM , and can be carried out by it.
It is not hard to see that S decides HALTTM . Since
HALTTM is undecidable, we conclude that ATM
is undecidable too.
26
The TM Emptiness Problem
We continue to demonstrate reductions by
showing that the language ETM , defined by

ETM  M  M is a TM And LM   
is undecidable.
Theorem
ETM is undecidable.
27

Proof Outline
The proof is by reduction from ATM :
1. We know that ATM is undecidable.
2. We want to prove ETM is undecidable.
3. We assume toward a contradiction that ETM
is decidable and devise a decider for ATM .
4. We conclude that ETM is undecidable.
28
Proof
Assume by way of contradiction that ETM is
decidable and let R be a TM deciding it. In
the next slides we devise TM S that uses R as
a subroutine and decides ATM .
29
Proof
Given an instance for ATM , M , w , we may try
to run R on this instance. If R accepts, we
know that LM    . In particular, M does not
accept w so a decider for ATM must reject
M ,w .
30
Proof
What happens if R rejects? The only conclusion
we can draw is that LM    . What we need
to know though is whether w  LM  .
In order to use our decider R for ETM , we once
again modify the input machine M to obtain
TM M1 :
31
M1
Description of___
We start with a TM satisfying LM1   LM  .
M1
nqstart
nqaccept
M
qstart
qaccept
qreject
nqreject
32
M1
Description of___
Now we add a filter to divert all inputs but w.
M1
nqaccept
x  w
M
filter
yes
nqstart
no
qaccept
xw
qstart
xw
w if M accepts w
LM1   
  if M rejects w
33
qreject
nqreject
Proof
TM M1 has a filter that rejects all inputs
excepts w, so the only input reaching M, is w.
Therefore, M1 satisfies:
w if M accepts w
LM1   
  if M rejects w
34
Proof
Here is a formal description of M1 :
M1  “On input x :
1. If x  w - reject .
2. If x  w - run M on w and accept if M
accepts. ”
Note: M accepts w if and only if LM1    .
35
Proof
S=“On input M , w where M is a TM:
1. Compute an encoding M 1 of TM M1 .
2. Run R on input M 1 .
3. If R rejects - accept, otherwise - reject.
37
Proof
Recall that R is a decider for ETM . If R rejects the
modified machine M1 , LM1    , hence by
the specification of M1 , w  LM  , and a
decider for ATM must accept M , w .
If however R accepts, it means that LM1    ,
hence w  LM , and S must reject M , w .
QED
38
REGULARTM is undecidable
_______
We continue to demonstrate reductions by
showing that the language REGULARTM :

REGULARTM  M  M is a TM And LM  IS Regular
is undecidable.
Theorem
REGULARTM is undecidable.
39

Proof Outline
The proof is by reduction from ATM :
1. We know that ATM is undecidable.
2. We want to prove REGULARTM is undecidable.
3. We assume that REGULARTM is decidable and
devise a decider for ATM .
4. We conclude that REGULARTM is undecidable.
40
Proof
Consider an instance M , w of ATM . Once again,
the idea is to transform TM M to another TM,
M 2 , such that LM 2  is regular if and only if
M , w  ATM .
Once we have such a machine we can run a
decider for REGULARTM with M 2 as input, and
accept M , w , if the decider accepts.
41
M2
Description of___
Here the idea is to devise a TM that satisfy:
*
if M accepts w
LM 2    n n
 0 1 | n  0 if M rejects w

.
42

M2
Description of___
TM M2 is obtained as follows:
1. Start with M.
2. Add a filter in front of M such that for every
input x:
2.1 If x is of the form 0n1n - accept.
2.2 Send w to M – If M accepts - accept.
43
M2
Description of___
We start with a TM satisfying LM 2   LM  .
M2
nqaccept
M
nqstart
qstart
qaccept
qreject
nqreject
44
M1
Description of___
Add a filter to accept all inputs of form 0n1n .
M2
nqaccept
x 0 1
n n
yes
0 n1n
filter
no
nqstart
M
qaccept
w
qstart
qreject
nqreject
45
Proof
M 2  “On input x :
1. If x has the form 0 n1n , accept .
2. If x does not have this form, run M on w
and accept if M accepts w . ”
Note: If M accept w then LM 2   * .
If M does not accepts w then
LM 2   0n1n | n  0 .

46

Proof
Now consider S:
S  “On input M , w :
1. Construct M 2 as described using
M ,w
.
2. Run R on M 2 .
3. If R accepts (Meaning LM 2   * ) - accept ,
otherwise ( LM 2   0n1n | n  0 ) - reject .”

47

TM Equivalence is Undecidable
Consider


EQTM  M 1 , M 2  LM 1   LM 2 
Theorem
EQTM is undecidable.
48
Proof
The proof is by reduction from ETM . We have to
show that if EQTM is decidable, so is ETM .
The idea is very intuitive: In order to check
that a language LM  of TM M is empty, as
required by ETM , we will check whether M is
equivalent to a TM that rejects all its inputs.
49
Proof
S=“On input M , where M is a TM:
1. Run R on input M , M 1 where M1 is a
TM that rejects all its inputs.
2. If R accepts – accept, otherwise – reject .
If R decides EQTM , S decides ETM . Since ETM is
undecidable, so is EQTM .
QED
50
Mapping Reductions
Mapping Reductions are the most common
reductions in Computer Science. In this
lecture we define mapping reductions and
demonstrate the way in which they are used.
51
Mapping Reductions
The idea of a mapping reduction is very simple:
If the instances (candidate elements) of one
language, say A, are mapped to the instances
of another language, say B, by a computable
mapping M in a way that I  A iff M I  B,
then a decider for B can be used to devise a
decider for A.
52
Computable Functions
Let A and B be two languages over * . A
function f : *  * is a computable function
if there exists a TM M such that for every
w  * , if M computes with input w it halts
with f w on its tape.
53
Examples of Computable Functions
1. Let m and n be natural numbers, let m, n be a
string encoding both m and n, and let m  n be
the string representing their sum. The function
f  m, n   m ,,n is computable.
r


g
w

w
2. The function
is a computable function.
Can you devise TM-s to compute f and g?
54
Examples of Computable Functions
3. Let M be an encoding of TM M and let M '
be an encoding of another TM M’ satisfying:
1. LM   LM ' .
2. TM M’ never makes two steps in the same
head direction.
The function t defined below is computable:
 M ' if M is an ecoding of TM M
t M 
  if M is not ecoding of any TM

55

Mapping Reductions
Let A and B be two languages over * . A
computable function f : *  * is a mapping
reduction from A to B if for every it holds
that follows: For each I  * it holds that
I  A iff f I   B . The function f is called
reduction of A to B. The arguments of the
reduction are often called instances.
56
Mapping Reductions
If there exists a mapping reduction from A to B,
We say that A is mapping reducible to B and
denote it by A m B .
If language A is mapping reducible to language
B, then a solution for B, can be used to
derive a solution for A. This fact is made
formal in the following theorem:
57
Theorem
If A m B and B is decidable, then A is
decidable.
58
Proof
Let M be a decider for B and let f be the
reduction from A to B. Consider TM N:
N=“On input w :
1. Compute f w .
2. Run M on f w and output whatever M
outputs. “
Clearly N accepts iff w B .
59
QED
Corollary
If A m B and A is undecidable, then B is
undecidable.
60
Discussion
The previous corollary is our main tool for
proving undecidability.
Notice that in order to prove B undecidable we
reduce from A which is known to be
undecidable to B. The reduction direction is
often a source of errors.
A similar tool is used in Complexity theory.
61
The Halting Problem Revisited
At the beginning of this lecture we looked at


HALTTM  M , w  M is a TM that halts on w
and proved that it is undecidable.
Now, we prove this theorem once more by
demonstrating a mapping reduction from
ATM to HALTTM .
62
The Halting Problem Revisited
The mapping reduction is presented by TM F :
F=“On input M , w:
1. Construct TM M’ .
M’=“On input x:
1. Run M on x.
2. if M accepts accept.
3. If M rejects, enter a loop. “
2. Output M ' , w . “
63
The Halting Problem Revisited
What happens if the input M , w does not
contain a valid description of a TM?
By the specification of ATM we know that in this
case M , w  ATM . Therefore in this case TM
F should output any string s satisfying
s  HALTTM .
64