# Validity of infinitesimal manipulations in Ito SDEs

Suppose I have the Ito SDE $$dX_t = -\theta X_t dt + \sigma dW_t$$ with some initial probability distribution $$X_0 \sim p_{X_0}$$. Then the process $$X$$ evolves as an Ornstein Uhlenbeck process. Since $$X$$ is semimartingale, the stochastic integral $$\int_0^T s dX_s$$ is defined. Formally, I can substitute in the SDE to get $$\int_0^T s dX_s = \int_0^T s ( -\theta X_s ds + \sigma dW_s) = -\theta\int_0^T s X_s ds + \sigma W_T.$$

On the other hand, the actual definition of $$\int_0^T s dX$$ is the limit in probability of $$\lim_{\Delta t \rightarrow 0} \sum_{i=0}^{\frac{T}{\Delta t}} i \frac{T}{\Delta t }(X_{(i+1)\frac{\Delta t}{T}} - X_{i\frac{\Delta t}{T}})$$.

Does the formal substitution give the same result as the real definition? If it does, how do we justify a manipulation like this in general?

First to be clear by stochastic integration by parts we have

$$\int_0^T s dX_s = \int_0^T s ( -\theta X_s ds + \sigma dW_s) = -\theta\int_0^T s X_s ds + \sigma TW_T-\sigma\int_{0}^{T}W_{s}ds.$$

We can see from the discrete side too: we have

$$\sum t_{i}(X_{t_{i}}-X_{t_{i-1}})=-\sum t_{i}\theta X_{t_{i}}(t_{i}-t_{i-1})+\sigma \sum t_{i}(W_{t_{i}}-W_{t_{i-1}}),$$

and for the last term by summation by parts we get

$$\sum t_{i}(W_{t_{i}}-W_{t_{i-1}})=T W_{T}-\sum W_{t_{i}}(t_{i}-t_{i-1}).$$