59
Costas Busch - LSU 1 The Post Correspondence Problem

Costas Busch - LSU1 The Post Correspondence Problem

Embed Size (px)

DESCRIPTION

Costas Busch - LSU3 We need a tool to prove that the previous problems for context-free languages are undecidable: The Post Correspondence Problem

Citation preview

Page 1: Costas Busch - LSU1 The Post Correspondence Problem

Costas Busch - LSU 1

The Post Correspondence Problem

Page 2: Costas Busch - LSU1 The Post Correspondence Problem

Costas Busch - LSU 2

Some undecidable problems forcontext-free languages:

• Is context-free grammar ambiguous?G

• Is ? )()( 21 GLGL

21,GG are context-free grammars

Page 3: Costas Busch - LSU1 The Post Correspondence Problem

Costas Busch - LSU 3

We need a tool to prove that the previousproblems for context-free languagesare undecidable:

The Post Correspondence Problem

Page 4: Costas Busch - LSU1 The Post Correspondence Problem

Costas Busch - LSU 4

The Post Correspondence Problem

Input: Two sets of strings

nwwwA ,,, 21

nvvvB ,,, 21

n

Page 5: Costas Busch - LSU1 The Post Correspondence Problem

Costas Busch - LSU 5

There is a Post Correspondence Solutionif there is a sequence such that:kji ,,,

kjikji vvvwww PC-solution:

Indices may be repeated or omitted

Page 6: Costas Busch - LSU1 The Post Correspondence Problem

Costas Busch - LSU 6

Example:11100 111

001 111 11

1w 2w 3w

1v 2v 3v

:A

:B

PC-solution: 3,1,2 312312 vvvwww

11100111

Page 7: Costas Busch - LSU1 The Post Correspondence Problem

Costas Busch - LSU 7

Example:00100 1000

0 11 011

1w 2w 3w

1v 2v 3v

:A

:B

There is no solution

Because total length of strings from is smaller than total length of strings from

BA

Page 8: Costas Busch - LSU1 The Post Correspondence Problem

Costas Busch - LSU 8

The Modified Post Correspondence Problem

Inputs: nwwwA ,,, 21

nvvvB ,,, 21

MPC-solution: kji ,,,,1

kjikji vvvvwwww 11

Page 9: Costas Busch - LSU1 The Post Correspondence Problem

Costas Busch - LSU 9

Example:11 100111

001111 11

1w 2w 3w

1v 2v 3v

:A

:B

MPC-solution: 2,3,1 231231 vvvwww

11100111

Page 10: Costas Busch - LSU1 The Post Correspondence Problem

Costas Busch - LSU 10

1. The MPC problem is undecidable

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

(by reducing the membership to MPC)

We will show:

Page 11: Costas Busch - LSU1 The Post Correspondence Problem

Costas Busch - LSU 11

Theorem: The MPC problem is undecidable

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

Page 12: Costas Busch - LSU1 The Post Correspondence Problem

Costas Busch - LSU 12

Membership problem

Input: Turing machine string

Mw

Question: ?)(MLw

Undecidable

Page 13: Costas Busch - LSU1 The Post Correspondence Problem

Costas Busch - LSU 13

Membership problem

Input: unrestricted grammar string

Gw

Question: ?)(GLw

Undecidable

Page 14: Costas Busch - LSU1 The Post Correspondence Problem

Costas Busch - LSU 14

Suppose we have a decider for the MPC problem

MPC solution?

YES

NO

String Sequences

MPC problemdecider

A

B

Page 15: Costas Busch - LSU1 The Post Correspondence Problem

Costas Busch - LSU 15

We will build a decider for the membership problem

YES

NO

Membershipproblemdecider

G

w

?)(GLw

Page 16: Costas Busch - LSU1 The Post Correspondence Problem

Costas Busch - LSU 16

MPC problemdecider

Membership problem decider

G

w

The reduction of the membership problemto the MPC problem:

A

B

yes yes

no no

Page 17: Costas Busch - LSU1 The Post Correspondence Problem

Costas Busch - LSU 17

MPC problemdecider

Membership problem decider

G

w

We need to convert the input instance ofone problem to the other

A

B

yes yes

no noReduction?

Page 18: Costas Busch - LSU1 The Post Correspondence Problem

Costas Busch - LSU 18

Convert grammar and string

Reduction:

G w

to sets of strings and A B

Such that:

generatesG wThere is an MPCsolution for BA,

Page 19: Costas Busch - LSU1 The Post Correspondence Problem

Costas Busch - LSU 19

A

FS

B

FF : special symbol

aa For every symbol

Grammar G

S : start variable

a

V V For every variable V

Page 20: Costas Busch - LSU1 The Post Correspondence Problem

Costas Busch - LSU 20

A

y

B

x

wEE

Grammar G

For every productionyx

E : special symbolstring w

Page 21: Costas Busch - LSU1 The Post Correspondence Problem

Costas Busch - LSU 21

Example:

Grammar : G

aacACCBb

BbbaABbS

|

String aaacw

Page 22: Costas Busch - LSU1 The Post Correspondence Problem

Costas Busch - LSU 22

A B

FS F:1w :1va ab bc cA

B

CS

A

B

CS

:2w

:8w

:2v

:8v

:3w :3v

Page 23: Costas Busch - LSU1 The Post Correspondence Problem

Costas Busch - LSU 23

A B

E aaacE:9w :9v

aABb SBbb SC Bbaac

AC

:14w

:14v

Page 24: Costas Busch - LSU1 The Post Correspondence Problem

Costas Busch - LSU 24

:)(GLaaac aaacaACaABbS

Grammar : G

aacACCBb

BbbaABbS

|

Page 25: Costas Busch - LSU1 The Post Correspondence Problem

Costas Busch - LSU 25

SF

:A

:B

1w

S

1v

aacACCBb

BbbaABbS

|Derivation:

Page 26: Costas Busch - LSU1 The Post Correspondence Problem

Costas Busch - LSU 26

bBAaSF

:A

:B

1w

aABbS

10w

1v 10v

aacACCBb

BbbaABbS

|Derivation:

Page 27: Costas Busch - LSU1 The Post Correspondence Problem

Costas Busch - LSU 27

CAabBAaSF

1w

aACaABbS

10w

1v 10v

14w 2w 5w 12w

14v 2v 5v 12v

aacACCBb

BbbaABbS

|

:A

:B

Derivation:

Page 28: Costas Busch - LSU1 The Post Correspondence Problem

Costas Busch - LSU 28

EcaaaCAabBAaSF

1w

aaacaACaABbS

10w

1v 10v

14w 2w 5w 12w

14v 2v 5v 12v 14v 2v 13v

14w 2w 13w

aacACCBb

BbbaABbS

|

:A

:B

Derivation:

Page 29: Costas Busch - LSU1 The Post Correspondence Problem

Costas Busch - LSU 29

EcaaaCAabBAaSF

1w

aaacaACaABbS

10w

1v 10v

14w 2w 5w 12w

14v 2v 5v 12v 14v 2v 13v 9v

14w 2w 13w 9w

aacACCBb

BbbaABbS

|

:A

:B

Derivation:

Page 30: Costas Busch - LSU1 The Post Correspondence Problem

Costas Busch - LSU 30

),( BA has an MPC-solution

)(GLw

if and only if

Page 31: Costas Busch - LSU1 The Post Correspondence Problem

Costas Busch - LSU 31

MPC problemdecider

Membership problem decider

G

w

ConstructBA,

A

B

yes yes

no no

Page 32: Costas Busch - LSU1 The Post Correspondence Problem

Costas Busch - LSU 32

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

END OF PROOF

Page 33: Costas Busch - LSU1 The Post Correspondence Problem

Costas Busch - LSU 33

Theorem: The PC problem is undecidable

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

Page 34: Costas Busch - LSU1 The Post Correspondence Problem

Costas Busch - LSU 34

Suppose we have a decider for the PC problem

PC solution?

YES

NO

String Sequences

PC problemdecider

C

D

Page 35: Costas Busch - LSU1 The Post Correspondence Problem

Costas Busch - LSU 35

We will build a decider for the MPC problem

MPC solution?

YES

NO

String Sequences

MPC problemdecider

A

B

Page 36: Costas Busch - LSU1 The Post Correspondence Problem

Costas Busch - LSU 36

PC problemdecider

MPC problem decider

The reduction of the MPC problemto the PC problem:

A

B

yes yes

no no

C

D

Page 37: Costas Busch - LSU1 The Post Correspondence Problem

Costas Busch - LSU 37

PC problemdecider

MPC problem decider

A

B

yes yes

no no

C

DReduction?

We need to convert the input instance ofone problem to the other

Page 38: Costas Busch - LSU1 The Post Correspondence Problem

Costas Busch - LSU 38

: input to the MPC problemBA,

nwwwA ,,, 21

nvvvB ,,, 21

11 ,,, nn wwwC

11 ,,, nn vvvD

: input to the PC problemDC ,

Translated to

Page 39: Costas Busch - LSU1 The Post Correspondence Problem

Costas Busch - LSU 39

kiw 21 *** 21 kiw

A C

B D

11 *ww

1nw

*1nv

For each i

iFor each ikiv 21 kiv **** 21

replace

Page 40: Costas Busch - LSU1 The Post Correspondence Problem

Costas Busch - LSU 40

PC-solution

1111 nkinki vwvvwwww

Has to start with These strings

C D

Page 41: Costas Busch - LSU1 The Post Correspondence Problem

Costas Busch - LSU 41

PC-solution

MPC-solution

kiki vvvwww 11

1111 nkinki vwvvwwww C D

A B

Page 42: Costas Busch - LSU1 The Post Correspondence Problem

Costas Busch - LSU 42

DC,

BA,

has a PC solution

has an MPC solution

if and only if

Page 43: Costas Busch - LSU1 The Post Correspondence Problem

Costas Busch - LSU 43

PC problemdecider

MPC problem decider

A

B

yes yes

no no

C

D

ConstructDC,

Page 44: Costas Busch - LSU1 The Post Correspondence Problem

Costas Busch - LSU 44

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

END OF PROOF

Page 45: Costas Busch - LSU1 The Post Correspondence Problem

Costas Busch - LSU 45

Some undecidable problems forcontext-free languages:

• Is context-free grammar ambiguous?

G

• Is ? )()( 21 GLGL21,GG are context-free grammars

We reduce the PC problem to these problems

Page 46: Costas Busch - LSU1 The Post Correspondence Problem

Costas Busch - LSU 46

Theorem:

Proof:

Let be context-free grammars. It is undecidableto determine if

21,GG

)()( 21 GLGL

Reduce the PC problem to thisproblem

(intersection problem)

Page 47: Costas Busch - LSU1 The Post Correspondence Problem

Costas Busch - LSU 47

Suppose we have a decider for theintersection problem

Empty-interectionproblemdecider

?)()( 21 GLGL

1G

2G

YES

NO

Context-free grammars

Page 48: Costas Busch - LSU1 The Post Correspondence Problem

Costas Busch - LSU 48

We will build a decider for the PC problem

PC solution?

YES

NO

String Sequences

PC problemdecider

A

B

Page 49: Costas Busch - LSU1 The Post Correspondence Problem

Costas Busch - LSU 49

PC problem decider

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

A

B

no yes

yes no

Intersectionproblemdecider

AG

BG

Page 50: Costas Busch - LSU1 The Post Correspondence Problem

Costas Busch - LSU 50

PC problem decider

A

B

no yes

yes no

AG

BGReduction?

We need to convert the input instance ofone problem to the other

Intersectionproblemdecider

Page 51: Costas Busch - LSU1 The Post Correspondence Problem

Costas Busch - LSU 51

nwwwA ,,, 21 naaa ,,, 21

}:{ ijkkjiA aaawwwssL

Context-free grammar : iiiAiA awaSwS |AG

Introduce new unique symbols:

nvvvB ,,, 21

}:{ ijkkjiB aaavvvssL

Context-free grammar : iiiBiB avaSvS |BG

Page 52: Costas Busch - LSU1 The Post Correspondence Problem

Costas Busch - LSU 52

)()( BA GLGL

if and only if

),( BA has a PC solution

Page 53: Costas Busch - LSU1 The Post Correspondence Problem

Costas Busch - LSU 53

ijkkji aaavvvs ijkkji aaawwws

naaa ,,, 21 Because are unique

)()( 21 GLGL

There is a PC solution:

kjikji vvvwww

Page 54: Costas Busch - LSU1 The Post Correspondence Problem

Costas Busch - LSU 54

PC problem decider

A

B

no yes

yes no

Intersectionproblemdecider

AG

BG

ConstructContext-FreeGrammars

Page 55: Costas Busch - LSU1 The Post Correspondence Problem

Costas Busch - LSU 55

Since PC is undecidable,the Intersection problem is undecidable

END OF PROOF

Page 56: Costas Busch - LSU1 The Post Correspondence Problem

Costas Busch - LSU 56

For a context-free grammar ,GTheorem:it is undecidable to determineif G is ambiguous

Proof: Reduce the PC problem to this problem

Page 57: Costas Busch - LSU1 The Post Correspondence Problem

Costas Busch - LSU 57

PC problem decider

A

B

no yes

yes no

Ambiguousproblemdecider

GConstructContext-FreeGrammar

Page 58: Costas Busch - LSU1 The Post Correspondence Problem

Costas Busch - LSU 58

AS start variable of AG

BS start variable of BG

S start variable of G

BA SSS |

Page 59: Costas Busch - LSU1 The Post Correspondence Problem

Costas Busch - LSU 59

if and only if

G is ambiguous

)()( BA GLGL

if and only if

),( BA has a PC solution