Almost sure identity $F^{-1}(F(X))=X$ where $F$ is the CDF of $X$ Let $F$ be the distribution function of a random variable $X$. If $F$ is continuous, then it holds that $F^{-1}(F(X))=X$ almost surely, where $F^{-1}$ denotes the generalized inverse of $F$. 
My question is now: Why does this result not hold for a discontinuous function $F$?
Generally it holds that $F^{-1}(F(x))\leq x$. Assume that $F$ is flat on the interval $[x_0,x_1]$. Then for $x\in(x_0,x_1]$ it follows $F^{-1}(F(x))=x_0<x$. However, we have that
$Pr(X\in(x_0,x_1])=F(x_1)-F(x_0)=0$ and therefore the set where $F^{-1}(F(X))=X$ does NOT hold has measure 0 and the equality holds almost surely. 
Now, assume there is a jump at $x_1$, i.e. the function is flat on the interval $[x_0,x_1)$. Then, in order to verify that the statement does not hold for discontinuous distribution function, we need to check the probability of $Pr(X\in (x_0,x_1))$. 
In my mind, this equals $Pr(X\in (x_0,x_1))=F(x_1-)-F(x_0)=0$, where $x_1-$ denotes the left limit of $x_1$. Hence, the set where $F^{-1}(F(X))=X$ does NOT hold has again measure zero and the statement holds almost surely. 
What am I doing wrong here?
 A: A problem with your approach is that $F$ having a jump at $x$ does not mean that $F$ is constant on some interval $(x',x)$ with $x'\lt x$ (actually the two notions are not even related)... But the result that $F^{-1}(F(X))=X$ almost surely indeed holds in full generality, whatever the distribution of $X$ may be.
A short route to prove this is to consider some random variable $U'$ uniformly distributed on $(0,1)$, possibly defined on another probability space $(\Omega',\mathcal F',P')$, to define $X'=F^{-1}(U')$, and to remember that $X$ and $X'$ have the same distribution. Furthermore, $$F^{-1}(F(X'))=F^{-1}(F\circ F^{-1}(U'))\quad\text{almost surely}.$$ 
Since $F\circ F^{-1}(t)\geqslant t$ for every $t$ and $F^{-1}$ is nondecreasing, this identity implies that $F^{-1}(F(X'))\geqslant F^{-1}(U')=X'$ almost surely. Since  $F^{-1}(F(x))\leqslant x$ for every $x$, 
$$
F^{-1}(F(X'))=X'\quad\text{almost surely}.$$ 
Now, the probability of the event $[F^{-1}(F(X'))=X']$ depends on the distribution of $X'$ only, hence $P(F^{-1}(F(X))=X)=P'(F^{-1}(F(X'))=X')=1$ and the proof is over.
The solution above follows the usual definition of the generalized inverse function of the CDF $F$ as $F^{-1}(t)=\inf\{x\in\mathbb R\mid F(x)\geqslant t\}$.
