Let be Context Free Grammars (CFGs) and be a regular expression. For a grammar , let denote the language generated by .
Which ONE among the following questions is decidable?
- (A)
Is ?
- (B)
Is ?
- (C)
Is ?
- (D)
Is ?
Let be Context Free Grammars (CFGs) and be a regular expression. For a grammar , let denote the language generated by .
Which ONE among the following questions is decidable?
Is ?
Is ?
Is ?
Is ?
ANSWER
The decidable question is (D): whether .
Official answer: DSource: Official answer key, GATE 2025 CS2 (IIT Roorkee)
Recall the decidability results for context-free languages. Emptiness, finiteness and membership are decidable. Equivalence of two CFGs, universality () and emptiness of an intersection of two CFLs are undecidable.
(A) is the equivalence problem for CFGs, which is undecidable.
(B) is undecidable. Post's Correspondence Problem reduces to it: for a PCP instance one can build two CFGs whose languages intersect exactly when the instance has a solution.
(C) is undecidable. Take . The question becomes whether , which is CFG universality, and that is undecidable. A problem that is undecidable for one choice of is undecidable in general.
(D) is decidable. Compute the set of generating variables. Start with the variables that have a production whose right side contains only terminals. Repeatedly add a variable that has a production whose right side contains only terminals and variables already in the set. The set grows at most once per variable, so this stops after finitely many rounds. Then exactly when the start symbol is in the set.
Only (D) is decidable, so the answer is (D).
KEY IDEA
Emptiness of a CFG is decidable by finding the generating variables and checking whether the start symbol is one of them. Equivalence, universality and intersection-emptiness for CFLs are undecidable.
WATCH OUT FOR
Treating (C) as decidable because is regular. Regular-versus-CFL equality is still undecidable, because choosing gives CFG universality. Another slip is assuming (B) is decidable because the emptiness of one CFL is.
From the GATE 2025 CS2 paper. Every question of this paper · Download the full paper · All 8 Turing machines questions, with notes