Show that following problem is P-complete in respect to logspace reduction in sense of Karp
Given: context free grammar $G$
Decide: Check if $G$ generates infinite language
Obviously this problem is in $P$ - it is sufficient to check if it contains cycle in derivation (and this derivation is non empty - contains some terminals). It is very easy to give polynomial algorithm.
When it comes to $P-completness$ I am hopeless. I have spent a hours to try reduce HORNSAT (which is $P$-complete) to problem in exercise.
Can you give me some clues ?
Edit after comments
We reduce checking if grammar generates empty language to our problem.
Let $G$ will be grammar ($S$ is starting symbol):
$$S\to A|B|C$$ we transform it to $G'$
Now, let's assume that $S$ generates some word (in other words $L(G)\neq \emptyset$).
Then $G'$ generates inifnite language, because we can arbitrarily many times repeat rule $S\to SA$: $$S\to SA \to SSA \to SSSA \to SSSSA \to BCCBA$$
Let assume that $G'$ generates infinite language. It means that $G'$ generates some word (so $L(G')\neq \emptyset$). So also $G$ generate some word - in other case $G'$ can't generate any word ($G'$ only repeat many times word from $L(G)$).