1

I need to construct a CFG for the language consisting of even length palindromes with the same number of a's and b's and then prove that it generates that language.

This is the CFG I got:

S→ abba | baab | abSba | baSab | ε

I'm unsure of what to do to prove it (I just came up with this logically)...If anyone could point me in the right direction I would appreciate it. Thank you!

user3000731
  • 93
  • 2
  • 11
  • S->aSa | bSb | ε. Your cfg wont generate only a's or only b's – Abhi Oct 14 '14 at 01:48
  • That grammar doesn't generate `aabbbbaa`. The usual approach to proving that a CFG generates a language is induction on the length of the string (so you need to prove that if all strings in the language of length <= n are generated by the CFG and no other strings of length <= n, then every string of length n + 2 (in this case) in the language will also be generated, and no other string of length n + 2. – rici Oct 14 '14 at 03:42

0 Answers0