[Math] Showing that a metric space is discrete if and only if any function from it to another metric space is continuous

metric-spacesreal-analysis

Let $(X, d)$ be a metric space and $(Y, p)$ is another metric space that has at least two distinct elements. Show that $(X, d)$ is a discrete metric space (a metric space is defined to be discrete if every subset is open) if and only if any function from $X$ to $Y$ is continuous.

I'm not too sure how to prove this, I'm guessing we need to use the open set characterization of continuity, i.e., $f:X \rightarrow Y$ is continuous if and only if for every open set $A \subset Y$, the set $f^{-1}(A) = \{x \in X : f(x) \in A\} \subseteq X$ is open. Can anyone provide a proof?

Best Answer

Suppose every $f: (X,d) \to (Y,p)$ is continuous.

First let $y_0 \neq y_1 \in Y$, which exist by assumption. So $r = d(y_0,y_1) > 0$. Define $U_0 = B_p(y_0, \frac{r}{2}), U_1 = B_p(y_1, \frac{r}{2})$, these are open and disjoint (by the triangle inequality).

Let $A \subseteq X$. Then define $f_A: X \to Y$ by $f(x) = y_0$ for $x \in A$, $f(x) = y_1$ for $x \notin A$. By assumption this is continuous. Note that $A = f^{-1}[U_0]$ (all $x \in A$ map to $y_0 \in U_0$ and all other $x$ map to $y_1 \notin U_0$). So $A$ is open, as the inverse image of an open set.
As $A$ was arbitrary, all subsets of $X$ are open, i.e. $X$ has the discrete topology.

Of $Y$ we only used it has a 2-point discrete subspace $\{y_0, y_1\}$, of $X$ nothing of the metric.

Related Question