A bound for martingale difference Let $n,d\in \mathbb N$ such that $d\leq n$.
Suppose we have a sequence of $n$ i.i.d tosses of a coin with $P[H]=p$, denoted by $X_1, ..., X_n$, where $H$ means head.
For $1\leq i \leq n-d+1$, we call the sequence of $l$ integers $(i,i+1, ..., i+d-1)$ an $d$-unit if $X_j=H$ for all $j\in\{i,i+1,...,i+d-1\}$. Define $T_n$ as the total number of $d$-units in this tossing experiment.
Define $T_{n,k}=\mathbb E[T_n|X_1, ..., X_k]$ and let $T_{n,0}:=\mathbb E[T_n]$.

Now we can see $\{T_{n,k}\}_{k=0}^n$ is a martingale. Moreover, we see $\{T_{n,k}-T_{n,k-1}\}_{k=1}^n$ is also a martingale.
My question is, to show that $|T_{n,k}-T_{n,k-1}|\leq d$ almost surely.

I was wanting to apply the Doob's martingale inequality (i.e. $P\left[ \max_{1 \leq i \leq n} \left| S_i \right| \geq \lambda \right] \leq \frac{\mathbb E \left[ S_n^2 \right]}{\lambda^2}$ for a martingale sequence $\{S_n\}$) to the martingale sequence $\{T_{n,k}-T_{n,k-1}\}_{k=1}^n$. But then I found, if I take $\lambda=d$, to prove the inequality we want, I would need to show that $\mathbb E[T_{n,k}^2-T_{n,k-1}^2]=0$, where we have used the fact that the successive differences of the martingale series are uncorrelated. I then got stuck here and I don't think $\mathbb E[T_{n,k}^2-T_{n,k-1}^2]=0$ is true. Am I on the right track and can anyone give an advice on how to proceed? Thank you so much!!
 A: I take heads to be $1$ and tails to be $0$. For $i\in[n]=\{1,\dots,n\}$ consider $x,x'\in\{0,1\}^n$ with $x_j=x'_j$ for $j\in[n]\setminus\{i\}$.
Let $T(x)$ be the number of $d$-units in $x$. Let $S_j=\{j,\dots,j+d-1\}\cap[n]$ for $j\in\mathbb Z$. For $j\in[n]\setminus S_{i-d+1}$, notice that $x$ has a $d$-unit on $S_j$ if and only if $x'$ has a $d$-unit on $S_j$.
Hence, they can only differ by $d$-units on $S_j$ for $j\in S_{i-d+1}$, and thereby $|T(x)-T(x')|\le d$.
For $k\in[n]$ and $x\in\{0,1\}^{k}$ let $f_k(x)=\mathbb E[T(X)|(X_1,\dots,X_k)=x]$, meaning that $T_{n,k}=f_k(X_1,\dots,X_k)$.
Using $x'=(x_1,\dots,x_{k-1})$ and independence (which allows to consider the unconditional expectation), we have
\begin{align*}
|f_k(x)-f_{k-1}(x')|
&=|\mathbb E[T(x,X_{k+1},\dots,X_n)]-\mathbb E[T(x',X_{k},\dots,X_n)]|\\
&\le\mathbb E[|T(x,X_{k+1},\dots,X_n)-T(x',X_{k},\dots,X_n)|]
\le d
\end{align*}
by the above, since $(x,X_{k+1},\dots,X_n)$ and $(x',X_{k},\dots,X_n)$ differ at most on the $k$-th coordinate almost surely. This immediately gives $|T_{n,k}-T_{n,k-1}|\le d$ almost surely.
