8/9/2019 Dec Id Ability
1/45
Fall 2003 Costas Busch - RPI 1
Decidability
8/9/2019 Dec Id Ability
2/45
Fall 2003 Costas Busch - RPI 2
Recall:
A language is decidable (recursive),
if there is a Turing machine (decider)
that accepts the language and
halts on every input string
A
M
A
Turing Machine
Input
string
Accept
Reject
M
Decider for A
Decision
On Halt:
Decidable Languages
8/9/2019 Dec Id Ability
3/45
Fall 2003 Costas Busch - RPI 3
}7,5,3,2,{1, -!P IMES
Is number prime?x
Corresponding language:
Problem:
8/9/2019 Dec Id Ability
4/45
Fall 2003 Costas Busch - RPI 4
On input number :xDivide with all possible numbers
between and
If any of them divides
Then reject
Else accept
x2 x
Decider for :PRIMES
x
8/9/2019 Dec Id Ability
5/45
Fall 2003 Costas Busch - RPI 5
We also say that the corresponding
prime number problem is solvable:
we can give an answer (positive or negative)
for every input instance of the problem
Thus, PR MESis decidable
8/9/2019 Dec Id Ability
6/45
Fall 2003 Costas Busch - RPI 6
(Input string)
Accept
Reject
is number prime?
Decider for PRIMES
Input number
YES
NO
the decider for the language
solves the corresponding problem
(Accept)
(Reject)
8/9/2019 Dec Id Ability
7/45
Fall 2003 Costas Busch - RPI 7
Problem: Does DFA accept
the empty language ?
M
Corresponding Language:
}languageemptyacceptsthatDFAais:{
!
MM
EMPTYDFA
X
Description of DFA as a stringM
!)(ML
(For example, we can represent as a
binary string, as we did for Turing machines)
M
8/9/2019 Dec Id Ability
8/45
Fall 2003 Costas Busch - RPI 8
Determine whether there is a path from
the initial state to any accepting state
Decider for :
On input :M
DFA
{)(ML
M DFA M
!)(ML
Reject MDecision: Accept M
DFAEMPTY
8/9/2019 Dec Id Ability
9/45
Fall 2003 Costas Busch - RPI 9
Problem: Does DFA accept
a finite language?
M
Corresponding Language:
}languagefiniteaacceptst atDFAais:{ MM
FINITEDFA !X
Decidable language
8/9/2019 Dec Id Ability
10/45
Fall 2003 Costas Busch - RPI 10
Decider for :
On input :M
DFA M DFA M
Reject MDecision: Accept M
Check if there is a walk with cycle
from the initial state to an accepting state
infinite finite
DFAFINITE
8/9/2019 Dec Id Ability
11/45
Fall 2003 Costas Busch - RPI 11
Problem: Does DFA accept string ?M
Corresponding Language:
}stringacceptst atDFAais:,{ MwM
ADFA !X
w
Decidable language
8/9/2019 Dec Id Ability
12/45
Fall 2003 Costas Busch - RPI 12
Decider for :
On input string :
DFAA
Run DFA on input stringM w
If accepts
Then accept (and halt)
Else reject (and halt)
M wwM,
wM,
wM,
8/9/2019 Dec Id Ability
13/45
Fall 2003 Costas Busch - RPI 13
Problem: Do DFAs and
accept the same language?
1M
Corresponding Language:
}languagessamethe
acceptthatDFAsareand:,{ 11 MMMM
EQUALDFA !X
Decidable language
M
8/9/2019 Dec Id Ability
14/45
Fall 2003 Costas Busch - RPI 14
Let be the language of DFA
Let be the language of DFA1L
2
L
)()()( 2121 LLLLML !
Decider for :
On input :21,MM
1M
2
M
Construct DFA such that:M
(combination of DFAs)
DFAEQUAL
8/9/2019 Dec Id Ability
15/45
Fall 2003 Costas Busch - RPI 15
! )()( 2121 LLLL
!21 LL !21 LLand
21 LL !
1L 2L 1L2L
21 LL 12 LL
2L 1L
8/9/2019 Dec Id Ability
16/45
Fall 2003 Costas Busch - RPI 16
{ )()( 2121 LLLL
{ 21 LL { 21 LLor
1L 2L 1L2L
21 LL 12 LL
21 LL {
8/9/2019 Dec Id Ability
17/45
Fall 2003 Costas Busch - RPI 17
Therefore, we only need
to determine whether
!! )()()(2121
LLLLML
which is a solvable problem for DFAs:
?)( DFAEMPTYML
8/9/2019 Dec Id Ability
18/45
Fall 2003 Costas Busch - RPI 18
Undecidable Languages
there is no Turing Machine
that reaches a decision (halts)
for all input strings of the language
undecidable language =language is not decidable
There is no decider for the language:
(decision may be reached for some strings)
8/9/2019 Dec Id Ability
19/45
Fall 2003 Costas Busch - RPI 19
For an undecidable language,
the corresponding problem is unsolvable:
there is no Turing Machine (Algorithm)
that gives an answer (solves the problem)
for all input instances of the problem
(answer may be given for some input instances)
8/9/2019 Dec Id Ability
20/45
Fall 2003 Costas Busch - RPI 20
We have shown before that there are
undecidable languages:
Decidable
Turing recognizable
L
L
L is Turing recognizable but not decidable
8/9/2019 Dec Id Ability
21/45
Fall 2003 Costas Busch - RPI 21
We will prove that two particular problems
are unsolvable:
Membership problem
Halting problem
8/9/2019 Dec Id Ability
22/45
Fall 2003 Costas Busch - RPI 22
Membership Problem
Input: TuringM
achineM
String w
Question: Does accept ?M w
?)(MLw
Corresponding language:
}stringaccepts
thatmachineTuringais:,{
w
MwMATM !
8/9/2019 Dec Id Ability
23/45
Fall 2003 Costas Busch - RPI 23
Theorem:
(The membership problem is unsolvable)
Proof:
We will assume that is decidable;
We will then prove that
every decidable language
is also Turing recognizable
TMA is undecidable
TMABasic idea:
A contradiction!
8/9/2019 Dec Id Ability
24/45
Fall 2003 Costas Busch - RPI 24
Suppose that is decidable
H
M
w
YES M accepts w
NO M rejects w
TMA
Decider
for TMAwM,
Input
string
8/9/2019 Dec Id Ability
25/45
Fall 2003 Costas Busch - RPI 25
Let be a Turing recognizable languageL
Let be the Turing Machine that acceptsLM L
We will prove that is also decidable:L
we will build a decider for L
8/9/2019 Dec Id Ability
26/45
Fall 2003 Costas Busch - RPI 26
NO
YESLM
s
Haccept
L
reject
Decider for
(and halt)
(and halt)
Decider forTMA
Inputstring
s
sLM accepts ?s
8/9/2019 Dec Id Ability
27/45
Fall 2003 Costas Busch - RPI 27
Therefore, L is decidable
But there are Turing recognizable
languages which are not decidable
Contradiction!!!!
Since is chosen arbitrarily, everyTuring recognizable language
is also decidable
L
END OF PROOF
8/9/2019 Dec Id Ability
28/45
Fall 2003 Costas Busch - RPI 28
We have shown:
Decidable
TMAUndecidable
8/9/2019 Dec Id Ability
29/45
Fall 2003 Costas Busch - RPI 29
We can actually show:
Decidable
TMATuring recognizable
8/9/2019 Dec Id Ability
30/45
Fall 2003 Costas Busch - RPI 30
Turing machine that accepts :TMA
wM,
Run on input
If acceptsthen accept
M w
Mw
wM,
TMA is Turing recognizable
8/9/2019 Dec Id Ability
31/45
Fall 2003 Costas Busch - RPI 31
Halting Problem
Input: TuringM
achineM
String w
Question: Does halt while
processing input string ?
M
w
Corresponding language:
}stringinputonhalts
thatachineTuringais:,{
w
MwMHALTTM
!
8/9/2019 Dec Id Ability
32/45
Fall 2003 Costas Busch - RPI 32
Theorem:
(The halting problem is unsolvable)
Proof:
Suppose that is decidable;
we will prove that
every decidable language
is also Turing recognizable
TMHALT is undecidable
Basic idea:
A contradiction!
TMHALT
8/9/2019 Dec Id Ability
33/45
Fall 2003 Costas Busch - RPI 33
M
w
YES Mhalts on
inputw
Mdoesnt halt
on input wNO
Suppose that is decidableTMHALT
Decider for
TMHALT
wM,
Input
string
8/9/2019 Dec Id Ability
34/45
Fall 2003 Costas Busch - RPI 34
Let be a Turing recognizable languageL
Let be the Turing Machine that acceptsLM L
We will prove that is also decidable:L
Lwe will build a decider for
8/9/2019 Dec Id Ability
35/45
Fall 2003 Costas Busch - RPI 35
halts
and accepts
L
M halts on ?s YES
NOLM
Run
with inputL
M
reject s
accept
reject
LDecider for
s
s
sInput
string
Decider for
TMHALT
s
LM
and halt
halts
and rejectsLM
and halt
and halt
8/9/2019 Dec Id Ability
36/45
Fall 2003 Costas Busch - RPI 36
Therefore L is decidable
But there are Turing recognizable
languages which are not decidable
Contradiction!!!!
Since is chosen arbitrarily, everyTuring recognizable language
is also decidable
L
END OF PROOF
8/9/2019 Dec Id Ability
37/45
Fall 2003 Costas Busch - RPI 37
Theorem:
Proof:
Assume for contradiction that
the halting problem is decidable;
(The halting problem is unsolvable)
TMHALT is undecidable
we will obtain a contradiction
using a diagonilization technique
An alternative proof
Basic idea:
8/9/2019 Dec Id Ability
38/45
Fall 2003 Costas Busch - RPI 38
HM
w
YES M halts on w
Mdoesnt
halt onw
NO
Suppose that is decidableTMHALT
Decider
for TMHALTwM,
Input
string
8/9/2019 Dec Id Ability
39/45
Fall 2003 Costas Busch - RPI 39
H
wM, 0qy
q
nq
Input string:YES
NO
Looking inside H
Decider for TMHALT
M halts on ?w
8/9/2019 Dec Id Ability
40/45
Fall 2003 Costas Busch - RPI 40
H
0q
yq
nq NO
aq bq
Hd Loop forever
YES
wM,
Construct machine :Hd
If halts on input Then Loop Forever
Else Halt
M w
M halts on ?w
8/9/2019 Dec Id Ability
41/45
Fall 2003 Costas Busch - RPI 41
Construct machine :
MM,Copy
on tapeHd
F
If M halts on inputM
Then loop forever
Else halt
MM
F
8/9/2019 Dec Id Ability
42/45
Fall 2003 Costas Busch - RPI 42
Run with input itself
FF,Copy
on tapeHd
If F halts on input F
Then loops forever on input
Else halts on input
FF
F
F
F
F
F
F
END OFPR
OOF
CONTRADICTION!!!
8/9/2019 Dec Id Ability
43/45
Fall 2003 Costas Busch - RPI 43
We have shown:
Decidable
Undecidable TMHALT
8/9/2019 Dec Id Ability
44/45
Fall 2003 Costas Busch - RPI 44
We can actually show:
Decidable
Turing recognizable
TMHAL
T
8/9/2019 Dec Id Ability
45/45
Fall 2003 Costas Busch RPI 45
Turing machine that accepts :
wM,
Run on input
If halts on
then accept
M w
M w
wM,
TMHALT
is Turing recognizableTMHALT