Consider the following two languages over the alphabet \(\{𝑎, 𝑏, 𝑐\}\),…
2025
Consider the following two languages over the alphabet \(\{𝑎, 𝑏, 𝑐\}\), where 𝑚 and 𝑛 are natural numbers.
\(L_1 = \{ a^m b^m c^{m+n} \mid m, n \geq 1 \} \\ L_2 = \{ a^m b^n c^{m+n} \mid m, n \geq 1 \} \)
Which ONE of the following statements is CORRECT?
- A.
Both
\(𝐿_1\)and\(𝐿_2\)are context-free languages. - B.
\(𝐿_1\)is a context-free language but\(𝐿_2\)is not a context-free language. - C.
\(𝐿_1\)is not a context-free language but\(𝐿_2\)is a context-free language. - D.
Neither
\(𝐿_1\)nor\(𝐿_2\)are context-free languages.
Attempted by 120 students.
Show answer & explanation
Correct answer: C
Answer: The first language is not context-free, and the second language is context-free.
Reason (second language is context-free):
A context-free grammar that generates the language a^m b^n c^{m+n} (with m,n ≥ 1) is:
S -> a S c | a B c
B -> b B c | b c
Each application of the first production adds one a at the front and one c at the end (counting toward the m part); when we stop producing a's we switch to B which produces n b's and n c's. Overall this yields a^m b^n c^{m+n} with m,n ≥ 1, so the language is context-free.
Reason (first language is not context-free):
Use the pumping lemma for context-free languages. Let p be the pumping length. Consider the string s = a^p b^p c^{p+1}, which belongs to the language a^m b^m c^{m+n} (take m = p and n = 1).
By the pumping lemma, s = u v w x y with |vwx| ≤ p and |vx| ≥ 1, and for all i ≥ 0 the string u v^i w x^i y must be in the language if it were context-free.
Because |vwx| ≤ p, the substring vwx lies entirely within one of these zones: the block of a's, the block of b's, or the block of the first p+1 c's, or it crosses a single adjacent boundary. In every case pumping with i = 0 changes the counts in a way that breaks the required relation between numbers of a's and b's or makes the c-count invalid (for example, if vwx lies inside a's, removing vx reduces the number of a's but leaves b's unchanged, so the numbers of a's and b's are no longer equal; if vwx lies inside the c's, removing vx can make the number of c's ≤ m which violates the requirement that c count = m+n with n ≥ 1). Thus for i = 0 the pumped string is not in the language, a contradiction.
Hence the first language cannot satisfy the pumping lemma for CFLs and is not context-free.
Conclusion: The correct statement is that the first language is not context-free while the second language is context-free.
A video solution is available for this question — log in and enroll to watch it.