Let $(\Omega, \mathcal{F}, P)$ be a probability space, $\mathcal{G}\subset \mathcal{F}$ be a sigma algebra, $X, Y : \Omega \to \mathbb{R}^n$ be random vectors, and $f$ be a measurable function on $\mathbb{R}^{2n}$. Suppose that $X$ is independent of $\mathcal{G}$, $f(X ,Y)$ is independent of $Y$, and $Y$ is $\mathcal{G}$-measurable. Is it true that $f(X,Y)$ is independent of $\mathcal{G}$?
Motivation: This question arises from a randomized algorithm. In this algorithm, each iteration receives some randomness that is independent of the previous iterations. In my question, $\mathcal{G}$ indeed represents the randomness of the algorithm up to iteration $k$, $Y$ is a vector generated by iteration $k$, $X$ is some new randomness injected into the algorithm at iteration $k+1$, and $f(X,Y)$ is a quantity computed from $X$ and $Y$. It turns out that $f(X,Y)$ is statistically independent of $Y$. I would like to prove that $f(X,Y)$ is independent of the first $k$ iterations, which will be interesting and convenient.
Any comments or criticism will be appreciated. Thank you.
A related question: Uniform distribution on the unit sphere rotated by a random orthogonal matrix.