The language {am bn cm+n ∣ m,n≥1} is
2004
The language {am bn cm+n ∣ m,n≥1} is
- A.
Regular
- B.
Context-free but not regular
- C.
Context sensitive but not context free
- D.
Type-0 but not context sensitive
Attempted by 104 students.
Show answer & explanation
Correct answer: B
Answer: Context-free but not regular
Context-free grammar that generates the language (m,n ≥ 1):
S -> a S c | a T c
T -> b T c | b c
Why this grammar works:
Each production a S c or a T c adds one a at the front and one c at the end, ensuring m copies of a and contributing m copies of c.
The nonterminal T generates b^n c^n with n ≥ 1, so T contributes n b's and n c's.
Total number of c's is m (from a-productions) plus n (from T), i.e., m+n, and at least one a and one b are guaranteed by the forms a T c and b c.
Proof it is not regular (pumping lemma):
Assume, for contradiction, the language is regular. Let p be the pumping length guaranteed by the pumping lemma.
Consider the string s = a^p b^p c^{2p}, which belongs to the language (take m = p, n = p).
By the pumping lemma, s can be split as s = x y z with |xy| ≤ p and |y| ≥ 1. Because |xy| ≤ p, the substring y consists only of a's.
Pump down with i = 0 to obtain x z. This reduces the number of a's to p - k for some k ≥ 1, while the numbers of b's and c's remain p and 2p respectively.
For x z to be in the language we would need the number of c's to equal (p - k) + p = 2p - k, but x z has 2p c's, which is greater than 2p - k. Hence x z ∉ L, contradicting the pumping lemma.
Therefore the language is not regular.
Conclusion: The language is generated by a context-free grammar (so it is context-free) but fails the pumping lemma for regular languages, so it is not regular.
A video solution is available for this question — log in and enroll to watch it.