Post Correspondence

download Post Correspondence

of 58

Transcript of Post Correspondence

  • 8/9/2019 Post Correspondence

    1/58

    Fall 2003 Costas Busch - RPI 1

    The Post Correspondence

    Problem

  • 8/9/2019 Post Correspondence

    2/58

    Fall 2003 Costas Busch - RPI 2

    Some undecidable problems for

    context-free languages:

    Is context-free grammar ambiguous?G

    Is ?! )()( 21 GLGL

    21,GG are context-free grammars

  • 8/9/2019 Post Correspondence

    3/58

    Fall 2003 Costas Busch - RPI 3

    We need a tool to prove that the previous

    problems for context-free languages

    are undecidable:

    The Post Correspondence Problem

  • 8/9/2019 Post Correspondence

    4/58

    Fall 2003 Costas Busch - RPI 4

    The Post Correspondence Problem

    Input: Two sequences of strings

    nwwwA ,,, 21 -!

    nvvvB ,,, 21 -!

    n

  • 8/9/2019 Post Correspondence

    5/58

    Fall 2003 Costas Busch - RPI 5

    There is a Post Correspondence Solution

    if there is a sequence such that:kji ,,, -

    kjikji vvv .. !PC-solution:

    Indeces may be repeated or ommited

  • 8/9/2019 Post Correspondence

    6/58

    Fall 2003 Costas Busch - RPI 6

    Example:

    11100 111

    001 111 11

    1w 2w 3w

    1v 2v 3v

    :

    :B

    PC-solution: 3,1,2312312

    vvvwww !

    11100111

  • 8/9/2019 Post Correspondence

    7/58

    Fall 2003 Costas Busch - RPI 7

    Example:

    00100 1000

    0 11 011

    1w 2w 3w

    1v 2v 3v

    :

    :B

    There is no solution

    Because total length of strings from

    is smaller than total length of strings from

    B

    A

  • 8/9/2019 Post Correspondence

    8/58

    Fall 2003 Costas Busch - RPI 8

    The Modified Post Correspondence Problem

    Inputs: nwwwA ,,, 21 -!

    nvvvB ,,, 21 -!

    MPC-solution: kji ,,,,1 -

    kjikji vvvvwwww .. 11 !

  • 8/9/2019 Post Correspondence

    9/58

    Fall 2003 Costas Busch - RPI 9

    Example:

    11 100111

    001111 11

    1w 2w 3w

    1v 2v 3v

    :A

    :B

    MPC-solution: 2,3,1 231231 vvvwww !

    11100111

  • 8/9/2019 Post Correspondence

    10/58

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

  • 8/9/2019 Post Correspondence

    11/58

    Fall 2003 Costas Busch - RPI 11

    Theorem: The MPC problem is undecidable

    Proof: We will reduce the membership

    problem to the MPC problem

  • 8/9/2019 Post Correspondence

    12/58

    Fall 2003 Costas Busch - RPI 12

    Membership problem

    Input: recursive languagestring

    L

    w

    Question: ?Lw

    Undecidable

  • 8/9/2019 Post Correspondence

    13/58

    Fall 2003 Costas Busch - RPI 13

    Membership problem

    Input: unrestricted grammarstring

    G

    w

    Question: ?)(GLw

    Undecidable

  • 8/9/2019 Post Correspondence

    14/58

    Fall 2003 Costas Busch - RPI 14

    Suppose we have a decider for

    theM

    PC problem

    MPC solution?

    YES

    NO

    String Sequences

    MPC problem

    decider

    A

    B

  • 8/9/2019 Post Correspondence

    15/58

    Fall 2003 Costas Busch - RPI 15

    We will build a decider for

    the membership problem

    YES

    NO

    Membership

    problem

    decider

    G

    w

    ?)(GLw

  • 8/9/2019 Post Correspondence

    16/58

    Fall 2003 Costas Busch - RPI 16

    MPC problemdecider

    Membership problem decider

    G

    w

    The reduction of the membership problem

    to the MPC problem:

    A

    B

    yes yes

    no no

  • 8/9/2019 Post Correspondence

    17/58

    Fall 2003 Costas Busch - RPI 17

    MPC problemdecider

    Membership problem decider

    G

    w

    We need to convert the input instance of

    one problem to the other

    A

    B

    yes yes

    no no

    convert

    inputs

    ?

  • 8/9/2019 Post Correspondence

    18/58

    Fall 2003 Costas Busch - RPI 18

    A

    FS

    B

    F

    F : special symbol

    aa For every symbol

    Grammar G

    S : start variable

    a

    V V For every variable V

  • 8/9/2019 Post Correspondence

    19/58

    Fall 2003 Costas Busch - RPI 19

    A

    y

    B

    x

    wEE

    Grammar G

    For every production

    yx p

    E : special symbol

    string w

  • 8/9/2019 Post Correspondence

    20/58

    Fall 2003 Costas Busch - RPI 20

    Example:

    Grammar :G

    aacAC

    CBb

    BbbaABbS

    p

    p

    p |

    String aaacw !

  • 8/9/2019 Post Correspondence

    21/58

    Fall 2003 Costas Busch - RPI 21

    A B

    FS F:1w :1v

    a a

    b bc c

    A

    B

    S

    A

    B

    S

    :2w

    /

    :8w

    :2v

    /

    :8v

    :3 :3v

  • 8/9/2019 Post Correspondence

    22/58

    Fall 2003 Costas Busch - RPI 22

    A B

    E aaacE:9w :9v

    aABb S

    Bbb

    S

    C Bb

    aac

    AC

    /

    :14w

    /

    :14v

  • 8/9/2019 Post Correspondence

    23/58

    Fall 2003 Costas Busch - RPI 23

    :)(GLaaac aaacaACaABbS

    Grammar :G

    aacACCBb

    BbbaABbS

    p

    p

    p |

  • 8/9/2019 Post Correspondence

    24/58

    Fall 2003 Costas Busch - RPI 24

    SF

    :A

    :B

    1w

    S

    1v

    aacAC

    CBb

    BbbaABbS

    p

    p

    p |

    Derivation:

  • 8/9/2019 Post Correspondence

    25/58

    Fall 2003 Costas Busch - RPI 25

    bBAaSF

    :A

    :B

    1w

    aABbS

    10w

    1v 10v

    aacAC

    CBb

    BbbaABbS

    p

    p

    p |Derivation:

  • 8/9/2019 Post Correspondence

    26/58

    Fall 2003 Costas Busch - RPI 26

    CAabBAaSF

    1w

    aACaABbS

    10w

    1v 10v

    14w 2w 5w 12w

    14v 2v 5v 12v

    aacAC

    CBb

    BbbaABbS

    p

    p

    p |

    :A

    :B

    Derivation:

  • 8/9/2019 Post Correspondence

    27/58

    Fall 2003 Costas Busch - RPI 27

    EcaaaCAabBAaSF

    1w

    aaacaACaABb

    S

    10w

    1v 10v

    14w 2w 5w 12w

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

    14w 2w 13w

    aacAC

    CBb

    BbbaABbS

    p

    p

    p |

    :A

    :B

    Derivation:

  • 8/9/2019 Post Correspondence

    28/58

    Fall 2003 Costas Busch - RPI 28

    EcaaaCAabBAaSF

    1w

    aaacaACaABbS

    10w

    1v 10v

    14w 2w 5w 12w

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

    14w 2w 13w 9w

    aacAC

    CBb

    BbbaABbS

    p

    p

    p |

    :A

    :B

    Derivation:

  • 8/9/2019 Post Correspondence

    29/58

    Fall 2003 Costas Busch - RPI 29

    ),( BA has an MPC-solution

    )(GLw

    if and

    only if

  • 8/9/2019 Post Correspondence

    30/58

    Fall 2003 Costas Busch - RPI 30

    MPC problem

    decider

    Membership problem decider

    G

    w

    ConstructBA,

    A

    B

    yes yes

    no no

  • 8/9/2019 Post Correspondence

    31/58

    Fall 2003 Costas Busch - RPI 31

    Since the membership problem is undecidable,

    The MPC problem is uncedecidable

    ENDOF PROOF

  • 8/9/2019 Post Correspondence

    32/58

    Fall 2003 Costas Busch - RPI 32

    Theorem: The PC problem is undecidable

    Proof: We will reduce the MPC problem

    to the PC problem

  • 8/9/2019 Post Correspondence

    33/58

    Fall 2003 Costas Busch - RPI 33

    Suppose we have a decider for

    the PC problem

    PC solution?

    YES

    NO

    String Sequences

    PC problem

    decider

    C

    D

  • 8/9/2019 Post Correspondence

    34/58

    Fall 2003 Costas Busch - RPI 34

    We will build a decider for

    theM

    PC problem

    MPC solution?

    YES

    NO

    String Sequences

    MPC problem

    decider

    A

    B

  • 8/9/2019 Post Correspondence

    35/58

    Fall 2003 Costas Busch - RPI 35

    PC problemdecider

    MPC problem decider

    The reduction of the MPC problem

    to the PC problem:

    A

    B

    yes yes

    no no

    C

  • 8/9/2019 Post Correspondence

    36/58

    Fall 2003 Costas Busch - RPI 36

    PC problemdecider

    MPC problem decider

    A

    B

    yes yes

    no no

    C

    convertinputs

    ?

    We need to convert the input instance of

    one problem to the other

  • 8/9/2019 Post Correspondence

    37/58

    Fall 2003 Costas Busch - RPI 37

    : input to the MPC problemBA,

    nwwwA

    ,,, 21-!

    nvvvB ,,, 21 -!

    110 ,,,, dddd! nn wwwwC -

    110 ,,,, dddd! nn vvvvD -

    : input to the PC problemDC ,

    Translatedto

  • 8/9/2019 Post Correspondence

    38/58

    Fall 2003 Costas Busch - RPI 38

    kiw WWW .

    21! ***

    21 kiw WWW .!d

    A C

    BD

    11*ww d!d

    !d1n

    w

    !d

    *1n

    v

    For each i

    iFor each i

    kiv TTT .21! ki

    v TTT **** 21 .!d

    replace

  • 8/9/2019 Post Correspondence

    39/58

    Fall 2003 Costas Busch - RPI 39

    PC-solution

    1111 dddd!dddd nkinki vwvvwwww ..

    Has to start with

    These strings

    C

  • 8/9/2019 Post Correspondence

    40/58

    Fall 2003 Costas Busch - RPI 40

    PC-solution

    MPC-solution

    kiki vvvwww .. 11 !

    1111 dddd!dddd nkinki vwvvwwww ..

    C D

    A B

  • 8/9/2019 Post Correspondence

    41/58

    Fall 2003 Costas Busch - RPI 41

    DC,

    BA,

    has a PC solution

    has an MPC solution

    if and

    only if

  • 8/9/2019 Post Correspondence

    42/58

    Fall 2003 Costas Busch - RPI 42

    PC problemdecider

    MPC problem decider

    A

    B

    yes yes

    no no

    C

    DConstruct

    DC,

  • 8/9/2019 Post Correspondence

    43/58

    Fall 2003 Costas Busch - RPI 43

    Since the MPC problem is undecidable,

    The PC problem is undecidable

    ENDOF PROOF

  • 8/9/2019 Post Correspondence

    44/58

    Fall 2003 Costas Busch - RPI 44

    Some undecidable problems for

    context-free languages:

    Is context-free grammar

    ambiguous?

    G

    Is ?! )()( 21 GLGL

    21,GG

    are context-free grammars

    We reduce the PC problem to these problems

  • 8/9/2019 Post Correspondence

    45/58

    Fall 2003 Costas Busch - RPI 45

    Theorem:

    Proof:

    Let be context-free

    grammars. It is undecidable

    to determine if

    21,GG

    ! )()( 21 GLGL

    Reduce the PC problem to this

    problem

  • 8/9/2019 Post Correspondence

    46/58

    Fall 2003 Costas Busch - RPI 46

    Suppose we have a decider for the

    empty-intersection problem

    Empty-

    interection

    problemdecider

    ?)()( 21 ! GLGL

    1G

    2G

    YES

    NO

    Context-free

    grammars

  • 8/9/2019 Post Correspondence

    47/58

    Fall 2003 Costas Busch - RPI 47

    We will build a decider for

    the PC problem

    PC solution?

    YES

    NO

    String Sequences

    PC problem

    decider

    A

    B

    Th d ti f th PC bl

  • 8/9/2019 Post Correspondence

    48/58

    Fall 2003 Costas Busch - RPI 48

    PC problem decider

    The reduction of the PC problem

    to the empty-intersection problem:

    A

    B

    no yes

    yes no

    Empty-interection

    problem

    decider

    AG

    BG

    W d t t th i t i t f

  • 8/9/2019 Post Correspondence

    49/58

    Fall 2003 Costas Busch - RPI 49

    PC problem decider

    A

    B

    no yes

    yes no

    Empty-interection

    problem

    decider

    AG

    BG

    convert

    inputs

    ?

    We need to convert the input instance of

    one problem to the other

    -I t d i b l

  • 8/9/2019 Post Correspondence

    50/58

    Fall 2003 Costas Busch - RPI 50

    nwwwA ,,, 21 -!

    naaa ,,, 21 -

    }:{ ijkkjiA aaawwwssL ..!!

    Context-free grammar : iiiAiA awaSwS |pAG

    Introduce new unique symbols:

    nvvvB ,,, 21 -!

    }:{ ijkkjiBaaavvvssL ..!!

    Context-free grammar : iiiBiB avaSvS |pBG

  • 8/9/2019 Post Correspondence

    51/58

    Fall 2003 Costas Busch - RPI 51

    { )()( BA GLGL

    if and

    only if

    ),( BA has a PC solution

  • 8/9/2019 Post Correspondence

    52/58

    Fall 2003 Costas Busch - RPI 52

    ijkkji aaavvvs ..!

    ijkkji aaawwws ..!

    naaa ,,, 21 -Because are unique

    { )()( 21 GLGL

    There is a PC solution:

    ijkkji aaawwws ..!

  • 8/9/2019 Post Correspondence

    53/58

    Fall 2003 Costas Busch - RPI 53

    PC problem decider

    A

    B

    no yes

    yes no

    Empty-interection

    problem

    decider

    AG

    BG

    Construct

    Context-Free

    Grammars

  • 8/9/2019 Post Correspondence

    54/58

    Fall 2003 Costas Busch - RPI 54

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

    ENDOF PROOF

  • 8/9/2019 Post Correspondence

    55/58

    Fall 2003 Costas Busch - RPI 55

    For a context-free grammar ,GTheorem:

    it is undecidable to determineif G is ambiguous

    Proof: Reduce the PC problemto this problem

  • 8/9/2019 Post Correspondence

    56/58

    Fall 2003 Costas Busch - RPI 56

    PC problem decider

    A

    B

    no yes

    yes no

    mbiguous-grammar

    problem

    decider

    GConstruct

    Context-Free

    Grammar

  • 8/9/2019 Post Correspondence

    57/58

    Fall 2003 Costas Busch - RPI 57

    AS start variable of AG

    BS start variable of BG

    S start variable of G

    BA SSS |p

  • 8/9/2019 Post Correspondence

    58/58

    if andonly if

    G is ambiguous

    { )()( BA GLGL

    if and

    only if

    ),( BA has a PC solution