Inverse image of a union equals the union of the inverse images

I just wonder if my following solution is true.

Let $X,Y$ be sets, let $f:X\to Y$ be a function, let $\{Y_i\}_{i\in I}$ be a family of subsets of $Y$. (Note: I use equalities instead of mutual containment)

$$\begin{align}f^{-1}\left[\bigcup_{i\in I} Y_i\right] &= \{x \in X: \mbox{there exists an}\quad i \in I\mbox{ such that } y \in Y_i,f(x)=y\} \\&=\bigcup_{i \in I} f^{-1}\left[Y_i\right] \end{align}$$

I initially do not know how to get from the left to right, but when I put both sets in set notation, they turn out to be the same, hence the one line proof. Something go ultimately wrong?


The statement is true, and your argument is essentially right, but I would say that you are skipping steps to achieve that identification. (Also, you should not have those $\infty$'s on top of the union symbol). I would instead add:

$$\begin{align*} f^{-1}\left[\bigcup_{i\in I}Y_i\right] &= \left\{ x\in X\;\left|\; f(x)\in\bigcup_{i\in I}Y_i\right\}\right.\\ &=\Biggl\{x\in X\;\Biggm|\; \exists i\in I\text{ such that }f(x)\in Y_i\Biggr\}\\ &= \bigcup_{i\in I}\{x\in X\mid f(x)\in Y_i\}\\ &= \bigcup_{i\in I}f^{-1}[Y_i]. \end{align*}$$ The first equality is by definition of inverse image; the second by definition of the union; the third is by definition of union; and the fourth by definition of inverse image.