Let $X$ and $Y$ be R.V.s and $\mathcal {H}$ be a sigma algebra defined on $\Omega$.
I know that $$\mathbb{E}(X|Y\in A)=\frac{\mathbb{E}(X\mathbb{1}_A)}{\mathbb{P}(Y\in A)}$$
And more generally
$$\mathbb{E}(X|\mathcal {H})=\sum_{B \in \mathcal {H}} \frac{\mathbb{E}(X\mathbb{1}_B)}{\mathbb{P}(B)}1_B$$
Can someone explain why those formulas are in fact correct and how can I derive them? Both in simplistic case and in more general, formal way.