[proofplan]
We prove the two directions separately. If $F$ is the distribution function of a real-valued [random variable](/page/Random%20Variable), monotonicity follows from inclusion of events, right-continuity follows from [continuity of probability](/theorems/1107) from above, and the endpoint limits follow from continuity from below and above. Conversely, given a nondecreasing right-[continuous function](/page/Continuous%20Function) with limits $0$ and $1$, we construct a random variable on the probability space $((0,1),\mathcal{B}((0,1)),\mathcal{L}^1|_{\mathcal{B}((0,1))})$ by the generalized inverse of $F$, and we show directly that its distribution function is exactly $F$.
[/proofplan]
[step:Derive monotonicity and the endpoint limits from event inclusions]
Assume first that $(\Omega,\mathcal{F},\mathbb{P})$ is a probability space and that
\begin{align*}
X:(\Omega,\mathcal{F}) \to (\mathbb{R},\mathcal{B}(\mathbb{R}))
\end{align*}
is a real-valued random variable. Define $F_X:\mathbb{R}\to[0,1]$ by
\begin{align*}
F_X(x)=\mathbb{P}(X\leq x).
\end{align*}
If $x,y\in\mathbb{R}$ and $x\leq y$, then
\begin{align*}
\{\omega\in\Omega:X(\omega)\leq x\}\subseteq \{\omega\in\Omega:X(\omega)\leq y\}.
\end{align*}
By monotonicity of the probability measure $\mathbb{P}$,
\begin{align*}
F_X(x)\leq F_X(y).
\end{align*}
Thus $F_X$ is nondecreasing.
For the limit at $+\infty$, define events $A_n\in\mathcal{F}$ by
\begin{align*}
A_n=\{\omega\in\Omega:X(\omega)\leq n\}
\end{align*}
for $n\in\mathbb{N}$. Since $X$ is real-valued, $\bigcup_{n=1}^{\infty}A_n=\Omega$. The sequence $(A_n)_{n\in\mathbb{N}}$ is increasing, so countable additivity gives continuity from below:
\begin{align*}
\lim_{n\to\infty}F_X(n)
=
\lim_{n\to\infty}\mathbb{P}(A_n)
=
\mathbb{P}(\Omega)
=
1.
\end{align*}
Since $F_X$ is nondecreasing, this implies
\begin{align*}
\lim_{x\to\infty}F_X(x)=1.
\end{align*}
For the limit at $-\infty$, define events $B_n\in\mathcal{F}$ by
\begin{align*}
B_n=\{\omega\in\Omega:X(\omega)\leq -n\}
\end{align*}
for $n\in\mathbb{N}$. Since $X$ is real-valued, $\bigcap_{n=1}^{\infty}B_n=\varnothing$. The sequence $(B_n)_{n\in\mathbb{N}}$ is decreasing and $\mathbb{P}(B_1)\leq 1<\infty$, so countable additivity gives continuity from above:
\begin{align*}
\lim_{n\to\infty}F_X(-n)
=
\lim_{n\to\infty}\mathbb{P}(B_n)
=
\mathbb{P}(\varnothing)
=
0.
\end{align*}
Since $F_X$ is nondecreasing, this implies
\begin{align*}
\lim_{x\to-\infty}F_X(x)=0.
\end{align*}
[guided]
Assume that $F_X$ is obtained from a real-valued random variable
\begin{align*}
X:(\Omega,\mathcal{F}) \to (\mathbb{R},\mathcal{B}(\mathbb{R}))
\end{align*}
on a probability space $(\Omega,\mathcal{F},\mathbb{P})$ by
\begin{align*}
F_X(x)=\mathbb{P}(X\leq x).
\end{align*}
The event $\{X\leq x\}$ is shorthand for the measurable set
\begin{align*}
\{\omega\in\Omega:X(\omega)\leq x\}=X^{-1}((-\infty,x]).
\end{align*}
This set belongs to $\mathcal{F}$ because $X$ is measurable and $(-\infty,x]\in\mathcal{B}(\mathbb{R})$.
If $x\leq y$, then every $\omega\in\Omega$ satisfying $X(\omega)\leq x$ also satisfies $X(\omega)\leq y$. Hence
\begin{align*}
\{\omega\in\Omega:X(\omega)\leq x\}\subseteq \{\omega\in\Omega:X(\omega)\leq y\}.
\end{align*}
Probability measures are monotone on measurable sets, so
\begin{align*}
F_X(x)=\mathbb{P}(X\leq x)\leq \mathbb{P}(X\leq y)=F_X(y).
\end{align*}
This proves that $F_X$ is nondecreasing.
To compute the limit as $x\to\infty$, define
\begin{align*}
A_n=\{\omega\in\Omega:X(\omega)\leq n\}
\end{align*}
for $n\in\mathbb{N}$. The events increase with $n$, and because $X(\omega)$ is a finite real number for every $\omega\in\Omega$, each $\omega$ lies in some $A_n$. Therefore
\begin{align*}
\bigcup_{n=1}^{\infty}A_n=\Omega.
\end{align*}
By continuity from below for probability measures,
\begin{align*}
\lim_{n\to\infty}F_X(n)
=
\lim_{n\to\infty}\mathbb{P}(A_n)
=
\mathbb{P}\left(\bigcup_{n=1}^{\infty}A_n\right)
=
\mathbb{P}(\Omega)
=
1.
\end{align*}
Since $F_X$ is nondecreasing, convergence along the integers to $1$ forces the full limit as $x\to\infty$ to be $1$.
For the left endpoint, define
\begin{align*}
B_n=\{\omega\in\Omega:X(\omega)\leq -n\}
\end{align*}
for $n\in\mathbb{N}$. These events decrease with $n$. Since $X(\omega)$ is a finite real number, no $\omega$ can satisfy $X(\omega)\leq -n$ for every $n$, so
\begin{align*}
\bigcap_{n=1}^{\infty}B_n=\varnothing.
\end{align*}
The probability of $B_1$ is finite because $\mathbb{P}(B_1)\leq 1$. Thus continuity from above gives
\begin{align*}
\lim_{n\to\infty}F_X(-n)
=
\lim_{n\to\infty}\mathbb{P}(B_n)
=
\mathbb{P}\left(\bigcap_{n=1}^{\infty}B_n\right)
=
\mathbb{P}(\varnothing)
=
0.
\end{align*}
Again using monotonicity of $F_X$, convergence along $-n$ implies the full limit
\begin{align*}
\lim_{x\to-\infty}F_X(x)=0.
\end{align*}
[/guided]
[/step]
[step:Prove right-continuity by continuity of probability from above]
Fix $x\in\mathbb{R}$. For $n\in\mathbb{N}$, define
\begin{align*}
C_n=\{\omega\in\Omega:X(\omega)\leq x+1/n\}.
\end{align*}
Then $(C_n)_{n\in\mathbb{N}}$ is decreasing and
\begin{align*}
\bigcap_{n=1}^{\infty}C_n
=
\{\omega\in\Omega:X(\omega)\leq x\}.
\end{align*}
Since $\mathbb{P}(C_1)\leq 1<\infty$, continuity from above gives
\begin{align*}
\lim_{n\to\infty}F_X(x+1/n)
=
\lim_{n\to\infty}\mathbb{P}(C_n)
=
\mathbb{P}(X\leq x)
=
F_X(x).
\end{align*}
Because $F_X$ is nondecreasing, the sequential limit along $x+1/n$ implies
\begin{align*}
\lim_{y\downarrow x}F_X(y)=F_X(x).
\end{align*}
Therefore $F_X$ is right-continuous.
[guided]
Fix a point $x\in\mathbb{R}$. To prove right-continuity, we must show that values of the distribution function just to the right of $x$ converge back to the value at $x$. Define measurable events
\begin{align*}
C_n=\{\omega\in\Omega:X(\omega)\leq x+1/n\}
\end{align*}
for $n\in\mathbb{N}$. Since $x+1/(n+1)<x+1/n$, the events decrease:
\begin{align*}
C_{n+1}\subseteq C_n.
\end{align*}
Their intersection is exactly the event $\{X\leq x\}$. Indeed, if $X(\omega)\leq x$, then $X(\omega)\leq x+1/n$ for every $n$. Conversely, if $X(\omega)\leq x+1/n$ for every $n$, then taking the infimum over $n$ gives $X(\omega)\leq x$.
The sequence $(C_n)_{n\in\mathbb{N}}$ is decreasing and $\mathbb{P}(C_1)\leq 1<\infty$, so continuity from above applies:
\begin{align*}
\lim_{n\to\infty}F_X(x+1/n)
=
\lim_{n\to\infty}\mathbb{P}(C_n)
=
\mathbb{P}\left(\bigcap_{n=1}^{\infty}C_n\right)
=
\mathbb{P}(X\leq x)
=
F_X(x).
\end{align*}
It remains to pass from the special sequence $x+1/n$ to an arbitrary right-hand approach. Since $F_X$ is nondecreasing, for every $n\in\mathbb{N}$ and every $y\in(x,x+1/n]$ we have
\begin{align*}
F_X(x)\leq F_X(y)\leq F_X(x+1/n).
\end{align*}
Given $\varepsilon>0$, choose $n\in\mathbb{N}$ such that $F_X(x+1/n)-F_X(x)<\varepsilon$. Then every $y\in(x,x+1/n]$ satisfies $0\leq F_X(y)-F_X(x)<\varepsilon$, which proves the right-hand limit. Hence
\begin{align*}
\lim_{y\downarrow x}F_X(y)=F_X(x),
\end{align*}
which is right-continuity at $x$.
[/guided]
[/step]
[step:Construct a generalized inverse on the unit interval]
Now assume that $F:\mathbb{R}\to[0,1]$ is nondecreasing, right-continuous, and satisfies
\begin{align*}
\lim_{x\to-\infty}F(x)&=0, &
\lim_{x\to\infty}F(x)&=1.
\end{align*}
Let $\mathcal{L}^1$ denote one-dimensional [Lebesgue measure](/page/Lebesgue%20Measure) on $(\mathbb{R},\mathcal{B}(\mathbb{R}))$. Define
\begin{align*}
\Omega&=(0,1),&
\mathcal{F}&=\mathcal{B}((0,1)),&
\mathbb{P}&=\mathcal{L}^1|_{\mathcal{B}((0,1))}.
\end{align*}
Here $\mathcal{L}^1|_{\mathcal{B}((0,1))}$ is the restriction of $\mathcal{L}^1$ to the Borel $\sigma$-algebra of $(0,1)$. This is a probability space because $\mathcal{L}^1((0,1))=1$.
Define
\begin{align*}
X:(0,1)&\to\mathbb{R}\\
u&\mapsto \inf\{x\in\mathbb{R}:F(x)\geq u\}.
\end{align*}
For each $u\in(0,1)$, the set $\{x\in\mathbb{R}:F(x)\geq u\}$ is nonempty by $\lim_{x\to\infty}F(x)=1$ and bounded below by $\lim_{x\to-\infty}F(x)=0$, so $X(u)\in\mathbb{R}$.
[guided]
We now build a random variable whose distribution function is the prescribed function $F$. The natural construction is the generalized inverse, also called the quantile map.
Let $\mathcal{L}^1$ denote one-dimensional Lebesgue measure on $(\mathbb{R},\mathcal{B}(\mathbb{R}))$. Set
\begin{align*}
\Omega&=(0,1),&
\mathcal{F}&=\mathcal{B}((0,1)),&
\mathbb{P}&=\mathcal{L}^1|_{\mathcal{B}((0,1))}.
\end{align*}
Here $\mathcal{L}^1|_{\mathcal{B}((0,1))}$ is the restriction of $\mathcal{L}^1$ to the Borel $\sigma$-algebra of $(0,1)$. Because $\mathcal{L}^1((0,1))=1$, this is a probability space.
For $u\in(0,1)$, define
\begin{align*}
X:(0,1)&\to\mathbb{R}\\
u&\mapsto \inf\{x\in\mathbb{R}:F(x)\geq u\}.
\end{align*}
We must check that this formula produces a finite real number. Since $\lim_{x\to\infty}F(x)=1$ and $u<1$, there exists $a\in\mathbb{R}$ such that $F(a)\geq u$, so the set whose infimum is being taken is nonempty. Since $\lim_{x\to-\infty}F(x)=0$ and $u>0$, there exists $b\in\mathbb{R}$ such that $F(b)<u$. Because $F$ is nondecreasing, every $x\leq b$ satisfies $F(x)\leq F(b)<u$, so no $x\leq b$ belongs to the set $\{t\in\mathbb{R}:F(t)\geq u\}$. Thus this set is bounded below, and its infimum is a finite real number.
[/guided]
[/step]
[step:Identify the sublevel sets of the generalized inverse]
For every $x\in\mathbb{R}$ and every $u\in(0,1)$,
\begin{align*}
X(u)\leq x \quad \iff \quad u\leq F(x).
\end{align*}
Indeed, if $u\leq F(x)$, then $x\in\{t\in\mathbb{R}:F(t)\geq u\}$, so $X(u)\leq x$.
Conversely, assume $X(u)\leq x$. For each $n\in\mathbb{N}$, the definition of infimum gives some $t_n\in\mathbb{R}$ such that
\begin{align*}
F(t_n)\geq u
\quad\text{and}\quad
t_n<x+1/n.
\end{align*}
Since $F$ is nondecreasing, $F(x+1/n)\geq F(t_n)\geq u$. Letting $n\to\infty$ and using right-continuity of $F$ at $x$ gives $F(x)\geq u$.
Therefore
\begin{align*}
\{u\in(0,1):X(u)\leq x\}
=
(0,F(x)]\cap(0,1).
\end{align*}
In particular, this set is Borel in $(0,1)$ for every $x\in\mathbb{R}$, so $X$ is measurable as a map
\begin{align*}
X:((0,1),\mathcal{B}((0,1)))\to(\mathbb{R},\mathcal{B}(\mathbb{R})).
\end{align*}
[guided]
The key point is to prove the exact equivalence
\begin{align*}
X(u)\leq x \quad \iff \quad u\leq F(x)
\end{align*}
for every $x\in\mathbb{R}$ and $u\in(0,1)$. This equivalence is what will turn Lebesgue length on $(0,1)$ into the desired distribution function.
First suppose $u\leq F(x)$. Then $x$ belongs to the set
\begin{align*}
\{t\in\mathbb{R}:F(t)\geq u\}.
\end{align*}
Since $X(u)$ is the infimum of this set, we obtain $X(u)\leq x$.
Conversely suppose $X(u)\leq x$. The infimum need not be attained, so we approximate it from above. For each $n\in\mathbb{N}$, by the defining property of the infimum, there exists $t_n\in\mathbb{R}$ such that
\begin{align*}
F(t_n)\geq u
\quad\text{and}\quad
t_n<X(u)+1/n.
\end{align*}
Since $X(u)\leq x$, we may choose the approximating point so that $t_n<x+1/n$. Monotonicity of $F$ gives
\begin{align*}
F(x+1/n)\geq F(t_n)\geq u.
\end{align*}
Now use right-continuity of $F$ at $x$:
\begin{align*}
F(x)=\lim_{n\to\infty}F(x+1/n)\geq u.
\end{align*}
Thus $u\leq F(x)$.
We have proved
\begin{align*}
\{u\in(0,1):X(u)\leq x\}
=
\{u\in(0,1):u\leq F(x)\}
=
(0,F(x)]\cap(0,1).
\end{align*}
Since intervals are Borel sets, this set lies in $\mathcal{B}((0,1))$ for every $x\in\mathbb{R}$. The half-lines $(-\infty,x]$ generate $\mathcal{B}(\mathbb{R})$, so this proves that $X$ is measurable as a map
\begin{align*}
X:((0,1),\mathcal{B}((0,1)))\to(\mathbb{R},\mathcal{B}(\mathbb{R})).
\end{align*}
[/guided]
[/step]
[step:Compute the distribution function of the constructed random variable]
For every $x\in\mathbb{R}$, the preceding step gives
\begin{align*}
\{u\in(0,1):X(u)\leq x\}=(0,F(x)]\cap(0,1).
\end{align*}
Since $F(x)\in[0,1]$, this set has one-dimensional Lebesgue measure $F(x)$. Therefore
\begin{align*}
\mathbb{P}(X\leq x)
=
\mathcal{L}^1\big((0,F(x)]\cap(0,1)\big)
=
F(x).
\end{align*}
Thus $F$ is the distribution function of the real-valued random variable $X$ on the probability space $((0,1),\mathcal{B}((0,1)),\mathcal{L}^1|_{\mathcal{B}((0,1))})$.
Combining this construction with the first direction proves the equivalence.
[guided]
Fix $x\in\mathbb{R}$. From the sublevel-set computation,
\begin{align*}
\{u\in(0,1):X(u)\leq x\}=(0,F(x)]\cap(0,1).
\end{align*}
Because the codomain of $F$ is $[0,1]$, the number $F(x)$ lies between $0$ and $1$. Hence
\begin{align*}
(0,F(x)]\cap(0,1)=(0,F(x)]
\end{align*}
up to the endpoint convention when $F(x)=0$ or $F(x)=1$, and in all cases its one-dimensional Lebesgue measure is $F(x)$. Therefore
\begin{align*}
\mathbb{P}(X\leq x)
=
\mathcal{L}^1\big((0,F(x)]\cap(0,1)\big)
=
F(x).
\end{align*}
This equality holds for every $x\in\mathbb{R}$, so the distribution function of $X$ is exactly the prescribed function $F$.
The first part of the proof showed that every distribution function must be nondecreasing, right-continuous, and have endpoint limits $0$ and $1$. The construction above showed that every function with those four properties is realized as the distribution function of a real-valued random variable. This proves the theorem.
[/guided]
[/step]