IAE Academy

GATE 2023 CS Q.24: solution and answer

GATE 2023 · CSQ.24 · 1 mark · MSQ

Which of the following statements is/are CORRECT?

  1. (A)

    The intersection of two regular languages is regular.

  2. (B)

    The intersection of two context-free languages is context-free.

  3. (C)

    The intersection of two recursive languages is recursive.

  4. (D)

    The intersection of two recursively enumerable languages is recursively enumerable.

See the question in the paper

Answer and solution

ANSWER

Statements A, C and D are correct. Only B is false.

Official answer: A, C, DSource: Official answer key, GATE 2023 CS (IIT Kanpur)

  1. (A) Regular languages are closed under intersection. Build the product DFA of the two machines, and accept when both components accept. TRUE.

  2. (B) Context-free languages are not closed under intersection. Take and . Both are context-free. Their intersection is , which is not context-free by the pumping lemma for CFLs. FALSE.

  3. (C) Recursive languages are closed under intersection. Run the deciders and one after the other on , and accept only if both accept. Both always halt, so the new machine always halts. TRUE.

  4. (D) Recursively enumerable languages are closed under intersection. Run and on , one after the other or interleaved, and accept if both accept. If is in both languages, both machines halt and accept. If not, the new machine need not halt, which is allowed for an RE language. TRUE.

  5. Statements A, C and D are correct, and B is the only false one.

KEY IDEA

Regular, recursive and recursively enumerable languages are all closed under intersection. Context-free languages are not.

WATCH OUT FOR

Assuming context-free languages are closed under intersection because they are closed under union. The standard counterexample is , which is the intersection of two context-free languages.

From the GATE 2023 CS paper. Every question of this paper · Download the full paper · All 8 Turing machines questions, with notes

More Turing machines questions