A given non-terminal A in a given grammar CFG is ever used in the generation of word.-Decidable/undecidable?
My attempt:
It should be decidable problem, We can solve this problem using membership algorithm for context free grammar- I'm stuck here.
Can you explain in brief way, please?
I'll assume that the question is "is there any derivation involving $A$"?
First you need to know which nonterminals can unfold to any word at all. You can find this by fixpoint iteration: start with an empty set, and whenever there's a production $B::=s_1\cdots s_k$ where each $s_i$ is either a terminal or a nontermial you have already identified as fully-unfoldable, then $B$ is fully unfoldable too.
Once you know the fully-unfoldable terminals, check whether there's a way for $S$ to derive a string that involves $A$ using only the fully-unfoldable productions you found before. That is a simple graph reachability problem.
If, on the other hand, the question is, "is there any word that can be produced with $A$ but not without it?" then this question is undecidable, because subset-inclusion of context-free languages is undecidable.