Let $X$ be a random variable on $\mathcal{X}$ while $Y$ is a random variable on $\mathcal{Y}$. Further $c$ is a map:
$c:\mathcal{X}\to \mathcal{Y}$
If $P(Y=y\mid X=x)=\chi_{\{c(x)=y\}} \; \; (*)$ where $\chi$ is the characteristic/indicator function, why is
$E[Y\lvert X]=Y$?
My idea: For any $x\in \mathcal{X}$, we have on the event $\{X=x\}$ that $Y=c(x)\; \; (**)$
For me it seems clear that then $c(X)=Y$, and if I were to be able to assume that $c$ is measurable I could simply state:
$E[Y\mid X]=E[c(X)\mid X]=c(X)=Y$.
Is there more rigourous reasoning why $(**)$ would imply that $c(X)=Y$?
$$\begin{align}P(Y \neq c(X))&=\sum_{y \in \mathcal{Y}}\sum_{x \in \mathcal{X}}\chi_{c(x)\neq y}(x,y)p_{Y|X}(y,x)p_X(x)\\&=\sum_{y \in \mathcal{Y}}\sum_{x \in \mathcal{X}}\chi_{c(x)\neq y}(x,y)\chi_{c(x)=y}(x,y)p_X(x)\\&=0\end{align}$$ So $Y=c(X)$ almost everywhere. Furthermore $$\begin{align}E[Y|X](x)&=\sum_{y \in \mathcal{Y}}yp_{Y|X}(y,x)\\&=\sum_{y \in \mathcal{Y}}y\chi_{c(x)=y}(x,y)\\&=\sum_{y \in \mathcal{Y}}c(x)\chi_{c(x)=y}(x,y) \\&=c(x)\sum_{y \in \mathcal{Y}}p_{Y|X}(y,x)\\&=c(x)\end{align}$$ which implies $E[Y|X]=Y$.