I am trying to develop a CFG for the language $L$ defined by:
$L = \{a^{n+2}bba^{n-2} | n > 1\}$
The problem I am having is that I cannot develop the CFG for this language no matter what I try. The closest I can get is:
$S \rightarrow aaaaXbbX$ (Production 1)
$X \rightarrow aX | \Lambda $ (Production 2)
This would be right if we were somehow forced to substitute the same value of the non-terminal $X$ in both its appearances in production 1. However, we can substitute $X \rightarrow aX$ in its first apperance in production 1 and $X \rightarrow \Lambda$ in its second appearance in production 1, thus throwing the balance of $a's$ off as defined in the language $L$.
The first question is, is there even a CFG for this?
Well, I would say according to theory, yes there is because:
- I am asked to draw a Determinate Push Down Automata for this language; and
- According to theory, every language accepted by a PDA is context-free
Am I correct that there is a CFG to this and what is it?