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):