Can anyone see why this lemma is true? Seems very confusing! Given a function f, we write $\bar{f}(t) = \sup_{u \leq t} f(u).$
Lemma: Let $s_{0},\dotsc,s_{T}$ be real numbers and $h:\mathbb R \to \mathbb R$. Then
$$\sum_{i=0}^{T-1}h(\bar{s}_{i})(s_{i+1}-s_{i})=\displaystyle \sum_{i=0}^{T-1}h(\bar{s}_{i})(\bar{s}_{i+1}-\bar{s}_{i})+h(\bar{s}_{T})(s_{T}-\bar{s}_{T}) \tag{1}
$$
Proof: This followed by properly rearranging summands. Indeed, observe that for a term on the right-hand side there are two possibilities; if $\bar{s}_{i+1}=\bar{s}_{i}$ respectively $s_{T}=\bar{s}_{T}$, it simply vanishes.
Otherwise it equals a sum $h(\bar{s}_{k})(s_{k+1}-s_{k})+.....+h(\bar{s}_{m})(s_{m+1}-s_{m})$ where $  \bar{s}_{k}=\dotsb=\bar{s}_{m}.$ In total, every summand on the left hand side is of (1) is accounted exactly once on the right.
My question is how it is showed that right hand side  equals a sum $h(\bar{s}_{k})(s_{k+1}-s_{k})+\dotsb+h(\bar{s}_{m})(s_{m+1}-s_{m})$? Any idea?
 A: I have given a glance to the paper. Peraphs the tag might be Statistic or Probability theory, but the lemma you have cited seems just a general support to the following proof, so it is not inherent to statistic, is it? I do the following reasoning (but I'm not too sure): starting by a generic term in the r.h.s., say it $\overline s_{i+1}-\overline s_i$,  we have $(1)$ that it may be happened that in $i+1$ the $sup$ is changed (compared to the previous $i$), i.e. $sup$ $s_{i+1}$ is exactly $s_{i+1}$. From this fact we obtain that $\overline s_{i+1}$ can be replaced by $s_{i+1}$. Otherwise $(2)$ it will be the value at some $j<i+1$; in this case we fall in the first possibility, i.e., the term vanishes because $\overline s_{i}=\overline s_{i+1}$ ($\overline s_{i+1}\gt s_{i+1}$, i.e., the supremum falls in an $m+1 \lt i+1$). At this point (case $(1)$) we must consider  $\overline s_i$; the argument is the same: obviously we must start from $m$($=i$), then we repeat until we have the supremum (if the steps end at the second stage then also $sup$ $s_{i}$ equals $s_{i}$, so, in this particular case, we have immediately the result). Finally, in the general case, we can note that proceeding this way  we have that $\overline s_m = \overline s_{m-1} = ... = \overline s_{m-n}$ ($=\overline s_{k}$), and joining the summands (being the $h(\overline s_i)$'s  equal) we obtain
$\qquad$ $s_{m+1}-s_m +s_m-s_{m-1} +s_{m-1}-\;...\;+ \; s_{m-m+1}-s_{m-n} =$ 
$\qquad$ $s_{m+1}-s_{m-n}=$
$\qquad$ $s_{i+1}-s_k =$
$\qquad$ $\overline s_{i+1} - \overline s_i$.
(p.s. Ask if something is not clear.)
