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
  • 15,071
  • 2
  • 27
  • 52
Cassie
  • 11
  • 3
  • https://cs.stackexchange.com/q/18524/755 – D.W. Apr 16 '21 at 19:17
  • 1
    Cross-posted: https://stackoverflow.com/q/67126401/781723, https://cs.stackexchange.com/q/138989/755. Please do not post the same question on multiple sites. – D.W. Apr 16 '21 at 19:17
  • Please do not delete your question after you receive an answer. Part of our mission is to build up an archive of high-quality questions and answers that will help not only you but others in the future, and answerers may be answering on that basis, so deleting the post is not very respectful of their effort. – D.W. Apr 19 '21 at 17:53

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
  • 15,071
  • 2
  • 27
  • 52