Hello everyone,
I have to check if the following language is context free:
L2={a^n * b^m * c^n * d^(n+m) :m>=0 n>=0 }
Please help, I am totally stuck and I have to hand it over on Monday.
Hello everyone,
I have to check if the following language is context free:
L2={a^n * b^m * c^n * d^(n+m) :m>=0 n>=0 }
Please help, I am totally stuck and I have to hand it over on Monday.
For disproving that it is context free: http://en.wikipedia.org/wiki/Pumping_lemma_for_context-free_languages
For proving that it is context free - come up with a context-free grammar that generates the language.
Try both of the above until one succeeds.
It's not context-free. a^n b^m c^n d^m is the first example of a non- context-free language, this one is very similar.
You can disprove it with the pumping lemma like Rafal wrote.
So you can prove that this isn't context free with a pretty standard pumping lemma by cases argument. (I don't do the whole model the pumping lemma as games, because that's just for people who don't understand quantifiers).
Take any m, now construct the string:
a^m b^m c^m d^2m
It should be pretty obvious that this string is in the language and is the case where n=m. Now what happens if we pump any part of the string, well clearly if we pump any part consisting of only one letter, then it will no longer be a member of the language. If we pump any of the overlaps then it will also no longer be a member of the language, because we won't be able to change the corresponding n or m component so that it corresponds to it. As an example if we pump the ab overlap then c won't have the same cardinality as a, so it won't be in the language.
Obviously you might need a little bit more rigor, but that's all that it takes.