# $X\perp Y \Leftrightarrow Y\perp r(X)$?

Consider the random variables $$Y$$ and $$X$$. Let $$\mathcal{X}$$ denote the support of $$X$$. Let $$\mathcal{Y}$$ denote the support of $$Y$$. Let $$r:\mathcal{X}\rightarrow \mathbb{R}$$. I have doubts about the following:

1) Let $$X$$ be independent of $$Y$$, i.e. $$X\perp Y$$. Does this imply $$Y\perp r(X)$$?

2) Let $$Y\perp r(X)$$. Does this imply $$Y\perp X$$?

My thoughts: I believe that the answer to both questions is "no", but I'm struggling to formalise arguments.

For example, regarding 1), suppose that the codomain of the function $$r$$ is $$\{0,1\}$$ and that $$\{x\in \mathcal{X}: r(x)=1\}=\{x_1,x_2\}$$. We assume that $$X\perp Y$$, that is $$P_{Y|X}(y|x)=P_Y(y) \hspace{1cm} \forall y\in \mathcal{Y}, \forall x \in \mathcal{X}$$ We want to show that $$P_{Y|r(X)}(y|r)=P_Y(y) \hspace{1cm} \forall y\in \mathcal{Y}, \forall r\in \{0,1\}$$ Now, note that $$P_{Y|r(X)}(y|1)=P_{Y|r(X)}(y|\{x_1,x_2\})$$ I don't think that we can claim that $$P_{Y|r(X)}(y|\{x_1,x_2\})=P_{Y}(y)$$.

For 1) see that for any measurable sets $$A,B$$: $$\mathbf P (r(X) \in A, Y \in B) = \mathbf P (X \in r^{-1}(A), Y \in B) = \mathbf P (X \in r^{-1}(A))\mathbf P (Y \in B) = \mathbf P(r(X) \in A) \mathbf P (Y \in B)$$ and thus $$r(X)$$ is independent of $$Y$$
For 2) take $$r(X) = 1$$ constant and $$Y = X$$. Then $$Y$$ is independent of $$1$$ but certainly not of $$X$$.