Consider the following languages: L1 = {ww | w ∈ {a, b}*} L2 = {an bn cm | m,n…
2022
Consider the following languages:
L1 = {ww | w ∈ {a, b}*}
L2 = {an bn cm | m,n ≥ 0}
L3 = {am bn cn | m,n ≥ 0}
Which of the following statements is/are FALSE?
- A.
\(L_1\)is not context-free but\(L_2\)and\(L_3\)are deterministic context-free. - B.
Neither
\(L_1\)nor\(L_2\)is context-free. - C.
\(L_2\),\(L_3\)and\(L_2 \cap L_3\)all are context-free. - D.
Neither
\(L_1\)nor its complement is context-free.
Attempted by 72 students.
Show answer & explanation
Correct answer: B, C, D
Answer: The false statements are the ones that assert the following texts:
Neither L1 nor L2 is context-free.
L2, L3 and L2 ∩ L3 all are context-free.
Neither L1 nor its complement is context-free.
Reasoning (concise):
Why L1 is not context-free: Let L1 = {ww | w ∈ {a,b}*}. Intersecting L1 with the regular language a* b* a* b* yields {a^n b^n a^n b^n}, which is a well-known non-context-free language. Since context-free languages are closed under intersection with regular languages, L1 cannot be context-free.
Why L2 and L3 are context-free (and deterministic CFLs): Provide simple grammars. For L2 = {a^n b^n c^m}: S → a S b | C ; C → c C | ε. This generates a^n b^n followed by any number of c's. For L3 = {a^m b^n c^n}: S → A D ; A → a A | ε ; D → b D c | ε. Both can be implemented by a deterministic PDA.
Why the claim that L2, L3 and their intersection are all context-free is false: Compute the intersection L2 ∩ L3. A string in the intersection must satisfy the L2 condition (number of a's equals number of b's) and the L3 condition (number of b's equals number of c's). Hence L2 ∩ L3 = {a^n b^n c^n | n ≥ 0}, which is a standard non-context-free language (e.g. by the pumping lemma). Therefore the intersection is not context-free.
Why the complement of L1 is context-free (sketch): The complement consists of odd-length strings and even-length strings whose first half differs from the second half at some position. A nondeterministic PDA can accept the complement by either accepting odd-length inputs immediately or, for even-length inputs, nondeterministically guessing an index i in the first half where a mismatch will occur, pushing symbols of the first half while remembering the guess, and then on the second half checking that the corresponding position indeed differs; acceptance follows if a mismatch is found. This nondeterministic strategy shows the complement is context-free.
Conclusion: The false statements are the three listed above. The first option (that L1 is not context-free while L2 and L3 are deterministic context-free) is correct.
A video solution is available for this question — log in and enroll to watch it.