The Post Correspondence Problem

Fall 2003

Costas Busch - RPI

1

Some undecidable problems for context-free languages: ‡ Is

L(G1 ) ‰ L(G2 ) ! ˆ ?
G1,G2 are context-free grammars

‡ Is context-free grammar

G ambiguous?
2

Fall 2003

Costas Busch - RPI

We need a tool to prove that the previous problems for context-free languages are undecidable:

The Post Correspondence Problem

Fall 2003

Costas Busch - RPI

3

The Post Correspondence Problem Input: Two sequences of n strings

A ! w1, w2 , - , wn

B ! v1, v2 , - , vn

Fall 2003

Costas Busch - RPI

4

There is a Post Correspondence Solution if there is a sequence i, j ,- , k such that:

PC-solution:

i

j.

k

! vi v j . vk

Indeces may be repeated or ommited
Fall 2003 Costas Busch - RPI 5

Example:

:

w1 100

w2 11

w3 111 v3 11

B:

v1 001

v2 111

PC-solution: 2,1,3

w2 w1w3 ! v2v1v3 11100111

Fall 2003

Costas Busch - RPI

6

Example:

:

w1 00

w2 001

w3 1000 v3 011

B:

v1 0

v2 11

There is no solution Because total length of strings from B is smaller than total length of strings from A
Fall 2003 Costas Busch - RPI 7

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
Fall 2003 Costas Busch - RPI 8

Example:

A:

w1 11

w2 111

w3 100 v3 001

B:

v1 111

v2 11

MPC-solution: 1,3,2

w1w3w2 ! v1v3v2

11100111
Fall 2003 Costas Busch - RPI 9

We will show: 1. The MPC problem is undecidable
(by reducing the membership to MPC)

2. The PC problem is undecidable
(by reducing MPC to PC)

Fall 2003

Costas Busch - RPI

10

Theorem: The MPC problem is undecidable

Proof: We will reduce the membership problem to the MPC problem

Fall 2003

Costas Busch - RPI

11

Membership problem Input: recursive language L string w Question:

w L ?

Undecidable

Fall 2003

Costas Busch - RPI

12

Membership problem Input: unrestricted grammar G string w Question: w  L(G ) ?

Undecidable

Fall 2003

Costas Busch - RPI

13

Suppose we have a decider for the MPC problem String Sequences MPC solution? YES

A B

MPC problem decider

NO

Fall 2003

Costas Busch - RPI

14

We will build a decider for the membership problem

w L(G ) ?
G
w
Membership problem decider YES

NO

Fall 2003

Costas Busch - RPI

15

The reduction of the membership problem to the MPC problem:

Membership problem decider

G
w

A

yes yes
MPC problem decider no

B

no

Fall 2003

Costas Busch - RPI

16

We need to convert the input instance of one problem to the other

Membership problem decider

G
w

convert inputs ?

A

yes yes
MPC problem decider no

B

no

Fall 2003

Costas Busch - RPI

17

A FS  

B F

Grammar G

S : start variable F : special symbol

a

a

For every symbol a

V

V

For every variable V

Fall 2003

Costas Busch - RPI

18

A E

B

Grammar G string w

  wE

E : special symbol y x
For every production

xp y

Fall 2003

Costas Busch - RPI

19

Example: Grammar G :

S p aABb | Bbb Bb p C AC p aac

String

w ! aaac

Fall 2003

Costas Busch - RPI

20

A

B FS   v1 : v2 :
v3 :

w1 : w2 :
3

a
b c A B

F a b c A B

:

/

/

Fall 2003

w8 :

S

Costas Busch - RPI

v8 :

S
21

A
w9 :
E

B
v9 :
  aaacE

aABb Bbb

S S /
Bb AC

/

C aac  

w14 :

v14 :

 

Fall 2003

Costas Busch - RPI

22

Grammar G :

S p aABb | Bbb Bb p C AC p aac

aaac  L(G ) :

S   aABb   aAC   aaac

Fall 2003

Costas Busch - RPI

23

S p aABb | Bbb

Derivation: S

Bb p C AC p aac

A:

w1
F S  

B:

v1

Fall 2003

Costas Busch - RPI

24

Derivation:

S p aABb | Bbb Bb p C AC p aac

S   aABb

A:

w1

w10

F S  a A B b

B:

v1 v10

Fall 2003

Costas Busch - RPI

25

Derivation:

S p aABb | Bbb Bb p C AC p aac

S   aABb   aAC

A:

w1

w10 w14 w2 w5 w12

F S  a A B b a A C

B : v1 v10 v14 v2 v5 v12

Fall 2003

Costas Busch - RPI

26

Derivation:

S p aABb | Bbb Bb p C AC p aac

S   aABb   aAC   aaac

A:

w1

w10 w14 w2 w5 w12w14 w2 w13

F S  a A B b a A C  a a a c E

B :v1 v10 v14 v2 v5 v12 v14 v2 v13

Fall 2003

Costas Busch - RPI

27

Derivation:

S p aABb | Bbb Bb p C AC p aac

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

B :v1 v10 v14 v2 v5 v12 v14 v2 v13

v9

Fall 2003

Costas Busch - RPI

28

( A, B ) has an MPC-solution
if and only if

w L(G )

Fall 2003

Costas Busch - RPI

29

Membership problem decider

G
w

Construct A, B

A

yes yes
MPC problem decider no

B

no

Fall 2003

Costas Busch - RPI

30

Since the membership problem is undecidable, The MPC problem is uncedecidable

