Consider the following decision problems:
Does a given finite state machine accept a given string?
Does a given context free grammar generate an infinite number of strings?
Which of the following statements is true?
View worked solution
Answer: A
To determine the decidability of the two decision problems, let us analyze them individually:
- Problem : Does a given finite state machine accept a given string?
This is the membership problem for regular languages. Given a finite state machine and a string , we can simulate the execution of on . Since has no loops without consuming input (or we can easily convert it to a deterministic finite automaton), the simulation is guaranteed to halt in exactly steps. If the final state is an accepting state, we accept; otherwise, we reject. Thus, is decidable.
- Problem : Does a given context-free grammar (CFG) generate an infinite number of strings?
This is the finiteness problem for context-free languages. We can decide this using the following algorithm:
- First, simplify the CFG by eliminating all useless symbols (non-generating and unreachable variables).
- Construct a directed dependency graph where the vertices are the remaining non-terminals, and a directed edge exists from to if there is a production of the form .
- If this dependency graph contains a cycle, the grammar can generate infinitely long derivations, meaning the language is infinite. If there are no cycles, the language is finite.
Since cycle detection in a finite graph is decidable, the finiteness problem for CFGs is decidable. Thus, is decidable.
Since both and are decidable, the correct option is A.
Free practice · Your answers on this page are not saved.
