TITLE: A sufficient condition for almost everywhere equality
QUESTION [5 upvotes]: Let $f,g:(0,\infty)\to \mathrm{R}$ be monotone decreasing functions.
Show that if
$m(\{x:f(x)>a\})=m(\{x;g(x)>a\}),\; \forall a\in \mathrm{R}$ where $m$ denotes Lebesgue measure, 
then $f=g~~~ a.e.$ in $(0,\infty)$.

Here's how I tried to do:
We need to show $m(\{x:f(x)\neq g(x)\})=0$.
Since conditions for $f$ and $g$ are symmetric, it suffices to show $m(\{x:f(x)> g(x)\})=0$.
To derive contradiction, assume $m(\{x:f(x)> g(x)\})>0$.
Then there are $x_1, x_2$ with $x_1<x_2$ such that $[x_1,x_2]\subset \{x:f(x)> g(x)\} $.
By the assumption, we have
$f(x_1)\geq f(x)\geq f(x_2)$, $g(x_1)\geq g(x)\geq g(x_2)~~ {\rm and}~~ f(x)>g(x) ~~\forall x\in (x_1,x_2)$.
If $f$ and $g$ were continuous and strictly decreasing, I can take a small neighborhood of a fixed $x^\star$ and argue that in that nighborhood, which is an open interval, $f(x)>f(x^\star)$ but $g(x)\leq f(x^\star)$, a contradiction.
I can't think of how to prove it without these assumptions.
Any comment or advise is greatly appreciated.
Thank you for reading.

REPLY [3 votes]: Note that for any $a \in \mathbb{R}$ the sets $\{ x : f(x) > a \}$ and $\{   x : g(x) > a \}$ are of either one of the following forms: 

$\varnothing$
$(0, \alpha)$
$(0, \alpha]$
$(0, \infty)$

for some $\alpha > 0$, thus one is always contained in the other.
Hence if $m \big( \{ x : f(x) > a \} \big) = m \big( \{   x : g(x) > a \} \big)$, then $m \big( \{ x : f(x) > a \geqslant g(x) \} \big) = 0.$ Moreover, for every $x \in (0, \infty)$
$$f(x) > g(x) \implies (\exists q \in \mathbb{Q}) \ f(x) > q \geqslant g(x),$$
so 
$$\{ x : f(x) > g(x) \} \subseteq \bigcup_{q \in \mathbb{Q}} \{ x : f(x) > q \geqslant g(x) \}$$
but 
$$m \left( \bigcup_{q \in \mathbb{Q}} \{ x : f(x) > q \geqslant g(x) \} \right) = 0.$$