0% found this document useful (0 votes)
9 views43 pages

Lecture 09

The lecture discusses the Halting Problem and its undecidability, demonstrating that the acceptance problem for Turing machines (ATM) is Turing recognizable but not decidable. A universal Turing machine is introduced, and a proof by contradiction is provided to show that if a decider for ATM existed, it would lead to an absurdity. The lecture concludes with the implications of Turing recognizability and co-Turing recognizability, emphasizing that if a language is not decidable, either it or its complement is not Turing recognizable.

Uploaded by

haniasohail777
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views43 pages

Lecture 09

The lecture discusses the Halting Problem and its undecidability, demonstrating that the acceptance problem for Turing machines (ATM) is Turing recognizable but not decidable. A universal Turing machine is introduced, and a proof by contradiction is provided to show that if a decider for ATM existed, it would lead to an absurdity. The lecture concludes with the implications of Turing recognizability and co-Turing recognizability, emphasizing that if a language is not decidable, either it or its complement is not Turing recognizable.

Uploaded by

haniasohail777
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 43

Theory of Computation

Lecture #9

Sarmad Abbasi

Virtual University

Sarmad Abbasi (Virtual University) Theory of Computation 1 / 43


Lecture 9: Overview

Halting Problem.
Undecidability of the Halting Problem
Diagonalization
Co-Turing Recognizability
the Halting Problem is not co-Turing Recognizable

Sarmad Abbasi (Virtual University) Theory of Computation 2 / 43


Acceptance Problem for TMs

Let us define

ATM = {hM, wi : M is a TM that accepts w}.


This is called the acceptance problem for TMs or the halting problem.

Sarmad Abbasi (Virtual University) Theory of Computation 3 / 43


Acceptance Problem for TMs

Last time we saw:


Theorem
ATM is Turing Recognizable.

Sarmad Abbasi (Virtual University) Theory of Computation 4 / 43


Acceptance Problem for TMs

On Input hM, wi
Simulate M on w.
If M accepts w accept.
This machine lets call it U is a recognizer for ATM .

Sarmad Abbasi (Virtual University) Theory of Computation 5 / 43


Acceptance Problem for TMs

Why is this not a decider.

If M loops on w then U will also loop on hM, wi.

Sarmad Abbasi (Virtual University) Theory of Computation 6 / 43


Universal Turning Machine

U is called a universal Turing Machine.

Sarmad Abbasi (Virtual University) Theory of Computation 7 / 43


Undecidability of the Halting Problem

Theorem
ATM is not decidable.

Sarmad Abbasi (Virtual University) Theory of Computation 8 / 43


Undecidability of the Halting Problem

The proof is via contradiction. We will start by assuming that ATM is


decidable and reach an absurdity. This method of proving
mathematical claims is called reductio ad absurdum.

Sarmad Abbasi (Virtual University) Theory of Computation 9 / 43


Undecidability of the Halting Problem

So let us assume that ATM is decidable. This means there is a decider


H such that

accept, if M accepts w;
H(hM, wi) =
reject, if M does not accept w.

Sarmad Abbasi (Virtual University) Theory of Computation 10 / 43


Undecidability of the Halting Problem

H is a spectacular TM. Since, it halts on all inputs. So, it must be doing


something very clever. Lets continue analyzing H. Note that if H exists
then we can use it as a subroutine in any other TM that we design.

Sarmad Abbasi (Virtual University) Theory of Computation 11 / 43


Undecidability of the Halting Problem

So, let us look at the following TM which we call D:


1 On input hMi.
2 Convert hMi into hM, hMii
3 Run H on hM, hMii.
4 Output the opposite of what H does; that is
If H accepts reject, if H rejects accept.

Sarmad Abbasi (Virtual University) Theory of Computation 12 / 43


Undecidability of the Halting Problem

Note that we can easily make this TM D provided H is given to us. So,
if H exists then so does D.
The main step D has to do is to convert the input hMi to hM, hMii.
What will running H on hM, hMii tell us?

Sarmad Abbasi (Virtual University) Theory of Computation 13 / 43


Undecidability of the Halting Problem

H accepts hM, hMii if and only if M accepts hMi.

So we are finding out if M accepts its own description or not!!

Sarmad Abbasi (Virtual University) Theory of Computation 14 / 43


Undecidability of the Halting Problem

Can Turing machines accept/reject their own description?


Can we run a program on itself?
Well why not!

Sarmad Abbasi (Virtual University) Theory of Computation 15 / 43


Undecidability of the Halting Problem

Here are some examples:


Word count program can be used to find out how many lines of
code does it have.
A compiler for C written in C can compile itself.

Sarmad Abbasi (Virtual University) Theory of Computation 16 / 43


