[proofplan]
Fix a real number $x$ and rewrite the event $\{X\le x\}$ as a union of the level-set events $\{X=s\}$ with $s\in S$ and $s\le x$. The containment of the range of $X$ in $S$ makes this union exact, and the level-set events are pairwise disjoint. Countable additivity of the probability measure then turns the probability of the union into the corresponding countable sum, which is exactly the asserted formula for the [cumulative distribution function](/page/Cumulative%20Distribution%20Function).
[/proofplan]
[step:Express the sublevel event as a countable union of level sets]
Fix $x\in\mathbb R$. Define the event
\begin{align*}
A_x:=\{\omega\in\Omega:X(\omega)\le x\}
\end{align*}
and, for each $s\in S$, define the level-set event
\begin{align*}
B_s:=\{\omega\in\Omega:X(\omega)=s\}.
\end{align*}
Because $X$ is $\mathcal F/\mathcal B(\mathbb R)$-measurable, $A_x=X^{-1}((-\infty,x])\in\mathcal F$ and $B_s=X^{-1}(\{s\})\in\mathcal F$.
Let
\begin{align*}
S_x:=\{s\in S:s\le x\}.
\end{align*}
Since $S$ is countable, $S_x$ is countable. We claim that
\begin{align*}
A_x=\bigcup_{s\in S_x}B_s.
\end{align*}
If $\omega\in A_x$, then $X(\omega)\le x$. Since the range of $X$ is contained in $S$, the number $X(\omega)$ belongs to $S$, hence $X(\omega)\in S_x$ and $\omega\in B_{X(\omega)}\subseteq\bigcup_{s\in S_x}B_s$. Conversely, if $\omega\in\bigcup_{s\in S_x}B_s$, then $\omega\in B_s$ for some $s\in S_x$, so $X(\omega)=s\le x$, and therefore $\omega\in A_x$.
[guided]
We fix $x\in\mathbb R$ because the formula is pointwise in $x$. The cumulative distribution function evaluates the probability of the event that $X$ falls at or below this fixed threshold, so we introduce
\begin{align*}
A_x:=\{\omega\in\Omega:X(\omega)\le x\}.
\end{align*}
For each possible value $s\in S$, we also introduce the level-set event
\begin{align*}
B_s:=\{\omega\in\Omega:X(\omega)=s\}.
\end{align*}
These are genuine events in $\mathcal F$: indeed, $A_x=X^{-1}((-\infty,x])$ and $(-\infty,x]\in\mathcal B(\mathbb R)$, while $B_s=X^{-1}(\{s\})$ and $\{s\}\in\mathcal B(\mathbb R)$. The measurability of $X$ therefore gives $A_x\in\mathcal F$ and $B_s\in\mathcal F$.
Now define the countable index set of allowed values below the threshold by
\begin{align*}
S_x:=\{s\in S:s\le x\}.
\end{align*}
Since $S_x\subseteq S$ and $S$ is countable, $S_x$ is countable. The key set identity is
\begin{align*}
A_x=\bigcup_{s\in S_x}B_s.
\end{align*}
To prove the inclusion from left to right, take $\omega\in A_x$. Then $X(\omega)\le x$. The range hypothesis says that every value attained by $X$ lies in $S$, so $X(\omega)\in S$. Combining $X(\omega)\in S$ with $X(\omega)\le x$ gives $X(\omega)\in S_x$. Hence $\omega\in B_{X(\omega)}$, and so $\omega\in\bigcup_{s\in S_x}B_s$.
For the reverse inclusion, take $\omega\in\bigcup_{s\in S_x}B_s$. Then there is some $s\in S_x$ such that $\omega\in B_s$. By definition of $B_s$, this means $X(\omega)=s$. By definition of $S_x$, this same $s$ satisfies $s\le x$. Therefore $X(\omega)\le x$, which is exactly $\omega\in A_x$.
[/guided]
[/step]
[step:Apply countable additivity to the disjoint level-set decomposition]
The family $(B_s)_{s\in S_x}$ is pairwise disjoint: if $s,t\in S_x$ with $s\ne t$, then no $\omega\in\Omega$ can satisfy both $X(\omega)=s$ and $X(\omega)=t$. If $S_x=\varnothing$, then the union identity from the preceding step gives $A_x=\varnothing$, so $\mathbb P(A_x)=0$, and the sum over the empty index set is also $0$.
Assume now that $S_x\ne\varnothing$. Since $S_x$ is countable, choose an enumeration $(s_k)_{k\in I}$ of $S_x$, where either $I=\mathbb N$ or $I=\{1,\dots,N\}$ for some $N\in\mathbb N$. In the finite case, extend the family by setting $E_k:=\varnothing$ for $k>N$; in the infinite case, set $E_k:=B_{s_k}$ for every $k\in\mathbb N$. Thus in all cases we have a sequence $(E_k)_{k=1}^{\infty}$ of pairwise disjoint events whose union is $A_x$, and whose nonempty members are exactly the sets $B_s$ with $s\in S_x$. The countable additivity axiom in the definition of a probability measure gives $\mathbb P(A_x)=\sum_{k=1}^{\infty}\mathbb P(E_k)=\sum_{\{s\in S:s\le x\}}\mathbb P(B_s)$. By the definition of $p_X$, we have $\mathbb P(B_s)=p_X(s)$ for every $s\in S$. Therefore $\mathbb P(A_x)=\sum_{\{s\in S:s\le x\}}p_X(s)$.
[guided]
The event decomposition from the preceding step is useful only because probabilities are countably additive on disjoint events. First we check disjointness. If $s,t\in S_x$ and $s\ne t$, then no outcome $\omega\in\Omega$ can satisfy both equations $X(\omega)=s$ and $X(\omega)=t$. Hence the family $(B_s)_{s\in S_x}$ is pairwise disjoint.
There is one degenerate case to remove. If $S_x=\varnothing$, then the identity $A_x=\bigcup_{s\in S_x}B_s$ gives $A_x=\varnothing$. Therefore $\mathbb P(A_x)=0$, and the sum over the empty index set is also $0$.
Now suppose $S_x\ne\varnothing$. Since $S_x$ is countable, we may enumerate it as $(s_k)_{k\in I}$, where either $I=\mathbb N$ or $I=\{1,\dots,N\}$ for some $N\in\mathbb N$. Countable additivity is stated for sequences, so in the finite case we extend the finite disjoint family to a sequence by setting $E_k:=\varnothing$ for $k>N$; in the infinite case we set $E_k:=B_{s_k}$ for every $k\in\mathbb N$. In both cases $(E_k)_{k=1}^{\infty}$ is a sequence of pairwise disjoint events, its union is $A_x$, and its nonempty members are exactly the level sets $B_s$ with $s\in S_x$.
Applying countable additivity of the probability measure $\mathbb P$ to this sequence gives $\mathbb P(A_x)=\sum_{k=1}^{\infty}\mathbb P(E_k)=\sum_{\{s\in S:s\le x\}}\mathbb P(B_s)$. Finally, by the definition of the probability mass function $p_X:S\to[0,1]$, each level-set probability is $\mathbb P(B_s)=p_X(s)$. Substituting this identity into the preceding sum gives $\mathbb P(A_x)=\sum_{\{s\in S:s\le x\}}p_X(s)$.
[/guided]
[/step]
[step:Identify the probability of the sublevel event with the cumulative distribution function]
By definition of the cumulative distribution function of $X$, $F_X(x)=\mathbb P(\{\omega\in\Omega:X(\omega)\le x\})=\mathbb P(A_x)$. Combining this identity with the preceding step yields $F_X(x)=\sum_{\{s\in S:s\le x\}}p_X(s)$. Since $x\in\mathbb R$ was arbitrary, the formula holds for every $x\in\mathbb R$.
[guided]
The previous step computed the probability of the event $A_x$. To translate that computation into the theorem's notation, we use the definition of the cumulative distribution function. Since
\begin{align*}
A_x=\{\omega\in\Omega:X(\omega)\le x\},
\end{align*}
the definition of $F_X:\mathbb R\to[0,1]$ gives
\begin{align*}
F_X(x)=\mathbb P(\{\omega\in\Omega:X(\omega)\le x\})=\mathbb P(A_x).
\end{align*}
The countable-additivity step proved
\begin{align*}
\mathbb P(A_x)=\sum_{\{s\in S:s\le x\}}p_X(s).
\end{align*}
Substituting this value of $\mathbb P(A_x)$ into the definition of $F_X(x)$ yields
\begin{align*}
F_X(x)=\sum_{\{s\in S:s\le x\}}p_X(s).
\end{align*}
Because the fixed threshold $x\in\mathbb R$ was arbitrary, the identity holds for every real number $x$.
[/guided]
[/step]