Let $X,Y$ be real random variable on the probability space $(\Omega,\mathcal F,P)$, and suppose that $Y$ is $P$-integrable and that $X$ has probability density $f$ with respect to the Lebesgue measure $\lambda$. Am trying to show that
$$\frac{d}{dx}E[1_{\{X\leq x\}}Y]=E[Y|X=x]f(x)$$
for $\lambda$-almost every $x\in\mathbb R$.
Attempt:
First lets recall the definition of $E[Y|X=x]$. The Doob-Dynkin lemma implies the existence of a real-valued Borel measurable map $g:\mathbb R\mathbb \to \mathbb R$ such that $E[Y|\sigma(X)]=g\circ X$ $P$-almost surely. Such map $g$ is $P_X$-integrable and unique $P_X$-almost surely. We let $E[Y|X=x]$ denote any version of $g$.
Now fix $x\in \mathbb R $ and compute using the properties of conditional expectation:
$$E[1_{\{X\leq x\}}Y]=E[1_{\{X\leq x\}}(g\circ X)]=E[(1_{(-\infty,x]}g) \circ X]=\int 1_{(-\infty,x]}g \,dP_X=\int 1_{(-\infty,x]}g f \, d\lambda$$
Moreover the same calculation without $1_{\{X\leq x\}}$ shows that $g f$ is $\lambda$-integrable. Hence we can invoke the Lebesgue differentiation theorem to obtain the result.
Am I missing something? Thanks a lot for your help.
I think this could work: $$\int_{(-\infty,x]} E[Y|X=z]f(z)dz=E[\mathbf{1}_{\{X\leq x\}}E[Y|X]]=E[\mathbf{1}_{\{X\leq x\}}Y]$$ Now take the derivative wrt $x$.