Question about conditional expectation of bounded random variables I was recently asked a question about Exercise 9.2.4(i) in Klenke's Probability theory. First I state the exercise itself.
Let $X$ be a real-valued random variable (on $(\Omega,\mathcal F,\mathbb P)$) with $|X|\leq 1$ almost surely. Then there exists a random variable $Y:\Omega\rightarrow \{-1,1\}$ such that $E[Y|X]=X$.
Now the question is regarding the following counter-example. Consider two coin tosses, which leads to the event space $$\Omega=\{HH,HT,TH,TT\},$$ and the random variable $X:\Omega\rightarrow\mathbb R$ with $$X(HH)=-0.5, \, X(HT)=X(TH)=0, \, X(TT)=0.5.$$
Using the definition of conditional expectation $E[Y|X]$ is a random variable defined w.r.t. $\sigma(X)$ and satisfies
$$ E[Y|X](TT)\, \mathbb P(\{TT\}) = \int_{\{TT\}} E[Y|X](\omega)d\mathbb P(\omega) = \int_{\{TT\}} Y (\omega) d\mathbb P(\omega) = Y(TT)\mathbb P(\{TT\}),  $$
and therefore $E[Y|X]=X$ would mean that
$$0.5=X(TT)= E[Y|X](TT)=Y(TT),$$
which means that $Y$ has to have values other than $\{-1,1\}$. But this contradicts the exercise which states that $Y$ should only have values in $\{-1,1\}$.
Question: What is the issue with the argument in this counterexample.
Its possible that I missing something simple with conditional expectations.
Also any hints on the original question in Klenke's book.
 A: I'm not sure where the original exercise comes from, but it seems to be stated incorrectly for a minor technical reason.
I think the intended idea is to define a random variable $Y$ such that $P(Y=1 \mid X=x) = \frac{1+x}{2}$ and $P(Y=-1 \mid X=x) = \frac{1-x}{2}$ so that $E[Y \mid X=x] = \frac{1+x}{2} \cdot 1 + \frac{1-x}{2} \cdot (-1) = x$.
But if $\sigma(X)=\mathcal{F}$ like in your counterexample, there may not be enough "room" in the probability space $(\Omega, \mathcal{F})$ to define this new random variable $Y$ on the same probability space.
Edit: The original problem statement did not explicitly specify probability spaces $(\Omega, \mathcal{F})$ so the above solution will work.
Here is the actual statement of the exercise:

If $X$ is a random variable with $|X| \le 1$ a.s., then there is a random variable $Y$ with values in $\{-1, 1\}$ and with $E[Y \mid X] = X$.


The error in your counterexample is $E[Y \mid X](TT) = Y(TT)$, which I think comes from your imposition that $Y$ must be measurable with respect to $\sigma(X)$. This is not required by the original problem statement. You should not have modified the statement of the exercise with explicit mentions of the $(\Omega, \mathcal{F})$; as your attempted counterexample shows, $Y$ generally should not be $\sigma(X)$-measurable for the exercise's claim to hold. In your counterexample, you would need to "augment" the probability space $\Omega$ in order to specify $Y$ (e.g., $\Omega' = \Omega \times \{-1, 1\}$).
