Professional Documents
Culture Documents
5 Undecidability
5 Undecidability
Chapter 9
1
Halting
Turing machine halts if it enters a state q and
there is no movement in that situation = (q,X)
is undefined.
2 types:
Halt and acceptance
Halt and reject
2
Decidability vs. Undecidability
There are two types of TMs (based on halting):
(Recursive)
TMs that always halt, no matter accepting or non-
accepting DECIDABLE PROBLEMS
(Recursively enumerable)
TMs that are guaranteed to halt only on acceptance. If
non-accepting, it may or may not halt (i.e., could loop
forever).
Undecidability:
Undecidable problems are those that are not
recursive
3
Recursive, RE, Undecidable languages
No TMs exist
TMs that always halt
Enumerable (RE)
Recursively
Regular Context-
sensitive
Context
Recursive
(DFA)
free
(PDA)
“Undecidable” problems
“Decidable” problems
4
Recursive Languages &
Recursively Enumerable (RE)
Languages
Any TM for a Recursive language is going to
look like this:
“accept”
w
M
“reject”
5
Closure Properties
6
Recursive Languages are closed
under complementation
If L is Recursive, L is also Recursive
M
“accept” “accept”
w
w M
“reject” “reject”
7
Are Recursively Enumerable
Languages closed under
complementation? (NO)
If L is RE, L need not be RE
M
“accept” “accept” ?
w
w M
“reject”
?
8
Recursive Languages are
closed under Union
Let Mu = TM for L1 U L2
Mu construction: Mu
accept
1. Make 2-tapes and M1 reject
copy input w on both OR
tapes w accept
2. Simulate M1 on tape 1 M2 reject
3. Simulate M2 on tape 2
4. If either M1 or M2
accepts, then Mu
accepts
5. Otherwise, Mu rejects.
9
Recursive Languages are
closed under Intersection
Let Mn = TM for L1 L2
Mn construction: Mn
accept
1. Make 2-tapes and M1 reject
copy input w on both AND
AND
tapes w accept
2. Simulate M1 on tape 1 M2 reject
3. Simulate M2 on tape 2
4. If M1 AND M2 accepts,
then Mn accepts
5. Otherwise, Mn rejects.
10
Other Closure Property
Results
Recursive languages are also closed under:
Concatenation
Kleene closure (star operator)
Homomorphism, and inverse homomorphism
RE languages are closed under:
Union, intersection, concatenation, Kleene closure
11
The Halting Problem
12
The Halting Problem
Input − A Turing machine and an
input string w.
Problem − Does the Turing machine
finish computing of the string w in
a finite number of steps? The
answer must be either yes or no.
13
The Universal Turing Machine
At first, we will assume that such a Turing machine
exists to solve this problem and then we will show it is
contradicting itself.
Given TM M & its input w.
We will build another TM called “H”, that will output:
“accept” if M accepts w, and
“reject” otherwise
An algorithm for H:
Simulate M on w
accept, if M accepts w
H(<M,w>) =
reject, if M does does not accept w
14
The Universal Turing Machine
Input w Machine
Will it always halt?
M
“accept”
<M,w>
H
“reject”
HP Proof (step 1)
Let us construct a new TM D using H as a
subroutine:
On input <M>:
1. Run H on input <M, <M> >; //(i.e., run M on M itself)
2. Output the opposite of what H outputs;
“accept” “accept”
<M>
<M, “<M>” > H
“reject” “reject”
16
HP Proof (step 2)
The notion of inputing “<M>” to M itself
A program can be input to itself (e.g., a compiler is a
program that takes any program as input)
accept, if M does not accept <M>
D (<M>) =
reject, if M accepts <M>
Now, what happens if D is input to itself?
18