THE ABRACADABRA PROBLEM FRANCESCO CARAVENNA Abstract. We preset a detailed solutio of Exercise E0.6 i [Wil9]: i a radom sequece of letters, draw idepedetly ad uiformly from the Eglish alphabet, the expected time for the first appearace of the word ABRACADABRA is 26 + 26 4 + 26. We adopt the covetios N := {, 2, 3,...} ad N 0 := N {0}.. Formulatio of the problem Let U i ) i N deote radom letters draw idepedetly ad uiformly from the Eglish alphabet. More precisely, we assume that U i ) i N are idepedet ad idetically distributed radom variables, uiformly distributed i the set E := {A, B, C, D,..., X, Y, Z}, defied o some probability space Ω, A, P). For m, N with m, we use U [m,] as a shortcut for the vector U m, U m+,..., U ). Defie τ as the radom time i which the word ABRACADABRA first appears: τ := mi{ N, : U [ 0,] = ABRACADABRA},.) with the covetio mi := +. Our goal is to prove the followig result. Theorem. E[τ] = 26 + 26 4 + 26. 2. Strategy The proof is based o martigales. Let F ) N0 be the atural filtratio of U i ) i N, i.e., F 0 := {, Ω} ad F := σu,..., U ). We are goig to prove the followig results. Propositio 2. τ is a stoppig time with E[τ] <. Propositio 3. There exists a martigale M = M ) N0 ) M 0 = 0 ad M τ = 26 + 26 4 + 26 τ; such that: 2) M has bouded icremets: C 0, ) such that M + M C, for all N 0. Let us recall a special case of) Doob s optioal samplig theorem, cf. [Wil9, 0.0]. Theorem 4. If M = M ) N0 is a martigale with bouded icremets ad τ is a stoppig time with fiite mea, the E[M τ ] = E[M 0 ]. Combiig this with Propositios 2 ad 3, oe obtais immediately the proof of Theorem. Date: April 0, 205.
2 FRANCESCO CARAVENNA 3. Proof of Propositio 2 Recall that τ is a stoppig time if ad oly if {τ } F for every N 0. Note that {τ } = if 0, while for {τ } = {U [i 0,i] = ABRACADABRA}, i= which shows that the evet {τ } is i F it is expressed as a fuctio of U, U 2,..., U ). To prove that E[τ] <, we argue as i [Wil9, 0.; Exercise E0.5]. Lemma 5. For a positive radom variable τ, i order to have E[τ] < it is sufficiet that N N, ε > 0 : Pτ + N τ > ) ε N 0. 3.) This result is proved i Appedix A below. I order to apply it, let A be the evet that the word ABRACADABRA appears ot ecessarily for the first time!) at time + : A := {U [+,+] = ABRACADABRA}. By assumptio U i are idepedet ad uiformly chose letters, hece PA ) = p > 0, where p := E = 26. Sice A {τ + }, we have Pτ + τ > ) PA τ > ) for every N. However the evets A ad {τ > } are idepedet A is a fuctio of U [+,+], while {τ > } = {τ } c F is a fuctio of U [,] ), hece PA τ > ) = PA ). Thus Pτ + τ > ) PA ) = p, i.e. relatio 3.) holds with N = ad ε = p. It follows by Lemma 5 that E[τ] <. 4. Proof of Propositio 3 The required martigale M = M ) N0 will be costructed as the total et gai of a suitable family of gamblers, built as follows. At time 0 a first gambler eters the game, with a iitial capital of e. She bets o the evet that the first letter U is A the first letter of the word ABRACADABRA ). If she loses, her capital at time drops to 0e ad she stops playig i.e. her capital will stay 0e at all later times). O the other had, if she wis, her capital at time becomes 26e ad she goes o playig, bettig o the evet that the secod letter U 2 is B the secod letter of ABRACADABRA ). If she loses, her capital at time 2 is 0e ad she stops playig, while if she wis, her capital at time 2 equals 26) 2 e ad she goes o, bettig o the evet that the third letter U 3 is R the third letter of ABRACADABRA ), ad so o, util time. The gambler s capital at time is either 26) e, if the letters U [,] have formed exactly the word ABRACADABRA, or 0e otherwise. I ay case, the gambler stops playig after time, hece her capital will stay costat at all later times. Let us deote by x i be the i-th letter of the word ABRACADABRA, for i so that x = A, x 2 = B, x 3 = R,..., x = A). The capital i e) of this first gambler at time is the give by the process K ) N0 defied as follows: if = 0 K := K 26 {U=x} if. K if 2
THE ABRACADABRA PROBLEM 3 Note that if K = 0, the K = 0 irrespectively of U, as described above.) Now a secod gambler arrives, playig the same game, but with oe time uit of delay. Her iitial capital stays e at time 0 ad at time, the she bets o the evet that U 2 = x = A: if she loses, her capital at time 2 is 0e ad she stops playig, while if she wis, her capital at time 2 is 26e ad she goes o playig, bettig o the evet that U 3 = x 2 = B, etc. At time 2, the secod gambler s capital will be either 26) e or 0e, accordig to whether the letters U [2,2] have formed precisely the word ABRACADABRA or ot. At this poit she stops playig ad her capital stays costat at all later times. Geeralizig the picture, imagie that for each j N there is a j-th gambler with a iitial capital of e, who starts playig just before time j, bettig o the evet that U j = x, the if she wis) o U j+ = x 2,..., ad fially if she has wo all the previous bets) o U j+0 = x. After time j + 0 the gambler stops playig ad her capital stays costat. Deotig by K j) the capital i e) of the j-th gambler at time, for N 0, we have if < j K j) := 26 {U =x j)+ } if j j + 0. 4.) j+0 if > j + 0 We ca fially defie the process we are lookig for, that will be show to be a martigale: ) M 0 := 0, M := K j) 0 ) = K j). 4.2) Thus M is the sum of the et gais equality i 4.2), recall that 0 = for all j N. 0 of the first gamblers at time. For the Lemma 6. For τ defied as i.), oe has M τ = 26) + 26) 4 + 26 τ. Proof. We eed to evaluate M τ = τ Recall that K τ j) is the capital at time τ of the gambler who starts bettig just before time j. It suffices to show that K τ j) = 0 except for j {τ 0, τ 3, τ}, for which τ ) τ. K τ 0) τ = 26), K τ 3) τ = 26) 4, K τ) τ = 26. Sice the complete word ABRACADABRA appears at time τ, the gambler who started playig just before time τ 0 has a capital of 26), i.e. K τ τ 0) = 26). The gambler who started playig just before time τ 3 has a capital K τ τ 3) = 26) 4, because the last four letters of ABRACADABRA are ABRA ad coicide with the first four letters of that word. Aalogously, sice the last letter A is the same as the first letter, the gambler who started playig just before time τ has wo his first bet ad his capital is K τ τ) = 26. Fially, for all j {τ 0, τ 3, τ} all gamblers have lost at least oe bet ad their capital is K τ j) = 0, because τ is the first time the word ABRACADABRA appears. We could have equivaletly summed the et gais of all gamblers, defiig M := Kj) because = 0 for j >. 0 ),
4 FRANCESCO CARAVENNA To complete the proof of Propositio 3, it remais to show that M = M ) N0 is a martigale with bouded icremets. We start lookig at the capital processes. Lemma 7. For every fixed j N, the capital process ) N0 is a martigale. Proof. We argue for fixed j N. Plaily, 0 = is F 0 -measurable. By 4.), K j) is a measurable fuctio of ad U, assumig iductively that is F -measurable, it follows that Sice is F -measurable. This shows that K j) ) N0 is a adapted process. by 4.), it follows iductively that Kj) 26 for all N, 26 are bouded ad, i particular, itegrable). Fially, the relatio E[K j) F ] = is trivially satisfied if < j or if > j + 0, while for {j,..., j + 0}, agai by 4.), hece the radom variables E[K j) F ] = E[ 26 {U =x j)+ } F ] = 26 PU = x j)+ ) =, because U is idepedet of F ad PU = a) = 26 for every a E. Lemma 8. The capital processes ) N0 have uiformly bouded icremets: 25, j, N. 4.3) Proof. Oe has K j) = 0 if < j or > j+0, by 4.), while for {j,..., j+0} Sice j =, relatio 4.3) follows. 26 {U =x j)+ } 25 Kj). We ca fially show that M is a martigale. Note that M is F -measurable ad i L, for every N, because by 4.2) M is a fiite sum of K j), each of which is F -measurable ad i L by Lemma 7. Furthermore, agai by 4.2), for all N we ca write E[M F ] = E[K j) F ] =. However for j = we have = K) = by defiitio, cf. 4.), hece E[M F ] = + = ) = M. This shows that M is a martigale. Fially, for all N M M = ) ) = K j) ), agai because for j = we have = K) =. Now observe that, agai by 4.), for j + oe has K j) = = Kj) j+0, hece M M = j= 0 K j) ) j= 0 25, havig applied 4.3). This shows that M has bouded icremets, completig the proof.
THE ABRACADABRA PROBLEM 5 The assumptios imply that Appedix A. Proof of Lemma 5 as we show below. We are goig to use the formula Pτ > ln) ε) l l N 0, A.) E[τ] = 0 Pτ > t) dt, A.2) valid for every radom variable τ takig values i [0, ]. Breakig up the itegral i the sub-itervals [ln, l + )N], with l N 0, sice Pτ > t) Pτ > ln) for t ln, we get E[τ] = l+)n Pτ > t) dt Pτ > ln) l N 0 l N 0 = ln N ε) = N ε <, l+)n ln dt l N 0 ε) l N havig applied the geometric series N 0 q = q. This shows that E[τ] <, as required. It remais to prove A.), which we do by iductio. For l = 0 there is othig to prove. For every l N 0, sice {τ > l + )N} {τ > ln}, we ca write Pτ > l + )N) = Pτ > l + )N, τ > ln) = Pτ > ln) Pτ > l + )N τ > ln). The iductio step yields Pτ > ln) ε)l, while assumptio 3.) gives Pτ > + N τ > ) ε), N. A.3) Choosig = ln yields Pτ > l + )N τ > ln) ε), which plugged ito A.3) yields Pτ > l + )N) ε) l+, as required. Refereces [Wil9] D. Williams 99), Probability with martigales, Cambridge Uiversity Press Dipartimeto di Matematica e Applicazioi, Uiversità degli Studi di Milao-Bicocca, via Cozzi 55, 2025 Milao, Italy E-mail address: fracesco.caravea@uimib.it For every T [0, ] oe has T = T dt = 0 0 {T t} dt, hece τω) = 0 {τω)>t} dt for every radom variable τ takig values i [0, ]. Takig expectatios of both sides ad exchagig the expectatio with the itegral which is justified by Fubii-Toelli, thaks to positivity) oe obtais A.2).