Undecidability of the Halting Problem

So, let us find out what D is doing:



accept, if M does not accept hMi;
D(hMi) =
reject, if M accepts hMi.
Now, comes the interesting twist in the proof. We simply ask the
question what does D do on its own description?

Sarmad Abbasi (Virtual University) Theory of Computation 17 / 43


Undecidability of the Halting Problem

So, let us find out what D is doing:



accept, if D does not accept hDi;
D(hDi) =
reject, if D accepts hDi.
But this is absurd in both cases. Hence, we conclude that D does not
exist and therefore H does not exist either.

Sarmad Abbasi (Virtual University) Theory of Computation 18 / 43


Undecidability of the Halting Problem

Assume that H exists. We use H to construct D. This is easy D simply


converts its input hMi into hM, hMii and calls H. It returns the answer
that is opposite of the one given by H.
1 H accepts hM, wi exactly when M accepts w.
2 D rejects hMi exactly when M accepts hMi.
3 D rejects hDi exactly when D accepts hDi.
This leads to a contradiction.

Sarmad Abbasi (Virtual University) Theory of Computation 19 / 43


Undecidability of the Halting Problem

Where is the diagonalization in this proof? Well it is hidden but we can


find it.
Lets make a matrix as follows:
1 Label the rows with TMs as M1 , M2 , M3 , . . . , Mk , . . .
2 Label the columns with descriptions of TMs as hM1 i, . . . ,
3 Entry i, j is accept if Mi accepts hMj i

Sarmad Abbasi (Virtual University) Theory of Computation 20 / 43


Undecidability of the Halting Problem

This matrix looks as follows:


hM1 i hM2 i hM3 i hM4 i ···
M1 accept reject accept accept ···
M2 accept accept accept accept ···
M3 accept reject loop reject ···
M4 accept accept loop reject ···
.. .. .. .. .. ..
. . . . . .

Sarmad Abbasi (Virtual University) Theory of Computation 21 / 43


Undecidability of the Halting Problem

1 the first three entries in the first row tells us that M1 accepts hM1 i
and hM3 i but not the hM2 i and so on...
2 M2 accepts all descriptions......
3 Similarly the 4th row tells us that M4 accepts hM1 i and hM2 i...

Sarmad Abbasi (Virtual University) Theory of Computation 22 / 43


Undecidability of the Halting Problem

Now, since we are given that H exists we can make a matrix


1 Label the rows with TMs as M1 , M2 , M3 , . . . , Mk , . . .
2 Label the colums with descriptions of TMs as hM1 i, . . . ,
3 Entry i, j is output of H on hMi , hMj ii
Lets look at this matrix. Note that all entries are filled.

Sarmad Abbasi (Virtual University) Theory of Computation 23 / 43


Undecidability of the Halting Problem

Fill the entries according to the output of H:


hM1 i hM2 i hM3 i hM4 i ···
M1 accept reject accept accept · · ·
M2 accept accept accept accept · · ·
M3 accept reject reject reject · · ·
M4 accept accept reject reject · · ·
.. .. .. .. .. ..
. . . . . .

Sarmad Abbasi (Virtual University) Theory of Computation 24 / 43


Undecidability of the Halting Problem

The machine D is when it is given hMi i as an input looks at the entry


i, i on the diagonal and outputs the opposite. Just like cantor’s idea.
Now, if D exists then there must be a row corresponding to D in this
matrix. Lets look at this row and see why we have a contradiction.

Sarmad Abbasi (Virtual University) Theory of Computation 25 / 43


Undecidability of the Halting Problem

Here we have filled the row for D.


D = Mi accept accept accept accept ···
1 The first element is reject and the second is reject where as the
third and fourth elements are reject.

Sarmad Abbasi (Virtual University) Theory of Computation 26 / 43


Undecidability of the Halting Problem

The contradiction comes when we try to fill out the entry that
corresponds to the column of D.
1 If we put an accept there, it should be reject.
2 Similarly, if we put a reject there, it should be accept.
hM1 i hM2 i hM3 i hM4 i ··· ··· hMi i ···
···
D = Mi accept accept reject reject ··· ··· ?? ···

Sarmad Abbasi (Virtual University) Theory of Computation 27 / 43


Undecidability of the Halting Problem

1 Assume H exists.
2 Construct D. We argue that D can be constructed from H.
3 We check what D will do if it is given its own description.
4 This leads to an absurdity. Therefore, H cannot exist.
5 Quad erat demenstratum

Sarmad Abbasi (Virtual University) Theory of Computation 28 / 43


A Turing un-recognizable language.

Theorem
A language A is decidable if and only if A is decidable.

