You are on page 1of 165

Lecture 9

We have already
Established Turing Machines as the gold standard
of computers and computability . . .

Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. – p.1
Lecture 9
We have already
Established Turing Machines as the gold standard
of computers and computability . . .
seen examples of solvable problems . . .

Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. – p.1
Lecture 9
We have already
Established Turing Machines as the gold standard
of computers and computability . . .
seen examples of solvable problems . . .
and saw one problem, ATM , that is
computationally unsolvable.

Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. – p.1
Lecture 9
We have already
Established Turing Machines as the gold standard
of computers and computability . . .
seen examples of solvable problems . . .
and saw one problem, ATM , that is
computationally unsolvable.

In this lecture, we look at other computationally


unsolvable problems, and establish the technique of
mapping reducibilities for prove that languages are
undecidable/non-enumerable.

Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. – p.1
Reducibility
Example:
Finding your way around a new city

Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. – p.2
Reducibility
Example:
Finding your way around a new city
reduces to . . .

Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. – p.2
Reducibility
Example:
Finding your way around a new city
reduces to . . .
obtaining a city map.

Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. – p.2
Reducibility, In Our Context
Always involves two problems, A and B.

Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. – p.3
Reducibility, In Our Context
Always involves two problems, A and B.
Desired Property: If A reduces to B, then any solution
of B can be used to find a solution of A.

Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. – p.3
Reducibility, In Our Context
Always involves two problems, A and B.
Desired Property: If A reduces to B, then any solution
of B can be used to find a solution of A.
Remark: This property says nothing about solving A
by itself or B by itself.

Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. – p.3
Examples
Reductions:
Traveling from Boshton to Paris . . .

Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. – p.4
Examples
Reductions:
Traveling from Boshton to Paris . . .
buying plane ticket . . .

Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. – p.4
Examples
Reductions:
Traveling from Boshton to Paris . . .
buying plane ticket . . .
earning the money for that ticket . . .

Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. – p.4
Examples
Reductions:
Traveling from Boshton to Paris . . .
buying plane ticket . . .
earning the money for that ticket . . .
finding a job
(or getting the $s from mom and dad. . . )

Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. – p.4
Examples
Reductions:
Measuring area of rectangle . . .

Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. – p.5
Examples
Reductions:
Measuring area of rectangle . . .
measuring lengths of sides.

Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. – p.5
Examples
Reductions:
Measuring area of rectangle . . .
measuring lengths of sides.
Also:

Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. – p.5
Examples
Reductions:
Measuring area of rectangle . . .
measuring lengths of sides.
Also:
Solving a system of linear equations . . .
inverting a matrix.

Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. – p.5
Reducibility
If A is reducible to B, then
A cannot be harder than B

Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. – p.6
Reducibility
If A is reducible to B, then
A cannot be harder than B
if B is decidable, so is A.

Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. – p.6
Reducibility
If A is reducible to B, then
A cannot be harder than B
if B is decidable, so is A.
if A is undecidable and reducible to B,
then B is undecidable.

Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. – p.6
Undecidable Problems
We have already established that ATM is undecidable.
Here is a related problem.
HTM = {hM, wi|M is a TM and M halts on input w}

Clarification: How does HTM differ from ATM ?

Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. – p.7
Undecidable Problems
HTM = {hM, wi|M is a TM and M halts on input w}
Theorem: HTM is undecidable.

Proof idea:
By contradiction.

Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. – p.8
Undecidable Problems
HTM = {hM, wi|M is a TM and M halts on input w}
Theorem: HTM is undecidable.

Proof idea:
By contradiction.
Assume HTM is decidable.

Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. – p.8
Undecidable Problems
HTM = {hM, wi|M is a TM and M halts on input w}
Theorem: HTM is undecidable.

Proof idea:
By contradiction.
Assume HTM is decidable.
Let R be a TM that decides HTM .

Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. – p.8
Undecidable Problems
HTM = {hM, wi|M is a TM and M halts on input w}
Theorem: HTM is undecidable.

Proof idea:
By contradiction.
Assume HTM is decidable.
Let R be a TM that decides HTM .
Use R to construct S, a TM that decides ATM .

Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. – p.8
Undecidable Problems
HTM = {hM, wi|M is a TM and M halts on input w}
Theorem: HTM is undecidable.

Proof idea:
By contradiction.
Assume HTM is decidable.
Let R be a TM that decides HTM .
Use R to construct S, a TM that decides ATM .
So ATM is reduced to HTM .

Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. – p.8
Undecidable Problems
HTM = {hM, wi|M is a TM and M halts on input w}
Theorem: HTM is undecidable.

