Beruflich Dokumente
Kultur Dokumente
Problem
• Is L(G1 ) L(G2 ) ?
G1,G2 are context-free grammars
A w1, w2 , , wn
B v1, v2 , , vn
PC-solution: wi w j wk vi v j vk
v1 v2 v3
B: 001 111 11
11100111
Fall 2003 Costas Busch - RPI 6
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
Fall 2003 Costas Busch - RPI 9
We will show:
Question: w L ?
Undecidable
Question: w L(G ) ?
Undecidable
A YES
MPC problem
decider
B NO
w L(G ) ?
G Membership
YES
problem
w decider NO
A yes yes
G MPC problem
B decider no no
w
A yes yes
G convert MPC problem
inputs decider no no
w B
?
FS F S : start variable
F : special symbol
E wE string w
E : special symbol
String w aaac
w1 : FS v1 : F
w2 : a v2 : a
w3 : b v3 : b
c c
A A
B B
C C
w8 : S v8 : S
Fall 2003 Costas Busch - RPI 21
A B
w9 : E v9 : aaacE
aABb S
Bbb S
C Bb
aac AC
w14 : v14 :
A: w1
F S
B: v1
A: w1 w10
F S a A B b
B: v1 v10
F S a A B ba A C
F S a A B ba A C a a a c E
F S a A B ba A C a a a c E
if and
only if
w L(G )
A yes yes
G Construct MPC problem
A, B B decider no no
w
END OF PROOF
Fall 2003 Costas Busch - RPI 31
Theorem: The PC problem is undecidable
C YES
PC problem
decider
D NO
A YES
MPC problem
decider
B NO
C yes yes
A PC problem
D decider no no
B
C yes yes
A convert PC problem
inputs D decider no no
B
?
wn1
D
B
vi 1 2 k vi * 1 * 2 * * k
A B
w 1wi w k v1vi v k
MPC-solution
if and
only if
C yes yes
A Construct PC problem
C, D D decider no no
B
END OF PROOF
• Is L(G1 ) L(G2 ) ?
G1,G2 are context-free grammars
• Is context-free grammar G
ambiguous?
A YES
PC problem
decider
B NO
PC problem decider
G A Empty- no yes
A
interection
GB problem
B yes no
decider
PC problem decider
G A Empty- no yes
A convert
inputs interection
GB problem
B ? yes no
decider
B v1, v2 , , vn
LB {s : s vi v j vk ak a j ai }
Context-free grammar GB : S B vi S B ai | vi ai
if and
only if
L(G A ) L(GB )
There is a PC solution:
s wi w j wk ak a j ai
Fall 2003 Costas Busch - RPI 52
PC problem decider
G A Empty- no yes
A Construct
Context-Free interection
GB problem
B Grammars yes no
decider
END OF PROOF
Ambiguous- no yes
A Construct
Context-Free
G grammar
Grammar problem
B yes no
decider
SB start variable of GB
S start variable of G
S S A | SB
Fall 2003 Costas Busch - RPI 57
( A, B ) has a PC solution
if and
only if
L(G A ) L(GB )
if and
only if
G is ambiguous