Question
Let be a regular language and be a context-free language. Which of the following languages is/are context-free?
Official answer and solution
- Official answer
- B, C and D
- From
- Official GATE 2021 answer key
Solution
Apply Boolean and set-theoretic identities alongside standard closure properties of regular and context-free languages.
Given that is regular and is context-free:
- Regular languages are closed under complementation, union, and intersection.
- Context-free languages (CFLs) are closed under union, but are NOT closed under intersection or complementation.
- The intersection of a regular language and a context-free language is always a context-free language.
Analyze each option:
- Option A: . Because CFLs are not closed under complementation, is not necessarily a CFL. If , then , which need not be context-free. Thus, option A is not necessarily context-free.
- Option B: . By De Morgan's laws, . Because the intersection of a regular language and a context-free language is always context-free, this language is always context-free. Option B is correct.
- Option C: . By associativity and commutativity of union, this simplifies to . Since is regular, it is also context-free. Option C is correct.
- Option D: . Using the distributive law of intersection over union:
Since is given to be context-free, this language is context-free. Option D is correct.
Final answer
B, C, D
The answer is the one in the official GATE answer key. The solution is this site's own explanation.
Source
- Paper
- GATE 2021 Computer Science and Information Technology - Session 2 (CS2)
- Question
- 22 of 65, printed as CS Q.12
- Section
- Computer Science and Information Technology
Report an error in this question
GATE questions are the work of the organising institutes. This site is independent and is not affiliated with them.