This question comes more from curiosity than a specific research problem. Let G be a group and S a finite symmetric generating set. By the WP(G,S) I mean the set of all words in the free monoid on S mapping to the identity of G.

A classical result of Anissimov says that WP(G,S) is a regular language iff G is finite. Regular languages have rational generating functions, so I am asking:

Dooes rationality of the generating function of WP(G,S) imply G is finite?

I believe, but didn't check, that rationality doesn't depend on the choice do S.

I guess that my motivation is when is the generating function for probability of return to the origin at step n of a random walk rational?