measurable functions and existence decreasing function Let $f(t)$ be a measurable and almost everywhere finite function, defined on the closed interval 
$E = [a, b]$. Prove the existence of a decreasing function $g (t)$, defined on [a, b], which satisfies the relation $m(E \cap \left \{ x: {g > x} \right \}) = m(E \cap \left \{ x: {f > x} \right \}) $ for all real x. 
I'm not sure I can use the theorem:
Let $f(x)$ be defined on the entire real line $\mathbb{R}$ and be measurable and finite 
almost everywhere. Then, for every $\varepsilon > 0$ and $\alpha> 0$, there exists a continuous function 
$g (x)$ defined on the entire line such that $m(\mathbb{R}\cap x:|f-g| \geq \alpha)<   \varepsilon$. Thanks.
 A: Let's begin by assuming $f$ is simple, i.e. of the form $\sum\limits_{n=1}^N a_nX_{A_n}$ with $\{a_n\}_{n=1}^N\subset \mathbb{R}$ and $\{A_n\}_{n=1}^N\subset \mathcal{B}_{[a,b]}$ with $A_i\cap A_j=\emptyset$ for $i\neq j$. Then we can WLTOG assume that $\{a_n\}_{n=1}^N$ is a decreasing sequence. We see that $f: [a,b] \rightarrow \mathbb{R}$ defined by $f=a_1X_{[a,\text{ }a_2+\mu(A_1)]}+a_2X_{[a+\mu(A_1),\text{ }a_2+\mu(A_1)+\mu(A_2)]}+ \cdots a_nX_{[a+\sum_{n=1}^{N-1}\mu(A_n),\text{ }a+\sum_{n=1}^N\mu(A_n)]}$ is non-increasing and that $\mu(f^{-1}((x,\infty)))=\mu(g^{-1}((x,\infty)))$ for any $x\in \mathbb{R}$. 
We now proceed by bootstrapping. If $f$ is non-negative we know there is a non- decreasing sequence of simple functions, $\{s_n\}_{n=1}^{\infty}$, defined on $[a,b]$ so that $\{s_n\}_{n=1}^{\infty}$ converges to $f$ uniformly. It is then quite clear that $\mu(f^{-1}((x,\infty)))=\lim\limits_{n \rightarrow \infty} \mu({s_n}^{-1}((x,\infty)))$ for any $x \in \mathbb{R}$ (1). We know from the above paragraph that for any $n\in\mathbb{N}$ there exists non-increasing $g_n$ so that $\mu({s_n}^{-1}((x,\infty)))=\mu({g_n}^{-1}((x,\infty)))$ for all $x\in \mathbb{R}$ (2). $\{g_n\}_{n=1}^{\infty}$ is a non- decreasing sequence and so converges pointwise in $\mathbb{R}^*$. Thus we can define $g=\lim\limits_{n \rightarrow \infty} g_n$ which must also be non-increasing.
As $g$ dominates $\{g_n\}_{n=1}^{\infty}$ it is clear that given $x\in \mathbb{R}$, $\mu(g^{-1}((x,\infty)))\geq \mu({g_n}^{-1}((x,\infty)))$ for all $n$ so $\mu(g^{-1}((x,\infty)))\geq \lim\limits_{n \rightarrow \infty} \mu({g_n}^{-1}((x,\infty)))$. It remains to show the reverse inequality so let $\epsilon>0$ be given. If $g^{-1}((x, \infty))=\emptyset$ there is nothing to check so assume it isn't. Set $c=\sup(g^{-1}((x, \infty))-\epsilon$, then $g(c)>x$ and as $g_n\uparrow g$ pointwise there is a $N$ such that $g_n(c)>x$ for $n\geq N$. It follows that $[a,c]\subset {g_n}^{-1}((x,\infty))$ and then by the construction of $c$ $\mu(g^{-1}((x,\infty)))-\epsilon=\mu([a,c])\leq\mu({g_n}^{-1}((x,\infty)))$. It follows that $\mu(g^{-1}((x,\infty)))-\epsilon\leq \lim\limits_{n \rightarrow \infty} \mu({g_n}^{-1}((x,\infty)))$. As $\epsilon>0$ was arbitrary we have shown that $\mu(g^{-1}((x,\infty)))=\lim\limits_{n \rightarrow \infty} \mu({g_n}^{-1}((x,\infty)))$. Combine this with 1 and 2 and we have $\mu(f^{-1}((x,\infty)))=\mu(g^{-1}((x,\infty)))$ for all $x\in \mathbb{R}$. 
We can now attempt one final push to extend the result to a measurable $f$ that is finite a.e. For such $f$ define the non- increasing sequence $\{f_n\}_{n=1}^{\infty}$, by $f_n=fX_{f^{-1}([-n,\infty))}$. These functions aren't
necessarily non-negative, but adding $n$ to them makes them non-negative so by the previous paragraph it should be clear that for all $n$ there exists a non-increasing function $g_n$ such that  $\mu({f_n}^{-1}((x,\infty)))=\mu({g_n}^{-1}((x,\infty)))$. $\{g_n\}_{n=1}^{\infty}$ is of course a non-increasing sequence itself so we can define $g=\lim\limits_{n \rightarrow \infty} g_n$. This function must be non-increasing. By pretty much the same argument as in the previous paragraph, $\mu(g^{-1}((x,\infty)))=\lim\limits_{n \rightarrow \infty} \mu({g_n}^{-1}((x,\infty)))$. Because $f$ and $f_n$ agree except on sets of measure shrinking to $0$ (here we are using that the set on which $f$ takes on the value $-\infty$ has measure $0$) we also have $\mu(f^{-1}((x,\infty)))=\lim\limits_{n \rightarrow \infty} \mu({f_n}^{-1}((x,\infty)))$ for all $x\in \mathbb{R}$. So $\mu(f^{-1}((x,\infty)))=\mu(g^{-1}((x,\infty)))$ for all $x\in \mathbb{R}$. 
Remark: in the above construction of $g$ we might get a function that attains the value $\infty$ at $a$ and/or $-\infty$ at $b$. We also see that since $f$ is finite a.e. $g$ cannot equal either of these values on $(a,b)$.
A: The comments and the cited wiki page on decreasing rearrangement give
an expression for $g$ but little hints as to why it works.
In the following I will try to provide an explanation.
Assuming $f:[a,b]\rightarrow [c,d]$,
we define first the repartition function 
$F: [c,d] \rightarrow [a,b]$:
 $$ F(x) = a + m \{t\in [a,b] : f(t) >x \}, \; \; x\in [c,d].$$
