Show this language is undecidable

decidabilityturing-machines

$L = \{ \langle G \rangle \mid G$ is context-free, $L(G)$ contains a palindrome $\}$

Reduce the post correspondence problem to $L$.

So I have to show that if I could decide L then I could decide PCP.
So I have to show a translation of any given PCP-problem into some form that makes it appearent that it actually is or can be viewed as a problem of determining whether or not a certain context-free grammar contains a palindrome.

As far as I understand PCP is about lining up blocks, each of them with an upper and a lower string, in a way that the concatenated upper and lower strings are the same.

A context-free grammar is a way of producing strings. Grammars that produce palindromes it seems need rules of the kind $T \rightarrow aTa$ (or something similar).

Given a PCP-instance as a bunch of 'building blocks' with an upper and a lower side, one might try to understand the possibility of arranging them in any order as an application of grammar rules that write a 'left' (corresponding to the upper strings, say) and a 'right' word (corresponding to the lower strings). But there are so many ways to put them together! How to describe this by a few rules? You can even use any building block as many times as you want. So basically there must be a rule for 'everything that can happen'. Also, the grammar needs to spell one of the words (the left or the right one) in reverse order. It should be possible to build a palindrome in that way whenever the blocks can be put together to give the same string upper and lower side.

So let there $k$ blocks be given, with upper words $a_1,…a_k$ and lower words $b_1…,b_k$.
I can start with any of the blocks, so let's introduce a grammar with every rule $$S \rightarrow a_iS\overleftarrow{b_i} $$ for every $i=1,..k$. This rule should suffice whenever I'd like to add block number $i$. Also I think we need $S \rightarrow \varepsilon$ to stop the procedure.

I'm not sure whether we need any further rules.

Now some alignment of blocks, say $i, j, l$, that is an upper string $a_i,a_j,a_l$ and a lower string $b_i,b_j,b_l$ correspond to the use of the rules $S \rightarrow a_iS\overleftarrow{b_i}, S \rightarrow a_jS\overleftarrow{b_j}, S \rightarrow a_lS\overleftarrow{b_l} $, producing the string $a_i a_j a_l \overleftarrow{b_l} \overleftarrow{b_j} \overleftarrow{b_i}$. And this should be a palindrome whenever the $a$-string and the $b$-string match.

Is this it? Am I done? It looks I used a lot of informal language, should this be more formally? Although more or less convincing it doesn't seem too rigourous, as if I could be missing something…

Best Answer

There is a helpful construction for this type of problems

This problem asks you to use this construction to show that AMBIGcfg is undecidable

Hopefully you can see that T generates a string from the upper strings and B generates a string from the lower strings

The terminals at the end encode the sequence of "dominos" used , so if T generates a string (assume that the alphabet for this PCP Instance is {a,b}) : aaab12 and B generates a string aaab12 , then a match was found , that is because we formed the match aaab using the same sequence of dominos 12 (here we use domino 2 then 1 think about it !) , this encoding guarantees that both T which uses the upper strings and B which uses the lower strings have used dominos in the same order when they formed the match

A further example to emphasis the idea , assume we use T --> t1 T a1 , then use T --> t2 a2 we generate the string t1 t2 a2 a1 , the string generated by dominos is t1 t2 and the sequence of dominos used is a1 then a2 , once again ,if B generates a string b1 b2 a2 a1, where b1 b2 = t1 t2 , then we found a match , since strings are the same with same sequence of dominos used , hopefully by now you understand how the construction works and are convinced that T and B generate the same string only if we have a match

In this problem , if both T and B generate the same string , the grammer is ambiguous and we accept , else we reject , deciding the PCP

Now can you tweek this construction for our problem ?

We replace S --> T|B by S -->TB , and replace every rule B --> bi B ai by B --> ai B bi , and replace every rule B --> bi ai by B --> ai bi ( reversing the strings on right side of rules which have B on left side )

If a match w exists , then T would generate w , and B would generate w^R , then TB is ww^R which is palindrome , ex : if w is aaab12 then T generates aaab12 and B generates 21baaa , so S is aaab1221baaa , which is a palindrome

I leave it you you to convince your self that the only way for a palindrome to exist is to have a match , if you consider that a match is represented in our grammer by the string followed by a unique sequence of dominos used for this string , then it should be easy to see how it works

So construct G with rules provided above , we assume that a decider R exists for L , we run L on < G> ,

If a match exists G generates some palindrome and L accepts

If a match doesn't exist , G generates no palindromes , and L rejects