The language {am bn cm+n ∣ m,n≥1} is

2004

The language {am  bn  cm+n ∣ m,n≥1} is

  1. A.

    Regular

  2. B.

    Context-free but not regular

  3. C.

    Context sensitive but not context free

  4. 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):

  1. Assume, for contradiction, the language is regular. Let p be the pumping length guaranteed by the pumping lemma.

  2. Consider the string s = a^p b^p c^{2p}, which belongs to the language (take m = p, n = p).

  3. 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.

  4. 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.

  5. 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.

  6. 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.

Explore the full course: Gate Guidance By Sanchit Sir

Loading lesson…