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


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?


  • $\begingroup$ 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. $\endgroup$
    – PseudoNeo
    May 9, 2011 at 12:06
  • $\begingroup$ Thanks. It isn't homework, it's a statement I've come across (implicitly) in a textbook. $\endgroup$
    – user938272
    May 9, 2011 at 12:11
  • $\begingroup$ 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 :) $\endgroup$ May 9, 2011 at 16:46

3 Answers 3


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)$).

  • $\begingroup$ 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. $\endgroup$
    – Asaf Karagila
    May 9, 2011 at 12:24
  • $\begingroup$ @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. $\endgroup$ May 9, 2011 at 16:45
  • $\begingroup$ @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. :-) $\endgroup$
    – Asaf Karagila
    May 9, 2011 at 17:28
  • $\begingroup$ 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. $\endgroup$
    – JSchlather
    May 9, 2011 at 20:40
  • 1
    $\begingroup$ @Jacob: and why is $f$ a continuous map? $\endgroup$ May 9, 2011 at 20:54

This question has been asked a long time ago, but the accepted answer is not as general as it could be, so I add a proof here for future readers.

A function $f : X \to Y$ where $X$ is a topological space and $Y$ is a set is called locally constant if every point $x \in X$ admits a neighborhood $U$ where $f|_U$ is constant. An equivalent way to state this is that $f$ is continuous when $Y$ is equipped with the discrete topology ; saying that every point admits a neighborhood where the function is constant is equivalent to saying that $f^{-1}(f(x))$ is open for every $x \in X$.

So suppose $X$ connected. Then for $y \in Y$, $f^{-1}(y)$ is open, and it is also closed since $X \backslash f^{-1}(y) = f^{-1}(Y \backslash \{y\}) = \bigcup_{z \in Y \backslash\{y\} } f^{-1}(z)$ is a union of open sets in $X$. Since it is clopen and $X$ is connected, $f^{-1}(f(x)) = X$ for any $x \in X$, that is, $f$ is constant.

In particular, a locally constant function $f : X \to Y$ is a function which is constant on the connected components of $X$, since the restriction of a locally constant function to a subspace is locally constant (use the fact that inclusion maps are continuous and use the topological definition of locally constant given above). Note however that the connected components need not be one of those neighborhoods where the function is constant as in the original definition, since they are not necessarily open.

To know exactly on what open sets $f$ has to be constant, consider the following equivalence relation : for $x,y \in X$, we write $x \equiv y$ if and only if there exists a connected subset $C \subseteq X$ with $x,y \in C$. Since the intersection of two connected subsets with non-empty intersection is connected, $\equiv$ is an equivalence relation whose partition of $X$ gives the connected components of $X$. Consider the space $X/\equiv$ of equivalence classes, i.e. we collapsed each connected component to a point ; equip $X/\equiv$ with the quotient topology. Then a locally constant function $f : X \to Y$ (i.e. a continuous map with $Y$ discretE), being constant on connected components, factors through a continuous map $\widetilde f : X/\equiv \to Y$. Since in $X/\equiv$, the connected components are points (we say that $X/\equiv$ is totally disconnected), but the topology on $X/\equiv$ might not be trivial ; a locally constant function $f$ is precisely one for which $\widetilde f$ is continuous, i.e. for every $[x] \in X/\equiv$, $f$ is constant on $\pi^{-1}(U)$ for some open neighborhood $U$ of $[x]$ in $X/\equiv$.

Think of a locally constant function on $\mathbb Q$ (with the subspace topology from the reals). Even though the connected components are points, not every function on $\mathbb Q$ is locally constant.

Hope that helps,

  • $\begingroup$ What is the definition of Locally Constant for a metric space and what is an example of such function? $\endgroup$ Mar 25, 2016 at 8:04
  • $\begingroup$ @The Silence of the Cows : The definition I gave above is also valid for a metric space. You can replace the word "neighborhood" by "open ball of radius $r$ for some $r > 0$" (since any neighborhood contains an open ball and open balls are neighborhoods). $\endgroup$ Mar 25, 2016 at 8:06
  • $\begingroup$ how can I prove that if f is locally one one, f continuous, defined on a connected set, and such there is a continuous function g such that f(g)= id, then f must be invertible. $\endgroup$
    – 0212user
    Oct 22, 2017 at 23:35

Here's what's hopefully a new approach: for any set $Y$ (not necessarily a metric space or even a topological space) if $f: X \to Y$ is locally constant then it is continuous with respect to the discrete topology on $Y$. On the other hand, any continuous function from a connected space to a discrete space is constant. Therefore, $f$ is constant


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.