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!
Asked
Active
Viewed 1,712 times
1 Answers
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