My question is about this theorem regarding projection-valued measures.
Suppose $H$ is a separable Hilbert space (in many cases we are just concerned about the separable case). Suppose $A$ is an unbounded self-adjoint operator on $H$. Then there is a projection valued measure(PVM) $\mu^A$ on $\sigma(A)$ such that $$ \int_{\sigma(A)} \lambda d\mu^A (\lambda)=A. $$
Now, I am wondering about one thing: by the definition of PVM, for $\lambda_1,\lambda_2\in \sigma(A)$, $\mu^A(\lambda_1)(H)$ (range of the projection) and $\mu^A(\lambda_2)(H)$ are orthogonal subspaces of $H$. Since $H$ is separable, there can be countably many $\lambda$ for which $\mu^A(\lambda)(H)\neq\{0\}$. Therefore, the integral above could be actually written as a sum.
However, sometimes, I find out that, although it is clear that we just need to consider the case where $H$ is separable, the above theorem is still written as an integral, rather than a sum.
Why do we need to write it as an integral?
I think you are taking $\mu(\lambda)$ to mean $\mu(\{\lambda\})$, which it is not. In the first case, $\lambda$ is a dummy variable. In the second case it the spectral projection associated with $\{\lambda\}$, which could be $0$ for all $\lambda$. For example, $\mu(S)f=\chi_{S}f$ is the spectral measure associated with multiplication by $\lambda$ on $L^2(\mathbb{R})$. That is, $$ \mu(S)f = \chi_{S}f,\;\;\; f\in L^2(\mathbb{R}). $$ You would use dummy variable to write $\int \lambda d\mu(\lambda)f$ in order to write $(Mf)=\lambda f(\lambda)$ as an integral. The spectral measure $P$ in this case is $P(S)f = \chi_{S}f$, which is multiplication by the characteristic function of the set $S$. Note that $P(\{\lambda\})=0$ is the $0$ operator because multiplication by $\chi_{\{\lambda\}}=0$ on $L^2(\mathbb{R})$ is the $0$ operator.