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
strings: and - there is a post correspondence solution is there is a sequence
such that (indices may be repeated or omitted)
examples
1 2 3 4 5 |
|
1 2 3 4 5 |
|
Modified PC Problem
- input: two sets of
strings: and - MPC solution:
=>
examples
1 2 3 4 |
|
We can show:
- MPC problem is undecidable by reducing the membership problem to MCP.
- 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
and string => question ? => undecidable - change it to: input unrestricted grammar
(equivalent to TM) and string => question ? => undecidable
Suppose we have a decider for the MPC problem. Then:
string sequences
We build a decider for the membership problem:
string sequences
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
How to build reduction:
- Left: how to build a, b
- Right: Grammar G productions
- a,b generate the derivation of
Grammar |
||
---|---|---|
for every symbol |
||
for every variable |
||
string |
||
For every production |
||
example
-
Grammar
: |
-
string
Derivation:
1 2 3 |
|
It can be shown that
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
We build a decider for the MPC problem:
String sequences
Reduction of the MPC problem to the PC problem:
MPC problem decider |===================================| A ---> | reduction |-----C----> | PC |---> yes B ---> | |-----D----> | decider |---> no |===================================|
Translate
-
-
-
for each
in A: => replace in C: -
for each
in B: => replace in C: -
PC solution
has to start with and- PC solution C = D:
- MPC solution A = B:
- PC solution C = D:
-
=>
has a solution if and only if 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
- for context-free grammars
and , is - is context-free grammar
ambiguous?
=> reduce PC problem to these problems to prove these are undecidable.
example 1: intersection problem
Suppose we have a decider for intersection problem:
We build a decider for PC problem:
To reduce, we need to concert input instance
Introduce new unique symbols:
-
Grammar 1 (A):
- CFG:
-
Grammar 2 (B):
- CFG:
If
=> and- Because
are unique, there isa PC solution
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
Proof. reduce PC problem to this problem.
PC problem decider |==================================| A ---> | construct | G | ambig. |---> yes B ---> | CFG |---------> | decider |---> no |==================================|
=>
If