This article does not cite any sources. Please help improve this article by adding citations to reliable sources. Unsourced material may be challenged and removed.Find sources: "Locally constant function" – news · newspapers · books · scholar · JSTOR (December 2009) (Learn how and when to remove this template message)
The Signum function restricted to the domain ${\displaystyle \mathbb {R} \setminus \{0\))$ is locally constant.

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 ${\displaystyle f:X\to S}$ be a function from a topological space ${\displaystyle X}$ into a set ${\displaystyle S.}$ If ${\displaystyle x\in X}$ then ${\displaystyle f}$ is said to locally constant at ${\displaystyle x}$ if there exists a neighborhood ${\displaystyle U\subseteq X}$ of ${\displaystyle x}$ such that ${\displaystyle f}$ is constant on ${\displaystyle U,}$ which by definition means that ${\displaystyle f(u)=f(v)}$ for all ${\displaystyle u,v\in U.}$ The function ${\displaystyle f:X\to S}$ is called locally constant if it is locally constant at every point ${\displaystyle 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 ${\displaystyle \mathbb {R} }$ to ${\displaystyle \mathbb {R} }$ is constant, by the connectedness of ${\displaystyle \mathbb {R} .}$ But the function ${\displaystyle f:\mathbb {Q} \to \mathbb {R} }$ from the rationals ${\displaystyle \mathbb {Q} }$ to ${\displaystyle \mathbb {R} ,}$ defined by ${\displaystyle f(x)=0{\text{ for ))x<\pi ,}$ and ${\displaystyle f(x)=1{\text{ for ))x>\pi ,}$ is locally constant (this uses the fact that ${\displaystyle \pi }$ is irrational and that therefore the two sets ${\displaystyle \{x\in \mathbb {Q} :x<\pi \))$ and ${\displaystyle \{x\in \mathbb {Q} :x>\pi \))$ are both open in ${\displaystyle \mathbb {Q} }$).

If ${\displaystyle f:A\to B}$ is locally constant, then it is constant on any connected component of ${\displaystyle 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 ${\displaystyle p:C\to X,}$ then to each point ${\displaystyle x\in X}$ we can assign the cardinality of the fiber ${\displaystyle p^{-1}(x)}$ over ${\displaystyle x}$; this assignment is locally constant.
• A map from a topological space ${\displaystyle A}$ to a discrete space ${\displaystyle B}$ is continuous if and only if it is locally constant.

## Connection with sheaf theory

There are sheaves of locally constant functions on ${\displaystyle X.}$ To be more definite, the locally constant integer-valued functions on ${\displaystyle X}$ form a sheaf in the sense that for each open set ${\displaystyle U}$ of ${\displaystyle X}$ we can form the functions of this kind; and then verify that the sheaf axioms hold for this construction, giving us a sheaf of abelian groups (even commutative rings). This sheaf could be written ${\displaystyle Z_{X))$; described by means of stalks we have stalk ${\displaystyle Z_{x},}$ a copy of ${\displaystyle Z}$ at ${\displaystyle x,}$ for each ${\displaystyle x\in X.}$ This can be referred to a constant sheaf, meaning exactly sheaf of locally constant functions 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 locally look like such 'harmless' sheaves (near any ${\displaystyle x}$), but from a global point of view exhibit some 'twisting'.