How can I show this equality between inverses of functions? Let $f:X\to Y$ be a function between metric spaces $X$ and $Y$. Show that for any $B\subset Y$, $f^{-1}(B^\complement)=(f^{-1}(B))^\complement$.
I was able to show that they both map to $B^\complement$, but I know that that's not enough to prove equality. By definition, $(f^{-1}(B))^\complement = X \setminus f^{-1}(B)$. We know that $f^{-1}(B)=\{x\in X: f(x) \in B\}$ so all $\{x\in X : f(x) \notin B\} = f^{-1}(B^\complement)$. So, taking $f(f^{-1}(B^\complement))=B^\complement$. Taking $f[(f^{-1}(B))^\complement] = f(X\setminus f^{-1}(B)) = Y\setminus B = B^\complement$. So, $f^{-1}(B^\complement)\subseteq (f^{-1}(B))^\complement$ since $f^{-1}(B^\complement)\not\subset B$ and $(f^{-1}(B))^\complement\subseteq f^{-1}(B^\complement)$ since they both map to $B^\complement$. I am not sure if this is all correct, so any suggestion would be greatly appreciated. Thanks!

Your $f^{-1}(B^\complement)\not\subset B$ is true but probably not what you meant, since the lefthand side is a subset of $X$ and the righthand side a subset of $Y$.
In any case you’re making it much too hard: $x\in f^{-1}[Y\setminus B]$ iff $f(x)\in Y\setminus B$ iff $f(x)\notin B$ iff $x\notin f^{-1}[B]$ iff $x\in X\setminus f^{-1}[B]$.
