On a certain deterministic integral related to Tanaka’s formula Note: We define the signum function, $\text{sgn}$ by $\text{sgn}(x) = 1$ if $x \geq 0$, and $-1$ otherwise.
Suppose $f: [0, \infty) \to \mathbb R$ is continuous and of locally bounded variation, with $f(0) = 0$. Is it true that the integral
$$\int_0^t f \, d\, \text{sgn(f)} := f(t) \, \text{sgn}(f(t)) - \int_0^t \text{sgn} (f(s)) \, df(s)$$
$$= \lvert f(t) \rvert - \int_0^t \text{sgn} (f(s)) \, df(s)$$
vanishes for all $t \geq 0?$
Remark: Note that the RHS is a definition for the LHS! The integral on the RHS is to be interpreted as a regular Lebesgue Stiltjes integral.
 A: $\newcommand\sgn{\operatorname{sgn}}$Yes, this is true. Indeed, fix any real $t>0$. Let
\begin{equation}
    S_+:=\{s\in(0,t)\colon f(s)\ge0\},\quad S_-:=\{s\in(0,t)\colon f(s)<0\}. 
\end{equation}
Then
\begin{equation}
    I:=\int_0^t\sgn(f(s))\,df(s)=I_+ - I_-,
\end{equation}
where
\begin{equation}
    I_-:=\int_{S_-}df(s),
\end{equation}
\begin{equation}
    I_+:=\int_{S_+}df(s)=\int_0^1 df(s)-\int_{S_-}df(s)=f(t)-I_-, 
\end{equation}
so that
\begin{equation}
    I=f(t) - 2I_-. 
\end{equation}
Since $f$ is continuous, the set $S_-$ is open, so that $S_-$ is the union of at most countably many disjoint nonempty open intervals. If the right endpoint of one of those intervals is $t$, let us write that interval as $(a,t)$, with $a\in[0,t)$. If the right endpoint of none of those intervals is $t$, let us use the empty interval $(a,t)$ with $a=t$.
So,
\begin{equation}
    S_-=(a,t)\cup\bigcup_{j\in J}(a_j,b_j),
\end{equation}
where $J$ is an at most countable set, $0\le a_j<b_j\le a\le t$ and $b_j<t$ for all $j\in J$ and the intervals $(a_j,b_j)$ are pairwise disjoint.
If $f(t)>0$, then $a=t$ by the continuity of $f$, and hence $\int_{(a,t)}df(s)=0=f(t)\,1(f(t)\le0)$.
If $f(t)\le0$ and $a=t$, then $f(t)=0$ by the continuity of $f$, and hence $\int_{(a,t)}df(s)=0=f(t)\,1(f(t)\le0)$.
If $f(t)\le0$ and $a<t$, then $f(a)=0$ by the continuity of $f$,
and hence $\int_{(a,t)}df(s)=f(t)-f(a)=f(t)=f(t)\,1(f(t)\le0)$.
So, in any case,
\begin{equation}
    \int_{(a,t)}df(s)=f(t)\,1(f(t)\le0). 
\end{equation}
Also, by the continuity of $f$, we have $\int_{(a_j,b_j)}df(s)=f(b_j)-f(a_j)=0-0$ for all $j\in J$.
So,
\begin{equation}
    I_-=\int_{(a,t)}df(s)+\sum_{j\in J}\int_{(a_j,b_j)}df(s)=f(t)\,1(f(t)\le0). 
\end{equation}
Thus,
\begin{equation}
    I=f(t) - 2I_-=f(t) - 2f(t)\,1(f(t)\le0)=|f(t)|,
\end{equation}
as claimed.
