# Characterization of closed sets in metric spaces

Let $X$ and be $Y$ be two metric spaces and $f:X\to Y$ a continuous function. We know that if $A$ is a closed set in $Y$ then $f^{-1}(A)=\{x\in X, \ \ f(x)\in A \}$ is a closed set in $X$.

Now if we have $B$ is a closed set in $X$, does $B$ have the form $B=f^{-1}(A)$ where $A$ is a closed set in $Y$ ?

• No. Give $X=\Bbb R$ the discrete metric and $Y=\Bbb R$ the usual metric and consider the identity mapping from $X$ to $Y$. – David Mitra Jul 4 '14 at 0:35
• Or, perhaps more interesting, take $f(x)=\sin x$ on $[0,\pi]$ with the usual topology and $B=[0,\pi/3]$ (here, there is no $A$ with $f^{-1}(A)=B$). – David Mitra Jul 4 '14 at 0:43
• Another counterexample: take $f$ to be any constant function, and let $X$ be any metric space with a proper, non-empty, closed subset. – Ben Grossmann Jul 4 '14 at 0:53

Multiple examples of when this fails were already given. Let's look at the general question: how could this property hold? First, the only candidate for a set $A$ such that $f^{-1}(A)=B$ is $f(A)$. So, we need $$f^{-1}(f(A))=A$$ for every closed set. Since single points are closed, it follows that $f$ is injective. Let $g$ be the inverse of $f$, which is defined on $f(X)$.
Also, we need $f(A)$ to be closed whenever $A$ is. This is equivalent to $g$ being continuous.
Conclusion: the property you described holds if and only if $f$ is a homeomorphism onto its image. Such a map is called a (topological) embedding of $X$ into $Y$.