Undecidable problems
for
Recursively enumerable languages
continued…
1
Take a recursively enumerable language L
Decision problems:
• L is empty?
• L is finite?
• L contains two different strings
of the same length?
All these problems are undecidable
2
Theorem:
For a recursively enumerable language L
it is undecidable to determine whether
L is finite
Proof:
We will reduce the halting problem
to this problem
3
Let M be the TM with L( M ) = L
Suppose we have a decider
for the finite language problem:
YES L(M ) finite
finite language
M problem
decider NO L(M ) not finite
4
We will build a decider
for the halting problem:
M YES M halts on w
Halting problem
decider
w NO doesn’t
M w
halt on
5
We want to reduce the halting problem to
the finite language problem
Halting problem decider
YES NO
M finite language
Mw
problem
w YES
decider NO
6
We need to convert one problem instance
to the other problem instance
Halting problem decider
YES NO
M convert finite language
Mw
input problem
w YES
? decider NO
7
Construct machine M w:
On arbitrary input string s
Initially, simulates M on input w
If M enters a halt state,
accept s ( Σ* inifinite language)
Otherwise, reject s ( ∅ finite language)
8
M halts on w
if and
only if
L( M w ) is infinite
*
L( M w ) = Σ
9
halting problem decider
YES NO
M construct M w finite language
problem
w Mw decider YES
NO
10
Take a recursively enumerable language L
Decision problems:
• L is empty?
• L is finite?
• L contains two different strings
of the same length?
All these problems are undecidable
11
Theorem:
For a recursively enumerable language L
it is undecidable to determine whether
L contains two different strings of
same length
Proof: We will reduce the halting problem
to this problem
12
Let M be the TM with L( M ) = L
Suppose we have the decider
for the two-strings problem:
YES L(M ) contains
Two-strings
M problem
decider NO Doesn’t
L(M )
contain
two equal length strings
13
We will build a decider for
the halting problem:
M YES M halts on w
Halting problem
decider
w NO doesn’t
M w
halt on
14
We want to reduce the halting problem to
the empty language problem
Halting problem decider
YES YES
M M w Two-strings
problem
w decider
NO NO
15
We need to convert one problem instance
to the other problem instance
Halting problem decider
YES YES
M convert M Two-strings
w
inputs problem
w decider
NO NO
?
16
Construct machine Mw :
On arbitrary input string s
Initially, simulate M on input w
When M enters a halt state,
accept if s = a or s = b
(two equal length strings L( M w ) = {a, b} )
Otherwise, reject s ( L( M w ) = ∅ )
17
M halts on w
if and
only if
M w accepts two equal length strings
Mw accepts a and b
18
Halting problem decider
YES YES
M construct M w Two-strings
problem
w Mw decider
NO NO
19
Rice’s Theorem
20
Definition:
Non-trivial properties of
recursively enumerable languages:
any property possessed by some (not all)
recursively enumerable languages
21
Some non-trivial properties of
recursively enumerable languages:
• L is empty
• L is finite
• L contains two different strings
of the same length
22
Rice’s Theorem:
Any non-trivial property of
a recursively enumerable language
is undecidable
23
The Post Correspondence
Problem
24
Some undecidable problems for
context-free languages:
• Is L(G1 ) ∩ L(G2 ) = ∅ ?
G1,G2 are context-free grammars
• Is context-free grammar G ambiguous?
25
We need a tool to prove that the previous
problems for context-free languages
are undecidable:
The Post Correspondence Problem
26
The Post Correspondence Problem
Input: Two sequences of n strings
A = w1, w2 , , wn
B = v1, v2 , , vn
27
There is a Post Correspondence Solution
if there is a sequence i, j , , k such that:
PC-solution: wi w j wk = vi v j vk
Indices may be repeated or omitted
28
Example: w1 w2 w3
A: 100 11 111
v1 v2 v3
B: 001 111 11
PC-solution: 2,1,3 w2 w1w3 = v2v1v3
11100111
29
Example: w1 w2 w3
A: 00 001 1000
v1 v2 v3
B: 0 11 011
There is no solution
Because total length of strings from B
is smaller than total length of strings from A
30
The Modified Post Correspondence Problem
Inputs: A = w1, w2 , , wn
B = v1, v2 , , vn
MPC-solution: 1, i, j , , k
w1wi w j wk = v1vi v j vk
31
Example: w1 w2 w3
A: 11 111 100
v1 v2 v3
B: 111 11 001
MPC-solution: 1,3,2 w1w3w2 = v1v3v2
11100111
32
Theorems
1. The MPC problem is undecidable
(by reducing the membership to MPC)
2. The PC problem is undecidable
(by reducing MPC to PC)
33
Theorem: The MPC problem is undecidable
Proof: We will reduce the membership
problem to the MPC problem
34
Membership problem
Input: recursive language L
string w
Question: w∈ L ?
Undecidable
35
Membership problem
Input: unrestricted grammar G
string w
Question: w∈ L(G ) ?
Undecidable
36
Suppose we have a decider for
the MPC problem
String Sequences MPC solution?
A YES
MPC problem
decider
B NO
37
We will build a decider for
the membership problem
w∈ L(G ) ?
G Membership YES
problem
w decider NO
38
The reduction of the membership problem
to the MPC problem:
Membership problem decider
A yes yes
G MPC problem
B decider no no
w
39
We need to convert the input instance of
one problem to the other
Membership problem decider
A yes yes
G convert MPC problem
inputs decider no no
w B
?
40
A B Grammar G
FS ⇒ F S : start variable
F : special symbol
a a For every symbol a
V V For every variable V
41
A B Grammar G
E ⇒ wE string w
E : special symbol
y x For every production
x→ y
⇒ ⇒
42
Example:
Grammar G : S → aABb | Bbb
Bb → C
AC → aac
String w = aaac
43
A B
w1 : FS ⇒ v1 : F
w2 : a v2 : a
b b
c c
A A
B B
C C
w8 : S v8 : S 44
A B
w9 : E⇒ v9 : aaacE
aABb S
Bbb S
C Bb
aac AC
w14 : ⇒ v14 : ⇒
45
Grammar G : S → aABb | Bbb
Bb → C
AC → aac
aaac ∈ L(G )
S ⇒ aABb ⇒ aAC ⇒ aaac
46
S ⇒ aABb
A
w1 w10
F S ⇒a A B b
v1 v10
B
47
S ⇒ aABb ⇒ aAC
A
w1 w10 w14 w2 w5 w12
F S ⇒a A B b⇒a A C
v1 v10 v14 v2 v5 v12
48
S ⇒ aABb ⇒ aAC ⇒ aaac
A
w1 w10 w14 w2 w5 w12w14 w2 w13 w9
F S ⇒a A B b⇒a A C ⇒a a a c E
v1 v10 v14 v2 v5 v12 v14 v2 v13 v9
49
( A, B ) has an MPC-solution
if and
only if
w∈ L(G )
50
Membership problem decider
A yes yes
G Construct MPC problem
A, B B decider no no
w
51
Since the membership problem is undecidable,
The MPC problem is undecidable
END OF PROOF
52
Theorem: The PC problem is undecidable
Proof: (omitted) The MPC problem can be
reduced to the PC problem
53
Some undecidable problems for
context-free languages:
• Is L(G1 ) ∩ L(G2 ) = ∅ ?
G1,G2 are context-free grammars
• Is context-free grammar G
ambiguous?
We reduce the PC problem to these problems
54