53 53 votes Consider the following decision problems: $(P1):$ Does a given finite state machine accept a given string? $(P2):$ Does a given context free grammar generate an infinite number of strings? Which of the following statements is true? Both$(P1)$ and $(P2)$ are decidable Neither $(P1)$ nor $(P2)$ is decidable Only $(P1)$ is decidable Only $(P2)$ is decidable Theory of Computation gatecse-2000 theory-of-computation decidability normal + – Kathleen 14.5k views answer comment Share Follow Print See all 3 Comments 3 3 Comments reply shashankrustagi commented Jan 16, 2021 reply Follow flag p2, convert cfg to cnf now you can say it is decidable 1 1 replyShare Deepak Poonia commented Oct 27, 2022 reply Follow flag Know the “Reason” behind every answer. Watch the following Video Solution. Detailed Video Solution, with Proof of Both Statements 4 4 replyShare Hazard commented Dec 9, 2025 reply Follow flag For P1 just run it on NFA or DFA if reachable then accept otherwise reject. 0 0 replyShare Please log in or register to add a comment.
Best answer 48 48 votes For $P1$, we just need to give a run on the machine. Finite state machines always halts unlike TM. For$ P2$, check if the $CFG$ generates any string of length between $n$ and $2n-1$, where $n$ is the pumping lemma constant. If So, $L(CFG)$ is infinite, else finite. Finding the pumping lemma constant is not trivial - but there are other procedures which can do this - http://cs.stackexchange.com/questions/52507/is-it-decidable-whether-a-given-context-free-grammar-generates-an-infinite-numbe/52520 Hence, both $P1$ and $P2$ are decidable - answer is (A). http://gatecse.in/wiki/Grammar:_Decidable_and_Undecidable_Problems Arjun answered Nov 13, 2014 • edited Jun 15, 2018 by Milicevic3306 Arjun comment Share Follow See all 15 Comments 15 15 Comments reply Show 12 previous comments talha hashim commented Sep 4, 2018 reply Follow flag the first one is membership property of regular grammer and second one is the finiteness problem of CFG https://gatecse.in/grammar-decidable-and-undecidable-problems/ 4 4 replyShare Deepak Poonia commented Oct 1, 2022 reply Follow flag Problem: Given a CFG $G$, decide if $L(G)$ is infinite. Algorithm: Convert $G$ into Chomsky Normal Form(CNF) (this can be done Algorithmically). Now that $G$ is in Chomsky normal form with no unit productions, no useless symbols and no nullable symbols. Recall that in Chomsky normal form, all productions are of the form $A → a, A → BC$. Create the “Reachability” graph from CNF $G$. Let $H$ be a graph with vertices $V$. Draw an arrow $A → B$ and $A → C$ for each production $A → BC$. Then $L(G)$ is infinite if and only if $H$ has some cycle. Since, there exists an Algorithm to determine if a CFG generates an Infinite language, it is a Decidable problem. https://www.classes.cs.uchicago.edu/archive/2015/winter/28000-1/Lec11.pdf 18 18 replyShare cprdereddyy commented Nov 8, 2024 reply Follow flag we can convert that CFG into CNF which ofcourse have finite number of transitions n by its defination if it stops it should stop with in 2n-1 steps or else it will never stop because it loops itself based on pigeon hole principle so , it is decidable 3 3 replyShare Please log in or register to add a comment.
14 14 votes P1; membership problem of DFA is decidable. p2: finiteness problem of CFG ia also decidable abhishekmehta4u answered Mar 23, 2019 abhishekmehta4u comment Share Follow 0 reply Please log in or register to add a comment.