0

I started learning CFG and I'm trying to find CFG for this language, but I have no idea where to start and I can't seem to find this one online anywhere. It would be great help, if someone could show me how to do it. Thank you!

Nathaniel
  • 18,309
  • 2
  • 30
  • 58
Cassie
  • 11
  • 4

1 Answers1

0

You can verify that the following CFG recognizes the language $\{a^nb^mc^k|n,m,k>0, n+m=k\}$:

$S \rightarrow aXc | aSc$

$X \rightarrow bXc | bc$

Now your language $L$ can be written as $L = L_1 \cup L_2$ where $L_1 = \{a^nb^mc^k|n,m,k>0, n+m>k\}$ and $L_2 = \{a^nb^mc^k|n,m,k>0, n+m<k\}$.

You can then find a CFG for $L_1$ and $L_2$, based on the grammar I gave you above.

Nathaniel
  • 18,309
  • 2
  • 30
  • 58