Continuity of Mapping between Metric Spaces by Closed Sets

Theorem
Let $M_1 = \left({A_1, d_1}\right)$ and $M_2 = \left({A_2, d_2}\right)$ be metric spaces.

Let $f: A_1 \to A_2$ be a mapping.

Then $f$ is continuous iff:
 * for every $V \subseteq A_2$ which is closed in $M_2$, $f^{-1} \left({V}\right)$ is closed in $M_1$.

Proof
First the following is established.

Let $W \in A_2$.

We note that:
 * $f^{-1} \left[{A_2}\right] = A_1$

Hence, from Preimage of Set Difference under Mapping:
 * $f^{-1} \left[{A_2 \setminus W}\right] = A_1 \setminus f^{-1} \left[{W}\right]$

Necessary Condition
Suppose that:
 * for every $V \subseteq A_2$ which is closed in $M_2$, $f^{-1} \left({V}\right)$ is closed in $M_1$.

Let $U$ be open in $M_2$.

Then by definition $A_2 \setminus U$ is closed in $M_2$.

By hypothesis, $f^{-1} \left[{A_2 \setminus U}\right] = A_1 \setminus f^{-1} \left[{U}\right]$ is closed in $M_1$.

So $f^{-1} \left[{U}\right]$ is open in $M_1$.

This is true for any $U \in A_2$ as $U$ is arbitrary.

It follows by definition that $f$ is continuous.

Sufficient Condition
Now let $f$ be continuous.

Let $V$ be closed in $M_2$.

Then $A_2 \setminus V$ is open in $M_2$.

As $f$ is continuous, $f^{-1} \left[{A_2 \setminus V}\right] = A_1 \setminus f^{-1} \left[{V}\right]$ is open in $M_1$.

So $f^{-1} \left[{V}\right]$ is closed in $M_1$.