# What is the sigma algebra generated by the indicator function of random variable?

I was thinking what is the $\sigma$-algebra generated by the random variable $Z= \mathbb{I}(X+Y=0)$ where $X,Y\sim\operatorname{Bern}(p)$ iid. (Note: $\mathbb{I}$ is the indicator function.)

-

It's the smallest $\sigma$-algebra making $Z$ measurable. As the values of $Z$ are $0$ or $1$, $\sigma(Z)=\left\{\emptyset,\Omega, Z^{-1}\left(\{0\}\right),Z^{-1}(\{1\})\right\}$ and $$Z^{-1}(\{0\})=\{X\neq -Y\}=\{X=1,Y=1\}\cup\{X=-1,Y=-1\}.$$
In order to compute $\mathbb E\left[X\mid Z\right]$, we compute $\mathbb E\left[X\mathbf 1\{Z=0\}\right]$ and $\mathbb E\left[X\mathbf 1\{Z=1\}\right]$. We have $$\mathbb E\left[X\mathbf 1\{Z=0\}\right]=\mathbb E\left[X\mathbf 1\{X=1\}\mathbf 1\{Y=1\}\right]+\mathbb E\left[X\mathbf 1\{X=-1\}\mathbf 1\{Y=-1\}\right]=p^2-(1-p)^2,$$ and we compute similarly $\mathbb E\left[X\mathbf 1\{Z=1\}\right]$. Then we use the formula which gives the conditional expectation of a random variable with respect to a $\sigma$-algebra generated by a finite partition.