Let $\mathbb{B}$ be a $\sigma$-algebra on a set $X$ and let $f\,:\,X \rightarrow \overline R$ be an extended real-valued function. Define the sets $P\:= f^{-1}(-\infty)$ and $N\:=f^{-1}(+\infty)$.
Define a real-valued function $g\,:\,X \rightarrow \mathbb{R}$ by
$$ g(x)= \begin{cases} f(x), & f(x)\in \mathbb{R}\\ 0, & otherwise \end{cases}.$$
Prove that $f$ is $\mathbb{B}$-measurable if and only if $g$ is $\mathbb{B}$-measurable and $P,N\in \mathbb{B}$.
So i tried to prove this like this:
$(\Rightarrow)$ $P,N \in \mathbb{B}$ obviously. Now assume $f$ is $\mathbb{B}$-measurable. Let $\alpha \in \mathbb{R}$. Consider
$\{x\in X | g(x)>\alpha\}$=$\{x\in X| f(x)>\alpha\} \setminus P$. In this circumstance $P\in \mathbb{B}$, $\{x\in X| f(x)>\alpha\}\in \mathbb{B}$ so $\{x\in X| f(x)>\alpha\} \setminus P \in \mathbb{B}$. So $P^c \cap \{x\in X| f(x)>\alpha\}\in \mathbb{B}$. This is because, $\mathbb{B}$ is closed under finite intersection.
$(\Leftarrow)$ $g$ is $\mathbb{B}$-measurable. Then
$$ \{x\in X| f(x)>\alpha\}=
\begin{cases}
\{x\in X| g(x)>\alpha\}\cup P, & \alpha>0 \\
\{x\in X| g(x)>\alpha\}\setminus N, & \alpha \leq 0
\end{cases}.$$
Both of cases, observe that output sets belongs to $\mathbb{B}$.
But my professor said the proof was wrong. Where am I going wrong? Can you help me?
$\{x\in X | g(x)>\alpha\}$=$\{x\in X| f(x)>\alpha\} \setminus P$ is wrong. If $\alpha =-1$ and $f(x)=-\infty$ then $g(x) >\alpha$. So $x$ is in LHS but not in RHS. You have to consider the cases $\alpha <0$ and $\alpha \geq 0$ separately.