I am trying to understand a generating function in the explanation of Smirnov words in this book, in page $204-205$.
It is said that
" Smirnov words. Following the treatment of Goulden and Jackson [303], we define a Smirnov word to be any word that has no consecutive equal letters. Let $W = SEQ(A)$ be the set of words over the alphabet $A = {a_1,. . . , a_r}$ of cardinality $r$, and $S$ be the set of Smirnov words
Let also $v_j$ mark the number of occurrences of the $j$th letter in a word.One has $$W(v_1,v_2,...,v_r)=\frac{1}{1-z(v_1+v_2+..+v_r)}$$ "
Here , I understood that for example $v_1$ marks the number of occurences of $a_1$ in a word. Am I right here ?
Now, lets come to my main question.By thinking my foregoing deduction as true ,i.e , $v_1$ denotes the number of occurences of $a_1$, assume that our alphabet is $A={a,b}$ and by giving any occurrence to these letters, i can obtain the number of any words of desired size. Am I also right here ?
So , i think that lets say that $a$ can occur two times and $b$ can occur maximum three times. Then $$W(x^2,(x+x^2+x^3))=\frac{1}{1-z\bigg((x^2)+(x+x^2+x^3)\bigg)}$$
Then , I want to learn the number of all words of length $3$ using $a,b$, it must be $2^3=8$ , but when i look at the coefficient of $[z^3x^3]$ in wolfram, it is $1$
Is there any deficit part in the book ? I think that it should have been indicated that "Let also $v_j$ mark the number of occurrences of the $j$th letter in a word from one to desired repetition".
Am I right here ? Should we always start from $x^1$ up to $x^k$ where $k$ is the number of maximum consecutive identical letter.
Here we consider a binary alphabet $\mathcal{A}=\{a,b\}$ and derive a generating function of Smirnov words following closely the example III.24 given in Analytic Combinatorics by R. Sedgewick and P. Flajolet.
Binary words over $\mathcal{A}$:
The set $\mathcal{W}$ of all binary words over the alphabet $\mathcal{A}$ is \begin{align*} \mathcal{W}=\{&\varepsilon,a,b,aa,ab,ba,bb,\\ &aaa,aab,aba,baa,abb,bab,bba,bbb,aaaa,\ldots\} \end{align*} where $\varepsilon$ denotes the empty word of length $0$. A generating function $W(z;a,b)$ for the set of all binary words is the geometric series \begin{align*} \color{blue}{W(z;a,b)}&=1+(a+b)z+(a^2+2ab+b^2)z^2\\ &\qquad\qquad+(a^3+3a^2b+3ab^2+b^3)z^3+a^4z^4+\cdots\\ &=\sum_{n=0}^{\infty}(a+b)^nz^n\\ &\,\,\color{blue}{=\frac{1}{1-(a+b)z}} \end{align*}
Smirnov words over $\mathcal{A}$:
The set $\mathcal{S}$ of all binary Smirnov words, i.e. all binary words with no consecutive equal characters over $\mathcal{A}$ is \begin{align*} \mathcal{S}=\{&\varepsilon,a,b,ab,ba,aba,bab,\\ &abab,baba,ababa,babab,ababab,bababa,\ldots\}\tag{1} \end{align*} Of course we see in (1) at a glance there are precisely two non-empty Smirnov Words of length $n, n\geq 0$. One of them starting with $a$, the other with $b$. A generating function $S(z)$ which counts the number of Smirnov words in the binary case is simply \begin{align*} S(z)&=1+2z+2z^2+2z^3+2z^4+\cdots\\ &=1+\sum_{n=1}^{\infty}2z^n\\ &=1+\frac{2z}{1-z} \end{align*} Looking at (1) we can also derive a generating function $S(z;a,b)$. Here the exponent of $a$ resp. $b$ indicates the number of occurrences of $a$ resp. $b$. We prefer to derive $S(z;a,b)$ from $W(z;a,b)$ which also provides information how this can be reached in the general case with alphabets of size $r\geq 2$.
The key observation is that a binary words can be transformed to a Smirnov word by replacing all consecutive characters by just one of them and on the other hand we can obtain all binary words by starting with the set $\mathcal{S}$ of Smirnov words and by replacing each occurrence of a character by one or more occurrences of this character. This transformation is done by \begin{align*} a\quad\to\quad a+a^2+a^3+a^4+\cdots&=\frac{a}{1-a}\\ b\quad\to\quad\ b+b^2+b^3+b^4+\cdots\ &=\frac{b}{1-b}\\ \end{align*} We therefore have the following relationship between $S(z;a,b)$ and $W(z;a,b)$ \begin{align*} \color{blue}{S\left(z;\frac{a}{1-a},\frac{b}{1-b}\right)=W(z;a,b)}\tag{2} \end{align*} For instance the Smirnov word $abab$ corresponds via (2) with the binary words \begin{align*} abab\quad\longleftrightarrow\qquad &abab,\\ &aabab,abbab,abaab,ababb,\\ &aaabab,abbbab,abaaab,ababbb,\\ &aaaabab,abbbbab,abaaaab,ababbbb,\\ &aabbab,aabaab,aababb,abbaab,abbabb,abaabb,\\ &\ldots \end{align*} We have the following relationship \begin{align*} a\quad\to\quad \frac{a}{1-a}\qquad\qquad \frac{\frac{a}{1+a}}{1-\frac{a}{1+a}}=a\tag{3} \end{align*} Thanks to (2) and (3) we can also derive the generating function $S(z;a,b)$ from $W(z;a,b)$ via \begin{align*} \color{blue}{S(z;a,b)=W\left(z;\frac{a}{1+a},\frac{b}{1+b}\right)}\tag{4} \end{align*} and we derive from (4)
We see the generating function $S(z;a,b)$ in (6) corresponds nicely with the set $\mathcal{S}$ in (1) giving for each even length $2m$ two Smirnov words with $m$ $a$'s and $m$ $b$'s and for each odd length $2m+1$ two Smirnov words with either one more $a$ than $b$'s or vice versa.
Note: As requested by a comment we can also show the validity of (2) algebraically. We consider (5) in the form \begin{align*} \frac{1+az+bz+abz^2}{1-abz^2} \end{align*} and have according to (3) to substitute each occurrence of $az$ with $\frac{az}{1+az}$ and each occurrence of $bz$ with $\frac{bz}{1+bz}$. This type of substitution is indicated in the parameter representation in (4).
We obtain from (5) \begin{align*} &\color{blue}{S\left(z;\frac{a}{1-a},\frac{b}{1-b}\right)}\\ &\qquad=\frac{1+\frac{az}{1-az}+\frac{bz}{1-bz}+\frac{az}{1-az}\,\frac{bz}{1-bz}} {1-\frac{az}{1-az}\,\frac{bz}{1-bz}}\\ &\qquad=\frac{(1-az)(1-bz)+az(1-bz)+bz(1-az)+abz^2}{(1-az)(1-bz)-abz^2}\\ &\qquad=\frac{1}{1-(a+b)z}\\ &\qquad\,\,\color{blue}{=W(z;a,b)} \end{align*} and (2) follows.