Let $(Ω, \mathcal{F}, \mathbb{P})$ be a probability space, where $|Ω| < ∞ $ and $\mathcal{F}$ is a power set of $Ω$. Let $\mathcal{G} ⊆ \mathcal{F}$ a further $σ-$algebra, that is generated by partition $B_1, . . . , B_k$. Let $Z$ be a $\mathcal{G}-$ measuravle random variable, such that for all $B ∈ \mathcal{G},\;$ $\mathbb{E} I_BZ = \mathbb{E}I_BX $. Show, that $Z = \mathbb{E}[X|G]$
Random variable $X : Ω → \mathbb{R}$ is $\mathcal{G-}$ measurable, iff for all $a ∈ \mathbb{R}:$ $$\{X ≤ a\} = X^{−1}((−∞, a]) ∈ \mathcal{G}.$$
Let $\mathcal{G}$ be a $σ-$algebra with partition $B_1, . . . , B_k.$ Then we define the conditional expecation of $X$ given $\mathcal{G}$ defined: $$\mathbb{E}[X|\mathcal{G}] := \sum_{i=1}^{k}I_{B_i}\mathbb{E}[X|Bi].$$
I would appreciate any kind of help, I am really stuck on this. I understand, that this is a different characterisation of conditional expectation. I was thinking about the null set, but wasn't sure how to apply it in this contest.
Question: How to show, that $Z = \mathbb{E}[X|G]$