IAE Academy

ISRO CS 2023 Q.59: solution and answer

ISRO 2023 · CSQ.59 · 1 mark · MCQ

Which of the following statements is FALSE:

  1. (A)

    The intersection of a regular language and a context-free language is context-free

  2. (B)

    The intersection of a regular language and context-free language is regular

  3. (C)

    The union of two context-free languages is context-free

  4. (D)

    The union of two regular languages is regular

See the question in the paper

Answer and solution

ANSWER

The false statement is (b): the intersection of a regular language and a context-free language is context-free, but it need not be regular.

Official answer: BSource: ISRO's revised and final answer key of 16 February 2024

  1. Context-free languages (CFLs) are closed under union, concatenation and Kleene star, and under intersection with a regular language. They are not closed under intersection with each other or under complement.

  2. Option (a): run a PDA for the CFL in parallel with a DFA for the regular language (product construction). The product machine is still a PDA, so the intersection is context-free. This statement is true.

  3. Option (b): take , which is context-free, and , which is regular. Then , which is context-free but not regular. So the intersection need not be regular, and this statement is false.

  4. Option (c): for grammars with start symbols (with disjoint variable sets), add a new start symbol with rules . This is a CFG for the union, so the statement is true.

  5. Option (d): regular languages are closed under union (use an NFA with a new start state and -moves to the two start states). This statement is true.

  6. Only option (b) is false, so the answer is (b).

KEY IDEA

Context-free languages are closed under union and under intersection with a regular language (product of a PDA and a DFA). The result of that intersection is context-free in general, not regular.

WATCH OUT FOR

Confusing the closure properties: assuming that intersecting with a regular language makes the result regular, or assuming CFLs are closed under intersection with each other. The example shows the result can stay non-regular.

From the ISRO CS 2023 paper. Every question of this paper · The full paper (PDF, ISRO) · All 1 ISRO Context-free languages question, with notes