Prove that if $X$ and $Y$ are independent discrete variables, for $f: \mathbb{R} \rightarrow \mathbb{R}$, then $f(X)$ and $f(Y)$ are independent.
Here is the exact same question. I define independence identically to this question. My main question is regarding one of the answers.
"$X,Y$ are independent iff for all measurable $A,B$, the events $X^{-1}(A)$ and $Y^{-1}(B)$ are independent."
Why is that true? I understand the rest of the proof. Just not that part.