1 Proof is actually one line.


2 If we have a decider M that accepts A.
3 We can switch the accept and reject states to make another
decider M 0 .
4 M 0 accepts A.

Sarmad Abbasi (Virtual University) Theory of Computation 29 / 43


A Turing un-recognizable language.

Lets recall that a language A is Turing recognizable if there is a TM M


such that

L(M) = A.
The TM M does not have to halt on all inputs. All we want is

accept, x ∈ A;
M(x) =
does not accept, x 6∈ A.
Note that the same trick we did in the previous theorem will not work
here. If we switch the accept and reject states of M we get a new
machine M 0 that does the following:

Sarmad Abbasi (Virtual University) Theory of Computation 30 / 43


A Turing un-recognizable language.


0 rejects, x 6∈ A;
M (x) =
accepts or loops, x ∈ A.

Sarmad Abbasi (Virtual University) Theory of Computation 31 / 43


A Turing un-recognizable language.

So it is sensible to talk about a Language whose complement is Turing


recognizable.

Definition
A language B is called co-Turing-recognizable if B is
Turing-recognizable.

Sarmad Abbasi (Virtual University) Theory of Computation 32 / 43


A Turing un-recognizable language.

Lets now prove another theorem.


Theorem
If a language is Turing recognizable and co-Turing-recognizable then it
is decidable.

Sarmad Abbasi (Virtual University) Theory of Computation 33 / 43


A Turing un-recognizable language.

Suppose A is Turing-recognizable and co-Turing-recognizable.


1 There is a TM M1 such that L(M1 ) = A.
2 There is a TM M2 such that L(M2 ) = A.

1 if x ∈ A then M1 accepts x.
2 if x ∈ A then M2 accepts x.
Lets consider the TM N now.

Sarmad Abbasi (Virtual University) Theory of Computation 34 / 43


A Turing un-recognizable language.

1 On input x.
2 Run M1 and M2 on x in parallel.
3 If M1 accepts x accept.
4 If M2 accepts x reject.
We can use dovetailing to run both machines in parallel.

Sarmad Abbasi (Virtual University) Theory of Computation 35 / 43


A Turing un-recognizable language.

1 On input x.
2 Place the start configuration of M1 on x on one tape.
3 Place the start configuration of M2 on x on second tape.
4 For i = 1, 2, 3, . . . ,
5 Simulate one step of M1 . If M1 accepts accept.
6 Simulate one step of M2 . If M2 accepts reject.

Sarmad Abbasi (Virtual University) Theory of Computation 36 / 43


A Turing un-recognizable language.

Now what is L(N)?


If x ∈ A then N accepts x and if x 6∈ A then N rejects x. Therefore,

L(N) = A.

Furthermore, N halts on all inputs. This is because

A ∪ A = Σ∗ .

Sarmad Abbasi (Virtual University) Theory of Computation 37 / 43


A Turing un-recognizable language.

We have proved the following theorem:

Theorem (4.16)
If a language is Turing recognizable and co-Turing-recognizable then it
is decidable.
Lets apply this theorem to the Halting Problem. We cannot apply is
directly.

Sarmad Abbasi (Virtual University) Theory of Computation 38 / 43


A Turing un-recognizable language.

What do we know about Atm .


1 Atm is Turing recognizable.
2 Atm is not decidable.
So what can we conclude? We conclude that

ATM is not Turing recognizable.

Sarmad Abbasi (Virtual University) Theory of Computation 39 / 43


A Turing un-recognizable language.

Theorem
If A is not decidable the either A or A is not Turing-recognizable.

This theorem is just the contrapositive of the previous theorem.

Sarmad Abbasi (Virtual University) Theory of Computation 40 / 43


A Turing un-recognizable language.

Recall what a contrapositive is:


1 If we have a statement S : P ⇒ Q
2 Contrapositive of S is

not Q ⇒ not P

Sarmad Abbasi (Virtual University) Theory of Computation 41 / 43


A Turing un-recognizable language.
Now, suppose we have a statement

P1 ∧ P2 ⇒ Q
then its contrapositive is

not Q ⇒ not (P1 ∧ P2 ).


However, Demorgan’s laws tell us that

not (P1 ∧ P2 ) ⇔ not P1 ∨ not P2 .


Hence,
the contrapositive becomes

not Q ⇒ not P1 ∨ not P2 .

Sarmad Abbasi (Virtual University) Theory of Computation 42 / 43


A Turing un-recognizable language.

We showed that ATM is undecidable.


We showed that if A is TR and co-TR then A is decidable.
We concluded that ATM is not TR.

Sarmad Abbasi (Virtual University) Theory of Computation 43 / 43

You might also like