I have a language L, which is defined as: L = { b^nc^na^n , n>=1} The corresponding grammar would be able to create words such as: bca bbccaa bbbcccaaa ... How would such a grammar look like? Making two variables dependent of each other is relatively simple, but I have trouble with doing it for three. Thanks in advance!
L = { b^nc^na^n , n>=1}
As pointed out in the comments, this is a canonical example of a language which is not context free. It can be shown using the pumping lemma for context-free languages. Basically, consider a string like b^pc^pa^p
where p
is the pumping length and then show no matter what part you pump, you will throw off the balance (basically, the size of the part that's pumped is less than p
, so it cannot "span" all three symbols to keep them in sync).
L = {a^mb^nc^na^(m+n) |m ≥ 0,n ≥ 1}
As suggested in the comments, this is not context free either. It can be shown using the pumping lemma for context-free languages as well. However, given a proof (or acceptance) of the above, there is an easier way. Recall that the intersection of a regular language and a context-free language must be context free. Assume L
is context-free. Then so must be its intersection with the regular language (b+c)(b+c)* a*
. However, that intersection can be expressed as b^nc^na^n
(since m
is forced to be zero), which we know is not context-free, a contradiction. Therefore, our assumption was wrong and L
is not context free either.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.