Properties of conditional variance Full statement of problem:

Let $(\Omega,\mathcal{F},P)$ be a probability space and $\mathcal{G}\subset \mathcal{F}$ a $\sigma$-algebra. Let $X\in L^2$. Define $$\text{var}(X \mid \mathcal{G})=E[|X-E[X \mid \mathcal{G}]|^2\mid \mathcal{G}].$$ Prove that:
(a) $\text{var}(X \mid \mathcal{G})=E[X^2 \mid \mathcal{G}]-(E[X \mid \mathcal{G}])^2$ a.s.
(b)$\text{var}(X)=E[\text{var}(X \mid \mathcal{G})]+\text{var}(E[X \mid \mathcal{G}])$

Part (a) just seems like a simple computation using definitions of conditional expectation, but how do I prove (b)? Any help would be much appreciated, thanks in advance!

Hints for part (b):


*

*Show that $$\mathbb{E} \big[ (X-\mathbb{E}(X \mid \mathcal{G}) \mathbb{E}(X \mid \mathcal{G}) \big]=0 \tag{1}$$ and $$\mathbb{E}(X- \mathbb{E}(X \mid \mathcal{G}))=0. \tag{2}$$

*Conclude from $$X-\mathbb{E}(X) = (X-\mathbb{E}(X \mid \mathcal{G})) + (\mathbb{E}(X \mid \mathcal{G})-\mathbb{E}(X))$$ that $$\begin{align*} \text{var}(X) =& \mathbb{E} \big[ (X-\mathbb{E}(X \mid \mathcal{G}))^2 \big] + \mathbb{E} \big[ (\mathbb{E}(X \mid \mathcal{G})-\mathbb{E}(X))^2 \big] \\ &\quad +2 \mathbb{E} \big[ (X-\mathbb{E}(X \mid \mathcal{G}))(\mathbb{E}(X \mid \mathcal{G})-\mathbb{E}(X)) \big] \tag{3} \end{align*}$$

*Use Step 1 to show that the third term on the right-hand side of $(3)$ equals zero. Identify the other two terms.

