Consider a symmetric random walk, where $S_n = X_1 + \cdots + X_n$ and $X_i$ are IID with probability $0.5$ of being $1$ or $-1$.
I want to show that $S_{n}^2 - (n)$ is a martingale.
So I started with:
$$ E[S_{n+1}^2 - (n + 1) \mid S_n, \ldots, S_1] \\ $$
and I want to show that this is $= S_n ^2 - n$.
I know that $S_{n + 1} = S_n + X_{n+1}$, plugging this in, we have
\begin{align} E[(S_n + X_{n + 1})^2 - (n + 1)\mid S_n, \ldots, S_1] &= E[S_n^2 + 2S_nX_{n+1} + X_{n + 1}^2 - (n + 1)\mid S_n, \ldots, S_1] \\&= E[S_n^2 + 2S_nX_{n+1} + X_{n + 1}^2 \mid S_n, \ldots, S_1] - (n + 1) \\&= E[S_n^2 \mid S_n, \ldots, S_1] + 2E[S_nX_{n+1} \mid S_n, \ldots, S_1] + E[X_{n + 1}^2 \mid S_n, \ldots, S_1] - (n + 1) \end{align}
We know that $X_{n+1}$ is independent of $S_n, \ldots, S_1$, so $$2E[S_nX_{n+1} \mid S_n, \ldots, S_1] = 2E[S_n \mid S_n, \ldots, S_1]E[X_{n+1}] = 0\,,$$ and $$E[X_{n+1}^2 \mid S_n, \ldots, S_1] = E[X_{n+1}^2] = 1.$$
Now, I am confused what $E[S_n^2 \mid S_n, \ldots, S_1]$ means. I believe this quantity should just be $S_n^2$, but how do I show that?
If it is indeed that, then we would have shown that $$ E[S_{n+1}^2 - (n + 1) \mid S_n, \ldots, S_1] = S_n^2 - n $$ hence $S_n^2 - n$ is a martingale.
My next question on this problem is, in my notes, it shows
$$ E[S_{n+1}^2 - (n + 1)] = 0.5[(s_n + 1)^2 + (s_n - 1)^2] - (n + 1) = s_n^2 - n $$
where lower case $s_n$ is a realization of $S_n$. Is this a valid derivation?
Your work is fine. $E[S_n^2 \mid S_n, \ldots, S_1] = S_n^2$ because $S_n^2$ is measurable with respect to $\sigma(S_n, \ldots, S_1)$ (or in less measure-theoretic terms, $S_n^2$ is "known" given $S_n, \ldots, S_1$).
Regarding the last part of your post, there is a notational issue (the left-hand side doesn't depend on $s_n$ so how could the right-hand side?). What is probably meant is $$E[S_{n+1}^2 \mid S_n = s_n] = E[(s_n + X_{n+1})^2] = \frac{1}{2}(s_n + 1)^2 + \frac{1}{2} (s_n-1)^2.$$ which implies $$E[S_{n+1}^2 \mid S_n ] = \frac{1}{2}(S_n + 1)^2 + \frac{1}{2} (S_n-1)^2 $$