If $X$ is a connected metric space, then a locally constant function $f: X \to$ M, $M$ a metric space, is constant

If $X$ is a connected metric space, then a locally constant function $f: X \to$ M, $M$ a metric space, is constant.

Thoughts:

I can see that this is similar to the definition of connectedness: that any continuous map from $X$ to a two-point space is constant. How would I go about proving the above statement though?

Thanks.

-
Is really this your definition of connectedness? (The more standard one is that the empty set and the whole set are the only parts of your topological space that are open and closed, and the proof of the equivalence between those properties easily proves the more general statement you're interested in. (BTW, if it is homework, you should tag it accordingly). – PseudoNeo May 9 '11 at 12:06
Thanks. It isn't homework, it's a statement I've come across (implicitly) in a textbook. – user938272 May 9 '11 at 12:11
The hint would be: show that the preimage of an arbitrary point is both open and closed. If you get stuck, look at the solution provided by Willie Wong :) – wildildildlife May 9 '11 at 16:46

Generally when you have to make use of the connectedness assumption, the basic framework of the proof is always to first define a subset $U\subset X$ on which a property is true, and show that $U$ is both open and closed (in the topology of $X$), and is nonempty. If $U$ is closed, then $U^c$ is open. And $U \cup U^c = X$ is a disjoint union of open sets covering $X$, which contradicts the assumption that $X$ is connected unless one of the two sets $U$ and $U^c$ is empty.

So now, pick an arbitrary $x_0$ in $X$, let $U$ be the subset

$$U:= \{ y\in X | f(y) = f(x_0) \}$$

Clearly $x_0\in U$, so $U$ is non-empty. The definition of locally constant immediately implies that $U$ is open. (If $x\in U$, then the neighborhood on which $f$ is locally constant is in $U$.)

It remains to show that $U$ is closed. To do so we use that $f$ is necessarily continuous. The definition of locally constant says that for any point $y\in X$, there exists some open neighborhood $N_y\subset X$ on which $f(y)$ is constant. It is easy to see that the same neighborhood can be used as the "$\delta-\epsilon$" neighborhood for continuity.

Then since $f$ is a continuous function, the set $U$ which is defined by an equality condition must be closed (take a limit of a sequence of points $x_n$ in $U$ converging to $x\in X$, $f(x_0) = \lim f(x_n) = f(x)$).

-
Although the $\epsilon-\delta$ argument works in this case, as this is locally constant - you can't really use this definition if $M$ is not metric. You can do that by arguing that a sequence (which is enough in metric spaces) has to be in the constant neighbourhood and therefore its images are eventually constant - thus $f$ is continuous. – Asaf Karagila May 9 '11 at 12:24
@Asaf: I don't understand your comment. First you say that the argument doesn't work if $M$ is not a metric space, and then you suggest to solve this by an argument which is based on $M$ being a metric space? (I think that "as this is locally constant" should have been "as $M$ is a metric space"?) In any case, whatever definition you're using, it comes down to: a constant function is continuous, and continuity is a local concept. – wildildildlife May 9 '11 at 16:45
@wildildildlife: The idea of $\epsilon-\delta$ continuity is that the distance between the images is very small when the distance between the dots is very small. If $M$ is not metric then you cannot use this argument. You can use the one saying the same thing only using open sets, it is not the same as saying $\epsilon-\delta$. However, since this is a locally constant function, every sequence approaching $x$ is eventually constant, therefore renders the choice of $\delta$ moot, and thus working even if $M$ is not metric. Although now I see that it is metric so it doesn't even matter. :-) – Asaf Karagila May 9 '11 at 17:28
I think you guys are making showing that this is closed more challenging than it is. Let $y=f(x_0)$ then $\{y\}$ is a closed subset of $M$, since metric spaces are Hausdorff. Furthermore $f$ is a continuous map so $f^{-1}(y)$ is closed and $U$ is precisely $f^{-1}(y)$ so it is also closed. – JSchlather May 9 '11 at 20:40
@Jacob: and why is $f$ a continuous map? – Willie Wong May 9 '11 at 20:54