Consider \(𝐿 = 𝐿_1∩𝐿_2\) where \(L_1 = \{ 0^m 1^m 20^n 1^n \mid m,n \geq 0…
2020
Consider \(𝐿 = 𝐿_1∩𝐿_2\) where
\(L_1 = \{ 0^m 1^m 20^n 1^n \mid m,n \geq 0 \} \\ L_2 = \{0^m1^n2^k \mid m,n,k \geq 0 \}\)
Then, the language 𝐿 is
- A.
Recursively enumerable but not context free
- B.
Regular
- C.
Context free but not regular
- D.
Not recursive
Attempted by 56 students.
Show answer & explanation
Correct answer: C
Key idea: use the forms of the two languages to simplify the intersection.
Strings in the first language have the form 0^m1^m2 0^n1^n (with m,n ≥ 0).
Strings in the second language have the form 0^p1^q2^r (with p,q,r ≥ 0), so all 1s occur before any 2s and any 2s (if present) are at the end.
For a string to be in the intersection, the suffix 0^n1^n (which occurs after the 2 in the first form) must be compatible with the second form. Because the second form does not allow 0s or 1s after the 2, that suffix must be empty, so n = 0.
Therefore the intersection equals {0^m1^m2 | m ≥ 0}.
Why this language is context-free:
A context-free grammar generating {0^m1^m2 | m ≥ 0} is: S -> A 2 ; A -> 0 A 1 | ε.
Why this language is not regular:
The substring before the 2 is {0^m1^m | m ≥ 0}, which is a standard non-regular language. One can use the pumping lemma or closure properties to show non-regularity; hence {0^m1^m2 | m ≥ 0} is not regular.
Conclusion: The intersection language is context-free but not regular.
A video solution is available for this question — log in and enroll to watch it.