Set with Lebesgue measure 0 or 1. Set $f:[0,1]\rightarrow \mathbb{R}$ for which each set $X_{c}=\{x\in [0,1] \mid f(x)\leq c \}$ has Lebesgue measure 0 or 1. Prove that there is $c_{0}$ such that $f(x)=c_{0}$ q.t.p $x\in[0,1]$. 
I take $c_{0}:=\inf \{c , m(X_{c})=1 \}$, where $m$ is the Lebesgue measure.
Any help would be appreciated. Thanks!
 A: For any $c<c_0$ one has $m(X_c)=0$. Let $q_i, i \in \mathbb{N}$, be an increasing sequence of numbers approaching $c_0$. Then
$$\{x: f(x)<c_0\}=\bigcup_{i=1}^\infty \{x: f(x) \leq q_i\}=\bigcup_{i=1}^\infty X_{q_i},$$
and since $m(X_{q_i})=0$, one has $m\{x: f(x)<c_0\}=0$. 
Next, let $p_i$ be a decreasing sequence of numbers approaching $c_0$, and let $p_1=\infty$. Then 
$$\{x: f(x)>c_0\}=\bigcup_{i=1}^{\infty} \{x: p_{i+1}<f(x) \leq p_i\}.$$
But $$m\{x: p_{i+1}<f(x) \leq p_i\}=m\{x: f(x) \leq p_i\} -  m \{x: f(x) \leq p_{i+1}\}=1-1=0.$$
It follows that $m \{x: f(x)>c_0\}=0$. Therefore,
$m\{x: f(x) \neq c_0\}=m\{x: f(x)<c_0\}+m\{x: f(x)<c_0\}=0$ which implies the claim. 
A: Hint Prove $C:=m(f^{-1}((-\infty, c_0)))=0$ and then use $m(f^{-1}(\{c_0\}))=m(X_{c_0}) -C =1$.
A: Let $\phi(c) = m X_c$. Then $\phi$ is non decreasing and takes both values $0,1$. Furthermore,
$\phi $ is right continuous, and hence $c_0 = \min \{ c | \phi(c) = 1 \}$ is well defined.
In particular, $m X_{c_0} = 1$ and $m X_{c_0 -{1 \over n}} = 0$ for all $n$. Hence
$m \{ x | f(x) = c_0 \} = m ( X_{c_0} \setminus \cup_n X_{c_0 -{1 \over n}} ) = 1$.
A: Let $c_0=\inf\{c:m(X_c)=1\}$, as you said.


*

*For all $c>c_0$, $m(X_c)=1$. Let $c_n$ be a sequence decreasing to $c_0$. Since $\bigcap_{n} X_{c_n}=\{x:f(x)\le c_0\}$ (think about why this is true), it follows that $$m(\{x:f(x)\le c_0\})=\lim_{n\to\infty} m(X_{c_n})=\lim_n 1=1.$$

*For all $c<c_0$, $m(X_c)=0$. Let $c_n$ be a sequence increasing to $c_0$. Since $\bigcup_{n} X_{c_n}=\{x:f(x)<c_0\}$ (think about why this is true), it follows that $$m(\{x:f(x)<c_0\})=\lim_{n\to\infty} m(X_{c_n})=\lim_n 0=0.$$
Conclude by using
$$
m(\{x:f(x)=c_0\})=m(\{x:f(x)\le c_0\})-m(\{x:f(x)<c_0\}).
$$
