probability theory – key identities in the proof of the optional sampling theorem

Let $ ( Omega, mathscr {F}, mu) $ be a $ sigma $– finite measurement space,
let $ ( mathscr {F} _n) _ {n in mathbb {N}} $ to be a filtration of sub-sigma-algebras
of $ mathscr {F} $, let $ (u_n) _ {n in mathbb {N}} $ to be a submartingale
related to $ ( mathscr {F} _n) _ {n in mathbb {N}} $,
and let $ sigma $ and $ tau $ be bounded time out (compared to $ ( mathscr {F} _n) _ {n in mathbb {N}} $) such as $ color {red} { sigma leq tau leq N} $.
The optional sampling theorem states that
$$
int (u_ sigma-u_ tau) d mu leq0.
$$

One way to prove it is to use key identities
$$
color {black} {int (u_ sigma-u_ tau) of mu}
= color {blue} { int sum_ {n = sigma (w)} mu (dw)}
= color {green} { sum_ {n = 0} ^ {N-1} int (u_n-u_ {n + 1}) 1_ {[sigma=n]cap[tau>n]} d mu}.
$$

Black = blue identity is easy. However, I fought with the blue -> green. Although it sounds simple, I have not found a rigorous way to establish that.

My question: Is there a rigorous way to establish the identity blue = green?

Any help / hint is highly appreciated.