<s>[INST] A simple conditional expectation problem $X, Y$ iid uniform random variables on $[0,1]$
$$Z =
\left\{
\begin{aligned}
X+Y \quad&\text{ if }  X>\frac{1}{2}
\\
\frac{1}{2} + Y \quad & \text{ if } X\leq\frac{1}{2}
\end{aligned}
\right.$$
The question is $E\{Z|Z\leq 1\}= ?$
I tried $\displaystyle \int_0^1 E\{Z|Z = z\} P\{Z = z\}dz$ and got $5/8$, but I am not so sure about the result since I haven't touched probability for years.
 [/INST] For $x \in (1/2,1]$, let
$$
F_{Z|Z \leq 1}(x) = {\rm P}(Z \leq x | Z \leq 1) = \frac{{{\rm P}(Z \le x)}}{{{\rm P}(Z \le 1)}},
$$
and let
$$
f_{Z|Z \leq 1}(x) = \frac{{\rm d}}{{{\rm d}x}}F_{Z|Z \le 1} (x) = \frac{1}{{{\rm P}(Z \le 1)}}\frac{{\rm d}}{{{\rm d}x}}{\rm P}(Z \le x).
$$
Then,
$$
{\rm E}[Z|Z \le 1] = \int_{1/2}^1 {xf_{Z|Z \le 1} (x)\,{\rm d}x} .
$$
So now the problem reduces to calculating ${\rm P}(Z \leq x)$, for $x \in (1/2,1]$.
This can be done using the law of total probability, conditioning on $X$, leading to
$$
{\rm E}[Z|Z \le 1] = 7/9.
$$
EDIT: 
Fix $x \in (1/2,1]$. Then, by the law of total probability,
$$
{\rm P}(Z \leq x) = \int_0^{1/2} {{\rm P}(Z \le x|X = s)\,{\rm d}s}  + \int_{1/2}^1 {{\rm P}(Z \le x|X = s)\,{\rm d}s} .
$$
It thus follows from the definition of $Z$ (and the independence of $X$ and $Y$) that
$$
{\rm P}(Z \leq x) = \int_0^{1/2} {{\rm P}( Y \le x - 1/2)\,{\rm d}s}  + \int_{1/2}^1 {{\rm P}(Y \le x - s)\,{\rm d}s} .
$$
Now,
$$
\int_0^{1/2} {{\rm P}( Y \le x - 1/2)\,{\rm d}s} = \frac{1}{2}{\rm P}(Y \le x - 1/2) = \frac{{x - 1/2}}{2} = \frac{x}{2} - \frac{1}{4}
$$
and
$$
\int_{1/2}^1 {{\rm P}(Y \le x - s)\,{\rm d}s} = \int_{1/2}^x {{\rm P}(Y \le x - s)\,{\rm d}s}  = \int_{1/2}^x {(x - s)\,{\rm d}s}  = \frac{{x^2 }}{2} - \frac{x}{2} + \frac{1}{8}.
$$
Hence
$$
{\rm P}(Z \leq x) = \bigg(\frac{x}{2} - \frac{1}{4}\bigg) + \bigg(\frac{{x^2 }}{2} - \frac{x}{2} + \frac{1}{8}\bigg) = \frac{{x^2 }}{2} - \frac{1}{8}.
$$
In particular,
$$
{\rm P}(Z \leq 1) = \frac{3}{8}.
$$
Thus,
$$
F_{Z|Z \leq 1}(x) = \frac{8}{3}\bigg(\frac{{x^2 }}{2} - \frac{1}{8}\bigg) = \frac{{4x^2  - 1}}{3},
$$
and in turn
$$
f_{Z|Z \leq 1}(x) = \frac{{8x}}{3}.
$$
Finally,
$$
{\rm E}[Z|Z \le 1] = \int_{1/2}^1 {xf_{Z|Z \le 1} (x)\,{\rm d}x} = \frac{8}{3}\int_{1/2}^1 {x^2 \,{\rm d}x}  = \frac{8}{3}\bigg(\frac{{1 - 1/8}}{3}\bigg) = \frac{7}{9}.
$$
</s>