Let $(X, d_x)$ and $(Y, d_y)$ be metric spaces. Let $f: X \rightarrow Y$ be a function.
Show that $f$ is continuous (w.r.t. the metrics $d_x, d_y$) if and only if $f$ inverts closed sets to closed sets.
I know that a continuous function maps compact sets to compact sets. Would the proof for this have something to do with that? Since compact sets are closed and bounded, it makes sense that a continuous function has to map closed sets to closed sets (for the compact sets to compact sets fact to hold).
I'm a bit stuck on the closed sets to closed sets $\implies$ continuous function part. Every point in a closed set is an accumulation point; and, for a function to be continuous, whenever a real sequence $(a_n)$ converges to $p$, then $f(a_n)$ must converge to $f(p)$ as well. How do I make the connection between the RHS and LHS?
Any help would be greatly appreciated. Thank you.
You don't have to think about compactness. Remember that a function is continuous if and only if the preimage of an open set is always open.
Suppose that for any closed set $V \subset Y$ we have that $f^{-1}(V)$ is closed. Let $U \subset Y$ be open. Then the complement $Y \setminus U$ is closed (by definition). From basic set theory (https://proofwiki.org/wiki/Preimage_of_Set_Difference_under_Mapping), $$ f^{-1}(Y \setminus U) = f^{-1}(Y) \setminus f^{-1}(U) = X \setminus f^{-1}(U) $$ Thus $X \setminus f^{-1}(U)$ is closed, so $f^{-1}(U)$ is open. Thus $f$ is continuous.