0

I been watching tutorials about how to check if a language is not context-free and in 1 video there was a language: L = {a^n b^n c^n | n ≥ 0} and they used a pumping lemma to prove that it's not context-free, I am only a beginner at CFG however I thought a language is Context-free if you are able to create a CFG for it, and this is the CFG i created for this language:

S --> aSX |  
X --> bXY | 
Y --> cY | 

Or am I not understand CFG and what I wrote doesn't make sense?

john3901
  • 13
  • 3
  • Welcome to [cs.SE]! We get asked this sort of question a lot, so we've written some reference questions which cover your problem in detail. I think you'll find it helpful to work through the related questions listed there. See especially http://cs.stackexchange.com/q/18524/755 and http://cs.stackexchange.com/q/11315/755. Hint: try to prove your CFG is correct using the methods in the latter question; I think you'll discover for yourself what happened. – D.W. Dec 06 '15 at 19:26

1 Answers1

1

The grammar you wrote can generate the word "aaa", which is not supposed to be generated, if the grammar generates exactly $L$.

ergo, the grammar is incorrect for $L$. (which is great, since $L$ is not CFL, and no grammar can generate it!)

Ran G.
  • 20,684
  • 3
  • 60
  • 115
  • Oh yeah i forgot about the epsilon, so even if the input aaabbbccc could theoretically be generated nothing stops you from supplying aaa, either, thanks for that – john3901 Dec 06 '15 at 14:25