How to find whether a grammar's language is finite or infinite? I have this context-free grammar and I want to find out whether its language is finite or infinite.

S -&gt; XY|bb  Step 1
X -&gt; XY|SS  Step 2
Y -&gt; XY|SS  Step 3


So I would do

S -&gt; XY            From step 1
S -&gt; YYY           From step 2
S -&gt; SSYY          From step 3
S -&gt; SSSSY         From step 3
S -&gt; SSSSSS        From step 3
S -&gt; bbSSSSS       From step 1
S -&gt; bbbbSSS       From step 1
S -&gt; bbbbbbSSS     From step 1
S -&gt; bbbbbbbbSS    From step 1
S -&gt; bbbbbbbbbbS   From step 1
S -&gt; bbbbbbbbbbbb  From step 1

bbbbbbbbbbbb 


So I know how to generate words like this but how to find out whether the language is finite or infinite?
A language is infinite if it can generate infinitely many words. In order to prove that a language generated by a grammar is infinite, you need come up with some infinite list of words generated by the grammar. Proving that the language is finite is slightly more messy&mdash;you need to make a list of all possible derivations, and show that all of the terminate.

In your case, you have the derivation $S\to^*SSSS$, which suggests that the language is infinite. Can you come up with an infinite list of words generated by this grammar?