END OF PROOF
Fall 2003 Costas Busch - RPI 31

Theorem: The PC problem is undecidable

Proof: We will reduce the MPC problem to the PC problem

Fall 2003

Costas Busch - RPI

32

Suppose we have a decider for the PC problem String Sequences PC solution? YES

C
D

PC problem decider

NO

Fall 2003

Costas Busch - RPI

33

We will build a decider for the MPC problem String Sequences MPC solution? YES

A

MPC problem decider

B

NO

Fall 2003

Costas Busch - RPI

34

The reduction of the MPC problem to the PC problem:

MPC problem decider A
B C
PC problem decider

yes yes no no

Fall 2003

Costas Busch - RPI

35

We need to convert the input instance of one problem to the other

MPC problem decider A
B

convert inputs ?

C
PC problem decider

yes yes no no

Fall 2003

Costas Busch - RPI

36

A, B : input to the MPC problem
A ! w1, w2 ,- , wn B ! v1, v2 ,- , vn
Translated to

C ,D

: input to the PC problem

d d d d C ! w0 , w1,- , wn , wn 1 dd dd D ! v0 , v1,- , vn , vn 1
Fall 2003 Costas Busch - RPI 37

A
w i ! W 1W 2 . W k

C
wid W 1 * W 2 * . W k * !

For each

i

replace w 1d * w 1d !
wnd ! ¢ 1

B
vi ! T 1T 2 . T k

D
vid *T 1 * T 2 * . * T k !

For each i

v nd ! *¢ 1

Fall 2003

Costas Busch - RPI

38

C

PC-solution

d. w 1dd w kdnd ! v 1vid w kdd wi . w 1 vn 1

Has to start with These strings

Fall 2003

Costas Busch - RPI

39

C

PC-solution

D

d. w 1dd w kdnd ! v 1vid w kdd wi . w 1 vn 1

A

B
MPC-solution

w 1w i . w k ! v 1vi . v k

Fall 2003

Costas Busch - RPI

40

C, D

has a PC solution if and only if

A, B

has an MPC solution

Fall 2003

Costas Busch - RPI

41

MPC problem decider A
B

Construct C, D

C

yes yes
PC problem decider

D

no

no

Fall 2003

Costas Busch - RPI

42

Since the MPC problem is undecidable, The PC problem is undecidable

END OF PROOF
Fall 2003 Costas Busch - RPI 43

Some undecidable problems for context-free languages: ‡ Is

L(G1 ) ‰ L(G2 ) ! ˆ ?
G1,G2 are context-free grammars

‡ Is context-free grammar ambiguous?

G

We reduce the PC problem to these problems
Fall 2003 Costas Busch - RPI 44

Theorem: Let G1,G2 be context-free grammars. It is undecidable to determine if L(G1 ) ‰ L(G2 ) ! ˆ

Proof: Reduce the PC problem to this problem

Fall 2003

Costas Busch - RPI

45

Suppose we have a decider for the empty-intersection problem

Context-free grammars

L(G1 ) ‰ L(G2 ) ! ˆ ?
Emptyinterection problem decider YES NO

G1 G2

Fall 2003

Costas Busch - RPI

46

We will build a decider for the PC problem String Sequences PC solution? YES

A

PC problem decider

B

NO

Fall 2003

Costas Busch - RPI

47

The reduction of the PC problem to the empty-intersection problem:

PC problem decider A B G A EmptyGB
interection problem decider

no

yes

yes no

Fall 2003

Costas Busch - RPI

48

We need to convert the input instance of one problem to the other

PC problem decider A B convert inputs ? G A EmptyGB
interection problem decider

no

yes

yes no

Fall 2003

Costas Busch - RPI

49

Introduce new unique symbols:

a1, a2 ,- , an

A ! w1, w2 ,- , wn LA ! {s : s ! wi w j . wk ak . a j ai }
Context-free grammar G A : S A p wi S Aai | wi ai

B ! v1, v2 ,- , vn

LB ! {s : s ! vi v j . vk ak . a j ai }
Context-free grammar GB : S B p vi S B ai | vi ai
Fall 2003 Costas Busch - RPI 50

( A, B ) has a PC solution
if and only if

L (G A ) ‰ L (G B ) { ˆ

Fall 2003

Costas Busch - RPI

51

L(G1 ) ‰ L (G2 ) { ˆ

s ! wi w j . wk ak . a j ai s ! vi v j . vk ak . a j ai

Because

a1, a2 ,- , an

are unique

There is a PC solution:

s ! wi w j . wk ak . a j ai
Fall 2003 Costas Busch - RPI 52

PC problem decider A B
Construct Context-Free GB Grammars

G A Emptyinterection problem decider

no

yes

yes no

Fall 2003

Costas Busch - RPI

53

Since PC is undecidable, the empty-intersection problem is undecidable

END OF PROOF
Fall 2003 Costas Busch - RPI 54

Theorem: For a context-free grammar

G ,

it is undecidable to determine if G is ambiguous

Proof:

Reduce the PC problem to this problem

Fall 2003

Costas Busch - RPI

55

PC problem decider A B
Construct Context-Free Grammar

G

mbiguousgrammar problem decider

no

yes

yes no

Fall 2003

Costas Busch - RPI

56

SA SB

start variable of G A start variable of GB

S

start variable of

G

S p 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
Fall 2003

is ambiguous
Costas Busch - RPI 58

Sign up to vote on this title
UsefulNot useful