IAE Academy

GATE 2018 CS Q.36: solution and answer

GATE 2018 · CSQ.36 · 2 marks · MCQ

Consider the following problems. denotes the language generated by a grammar . denotes the language accepted by a machine .

(I) For an unrestricted grammar and a string , whether
(II) Given a Turing machine , whether is regular
(III) Given two grammars and , whether
(IV) Given an NFA , whether there is a deterministic PDA such that and accept the same language.

Which one of the following statements is correct?

  1. (A)

    Only I and II are undecidable

  2. (B)

    Only III is undecidable

  3. (C)

    Only II and IV are undecidable

  4. (D)

    Only I, II and III are undecidable

See the question in the paper

Answer and solution

ANSWER

Option D: only I, II and III are undecidable; IV is decidable because its answer is always yes.

Official answer: DSource: Official answer key, GATE 2018 CS (IIT Guwahati)

  1. (I) Type-0 (unrestricted) grammars generate exactly the recursively enumerable languages. Deciding whether would decide whether a Turing machine accepts , which is the acceptance (halting) problem. So (I) is undecidable.

  2. (II) "Is regular?" is a property of the language of a Turing machine. It is non-trivial: is regular, while is not. By Rice's theorem, a non-trivial property of recursively enumerable languages is undecidable. So (II) is undecidable.

  3. (III) Equivalence is undecidable already when and are context-free grammars. A context-free grammar is a grammar, so a decision procedure for arbitrary grammars would also decide it for context-free grammars. So (III) is undecidable.

  4. (IV) Every NFA accepts a regular language. Every regular language is accepted by a deterministic PDA, namely a DFA that never uses its stack. So for every NFA a suitable exists and the answer is always yes. A procedure that always outputs yes is a decision procedure, so (IV) is decidable.

  5. Undecidable: (I), (II), (III). Decidable: (IV). This is option (D).

KEY IDEA

Membership for type-0 grammars, regularity of a Turing machine's language (Rice) and grammar equivalence are undecidable. The NFA-to-DPDA question is trivially decidable, since every regular language has a DPDA.

WATCH OUT FOR

Treating (IV) as hard because it mentions a deterministic PDA. Deterministic PDAs are strictly weaker than nondeterministic ones, but every regular language still has a DPDA, so the answer is always yes. Another slip is calling (II) decidable because regular languages look simple, when Rice's theorem applies to the TM's language.

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

More Turing machines questions