I'm reading the financial mathematics book "Interest rate models, theory and practice" by Brigo and Mercurio. There, they make a derivation that I can't seem to follow:

The background: We have a probability space $\left( \Omega, \mathcal{F}, \mathbb{Q} \right)$ and $\tau$ is a random variable that takes values in $(0,\infty]$. $L_{GD}$ is a constant and $\mathbb{E}$ denotes the expectation under $\mathbb{Q}$. I'm interested in particular in the equality reached in the second line, which concerns the function $D(0,\cdot)$. In this context, it represents a ``stochastic discount", but can be thought as a continuous (Borel) function from $[0,\infty]$ to $[0,\infty]$.
My question is: It seems the authors express $D(0,\tau)$ as $\int_{t=0}^{\infty} D(0,t) \mathbb{1}_{ \left\{ \tau \in [t,t+dt) \right\} }$. I get confused with the use of the integral sign here. It is an integral with respect to...? Or does it represent an infinite sum? Should there be a partition of the range of values of $\tau$ and then take some limit on this partition by refining it (and somehow justifies the $dt$ in the indicator function). How can I formally (in a mathematical sense), step by step, justify this equality? I hope my question is clear.
Presumably $\tau$ is a stopping time, so you can view the equality you posted as some sort of conditional expectation:
$\mathbb{E}[W(\tau)] = \int W(t) f(\tau = t) dt$
(Here, I am using $W(t) = 1_{\tau \in [T_a, T_b]} D(0,\tau)$)
They are using the indicators to approximate for the density of $\tau$ (which presumably may not have a density w.r.t. Lebesgue measure so I guess what they are doing is "more right" than the equality I wrote but hopefully conveys the intuition better.)
If you wanted to formalize this, you would probably want to not write that equality; the original expectation can be viewed as a Lebesgue integral with a measure $\mu$ s.t. $\mu(A) = P(\tau \in A)$ for $A$ in the sigma algebra generated by $\tau$, and then go through standard machinery of approximating your function $W$ by simple functions etc. If your function is Riemann integrable, then you can do this $dt$ business where you can chop up your function to small intervals.
I would just interpret that integral as a Riemann integral from the form you took and assume what they mean is
$\lim_{\delta \rightarrow 0} \sum_i W(\delta i) P(\tau \in (\delta i, (\delta+1)i)$
(I pulled the expectation inside, but maybe it is not necessarily wise to do so; this should be operational though)