Quantile function is the almost surely left inverse of CDF In the Wikipedia page of Quantile function, it says that 'In general, even though the distribution function $F$ may fail to possess a left or right inverse, the quantile function $Q$ behaves as an "almost sure left inverse" for the distribution function, in the sense that $Q(F(X))=X$ almost surely', where $X$ is a general random variable (not need to be discrete or continuous) and $F$ is its CDF and $Q(p) = \inf\{x:F(x)\geq p\}$ is the quantile function.
I want to ask how can we prove this conclusion?
 A: Let $U$ be uniformly distributed on $[0,1]$ and let $\bar X:= Q(U)$.
Composing by $Q\circ F$ on both sides, it holds that :
$$ Q(F(\bar X)) = Q(F(Q(U))\;\;\text{ almost surely}$$
To make it slightly easier to read, I rewrite it as follows :
$$ Q(F(\bar X)) = Q(F\circ Q(U)) \;\;\text{ almost surely} \tag1$$
Now, by definition of $Q$, it holds that for all $p\in\mathbb R$, $F\circ Q(p)\ge p$. Applying $Q$ (which is non-decreasing) on both sides gives $Q(F\circ Q(p))\ge Q(p) $ for all $p$, from which we deduce that :
$$ Q(F\circ Q(U)) \ge Q(U) = \bar X\;\;\text{ almost surely} \tag A$$
Now, again by definition of $Q$, we have that for all $p\in\mathbb R$, $Q(F(p)) \le p $, which implies that : $$Q(F(\bar X)) \le \bar X\;\;\text{ almost surely} \tag B$$
From $(A)$ and $(B)$ we deduce that $$Q(F(\bar X)) =\bar X\;\;\text{ almost surely}  $$
To conclude, note that $\bar X$ and $X$ have the same distribution (I let you do the proof), so for any set $S$, it holds that $\mathbb P(X\in S) = \mathbb P(\bar X\in S)$. In particular if we consider the set $S:=\{x\in \mathbb R \ |\ Q(F(x)) =x\}$, we have that
$$ \mathbb P(\{Q(F(X) = X\}) =\mathbb P(X\in S) = \mathbb P(\bar X\in S) =\mathbb P(\{Q(F(\bar X) =\bar X\}) = 1  $$
And we are done.
