Professional Documents
Culture Documents
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?
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
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
YES NO
M finite language
Mw
problem
w YES
decider NO
6
We need to convert one problem instance
to the other problem instance
YES NO
M convert finite language
Mw
input problem
w YES
? decider NO
7
Construct machine M w:
On arbitrary input string s
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?
11
Theorem:
12
Let M be the TM with L( M ) = L
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
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
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
Otherwise, reject s ( L( M w ) = ∅ )
17
M halts on w
if and
only if
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:
21
Some non-trivial properties of
recursively enumerable languages:
• L is empty
• L is finite
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
25
We need a tool to prove that the previous
problems for context-free languages
are undecidable:
26
The Post Correspondence Problem
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
28
Example: w1 w2 w3
A: 100 11 111
v1 v2 v3
B: 001 111 11
11100111
29
Example: w1 w2 w3
A: 00 001 1000
v1 v2 v3
B: 0 11 011
There is no solution
Inputs: A = w1, w2 , , wn
B = v1, v2 , , vn
MPC-solution: 1, i, j , , k
v1 v2 v3
B: 111 11 001
11100111
32
Theorems
33
Theorem: The MPC problem is undecidable
34
Membership problem
Question: w∈ L ?
Undecidable
35
Membership problem
Question: w∈ L(G ) ?
Undecidable
36
Suppose we have a decider for
the MPC problem
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:
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
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
41
A B Grammar G
E ⇒ wE string w
E : special symbol
⇒ ⇒
42
Example:
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 )
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
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
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
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?