So i am working on a problem in probability theory and i came across the following equation
$$E[XY\mid \mathcal{F}] = \sum_{i \in [6]}E[XY\mid X = i]1_{\{X=i\}} = \sum_{i \in [6]}\frac{E[XY, X = i]}{P[X=i]}1_{\{X=i\}} = \sum_{i \in [6]}\frac{iE[Y, X = i]}{P[X=i]}1_{\{X=i\}} = \sum_{i \in [6]}\frac{iE[Y]P[X = i]}{P[X=i]}1_{\{X=i\}}$$
For context: $[6]$ describes the set $\{1,...,6\}$ and $X,Y$ are the projections $X,Y: [6]^2 \to [6]$ and $\mathcal{F} = \sigma(X)$ the $\sigma$-algebra generated by the projection $X$.
Unfortunately, I dont know why the 3rd "=" and the last "=" hold. Can someone help me understanding these 2 equations?
$$E[XY\mid \mathcal{F}] = \sum_{i \in [6]}E[XY\mid X = i]1_{\{X=i\}} \overset{(1)}{=} \sum_{i \in [6]}iE[Y\mid X = i]1_{\{X=i\}} $$ $$\overset{(2)}{=}\sum_{i \in [6]}i\frac{E(Y1_{\{X=i \}})}{P(X=i)}1_{\{X=i\}}$$
$$\overset{(3)}{=}\sum_{i \in [6]}i\frac{E(Y) E(1_{\{X=i \}})}{P(X=i)}1_{\{X=i\}}$$
$$=\sum_{i \in [6]}i\frac{E(Y) P(X=i )}{P(X=i)}1_{\{X=i\}}$$ $$=E(Y) \sum_{i \in [6]} i 1_{\{X=i\}}\overset{(4)}{=}E(Y)X$$
(1) Since $E(f(X)Y\mid X)=f(X)E(Y\mid X)$
(2) $E(Y|A)=\frac{E(Y1_A)}{P(A)}$
(3) $X$ and $Y$ are independent.
(4) $X$ is a simple function and $X=\sum_{i \in [6]} i 1_{\{X=i\}}$