Proof idea:
By contradiction.
Assume HTM is decidable.
Let R be a TM that decides HTM .
Use R to construct S, a TM that decides ATM .
So ATM is reduced to HTM .
Since ATM is undecidable, so is HTM .
Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. – p.8
Undecidable Problems
Theorem: HTM is undecidable.

Proof: Assume, by way of contradiction, that TM R


decides HTM . Define a new TM, S, as follows:

On input hM, wi,

Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. – p.9
Undecidable Problems
Theorem: HTM is undecidable.

Proof: Assume, by way of contradiction, that TM R


decides HTM . Define a new TM, S, as follows:

On input hM, wi,


run R on hM, wi.

Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. – p.9
Undecidable Problems
Theorem: HTM is undecidable.

Proof: Assume, by way of contradiction, that TM R


decides HTM . Define a new TM, S, as follows:

On input hM, wi,


run R on hM, wi.
If R rejects, reject.

Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. – p.9
Undecidable Problems
Theorem: HTM is undecidable.

Proof: Assume, by way of contradiction, that TM R


decides HTM . Define a new TM, S, as follows:

On input hM, wi,


run R on hM, wi.
If R rejects, reject.
If R accepts (meaning M halts on w), simulate
M on w until it halts.

Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. – p.9
Undecidable Problems
Theorem: HTM is undecidable.

Proof: Assume, by way of contradiction, that TM R


decides HTM . Define a new TM, S, as follows:

On input hM, wi,


run R on hM, wi.
If R rejects, reject.
If R accepts (meaning M halts on w), simulate
M on w until it halts.
If M accepted, accept; otherwise reject. ♣

Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. – p.9
Undecidable Problems (2)
Does a TM accept any string at all?
ETM = {hM i|M is a TM and L(M ) = ∅}

Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. – p.10
Undecidable Problems (2)
Does a TM accept any string at all?
ETM = {hM i|M is a TM and L(M ) = ∅}

Theorem: ETM is undecidable.

Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. – p.10
Undecidable Problems (2)
Does a TM accept any string at all?
ETM = {hM i|M is a TM and L(M ) = ∅}

Theorem: ETM is undecidable.

Proof structure:

Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. – p.10
Undecidable Problems (2)
Does a TM accept any string at all?
ETM = {hM i|M is a TM and L(M ) = ∅}

Theorem: ETM is undecidable.

Proof structure:

By contradiction.
Assume ETM is decidable.
Let R be a TM that decides ETM .
Use R to construct S, a TM that decides ATM .
Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. – p.10
Undecidable Problems (2)
ETM = {hM i|M is a TM and L(M ) = ∅}

Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. – p.11
Undecidable Problems (2)
ETM = {hM i|M is a TM and L(M ) = ∅}

First attempt: When S receives input hM, wi, it calls


R with input hM i.
If R accepts, then reject, because M does not
accept any string, let alone w.
But what if R rejects?

Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. – p.11
Undecidable Problems (2)
ETM = {hM i|M is a TM and L(M ) = ∅}

First attempt: When S receives input hM, wi, it calls


R with input hM i.
If R accepts, then reject, because M does not
accept any string, let alone w.
But what if R rejects?

Second attempt: Let’s modify M .

Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. – p.11
Undecidable Problems (2)
ETM = {hM i|M is a TM and L(M ) = ∅}

Define M1 : on input x,
1. if x 6= w, reject.
2. if x = w, run M on w and accept if M does.

Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. – p.12
Undecidable Problems (2)
ETM = {hM i|M is a TM and L(M ) = ∅}

Define M1 : on input x,
1. if x 6= w, reject.
2. if x = w, run M on w and accept if M does.

M1 either
accepts just w, or
accepts nothing.

Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. – p.12
Undecidable Problems (2)
Machine M1 : on input x,
1. if x 6= w, reject.
2. if x = w, run M on w and accept if M does.

Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. – p.13
Undecidable Problems (2)
Machine M1 : on input x,
1. if x 6= w, reject.
2. if x = w, run M on w and accept if M does.

Question: Can a TM construct M1 from M ?

Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. – p.13
Undecidable Problems (2)
Machine M1 : on input x,
1. if x 6= w, reject.
2. if x = w, run M on w and accept if M does.

Question: Can a TM construct M1 from M ?

Answer: Yes, because we need only hardwire w, and


add a few extra states to perform the “x = w?00 test.

Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. – p.13
Undecidable Problems (2)
ETM = {hM i|M is a TM and L(M ) = ∅}

Theorem: ETM is undecidable.

Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. – p.14
Undecidable Problems (2)
ETM = {hM i|M is a TM and L(M ) = ∅}

Theorem: ETM is undecidable.

Define S as follows:
On input hM, wi, where M is a TM and w a string,

Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. – p.14
Undecidable Problems (2)
ETM = {hM i|M is a TM and L(M ) = ∅}

