How can the decision algorithm be constructed for deciding whether…

2019

How can the decision algorithm be constructed for deciding whether context-free language 𝐿 is finite?

(a) By constructing redundant CFG G in CNF generating language 𝐿

(b) By constructing non-redundant CFG G in CNF generating language 𝐿

(c) By constructing non-redundant CFG G in CNF generating language 𝐿−{∧} ( ∧ stands for null)

Which of the following is correct?

  1. A.

    (a) Only

  2. B.

    (b) Only

  3. C.

    (c) Only

  4. D.

    None of (a), (b) and (c)

Attempted by 21 students.

Show answer & explanation

Correct answer: C

Correct approach: construct a non-redundant CNF for the language with the empty string removed (L − {ε}) and check for reachable cycles.

Reason: a reachable cycle among nonterminals that can generate terminal strings implies you can pump derivations to produce arbitrarily long distinct strings, so the language is infinite.

  1. Convert the grammar to Chomsky Normal Form (CNF) but first handle the empty string: if ε ∈ L, note it separately and consider L − {ε} for the infinite-growth test.

  2. Eliminate useless symbols (non-generating and unreachable nonterminals) to get a non-redundant (reduced) grammar. This ensures every remaining nonterminal is relevant for producing terminal strings.

  3. Build a directed graph whose nodes are the remaining nonterminals. For each CNF production of the form A → BC add edges A → B and A → C. (A → a produces no edges because it does not expand to nonterminals.)

  4. Decide if there exists a cycle in this graph that is reachable from the start symbol (and lies in the set of nonterminals that can derive terminal strings).

  5. Conclusion: if such a reachable cycle exists the language (or L − {ε}) is infinite; otherwise derivation depth is bounded by the number of nonterminals and the language is finite. If ε was in the original language, add it back in: presence of ε does not affect infiniteness except that L could be finite with ε included.

Therefore the correct method among the choices is to construct a non-redundant CNF for L − {ε} and apply the cycle/reachability test.

A video solution is available for this question — log in and enroll to watch it.

Explore the full course: Mppsc Assistant Professor