2

Language is $B = \{w \in \Sigma^* \mid w = a^n\#b^{2n}\#a^n \text{ for some } n \in \mathbb{N}\}$.

Assume the alphabet is $\Sigma = \{a, b, \#\}$.

I know this language is not context-free.

But below is a PDA that accepts all words from the above language: see PDA here

But isn't this a contradiction? How can the language not be context free and still be recognized by a PDA?

hgmath
  • 1,840
  • 2
    I think you would accept something like $a^n#b^{n+m}#a^m$ – Hagen von Eitzen Mar 24 '21 at 18:48
  • Right, so wouldn't it still be a contradiction though (under the theorem that a language is context-free iff it is recognized by a PDA) because eventhough lang B is a special case of the language accepted by the given PDA where n=m, it still accepts all words in B. So technically, B should be context-free?

    Also, B can be proven not context-free by pumping lemma.

    – bhujangee Mar 24 '21 at 19:22
  • 1
    @bhujangee Your "special case" argument does not make sense; just because $B$ is a subset of a context-free language, it does not need to be context-free. In fact, every language is a subset of $\Sigma^*$ but of course that doesn't make every language context-free! – hgmath Mar 24 '21 at 19:39
  • 1
    @hgmath thanks. That clears it up! – bhujangee Mar 24 '21 at 19:46

0 Answers0