While reading a solution of a particular exercise, I stumble in a certain point of the proof and would like some help understanding how Ito's formula is applied.
I am given a deterministic function $\sigma : \mathbb{R} \rightarrow \mathbb{R}$ such that $\int_0^T \sigma^2_t dt < \infty$ for any $T > 0,$ and a partition of $0 < t_1 < t_2 < \dotsc t_n = T$ of $[0,T],$ where now $T$ is fixed. We also introduce the integral process $$ Y_t = \int_0^t \sigma_s dW_s. $$ Part of the bigger solution claims that by Ito's formula we have \begin{equation} \big( Y_{t_{j+1}} - Y_{t_j} \big) ^2 = 2 \int_{t_j}^{t_{j+1}} \big(Y_s - Y_{t_j})\sigma_s dW_s + \int_{t_{j}}^{t_{j+1}} \sigma_s^2 dW_s, \end{equation} which I do not see exactly where it comes from. My attempt using differentials looks like: \begin{align} d((Y_t - Y_s)^2) &= 2(Y_t - Y_s) dY_t - 2(Y_t - Y_s)dY_s + \frac{1}{2}(2(dY_t)^2 + 2(dY_s)^2 - 4dY_tdY_s) \\ &= 2(Y_t - Y_s)\sigma_tdW_t - 2(Y_t-Y_s)\sigma_sdW_s + (\sigma_t^2dt + \sigma_s^2 ds - 2\sigma_t\sigma_s dtds) \end{align} I can see how reverting the differential equation above yields most of the terms from my desired result, but I do not see how others cancel. I am also a bit unsure whether I applied Ito's formula correctly as $Y_t, Y_s$ seem to be not independent.
Any hints appreciated!
Let us consider $s \in [t_{j},t_{j+1}]$. Then $$Z_s=Y_{s}-Y_{t_{j}}=\int_{t_{j}}^{s}\sigma_sdW_s$$ Our function is $F(z)=z^2$. The derivatives are $$\frac{\partial F}{\partial s}=0,\frac{\partial F}{\partial z}=2z,\frac{\partial^2 F}{\partial z^2}=2$$ So by Ito $$dF=\frac{\partial F}{\partial z}dZ_s+\frac{1}{2}\sigma_s^2\frac{\partial^2 F}{\partial z^2}ds=$$ $$=2Z_sdZ_s+\sigma_s^2ds=2(Y_s-Y_{t_j})\sigma_sdW_s+\sigma^2_sds$$ therefore $$(Y_{t_{j+1}}-Y_j)^2=2\int_{t_j}^{t_{j+1}}(Y_s-Y_{t_j})\sigma_sdW_s+\int_{t_j}^{t_{j+1}}\sigma^2_sds$$