Theorem: ETM is undecidable.

Define S as follows:
On input hM, wi, where M is a TM and w a string,
Construct M1 from M and w.
Run R on input hM1 i,
if R accepts, reject; if R rejects, accept. ♣

Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. – p.14
Undecidable Problems (3)
Does a TM accept a regular language?
RTM = {hM i|M is a TM and L(M ) is regular}

Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. – p.15
Undecidable Problems (3)
Does a TM accept a regular language?
RTM = {hM i|M is a TM and L(M ) is regular}

Theorem: RTM is undecidable.

Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. – p.15
Undecidable Problems (3)
Does a TM accept a regular language?
RTM = {hM i|M is a TM and L(M ) is regular}

Theorem: RTM is undecidable.


Skeleton of Proof:
By contradiction.
Assume RTM is decidable.
Let R be a TM that decides RTM .
Use R to construct S, a TM that decides ATM .

Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. – p.15
Undecidable Problems (3)
Does a TM accept a regular language?
RTM = {hM i|M is a TM and L(M ) is regular}

Theorem: RTM is undecidable.


Skeleton of Proof:
By contradiction.
Assume RTM is decidable.
Let R be a TM that decides RTM .
Use R to construct S, a TM that decides ATM .
But how?
Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. – p.15
Undecidable Problems (3)

RTM = {hM i|M is a TM and L(M ) is regular}

Modify M so that the resulting TM accepts a regular


language if and only if M accepts w.

Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. – p.16
Undecidable Problems (3)

RTM = {hM i|M is a TM and L(M ) is regular}

Modify M so that the resulting TM accepts a regular


language if and only if M accepts w.
Design M2 so that
if M does not accept w, then M2 accepts
{0n 1n |n ≥ 0} (non-regular)
if M accepts w, then M2 accepts Σ∗ (regular).

Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. – p.16
Undecidable Problems (3)
From M and w, define M2 :

Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. – p.17
Undecidable Problems (3)
From M and w, define M2 :
On input x,
1. If x has the form 0n 1n , accept it.
2. Otherwise, run M on input w and accept x if M
accepts w.

Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. – p.17
Undecidable Problems (3)
From M and w, define M2 :
On input x,
1. If x has the form 0n 1n , accept it.
2. Otherwise, run M on input w and accept x if M
accepts w.

Claim:
If M does not accept w, then M2 accepts
{0n 1n |n ≥ 0}.
If M accepts w, then M2 accepts Σ∗ .

Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. – p.17
Undecidable Problems (3)

RTM = {hM i|M is a TM and L(M ) is regular}

Theorem: RTM is undecidable.

Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. – p.18
Undecidable Problems (3)

RTM = {hM i|M is a TM and L(M ) is regular}

Theorem: RTM is undecidable.

Define S:
On input hM, wi,
1. Construct M2 from M and w.
2. Run R on input hM2 i.
3. If R accepts, accept; if R rejects, reject. ♣

Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. – p.18
Undecidable Problems (4)
Are two TMs equivalent?

EQTM = {hM1 , M2 i | M1 , M2 are TMs and


L(M1 ) = L(M2 )}
Theorem: EQTM is undecidable.

Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. – p.19
Undecidable Problems (4)
Are two TMs equivalent?

EQTM = {hM1 , M2 i | M1 , M2 are TMs and


L(M1 ) = L(M2 )}
Theorem: EQTM is undecidable.

We are getting tired of reducing ATM to everything.

Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. – p.19
Undecidable Problems (4)
Are two TMs equivalent?

EQTM = {hM1 , M2 i | M1 , M2 are TMs and


L(M1 ) = L(M2 )}
Theorem: EQTM is undecidable.

We are getting tired of reducing ATM to everything.


Let’s try instead a reduction from ETM to EQTM .

Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. – p.19
Undecidable Problems (4)
EQTM = {hM1 , M2 i | M1 , M2 are TMs and
L(M1 ) = L(M2 )}
Theorem: EQTM is undecidable.
Idea:
ETM is the problem of testing whether a TM
language is empty.

Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. – p.20
Undecidable Problems (4)
EQTM = {hM1 , M2 i | M1 , M2 are TMs and
L(M1 ) = L(M2 )}
Theorem: EQTM is undecidable.
Idea:
ETM is the problem of testing whether a TM
language is empty.
EQTM is the problem of testing whether two
TM languages are the same.

Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. – p.20
Undecidable Problems (4)
EQTM = {hM1 , M2 i | M1 , M2 are TMs and
L(M1 ) = L(M2 )}
Theorem: EQTM is undecidable.
Idea:
ETM is the problem of testing whether a TM
language is empty.
EQTM is the problem of testing whether two
TM languages are the same.
If one of these two TM languages happens to be
empty, then we are back to ETM .

Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. – p.20
Undecidable Problems (4)
EQTM = {hM1 , M2 i | M1 , M2 are TMs and
L(M1 ) = L(M2 )}
Theorem: EQTM is undecidable.
Idea:
ETM is the problem of testing whether a TM
language is empty.
EQTM is the problem of testing whether two
TM languages are the same.
If one of these two TM languages happens to be
empty, then we are back to ETM .
So ETM is a special case of EQTM .
The rest is easy.
Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. – p.20
Undecidable Problems (4)
EQTM = {hM1 , M2 i | M1 , M2 are TMs and
L(M1 ) = L(M2 )}
Theorem: EQTM is undecidable.

