Which of the following are context-free languages? (A) {wi xj yk zl ∣…
2024
Which of the following are context-free languages?
(A) {wi xj yk zl ∣ i+k=j+l,where i,j,k,l≥0}
(B) {wi xj yk zl ∣ i=j and k=l,where i,j,k,l≥0}
(C) {wi xj yk zl ∣ i=j and k ≠ l,where i,j,k,l≥0}
(D) {wi xj yk zl ∣ i=j=k+l,where i,j,k,l≥0}
(E) {wi xj yk zl ∣ i=j=l and k =0,where i,j,k,l≥0}
Choose the correct answer from the options given below:
- A.
(A), (B) Only
- B.
(B), (C) Only
- C.
(C), (D) Only
- D.
(D), (E) Only
Attempted by 66 students.
Show answer & explanation
Correct answer: A
Final answer: The context-free languages are the one defined by i+k = j+l and the one defined by i = j and k = l.
Reasoning and sketches of proofs:
Language with i+k = j+l:
A pushdown automaton can recognize this language: while reading the w-block, push one symbol per w; while reading the x-block, pop one symbol per x (if possible); while reading the y-block, push one symbol per y; while reading the z-block, pop one symbol per z. The input is accepted exactly when the stack is empty at the end, which enforces i + k = j + l. Hence this language is context-free.
Language with i = j and k = l:
This language is the concatenation of {w^n x^n | n ≥ 0} and {y^m z^m | m ≥ 0}. Each of those is a standard context-free language (generated by S -> w S x | ε and similarly for y and z), and the concatenation of context-free languages is context-free. Therefore this language is context-free.
Language with i = j = k + l:
Not context-free (sketch): any PDA that matches w^n with x^n will have emptied its stack by the time it reaches the y and z blocks, so it cannot enforce that the total number of y and z symbols equals the previously matched n; there is no finite control method to remember an unbounded n once the stack is emptied. A formal proof can be given by the pumping lemma for context-free languages or by a homomorphism/reduction from a known non-CFL.
Language with i = j = l and k = 0:
This becomes {w^n x^n z^n | n ≥ 0}, which is a^n b^n c^n in standard notation and is a classic example of a non-context-free language (proved by the pumping lemma for context-free languages).
If one of the listed items is a duplicate of another (for example, if a printed item repeats the i = j, k = l condition), treat it accordingly: duplication does not create a new language.
Conclusion: Only the languages defined by the linear relation i+k = j+l and by the independent equalities i = j and k = l are context-free; the others are not.
A video solution is available for this question — log in and enroll to watch it.