Locally constant function

In mathematics, a locally constant function is a function from a topological space into a set with the property that around every point of its domain, there exists some neighborhood of that point on which it restricts to a constant function.

Definition
Let $$f : X \to S$$ be a function from a topological space $$X$$ into a set $$S.$$ If $$x \in X$$ then $$f$$ is said to be locally constant at $$x$$ if there exists a neighborhood $$U \subseteq X$$ of $$x$$ such that $$f$$ is constant on $$U,$$ which by definition means that $$f(u) = f(v)$$ for all $$u, v \in U.$$ The function $$f : X \to S$$ is called locally constant if it is locally constant at every point $$x \in X$$ in its domain.

Examples
Every constant function is locally constant. The converse will hold if its domain is a connected space.

Every locally constant function from the real numbers $$\R$$ to $$\R$$ is constant, by the connectedness of $$\R.$$ But the function $$f : \Q \to \R$$ from the rationals $$\Q$$ to $$\R,$$ defined by $$f(x) = 0 \text{ for } x < \pi,$$ and $$f(x) = 1 \text{ for } x > \pi,$$ is locally constant (this uses the fact that $$\pi$$ is irrational and that therefore the two sets $$\{ x \in \Q : x < \pi \}$$ and $$\{ x \in \Q : x > \pi \}$$ are both open in $$\Q$$).

If $$f : A \to B$$ is locally constant, then it is constant on any connected component of $$A.$$ The converse is true for locally connected spaces, which are spaces whose connected components are open subsets.

Further examples include the following:
 * Given a covering map $$p : C \to X,$$ then to each point $$x \in X$$ we can assign the cardinality of the fiber $$p^{-1}(x)$$ over $$x$$; this assignment is locally constant.
 * A map from a topological space $$A$$ to a discrete space $$B$$ is continuous if and only if it is locally constant.

Connection with sheaf theory
There are of locally constant functions on $$X.$$ To be more definite, the locally constant integer-valued functions on $$X$$ form a sheaf in the sense that for each open set $$U$$ of $$X$$ we can form the functions of this kind; and then verify that the sheaf  hold for this construction, giving us a sheaf of abelian groups (even commutative rings). This sheaf could be written $$Z_X$$; described by means of we have stalk $$Z_x,$$ a copy of $$Z$$ at $$x,$$ for each $$x \in X.$$ This can be referred to a, meaning exactly  taking their values in the (same) group. The typical sheaf of course is not constant in this way; but the construction is useful in linking up sheaf cohomology with homology theory, and in logical applications of sheaves. The idea of local coefficient system is that we can have a theory of sheaves that look like such 'harmless' sheaves (near any $$x$$), but from a global point of view exhibit some 'twisting'.