Let M NO be the TM: On input x, reject.


Let R decide EQTM .

Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. – p.21
Undecidable Problems (4)
EQTM = {hM1 , M2 i | M1 , M2 are TMs and
L(M1 ) = L(M2 )}
Theorem: EQTM is undecidable.

Let M NO be the TM: On input x, reject.


Let R decide EQTM .

Let S be: On input hM i:


1. Run R on input hM, M NO i.
2. If R accepts, accept; if R rejects, reject.

Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. – p.21
Undecidable Problems (4)
EQTM = {hM1 , M2 i | M1 , M2 are TMs and
L(M1 ) = L(M2 )}
Theorem: EQTM is undecidable.

Let M NO be the TM: On input x, reject.


Let R decide EQTM .

Let S be: On input hM i:


1. Run R on input hM, M NO i.
2. If R accepts, accept; if R rejects, reject.
If R decides EQTM , then S decides ETM . ♣
Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. – p.21
Bucket of Undecidable Problems
Same techniques prove undecidability of

Does a TM accept a decidable language?

Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. – p.22
Bucket of Undecidable Problems
Same techniques prove undecidability of

Does a TM accept a decidable language?


Does a TM accept a enumerable language?

Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. – p.22
Bucket of Undecidable Problems
Same techniques prove undecidability of

Does a TM accept a decidable language?


Does a TM accept a enumerable language?
Does a TM accept a context-free language?

Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. – p.22
Bucket of Undecidable Problems
Same techniques prove undecidability of

Does a TM accept a decidable language?


Does a TM accept a enumerable language?
Does a TM accept a context-free language?
Does a TM accept a finite language?

Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. – p.22
Bucket of Undecidable Problems
Same techniques prove undecidability of

Does a TM accept a decidable language?


Does a TM accept a enumerable language?
Does a TM accept a context-free language?
Does a TM accept a finite language?
Does a TM halt on all inputs?

Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. – p.22
Bucket of Undecidable Problems
Same techniques prove undecidability of

Does a TM accept a decidable language?


Does a TM accept a enumerable language?
Does a TM accept a context-free language?
Does a TM accept a finite language?
Does a TM halt on all inputs?
Is there an input string that causes a TM to
traverse all its states?

Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. – p.22
Rice’s Theorem
By now, some of you may have become cynical and
embittered.
Like, been there, done that, bought the T-shirt.

Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. – p.23
Rice’s Theorem
By now, some of you may have become cynical and
embittered.
Like, been there, done that, bought the T-shirt.
Looks like any non-trivial property of TMs is
undecidable.

Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. – p.23
Rice’s Theorem
By now, some of you may have become cynical and
embittered.
Like, been there, done that, bought the T-shirt.
Looks like any non-trivial property of TMs is
undecidable.

That is correct.

Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. – p.23
Rice’s Theorem
Theorem: If C is a proper non-empty subset of the
set of enumerable languages, then it is undecidable
whether for a given TM, M , L(M ) is in C.

Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. – p.24
Rice’s Theorem
Theorem: If C is a proper non-empty subset of the
set of enumerable languages, then it is undecidable
whether for a given TM, M , L(M ) is in C.

Proof by reduction from HTM


(does M halt on input x?).

Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. – p.24
Rice’s Theorem
Theorem: If C is a proper non-empty subset of the
set of enumerable languages, then it is undecidable
whether for a given TM, M , L(M ) is in C.

Proof by reduction from HTM


(does M halt on input x?).

Assume R decides if L(M ) ∈ C.


Use R to implement S, which decides HTM .

Further details of proof not given at the moment . . .

Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. – p.24
Reducibility
So far, we have seen many examples of reductions
from one language to another, but the notion was
neither defined nor treated formally.
Reductions play an important role in
decidability theory
complexity theory (to come)

Time to get formal.

Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. – p.25
Computable Functions
A TM computes a function
f : Σ∗ −→ Σ∗
if the TM

Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. – p.26
Computable Functions
A TM computes a function
f : Σ∗ −→ Σ∗
if the TM

