Skip to content

21. Post-Correspondence

Mar 22, 2022

We need a tool to prove some CFL problems are undecidable => the post correspondence (PC) problem.

The PC Problem

  • input: two sets of n strings: A=w1,w2,,wn and B=v1,v2,,vn
  • there is a post correspondence solution is there is a sequence i,j,,k such that wi,wjwk=vi,vjvk (indices may be repeated or omitted)

examples

1
2
3
4
5
     w1   w2    w3           v1   v2    v3
A : 100   11    111     B:  001  111    11

PC-solution I: 2,1,3    w2w1w3 = v2v1v3  => 11100111
PC-solution II: 2,3     w2w3   = v2v3    => 11111
1
2
3
4
5
     w1   w2    w3           v1   v2    v3
A :  00   001   1000     B:  0    11    011

This example has no solution, because strings from B 
is smaller than total length of strings from A.

Modified PC Problem

  • input: two sets of n strings: A=w1,w2,,wn and B=v1,v2,,vn
  • MPC solution: 1,i,j,,k => w1,wi,wjwk=v1,vi,vjvk

examples

1
2
3
4
     w1   w2    w3           v1   v2    v3
A :  11   111   100      B:  111  11    001

PC-solution:  1,3,2   w1w3w2 = v1v3v2  => 11100111

We can show:

  1. MPC problem is undecidable by reducing the membership problem to MCP.
  2. The PC problem is undecidable by reducing MPC to PC.

MPC is undecidable

Theorem: The MPC problem is undecidable.

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

Membership problem:

  • input is Turing machine M and string w => question wL(M)? => undecidable
  • change it to: input unrestricted grammar G (equivalent to TM) and string w => question wL(M)? => undecidable

Suppose we have a decider for the MPC problem. Then:

string sequences <A,B> => MPC problem decider => MPC solution (YES/NO)

We build a decider for the membership problem:

string sequences <G,w> => MPC problem decider => wL(G) (YES/NO)

Reduction of the membership problem to the MPC problem:

              Membership problem decider
        |===================================|
 G ---> | reduction |-----A----> | MPC      |---> yes 
 w ---> |           |-----B----> | decider  |---> no
        |===================================|

Show that reduction exists then problem is decidable => this is a contradiction.

Reduction: Convert grammar G and string w to sets of strings A and B, such that G generates w there is a MPC solution for A,B.

How to build reduction:

  • Left: how to build a, b
  • Right: Grammar G productions
  • a,b generate the derivation of w
A B Grammar G
FS F S: start variable, F: special symbol
a a for every symbol a
V V for every variable V
E wE string w, E: special symbol
y x For every production xy

example

  • Grammar G:

    SaABb | Bbb
    BbC
    ACaac

  • string w=aaac

A B A B
w1:FS v1:F w8:S v8:S
w2:a v2:a w9:E v9 : aaacE
w3:b v3:b w10 : aABb v10 : S
w4:c v4:c w11 : Bbb v11 : S
w5:A v5:A w12 : C v12 : Bb
w6:B v6:B w13 : aac v13 : AC
w7:C v7:C w14 : v14 :

w=aaacL(G)   SaABbaAcaaac

Derivation: s

1
2
3
A:  |     w1     |    w10     |w14 |w2 |w5|w12 | w14 |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             |

It can be shown that (A,B) has a MPC solution wL(G).

              Membership problem decider
        |===================================|
 G ---> | construct |-----A----> | MPC      |---> yes 
 w ---> |   A,B     |-----B----> | decider  |---> no
        |===================================|

=> Since the membership problem is undecidable the MPC problem is undecidable.

PC is undecidable

Theorem: The PC problem is undecidable.

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

Suppose we have a decider for the PC problem:

String sequences <C,D> => PC problem decider => PC solution (YES/NO)

We build a decider for the MPC problem:

String sequences <A,B> => MPC problem decider => MPC solution (YES/NO)

Reduction of the MPC problem to the PC problem:

                MPC problem decider
        |===================================|
 A ---> | reduction |-----C----> | PC       |---> yes 
 B ---> |           |-----D----> | decider  |---> no
        |===================================|

Translate <A,B> input to the MPC problem to <C,D> input to the PC problem:

  • A=w1,w2,,wn   B=v1,v2,,vn

  • C=w1,w2,,wn,wn+1   D=v1,v2,,vn,vn+1

  • for each i in A: wi=σ1σ2σk => replace in C: wi=σ1σ2σk

  • for each i in B: wi=π1π2πk => replace in C: vi=π1π2πk

  • PC solution has to start with w1 and v1

    • PC solution C = D: w1,w2,,wn,wn+1=v1,v2,,vn,vn+1
    • MPC solution A = B: w1,w2,,wn=v1,v2,,vn
  • => <C,D> has a solution if and only if <A,B> has a MPC solution

              MPC problem decider
        |===================================|
 A ---> | construct |-----C----> | PC       |---> yes 
 B ---> |   C,D     |-----D----> | decider  |---> no
        |===================================|

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

CFL reductions

  1. for context-free grammars G1 and G2, is L(G1)L(G2)=
  2. is context-free grammar G ambiguous?

=> reduce PC problem to these problems to prove these are undecidable.

example 1: intersection problem

Suppose we have a decider for intersection problem:

<G1,G2> => empty-intersection decider => YES/NO

We build a decider for PC problem: <A,B> => PC decider => PC solution YES/NO

To reduce, we need to concert input instance <A,B> to <G1,G2>.

Introduce new unique symbols: a1,a2,,an

  • Grammar 1 (A):

    • A=w1,w2,,wn
    • LA={s:s=wiwjwkakajai}
    • CFG: GA:SAwiSAai|wiai
  • Grammar 2 (B):

    • B=v1,v2,,vn
    • LB={s:s=vivjvkakajai}
    • CFG: GB:SBviSBai|viai

If (A,B) has a PC solution L(G1)L(G2)

  • L(G1)L(G2) => s=wiwjwkakajai and s=vivjvkakajai
  • Because a1,a2,,an are unique, there isa PC solution wiwjwk=vivjvk
              PC problem decider
        |==================================|
 A ---> | construct |---G_A---> | Int.sec  |---> yes 
 B ---> |   CFGs    |---G_B---> | decider  |---> no
        |==================================|

Since PC problem is undecidable, the intersection problem is undecidable.

example 2: ambiguous grammar

For context-free grammar G it is undecidable to determine if G is ambiguous.

Proof. reduce PC problem to this problem.

              PC problem decider
        |==================================|
 A ---> | construct |    G      | ambig.   |---> yes 
 B ---> |   CFG     |---------> | decider  |---> no
        |==================================|

SA is start variable of GA and SB is start variable of GB

=> S is start variable of G   SSA|SB

If (A,B) has a PC solution L(G1)L(G2) G is ambiguous.