Generating function for strings in $\{a,b,c\}^*$ in terms of block decompositions Here is what my teacher did : Denote $A = \{a, aa, aaa, \ldots \} = a^*a$, 
$B=b^*b$, $C=c^*c$. 
Now let $D$ be the union of these sets. Define $f(A,B,C)$ to be the generating function on the set $D$ in three variables with weights equal to the number of $A$'s , $B$'s, and $C$'s respectively, summing over all block patterns of $\{a,b,c\}^*$
Note that the generating function for $A = \frac a {1-a}$, $B = \frac b {1-b}$, and $C = \frac c {1-c}$ (he re-uses the notation for the set itself and it's generating function)
*At this point, I cannot follow. He says this means that $f(\frac a {1-a}, \frac b {1-b}, \frac c {1-c}) = \frac 1 {1-(a+b+c)}$ since we are producing every ternary string exactly once. What is happening here? We are substituting a generating function in place of a variable.. why is this allowed, and why does it lead to the result described?
**The final part which I cannot understand is this: 
Write $a = \frac A {A+1}, b = \frac B {B+1}, c = \frac C {C+1}$ to obtain that
$f(A,B,C) = (1 - (\frac A {1+A} + \frac B {1+B} + \frac C {1+C})^{-1}$ 
It really looks like we are getting something out of nothing and I'd like some help understanding this.
 A: We need to solve a functional equation whose result is some f with the property :
$f[g(a),g(b),g(c)] = 1 + (a + b + c) + (a+b+c)^2 + (a+b+c)^3 + \dots$
where $g(x) = \frac{x}{1-x} = x + x^2 + x^3+\dots$
This is easy solvable using quite simple algebra and the result is the function :
$f(u,v,w) = {(1+u)(1+v)(1+w) \over 1- uv-uw - vw - 2uvw} = $
$ = 1 + u+v+w  + 2uv + 2uw +2vw +uvu + uwu + vuv + 6uvw + wuw+ vwv+ wvw + \dots$
so, the goal of the step (*) was just to obtain a formal expression f, an algebraic trick without combinatoric meaning. 
Step (**) 
If we replace in the formal expression found before $u$ with $a+a^2+a^3...$ $v$ with $b+b^2+b^3+\dots$ and $w$ with $c+c^2+c^3+\dots$ we get exactly $g(a+b+c)$ that generates $\{a,b,c\}^*$.
To conclude : If we want to generate $\{a,b,c\}^*$ using chunks $aaa...a$, $bb...b$, and $cc...c$ there we would have patterns like AB, BA, ABA, ... and these patterns will be counted by some "pattern generating function". Such a function must exist and must be unique. The $f$ that we have found is just doing this.