starts with input w, and

Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. – p.26
Computable Functions
A TM computes a function
f : Σ∗ −→ Σ∗
if the TM

starts with input w, and


halts with only f (w) on tape.

Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. – p.26
Computable Functions
Claim: All the usual arithmetic functions on integers
are computable.

Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. – p.27
Computable Functions
Claim: All the usual arithmetic functions on integers
are computable.
These include addition, subtraction, multiplication,
division (quotient and remainder), exponentiation,
roots (to a specified precision).

Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. – p.27
Computable Functions
Claim: All the usual arithmetic functions on integers
are computable.
These include addition, subtraction, multiplication,
division (quotient and remainder), exponentiation,
roots (to a specified precision).
Even non-arithmetic functions, like logarithms and
trigonometric functions, can be computed (to a
specified precision), using Taylor expansion or other
numeric mathematic techniques.

Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. – p.27
Computable Functions
Claim: All the usual arithmetic functions on integers
are computable.
These include addition, subtraction, multiplication,
division (quotient and remainder), exponentiation,
roots (to a specified precision).
Even non-arithmetic functions, like logarithms and
trigonometric functions, can be computed (to a
specified precision), using Taylor expansion or other
numeric mathematic techniques.
Exercise: Design a TM that on input hm, ni, halts
with hm + ni on tape.

Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. – p.27
Computable Functions
A useful class of functions modifies TM descriptions.
For example:
On input w:
if w = hM i for some TM,

Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. – p.28
Computable Functions
A useful class of functions modifies TM descriptions.
For example:
On input w:
if w = hM i for some TM,
construct hM 0 i, where

Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. – p.28
Computable Functions
A useful class of functions modifies TM descriptions.
For example:
On input w:
if w = hM i for some TM,
construct hM 0 i, where
L(M 0 ) = L(M ), but

Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. – p.28
Computable Functions
A useful class of functions modifies TM descriptions.
For example:
On input w:
if w = hM i for some TM,
construct hM 0 i, where
L(M 0 ) = L(M ), but
M 0 never tries to move off LHS of tape.

Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. – p.28
Computable Functions
A useful class of functions modifies TM descriptions.
For example:
On input w:
if w = hM i for some TM,
construct hM 0 i, where
L(M 0 ) = L(M ), but
M 0 never tries to move off LHS of tape.
otherwise write ε and halt.

Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. – p.28
Computable Functions
A useful class of functions modifies TM descriptions.
For example:
On input w:
if w = hM i for some TM,
construct hM 0 i, where
L(M 0 ) = L(M ), but
M 0 never tries to move off LHS of tape.
otherwise write ε and halt.
Left as an exercise.

Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. – p.28
Mapping Reductions
Definition: Let A and B be two languages. We say
that there is a mapping reduction from A to B, and
denote
A ≤m B

Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. – p.29
Mapping Reductions
Definition: Let A and B be two languages. We say
that there is a mapping reduction from A to B, and
denote
A ≤m B
if there is a computable function
f : Σ∗ −→ Σ∗
such that, for every w,

Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. – p.29
Mapping Reductions
Definition: Let A and B be two languages. We say
that there is a mapping reduction from A to B, and
denote
A ≤m B
if there is a computable function
f : Σ∗ −→ Σ∗
such that, for every w,

w ∈ A⇐⇒f (w) ∈ B.

The function f is called the reduction from A to B.

Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. – p.29
Mapping Reductions

A f B

Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. – p.30
Mapping Reductions

A f B

A mapping reduction converts questions about


membership in A to membership in B

Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. – p.30
Mapping Reductions
Theorem: If A ≤m B and B is decidable, then A is
decidable.

Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. – p.31
Mapping Reductions
Theorem: If A ≤m B and B is decidable, then A is
decidable.
Proof: Let
M be the decider for B, and
f the reduction from A to B.

Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. – p.31
Mapping Reductions
Theorem: If A ≤m B and B is decidable, then A is
decidable.
Proof: Let
M be the decider for B, and
f the reduction from A to B.
Define N : On input w
1. compute f (w)
2. run M on input f (w) and output whatever M
outputs.

Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. – p.31
Mapping Reductions
Corollary: If A ≤m B and A is undecidable, then B is
undecidable.

Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. – p.32
Mapping Reductions
Corollary: If A ≤m B and A is undecidable, then B is
undecidable.

In fact, this has been our principal tool for proving un-
decidability of languages other than ATM .

Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. – p.32
Example: Halting
Recall that

ATM = {hM, wi|TM M accepts input w}


HTM = {hM, wi|TM M halts on input w}

Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. – p.33
Example: Halting
Recall that

ATM = {hM, wi|TM M accepts input w}


