If a sequence of measurable functions $f_{n}$ converge to $f$ almost everywhere then $f$ is measurable $\textbf{Theorem}$
if a sequence of measurable functions $f_{n}$ converge to $f$ almost everywhere then $f$ is measurable
$\textbf{proof}$
Let $A=\{ x\in X : \lim f_n(x)=f(x)\}$. Since $f_n \to f$ a.e, it follows that $\mu(A^{c})=0$. Thus $A^{c}$ is measurable and hence $A$ is measurable. Now, let $a\in \mathbb{R}$. Observe that the equality 
$$A \cap f^{-1}((a,\infty)) =A \cap \left[\bigcup_{n=1}^{\infty} \bigcap_{i=n}^{\infty}\ f_{i}^{-1}\! \left(\left(a+\frac{1}{n},\infty\right)\right)\right]$$
I am not getting that how this above equality is coming? Please explain this with detailed arguments. I would be grateful for it.
 A: The equality doesn't seem to be correct.
$$
\begin{alignat}{10}
A \cap f^{-1}((a,\infty)) &= \{ x \in A : f(x) > a \}\\
&= \left\{ x \in A : \lim_{i \to \infty} f_i(x) > a \right\} \\
&= \left\{ x \in A : \lim_{i \to \infty} f_i(x) \geq a + 1/n \text{ for some } n \geq 1 \right\} \\
&= \bigcup_{n=1}^\infty \left\{ x \in A : \lim_{i \to \infty} f_i(x) \geq a + 1/n \right\} \\
&= \bigcup_{n=1}^\infty \{ x \in A : \exists\ N \geq 1 \text{ such that } f_i(x) \geq a + 1/n \text{ for all } i \geq N \}\\
&= \bigcup_{n=1}^\infty \bigcap_{i=N}^\infty \{ x \in A : f_i(x) \geq a + 1/n \}\\
&= \bigcup_{n=1}^\infty \bigcap_{i=N}^\infty A \cap f_i^{-1}([a+1/n,\infty))\\
&= A \cap \bigcup_{n=1}^\infty \bigcap_{i=N}^\infty f_i^{-1}([a+1/n,\infty)).
\end{alignat}
$$
So, you should be getting
$$
A \cap f^{-1}((a,\infty)) = A \cap \bigcup_{n=1}^\infty \bigcap_{i=N}^\infty f_i^{-1}([a+1/n,\infty)),
$$
where for each $n \in \mathbb{N}$, $N \in \mathbb{N}$ is such that $f_i(x) \geq a+1/n$ for all $i \geq N$.

Alternatively, you could use that for all $x \in A$,
$$
f(x) = \lim_{n \to \infty} f_n(x) = \limsup_{n \to \infty} f_n(x) = \inf_{n \geq 1} \left \{ g_n(x) \right\},
$$
where for each $n \in \mathbb{N}$, $g_n : A \to \mathbb{R}$ is defined by
$$
g_n(x) = \sup_{i \geq n} \{f_i(x)\}.
$$
This gives
$$
A \cap f^{-1}((a,\infty)) = \bigcap_{n=1}^\infty g_n^{-1}((a,\infty))
= A \cap \bigcap_{n=1}^\infty \bigcup_{i=n}^\infty f_i^{-1}((a,\infty)).
$$
