GATE / CS ARCHIVE

GATE CSE 2012 / QUESTION 24

Decidability and language complementation

Theory of Computation · Decidability & Computability · Full GATE CSE 2012 paper

GATE 2012, Q24 1 mark · MCQ
Report issue

Decidability & Computability

Question 24, GATE 2012: Which problems are decidable? (1) Does a given program ever produce an output? (2) Given a context-free language L, is its complement also context-free? (3) Given a regular language L, is its complement also regular? (4) Given a recursive language L, is its complement also recursive?
(A) 1,2,3,4 (B) 1,2 (C) 2,3,4 (D) 3,4. Complements, shown by overbars in the original, are essential.
Tap to enlarge
Your answer
Answer & solution

Official answer: D

The overbars in statements 2–4 are essential: each asks about the complement of L. Regular languages are closed under complementation (complete a DFA and exchange accepting/nonaccepting states), and recursive languages are closed under complementation (swap the outcomes of a halting decider), so 3 and 4 always answer yes. Whether an arbitrary program ever outputs is undecidable by simulating a machine and printing only if it halts. For a context-free input language, deciding whether its complement is context-free is an undecidable grammar-property problem; lack of closure alone would not suffice to prove undecidability. Thus the intended decidable entries are 3 and 4, D. For a reduction justifying statement 2, fix a CFL H over a separate alphabet Γ whose complement is the non-CFL {ak bk ck: k≥0}; H is context-free by expressing unequal counts and malformed strings as a union of CFLs. Given a CFG language L over Σ, construct the CFL K consisting of L#Γ*, Σ*#H, and all malformed strings outside Σ*#Γ*. Its complement is (Σ*−L)#(Γ*−H). If L=Σ*, this is empty and context-free. Otherwise, choosing w∉L and intersecting with regular w#Γ* leaves w#(Γ*−H), which is not context-free (remove the fixed prefix by left quotient). Therefore a test for context-freeness of complements would decide the undecidable CFG-universality problem.

Check: A closure fact gives a constant yes-answer for promises 3 and 4, hence a decider exists. For promise 2, nonclosure alone merely says some answers are no; the reduction is necessary to establish that no algorithm can decide all such instances.

Original paper, page 5 · Answer key