HTM = {hM, wi|TM M halts on input w}
Earlier we proved that
HTM undecidable
by (de facto) reduction from ATM .
Let’s reformulate this.

Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. – p.33
Example: Halting
Define a computable function, f :
input of form hM, wi

Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. – p.34
Example: Halting
Define a computable function, f :
input of form hM, wi
output of form hM 0 , w0 i

Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. – p.34
Example: Halting
Define a computable function, f :
input of form hM, wi
output of form hM 0 , w0 i
where hM, wi ∈ ATM ⇐⇒ hM 0 , w0 i ∈ HTM .

Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. – p.34
Example: Halting
The following machine computes this function f .
F = on input hM, wi:
Construct the following machine M 0 .
M 0 : on input x

Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. – p.35
Example: Halting
The following machine computes this function f .
F = on input hM, wi:
Construct the following machine M 0 .
M 0 : on input x
run M on x

Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. – p.35
Example: Halting
The following machine computes this function f .
F = on input hM, wi:
Construct the following machine M 0 .
M 0 : on input x
run M on x
If M accepts, accept.

Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. – p.35
Example: Halting
The following machine computes this function f .
F = on input hM, wi:
Construct the following machine M 0 .
M 0 : on input x
run M on x
If M accepts, accept.
if M rejects, enter a loop.

Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. – p.35
Example: Halting
The following machine computes this function f .
F = on input hM, wi:
Construct the following machine M 0 .
M 0 : on input x
run M on x
If M accepts, accept.
if M rejects, enter a loop.
output hM 0 , wi

Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. – p.35
Enumerability
Theorem: If A ≤m B and B is enumerable, then A
is enumerable.

Proof is same as before, using accepters instead of


deciders.

Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. – p.36
Enumerability
Corollary: If A ≤m B and A is not enumerable, then
B is not enumerable.

Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. – p.37
TM Equality
Theorem: Both EQTM and its complement, EQTM ,
are not enumerable. Stated differently, EQTM is
neither enumerable nor co-enumerable.

Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. – p.38
TM Equality
Theorem: Both EQTM and its complement, EQTM ,
are not enumerable. Stated differently, EQTM is
neither enumerable nor co-enumerable.

We show that ATM is reducible to EQTM . The


same function is also a mapping reduction from
ATM to EQTM , and thus EQTM is not
enumerable.

Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. – p.38
TM Equality
Theorem: Both EQTM and its complement, EQTM ,
are not enumerable. Stated differently, EQTM is
neither enumerable nor co-enumerable.

We show that ATM is reducible to EQTM . The


same function is also a mapping reduction from
ATM to EQTM , and thus EQTM is not
enumerable.
We then show that ATM is reducible to EQTM .
The new function is also a mapping reduction
from ATM to EQTM , and thus EQTM is not
enumerable.
Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. – p.38
TM Equality
Claim: ATM is reducible to EQTM .
f : ATM −→ EQTM works as follows:
F : On input hM, wi
Construct machine M1 : on any input, reject.

Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. – p.39
TM Equality
Claim: ATM is reducible to EQTM .
f : ATM −→ EQTM works as follows:
F : On input hM, wi
Construct machine M1 : on any input, reject.
Construct machine M2 : on input x, run M on w.
If it accepts, accept.

Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. – p.39
TM Equality
Claim: ATM is reducible to EQTM .
f : ATM −→ EQTM works as follows:
F : On input hM, wi
Construct machine M1 : on any input, reject.
Construct machine M2 : on input x, run M on w.
If it accepts, accept.
Output hM1 , M2 i.

Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. – p.39
TM Equality
F : On input hM, wi
Construct machine M1 : on any input, reject.
Construct machine M2 : on any input x, run M on w.
If it accepts, accept x.
Output hM1 , M2 i.

Note
M1 accepts nothing

Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. – p.40
TM Equality
F : On input hM, wi
Construct machine M1 : on any input, reject.
Construct machine M2 : on any input x, run M on w.
If it accepts, accept x.
Output hM1 , M2 i.

Note
M1 accepts nothing
if M accepts w then M2 accepts everything,
and otherwise nothing.

Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. – p.40
TM Equality
F : On input hM, wi
Construct machine M1 : on any input, reject.
Construct machine M2 : on any input x, run M on w.
If it accepts, accept x.
Output hM1 , M2 i.

Note
M1 accepts nothing
if M accepts w then M2 accepts everything,
and otherwise nothing.
so hM, wi ∈ ATM ⇐⇒ hM1 , M2 i ∈ EQTM

Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. – p.40
TM Equality
Claim: ATM is reducible to EQTM .

f : ATM −→ EQTM works as follows:

F : On input hM, wi
Construct machine M1 : on any input, accept.

Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. – p.41
TM Equality
Claim: ATM is reducible to EQTM .