(I have added $a$ to the result to map into the interval $[a.b]$).
$F$ is monotone decreasing and, what is crucial here,
right-continuous, since by
 $\sigma$-additivity of the measure:
  $$ F(x^+)-F(x)=\lim_{n\rightarrow \infty} F(x+\frac{1}{n}) -F(x) = 
\lim_{n\rightarrow \infty} m \{t\in [a,b] : x+\frac{1}{n}\geq f(t) >x \}
= 0 .$$
The goal is to construct 
a monotone decreasing function,
$g: [a,b]\rightarrow [c,d]$,
having the same partition function as $f$:
 $$F(x) = a+ m\{ t\in [a,b]: g(t)>x\}, \; \; x\in [c,d].$$
 Note first that when
 $g$ is decreasing, $g(t)>x$ implies $g(s)>x$ for every
$s\in [a,t]$ so
 the above condition is equivalent to:
$$ F(x) = \sup \{ t\in [a,b]: g(t)>x\}.$$
In the case that $F$ is a bijection from $[c,d]$ onto $[a,b]$,
 we may as $g$ in the above just take the inverse of $F$.
Problems arise, however, when $F$ is not continuous or not
injective. 
We claim that $g$ in any case
may be constructed in the completely symmetric fashion:
$$g(t) := \sup \{ x\in [a,b]: F(x)>t\}, \; \; t\in [a,b].$$
One may verify by $\epsilon$-$\delta$ argument that it satifies the
wanted relation  but the logic may (in my opinon) be difficult
to digest for human beings.
So instead let me describe a different
conceptual approach, in which
the use of right-continuity will appear naturally:
Write $R=[a,b]\times [c,d]$ and define 
$$ \Omega = \{ (t,x) \in R :  F(x) \leq t \}$$
 It is a subset of the rectangle having the properties:
(1) It is directed, i.e.:
 $ (t,x)\in \Omega \Rightarrow [t,b]\times [x,d]\subset \Omega$. (Make a drawing!)
(2) It is a closed subset of $R$. (This follows from the
  right-continuity of $F$).
Conversely, given a directed closed subset $\Omega$ of $R$ (i.e. having the above 
two properties)
we may reconstruct a corresponding
  $F$ (which becomes right-continuous because $\Omega$ is closed) by setting:
  $$ F(x) = \sup\{t\in [a,b] : (t,x)\notin \Omega\}.$$
There is thus a bijection between a closed directed set $\Omega$ and
a corresponding decreasing right-continuous map  $F: [c,d]\rightarrow [a,b]$.
The properties of the
set $\Omega$ is, however, completely symmetric in the way the
two coordinates are treated. So it is equally well in unique correspondance
with a function $g: [a,b]\rightarrow [c,d]$ where coordinates
have been exchanged and which therefore may
be constructed through:
  $$g(t) = 
     \sup\{ x\in [c,d] : (t,x) \notin \Omega \} =
     \sup\{ x\in [c,d] : F(x)>t \} $$
Because of the symmetry, the procedure for going from $g$ to $F$
is the very same with the variables exchanged, i.e.:
 $$F(x) = \sup \{ t\in [a,b] : g(t)>x\} $$
But this was precisely
the wanted property of the partition function. Magic?
