Let $(X, \textit{M})$ be a measure space. Let $f:X \rightarrow \mathbb{R}$ be a measurable function that actually contains only two values. Prove that there exist $a,b \in \mathbb{R}$ and $A \in \textit{M}$ such that $f(x)=a \mathbb{1}_{A}(x)+b$?
My idea: I know that $f$ is a simple function iff $f$ is measurable and the range of $f$ is a finite subset of $\mathbb{C}$.
By this result, the function $f$ is a simple function.
I also know that $f$ is a simple function if $f$ is a linear combination of the characteristic function of a measurable set.
Can anyone suggest me how do I prove the existence here?
Let $u,v$ be the values of $f$, write $A=f^{-1}(u)$, $f(x)=(u-v)1_A(x)+v$.
If $x\in A, 1_A(x)=1$, $(u-v)1_A(x)+v=u-v+v=u=f(x)$ if $x$ is not in $A$, $1_A(x)=0$ and $(u-v)1_A(x)+v=v=f(x)$.
Write $u-v=a, v=b, f(x)=a1_A(x)+b$.