f : ATM −→ EQTM works as follows:

F : On input hM, wi
Construct machine M1 : on any input, accept.
Construct machine M2 : on any input x, run M on
w.
If it accepts, accept.

Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. – p.41
TM Equality
Claim: ATM is reducible to EQTM .

f : ATM −→ EQTM works as follows:

F : On input hM, wi
Construct machine M1 : on any input, accept.
Construct machine M2 : on any input x, run M on
w.
If it accepts, accept.
Output hM1 , M2 i.

Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. – p.41
TM Equality
F : On input hM, wi
Construct machine M1 : on any input, accept.
Construct machine M2 : on any input x, run M on w.
If it accepts, accept.
Output hM1 , M2 i.

Note
M1 accepts everything

Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. – p.42
TM Equality
F : On input hM, wi
Construct machine M1 : on any input, accept.
Construct machine M2 : on any input x, run M on w.
If it accepts, accept.
Output hM1 , M2 i.

Note
M1 accepts everything
if M accepts w, then M2 accepts everything,
and otherwise nothing.

Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. – p.42
TM Equality
F : On input hM, wi
Construct machine M1 : on any input, accept.
Construct machine M2 : on any input x, run M on w.
If it accepts, accept.
Output hM1 , M2 i.

Note
M1 accepts everything
if M accepts w, then M2 accepts everything,
and otherwise nothing.
hM, wi ∈ ATM ⇐⇒ hM1 , M2 i ∈ EQTM .

Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. – p.42
Recursive Inseparability
Two disjoint languages L1 and L2 are recursively
inseparable if there is no decidable language D such
that
L1 ∩ D = ∅, and

Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. – p.43
Recursive Inseparability
Two disjoint languages L1 and L2 are recursively
inseparable if there is no decidable language D such
that
L1 ∩ D = ∅, and
L2 ⊂ D.

Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. – p.43
Recursive Inseparability
Two disjoint languages L1 and L2 are recursively
inseparable if there is no decidable language D such
that
L1 ∩ D = ∅, and
L2 ⊂ D.
Example of recursively separable languages:

L2 L1

Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. – p.43
Recursive Inseparability
ATM and ATM are a trivial example.

Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. – p.44
Recursive Inseparability
ATM and ATM are a trivial example.
Why?

Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. – p.44
Recursive Inseparability
ATM and ATM are a trivial example.
Why?
Are there non-trivial examples?

Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. – p.44
Recursive Inseparability
Define
Ayes = {hM i|M is a TM that accepts hM i}

and
Ano = {hM i|M is a TM that halts and rejects hM i}

Theorem: Ayes and Ano are recursively


inseparable.

Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. – p.45
Proof by Contradiction
Let D be a decidable language that separates them.

Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. – p.46
Proof by Contradiction
Let D be a decidable language that separates them.
Assume Ano ⊂ D and D ∩ Ayes = ∅.

Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. – p.46
Proof by Contradiction
Let D be a decidable language that separates them.
Assume Ano ⊂ D and D ∩ Ayes = ∅.
Let MD be the TM that decides D

Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. – p.46
Proof by Contradiction
Let D be a decidable language that separates them.
Assume Ano ⊂ D and D ∩ Ayes = ∅.
Let MD be the TM that decides D
What does MD do with input hMD i?

Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. – p.46
Proof by Contradiction
Let D be a decidable language that separates them.
Assume Ano ⊂ D and D ∩ Ayes = ∅.
Let MD be the TM that decides D
What does MD do with input hMD i?
It must halt. (why?)

Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. – p.46
Proof by Contradiction
Let D be a decidable language that separates them.
Assume Ano ⊂ D and D ∩ Ayes = ∅.
Let MD be the TM that decides D
What does MD do with input hMD i?
It must halt. (why?)
If MD accepts hMD i:

Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. – p.46
Proof by Contradiction
Let D be a decidable language that separates them.
Assume Ano ⊂ D and D ∩ Ayes = ∅.
Let MD be the TM that decides D
What does MD do with input hMD i?
It must halt. (why?)
If MD accepts hMD i:
hMD i ∈ Ayes

Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. – p.46
Proof by Contradiction
Let D be a decidable language that separates them.
Assume Ano ⊂ D and D ∩ Ayes = ∅.
Let MD be the TM that decides D
What does MD do with input hMD i?
It must halt. (why?)
If MD accepts hMD i:
hMD i ∈ Ayes
hMD i 6∈ D

Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. – p.46
Proof by Contradiction
Let D be a decidable language that separates them.
Assume Ano ⊂ D and D ∩ Ayes = ∅.
Let MD be the TM that decides D
What does MD do with input hMD i?
It must halt. (why?)
If MD accepts hMD i:
hMD i ∈ Ayes
hMD i 6∈ D
so MD rejects hMD i.

Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. – p.46
Proof by Contradiction
Let D be a decidable language that separates them.
Assume Ano ⊂ D and D ∩ Ayes = ∅.
Let MD be the TM that decides D
What does MD do with input hMD i?
It must halt. (why?)
If MD accepts hMD i:
hMD i ∈ Ayes
hMD i 6∈ D
so MD rejects hMD i.
If MD rejects hMD i:

Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. – p.46
Proof by Contradiction
Let D be a decidable language that separates them.
Assume Ano ⊂ D and D ∩ Ayes = ∅.
Let MD be the TM that decides D
What does MD do with input hMD i?
It must halt. (why?)
If MD accepts hMD i:
hMD i ∈ Ayes
hMD i 6∈ D
so MD rejects hMD i.
If MD rejects hMD i:
hMD i ∈ Ano

Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. – p.46
Proof by Contradiction
Let D be a decidable language that separates them.
Assume Ano ⊂ D and D ∩ Ayes = ∅.
Let MD be the TM that decides D
What does MD do with input hMD i?
It must halt. (why?)
If MD accepts hMD i:
hMD i ∈ Ayes
hMD i 6∈ D
so MD rejects hMD i.
If MD rejects hMD i:
hMD i ∈ Ano
hMD i ∈ D

Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. – p.46
Proof by Contradiction
Let D be a decidable language that separates them.
Assume Ano ⊂ D and D ∩ Ayes = ∅.
Let MD be the TM that decides D
What does MD do with input hMD i?
It must halt. (why?)
If MD accepts hMD i:
hMD i ∈ Ayes
hMD i 6∈ D
so MD rejects hMD i.
If MD rejects hMD i:
hMD i ∈ Ano
hMD i ∈ D
so MD accepts hMD i. ♣
Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. – p.46
Recursive Inseparability
Define
Byes = {hM i|M is a TM that accepts ε}

