Question
Let be any two context-free languages and be any regular language. Then which of the following is/are CORRECT?
I. is context-free.
II. is context-free.
III. is context-free.
IV. is context-free.
Official answer and solution
- Official answer
- B
- From
- Official GATE 2017 answer key
Solution
Apply known closure properties of Context-Free Languages (CFLs) under set operations.
Evaluate each statement:
- Statement I ( is context-free): Context-free languages are closed under union. If are start symbols of grammars for , we can introduce . Thus, Statement I is CORRECT.
- Statement II ( is context-free): CFLs are not closed under complementation. For example, is not context-free, but its complement is context-free. Thus, the complement of a CFL is not necessarily context-free. Statement II is INCORRECT.
- Statement III ( is context-free): Note that . Since is regular, its complement is also regular. The intersection of a context-free language with a regular language is always context-free. Thus, Statement III is CORRECT.
- Statement IV ( is context-free): CFLs are not closed under intersection. For instance, and are both CFLs, but is not context-free. Statement IV is INCORRECT.
Therefore, statements I and III only are correct, which corresponds to option B.
B
Assuming CFLs are closed under set difference; they are closed under difference with a regular language, but not under difference with another CFL.
The answer is the one in the official GATE answer key. The solution is this site's own explanation.
Source
- Paper
- GATE 2017 Computer Science and Information Technology (CS) Session 2
- Question
- 4 of 65, printed as CS Q.4
- 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.