In excercise 2.4 of these lectures notes on Donsker's theorem, it is stated that for a sum $S_n = \sum_{i=1}^n X_i$ of i.i.d random variables with mean $0$ and variance $1$, and for any continuous bounded function $f : \mathbb{R} \to \mathbb{R}$, we have $$ \frac{1}{N} \sum_{n=1}^N f \left( \frac{S_n}{\sqrt{n}}\right) \to \int_0^1 ds \ f(W(s)), \ N \to \infty,$$ where $W(s)$ is a standard Brownian motion, and the limit is understood as a weak limit.
However, I feel that I have a contradictory "proof" of a different limit, and I cannot quite understand what is going wrong.
By Skorohod's representation theorem, there exists probability triple $(\Omega', \mathcal{F}', \mathbb{P}')$, and a collection of random variables $\{Y_n\}_{n \in \mathbb{N}}$ and $Y_\infty$, such that $Y_n \to Y$ almost surely, and $$ \mathbb{P}'(Y_n \leq x) = \mathbb{P} \left( \frac{S_n}{\sqrt{n}} \leq x \right), \ \mathbb{P}(Y_\infty \leq x) = \mathbb{P}(G \leq x),$$ where $G$ is a standard Gaussian.
Let $f,g : \mathbb{R} \to \mathbb{R}$ be any continuous bounded functions. Since $Y_n \to Y_\infty$ almost surely, by continuity of $f$, it follows that $f(Y_n) \to f (Y_\infty)$ almost surely, and, because the mean of a convergent sequence converges to the limit of the sequence, we also have $$ \frac{1}{N} \sum_{n=1}^N f \left( Y_n \right) \to f (Y_\infty) .$$ Because $g$ is continous and bounded, we can apply dominated convergence from which we get $$ \mathbb{E}'g \left( \frac{1}{N} \sum_{n=1}^N f \left( Y_n \right)\right) \to \mathbb{E}' g \left(f (Y_\infty) \right) .$$ Now, by using the fact that the $Y_n$ and $Y_\infty$ are the same in law as the scaled sums, we have $$ \lim_{N \to \infty} \mathbb{E}g \left( \frac{1}{N} \sum_{n=1}^N f \left( \frac{S_n}{\sqrt{n}}\right)\right) = \lim_{N \to \infty} \mathbb{E}'g \left( \frac{1}{N} \sum_{n=1}^N f \left( Y_n \right)\right) = \mathbb{E}' g \left(f (Y_\infty) \right) = \mathbb{E} g \left( f(G) \right) .$$ This would imply that $$\frac{1}{N} \sum_{n=1}^N f \left( \frac{S_n}{\sqrt{n}}\right) \to f(G), \ N \to \infty, $$ weakly, but this seems to be in contradiction with the earlier presented result. What am I doing wrong here?
Skorohod Representation Theorem only tells you that $Y_n$ has the same distribution as $\frac {S_n} {\sqrt n}$ for each fixed $n$ and it says nothing about joint distributions of the $Y_n$'s. So you cannot say that $\frac 1 N \sum\limits_{k=1}^{n} f(\frac {S_n} {\sqrt n})$ has the same distribution as $\frac 1 N \sum\limits_{k=1}^{n} f(Y_n)$.