and
Bno = {hM i|M is a TM that halts and rejects ε}

Theorem: Byes and Bno are recursively


inseparable.

Proof by reduction and contradiction.

Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. – p.47
Recursive Inseparability
Theorem: Byes and Bno are recursively
inseparable.
By reduction and contradiction.
Assume Byes and Bno can be separated by E,
decided by TM ME .

Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. – p.48
Recursive Inseparability
Theorem: Byes and Bno are recursively
inseparable.
By reduction and contradiction.
Assume Byes and Bno can be separated by E,
decided by TM ME .
For TM M , define M 0 : On any input,

Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. – p.48
Recursive Inseparability
Theorem: Byes and Bno are recursively
inseparable.
By reduction and contradiction.
Assume Byes and Bno can be separated by E,
decided by TM ME .
For TM M , define M 0 : On any input,
1. run M on input hM i.

Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. – p.48
Recursive Inseparability
Theorem: Byes and Bno are recursively
inseparable.
By reduction and contradiction.
Assume Byes and Bno can be separated by E,
decided by TM ME .
For TM M , define M 0 : On any input,
1. run M on input hM i.
2. if M accepts, accept; if M rejects, reject;

Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. – p.48
Proof (Concluded)
Define N : On input hM i,

Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. – p.49
Proof (Concluded)
Define N : On input hM i,
1. construct description of M 0 .

Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. – p.49
Proof (Concluded)
Define N : On input hM i,
1. construct description of M 0 .
2. run ME on hM 0 i.

Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. – p.49
Proof (Concluded)
Define N : On input hM i,
1. construct description of M 0 .
2. run ME on hM 0 i.
3. if ME accepts, accept; if ME rejects, reject;

Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. – p.49
Proof (Concluded)
Define N : On input hM i,
1. construct description of M 0 .
2. run ME on hM 0 i.
3. if ME accepts, accept; if ME rejects, reject;
Claim:

Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. – p.49
Proof (Concluded)
Define N : On input hM i,
1. construct description of M 0 .
2. run ME on hM 0 i.
3. if ME accepts, accept; if ME rejects, reject;
Claim:
N is a decider. (why?)

Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. – p.49
Proof (Concluded)
Define N : On input hM i,
1. construct description of M 0 .
2. run ME on hM 0 i.
3. if ME accepts, accept; if ME rejects, reject;
Claim:
N is a decider. (why?)
So N decides a language D.

Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. – p.49
Proof (Concluded)
Define N : On input hM i,
1. construct description of M 0 .
2. run ME on hM 0 i.
3. if ME accepts, accept; if ME rejects, reject;
Claim:
N is a decider. (why?)
So N decides a language D.
D separates Ayes and Ano , contradiction. ♣

Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. – p.49

You might also like