I'm referencing the solution to this question Expectation of Square of Stopping Time where it says that this function: $S_n^4-6nS_n^2+3n^2$ is a martingale and I'm trying to prove it. Here, $S_n$ is a simple symmetric RW - that is: $S_{n} = \sum_{k=1}^nX_k$ where $X_k$ are i.i.d Bernoulli RVs (support -1 and 1) with probability 1/2.
We need to show: $E[S_{n+1}^4-6(n+1)S_{n+1}^2+3(n+1)^2|\mathscr{F}_n] = S_n^4-6nS_n^2+3n^2$. Here's what I've done so far.
1) $E[S_{n+1}^4|\mathscr{F}_n]=E[(S_{n}+X_{n+1})^4|\mathscr{F}_n] =E[S_n^4+4S_n^3X_{n+1}+4S_nX_{n+1}^3+6S_n^2X_{n+1}^2+X_{n+1}^4|\mathscr{F}_n]=S_n^4+6S_n^2+1$.
2) $E[6(n+1)S_{n+1}^2|\mathscr{F}_n]=6(n+1)E[S_{n+1}^2|\mathscr{F}_n]=6(n+1)(S_n^2+1)$
3) $E[3(n+1)^2|\mathscr{F}_n] = 3(n+1)^2$
1)-2)+3)
$=S_n^4+6S_n^2+1-6[nS_n^2+n+S_n^2+1]+(3n^2+6n+3)$
$ = S_n^4+6S_n^2+1 -6nS_n^2-6n-6S_n^2-6 +(3n^2+6n+3)$
$= S_n^4-6nS_n^2-6n-5+(3n^2+6n+3) $
$=S_n^4-6nS_n^2+3n^2-2$
I've redone this problem several times to try to remove the $-2$ and I can't seem to figure out where my mistake is.
As mentioned by Rhys in the comments, we cannot take an expression for a martingale related to Brownian motion and expect it to still give a martingale when applied to a simple random walk.
In particular, if $B_n = \sum_{k=1}^n Z_k$ is the sum of i.i.d. standard normal random variables, then $B_n^4 - 6nB_n^2+3n^2$ is a martingale. The proof of this fact uses $$\mathbb{E}[Z_k] = \mathbb{E}[Z_k^3] = 0 \\ \mathbb{E}[Z_k^2] = 1 \\ {\color{red}{\mathbb{E}[Z_k^4] = 3}}$$ Contrast this to the simple random walk $S_n = \sum_{k=1}^n X_k$, as the sum of i.i.d. Rademacher random variables, where we have $$\mathbb{E}[X_k] = \mathbb{E}[X_k^3] = 0 \\ \mathbb{E}[X_k^2] = 1 \\ {\color{red}{\mathbb{E}[X_k^4] = 1}}$$ This difference in the fourth moment is the source of the errant $2$.
Correcting for it is not hard, however, as we just need to add some function with constant increment $2$. For instance, this gives the fact that $$S_n^4 - 6nS_n^2 + 3n^2 + 2n$$ is a martingale.