Let be the first completion time of the word. A fresh gambler arrives before every throw with capital one, betting it all on the successive symbols . Each correct bet multiplies capital by six and each wrong bet loses it, so every bet is fair. A gambler who completes the word keeps the winnings.
At time , the gambler who bet on all four final throws has capital . The gambler who bet on the final two throws has correctly matched the suffix and has capital . There are no other survivors: the only nonempty suffixes of that are also prefixes are and . Thus the total surviving capital is .
To justify the expectation identity, independent blocks of four throws each have probability of equalling the pattern, so and . Total gambling capital minus the number of arriving unit stakes is a martingale with bounded increments before . Optional stopping therefore equates expected terminal capital with expected total stakes:
This is the waiting time for a word in independent uniform symbols. The extra reflects the overlapping occurrence of the prefix at the word's end.
Let be the natural filtration. An integer-valued random variable is a stopping time with respect to when
Thus whether one has stopped by time can be decided from the first observations, without seeing future variables. Equivalently, .
Write the stopped sum as
The event depends only on , so its indicator and are independent random variables. Since and , Tonelli theorem gives
We may consequently exchange expectation and summation. Using the tail-sum formula for proves Wald's equation:
For the renewal process, put and . The random variable is a stopping time. Since , Wald's equation gives
and hence
For , set and . Wald's equation still applies to the stopping time and the independent variables . Because ,
Therefore
By the monotone convergence theorem, as . Combining the bounds proves the elementary renewal theorem
For a fixed word over equally likely symbols, the waiting time for a word in independent uniform symbols has mean , where runs through the lengths of the borders of a word, including the full word. The word lava' has no proper nonempty border, so $$ \boxed{\mathbb E\tau_{\mathtt{lava}}=100^4=100\,000\,000}. $$ The word aa' has borders of lengths and , so
For a direct check, let be the expected remaining time with no trailing a' and $E_1$ with one trailing a'. Then
which gives .