Prove that $P_{S_N}(t) = P_N(P_X(t))$ for $S_N = X_1 + \cdots + X_N$. Let $N$ and $(X_i)_{(i \ge 1)}$ be independent random variables ($X_i$ have the same density). Let $S_N = X_1 + \cdots + X_N$. Prove that $P_{S_N}(t) = P_N(P_X(t))$ where $$P_X(t) = E(t^X) = \sum_{k=0}^\infty t^x \Pr(X=k) $$
is probability-generating function. I have this proof at my university, but I can't understand it. 
$$P_{S_N}(t) = E(t^{S_N}) \stackrel{(1)}{=} \\  \sum_{n=0}^\infty E(t^{S_N}\mid N=n) \Pr(N=n) \stackrel{(2)}{=}  \\ \sum_{n=0}^{ \infty } E(t^{S_n}) \Pr(N=n) \\  \sum_{n=0}^\infty P_{X_1 + \cdots + X_n}(t) \Pr(N=n)= \\  \sum_{n=0}^\infty [P_X(t)]^n \Pr(N=n) = \\P_N(P_X(t)) $$
I don't understand equal $(1)$ and $(2)$. Could explain me that? I will grateful for your help. Thanks in advance!
 A: $\newcommand{\E}{\mathbb E}$
The identity labeled $(1)$ in your question is an instance of the identity
$$
\E(Y) = \sum_x \E(Y \mid X=x) \Pr(X=x).
$$
This is often written as
$$
\E(Y) = \E(\E(Y\mid X))
$$
and is sometimes called the "law of total expectation" (except that the law of total expectation applies not only in the discrete case but more generally).
$$
\begin{align}
\E(Y) & = \sum_y y\Pr(Y=y) \\
& = \sum_y \left(y \sum_x \Pr(Y=y\ \&\ X=x) \right) \\
& = \sum_y \left( y \sum_x \Pr(Y=y\mid X=x)\Pr(X=x) \right) \\
& = \sum_x \sum_y \left( y \Pr(Y=y\mid X=x)\Pr(X=x) \right) \\
& = \sum_x \left(\Pr(X=x)\sum_y y\Pr(Y=y\mid X=x)\right) \tag{$\star$} \\
& = \sum_x \left(\Pr(X=x)\cdot\E(Y\mid X=x)\right).
\end{align}
$$
The "$=$" in $(\star)$ is true because the factor $\Pr(X=x)$ does not change as $y$ changes, going through the list of all possible values of the random variable $Y$.
The expression following your step $(2)$ would be correct if the superscript were $S_n$ rather than $S_N$, since $\E(t^{S_N}\mid N=n)=\E(t^{S_n})$.
Postscript on 11/6 responding to a comment below:
\begin{align}
\E(t^{S_N}\mid N=n) & = \sum_s t^s \Pr(S_N=s\mid N=n) \\[8pt]
& = \sum_s t^s \frac{\Pr(S_N=s\ \&\ N=n)}{\Pr(N=n)} \\[8pt]
& = \sum_s t^s \frac{\Pr(S_n=s)\cdot\Pr(N=n)}{\Pr(N=n)} \\[8pt]
& = \sum_s t^s \Pr(S_n=s) \\[8pt]
& = \E(s^{S_n}).
\end{align}
