# Metric space

In mathematics, a metric space is a set for which distances between all members of the set are defined. Those distances, taken together, are called a metric on the set.

The most familiar metric space is 3-dimensional Euclidean space. In fact, a "metric" is the generalization of the Euclidean metric arising from the four long-known properties of the Euclidean distance. The Euclidean metric defines the distance between two points as the length of the straight line segment connecting them. Other metric spaces occur for example in elliptic geometry and hyperbolic geometry, where distance on a sphere measured by angle is a metric, and the hyperboloid model of hyperbolic geometry is used by special relativity as a metric space of velocities.

A metric on a space induces topological properties like open and closed sets, which lead to the study of more abstract topological spaces.

In the most general definition of a metric space, the distance between set elements can be negative. Spaces like these are important in the theory of relativity.

## History

Maurice Fréchet introduced metric spaces in his work Sur quelques points du calcul fonctionnel, Rendic. Circ. Mat. Palermo 22 (1906) 1–74.

## Definition

${\displaystyle d\colon M\times M\rightarrow \mathbb {R} }$

such that for any ${\displaystyle x,y,z\in M}$, the following holds:[1]

The first condition follows from the other three, since: for any ${\displaystyle x,y\in M}$,

{\displaystyle {\begin{aligned}&d(x,y)+d(y,x)\geq d(x,x)\ {\text{(by triangle inequality)}}\\\implies &d(x,y)+d(x,y)\geq d(x,x)\ {\text{(by symmetry)}}\\\implies &2d(x,y)\geq 0\ {\text{(by identity of indiscernibles)}}\\\implies &d(x,y)\geq 0.\end{aligned}}}

The function ${\displaystyle d}$ is also called distance function or simply distance. Often, ${\displaystyle d}$ is omitted and one just writes ${\displaystyle M}$ for a metric space if it is clear from the context what metric is used.

Ignoring mathematical details, for any system of roads and terrains the distance between two locations can be defined as the length of the shortest route connecting those locations. To be a metric there shouldn't be any one-way roads. The triangle inequality expresses the fact that detours aren't shortcuts. Many of the examples below can be seen as concrete versions of this general idea.

## Open and closed sets, topology and convergence

Every metric space is a topological space in a natural manner, and therefore all definitions and theorems about general topological spaces also apply to all metric spaces.

About any point ${\displaystyle x}$ in a metric space ${\displaystyle M}$ we define the open ball of radius ${\displaystyle r>0}$ about ${\displaystyle x}$ as the set

${\displaystyle B(x;r)=\{y\in M:d(x,y)

These open balls form the base for a topology on M, making it a topological space.

Explicitly, a subset ${\displaystyle U}$ of ${\displaystyle M}$ is called open if for every ${\displaystyle x}$ in ${\displaystyle U}$ there exists an ${\displaystyle r>0}$ such that ${\displaystyle B(x;r)}$ is contained in ${\displaystyle U}$. The complement of an open set is called closed. A neighborhood of the point ${\displaystyle x}$ is any subset of ${\displaystyle M}$ that contains an open ball about ${\displaystyle x}$ as a subset.

A topological space which can arise in this way from a metric space is called a metrizable space; see the article on metrization theorems for further details.

A sequence (${\displaystyle x_{n}}$) in a metric space ${\displaystyle M}$ is said to converge to the limit ${\displaystyle x\in M}$ iff for every ${\displaystyle \epsilon >0}$, there exists a natural number N such that ${\displaystyle d(x_{n},x)<\epsilon }$ for all ${\displaystyle n>N}$. Equivalently, one can use the general definition of convergence available in all topological spaces.

A subset ${\displaystyle A}$ of the metric space ${\displaystyle M}$ is closed iff every sequence in ${\displaystyle A}$ that converges to a limit in ${\displaystyle M}$ has its limit in ${\displaystyle A}$.

## Types of metric spaces

### Complete spaces

{{#invoke:main|main}}

A metric space ${\displaystyle M}$ is said to be complete if every Cauchy sequence converges in ${\displaystyle M}$. That is to say: if ${\displaystyle d(x_{n},x_{m})\to 0}$ as both ${\displaystyle n}$ and ${\displaystyle m}$ independently go to infinity, then there is some ${\displaystyle y\in M}$ with ${\displaystyle d(x_{n},y)\to 0}$.

Every Euclidean space is complete, as is every closed subset of a complete space. The rational numbers, using the absolute value metric ${\displaystyle d(x,y)=\vert x-y\vert }$, are not complete.

Every metric space has a unique (up to isometry) completion, which is a complete space that contains the given space as a dense subset. For example, the real numbers are the completion of the rationals.

If ${\displaystyle X}$ is a complete subset of the metric space ${\displaystyle M}$, then ${\displaystyle X}$ is closed in ${\displaystyle M}$. Indeed, a space is complete iff it is closed in any containing metric space.

Every complete metric space is a Baire space.

### Bounded and totally bounded spaces

Diameter of a set.

{{#invoke:see also|seealso}} A metric space M is called bounded if there exists some number r, such that d(x,y) ≤ r for all x and y in M. The smallest possible such r is called the diameter of M. The space M is called precompact or totally bounded if for every r > 0 there exist finitely many open balls of radius r whose union covers M. Since the set of the centres of these balls is finite, it has finite diameter, from which it follows (using the triangle inequality) that every totally bounded space is bounded. The converse does not hold, since any infinite set can be given the discrete metric (one of the examples above) under which it is bounded and yet not totally bounded.

Note that in the context of intervals in the space of real numbers and occasionally regions in a Euclidean space Rn a bounded set is referred to as "a finite interval" or "finite region". However boundedness should not in general be confused with "finite", which refers to the number of elements, not to how far the set extends; finiteness implies boundedness, but not conversely. Also note that an unbounded subset of Rn may have a finite volume.

### Compact spaces

A metric space M is compact if every sequence in M has a subsequence that converges to a point in M. This is known as sequential compactness and, in metric spaces (but not in general topological spaces), is equivalent to the topological notions of countable compactness and compactness defined via open covers.

Examples of compact metric spaces include the closed interval [0,1] with the absolute value metric, all metric spaces with finitely many points, and the Cantor set. Every closed subset of a compact space is itself compact.

A metric space is compact iff it is complete and totally bounded. This is known as the Heine–Borel theorem. Note that compactness depends only on the topology, while boundedness depends on the metric.

Lebesgue's number lemma states that for every open cover of a compact metric space M, there exists a "Lebesgue number" δ such that every subset of M of diameter < δ is contained in some member of the cover.

Every compact metric space is second countable,[5] and is a continuous image of the Cantor set. (The latter result is due to Pavel Alexandrov and Urysohn.)

### Locally compact and proper spaces

A metric space is said to be locally compact if every point has a compact neighborhood. Euclidean spaces are locally compact, but infinite-dimensional Banach spaces are not.

A space is proper if every closed ball {y : d(x,y) ≤ r} is compact. Proper spaces are locally compact, but the converse is not true in general.

### Connectedness

A metric space ${\displaystyle M}$ is connected if the only subsets that are both open and closed are the empty set and ${\displaystyle M}$ itself.

A metric space ${\displaystyle M}$ is path connected if for any two points ${\displaystyle x,y\in M}$ there exists a continuous map ${\displaystyle f\colon [0,1]\to M}$ with ${\displaystyle f(0)=x}$ and ${\displaystyle f(1)=y}$. Every path connected space is connected, but the converse is not true in general.

There are also local versions of these definitions: locally connected spaces and locally path connected spaces.

Simply connected spaces are those that, in a certain sense, do not have "holes".

### Separable spaces

A metric space is separable space if it has a countable dense subset. Typical examples are the real numbers or any Euclidean space. For metric spaces (but not for general topological spaces) separability is equivalent to second countability and also to the Lindelöf property.

## Types of maps between metric spaces

Suppose (M1,d1) and (M2,d2) are two metric spaces.

### Continuous maps

{{#invoke:main|main}}

The map f:M1M2 is continuous if it has one (and therefore all) of the following equivalent properties:

General topological continuity
for every open set U in M2, the preimage f -1(U) is open in M1
This is the general definition of continuity in topology.
Sequential continuity
if (xn) is a sequence in M1 that converges to x in M1, then the sequence (f(xn)) converges to f(x) in M2.
This is sequential continuity, due to Eduard Heine.
ε-δ definition
for every x in M1 and every ε>0 there exists δ>0 such that for all y in M1 we have
${\displaystyle d_{1}(x,y)<\delta \Rightarrow d_{2}(f(x),f(y))<\varepsilon .}$
This uses the (ε, δ)-definition of limit, and is due to Augustin Louis Cauchy.

Moreover, f is continuous if and only if it is continuous on every compact subset of M1.

The image of every compact set under a continuous function is compact, and the image of every connected set under a continuous function is connected.

### Uniformly continuous maps

The map ƒ : M1 → M2 is uniformly continuous if for every ε > 0 there exists δ > 0 such that

${\displaystyle d_{1}(x,y)<\delta \Rightarrow d_{2}(f(x),f(y))<\varepsilon \quad {\mbox{for all}}\quad x,y\in M_{1}.}$

Every uniformly continuous map ƒ : M1 → M2 is continuous. The converse is true if M1 is compact (Heine–Cantor theorem).

Uniformly continuous maps turn Cauchy sequences in M1 into Cauchy sequences in M2. For continuous maps this is generally wrong; for example, a continuous map from the open interval (0,1) onto the real line turns some Cauchy sequences into unbounded sequences.

### Lipschitz-continuous maps and contractions

Given a number K > 0, the map ƒ : M1 → M2 is K-Lipschitz continuous if

${\displaystyle d_{2}(f(x),f(y))\leq Kd_{1}(x,y)\quad {\mbox{for all}}\quad x,y\in M_{1}.}$

Every Lipschitz-continuous map is uniformly continuous, but the converse is not true in general.

If K < 1, then ƒ is called a contraction. Suppose M2 = M1 and M1 is complete. If ƒ is a contraction, then ƒ admits a unique fixed point (Banach fixed point theorem). If M1 is compact, the condition can be weakened a bit: ƒ admits a unique fixed point if

${\displaystyle d(f(x),f(y)).

### Isometries

The map f:M1M2 is an isometry if

${\displaystyle d_{2}(f(x),f(y))=d_{1}(x,y)\quad {\mbox{for all}}\quad x,y\in M_{1}}$

Isometries are always injective; the image of a compact or complete set under an isometry is compact or complete, respectively. However, if the isometry is not surjective, then the image of a closed (or open) set need not be closed (or open).

### Quasi-isometries

The map f : M1 → M2 is a quasi-isometry if there exist constants A ≥ 1 and B ≥ 0 such that

${\displaystyle {\frac {1}{A}}d_{2}(f(x),f(y))-B\leq d_{1}(x,y)\leq Ad_{2}(f(x),f(y))+B{\text{ for all }}x,y\in M_{1}}$

and a constant C ≥ 0 such that every point in M2 has a distance at most C from some point in the image f(M1).

Note that a quasi-isometry is not required to be continuous. Quasi-isometries compare the "large-scale structure" of metric spaces; they find use in geometric group theory in relation to the word metric.

## Notions of metric space equivalence

Given two metric spaces (M1, d1) and (M2, d2):

• They are called homeomorphic (topologically isomorphic) if there exists a homeomorphism between them (i.e., a bijection continuous in both directions).
• They are called uniformic (uniformly isomorphic) if there exists a uniform isomorphism between them (i.e., a bijection uniformly continuous in both directions).
• They are called isometric if there exists a bijective isometry between them. In this case, the two metric spaces are essentially identical.
• They are called quasi-isometric if there exists a quasi-isometry between them.

## Topological properties

Metric spaces are paracompact[6] Hausdorff spaces[7] and hence normal (indeed they are perfectly normal). An important consequence is that every metric space admits partitions of unity and that every continuous real-valued function defined on a closed subset of a metric space can be extended to a continuous map on the whole space (Tietze extension theorem). It is also true that every real-valued Lipschitz-continuous map defined on a subset of a metric space can be extended to a Lipschitz-continuous map on the whole space.

Metric spaces are first countable since one can use balls with rational radius as a neighborhood base.

The metric topology on a metric space M is the coarsest topology on M relative to which the metric d is a continuous map from the product of M with itself to the non-negative real numbers.

## Distance between points and sets; Hausdorff distance and Gromov metric

A simple way to construct a function separating a point from a closed set (as required for a completely regular space) is to consider the distance between the point and the set. If (M,d) is a metric space, S is a subset of M and x is a point of M, we define the distance from x to S as

${\displaystyle d(x,S)=\inf\{d(x,s):s\in S\}}$ where ${\displaystyle \inf }$ represents the infimum.

Then d(x, S) = 0 if and only if x belongs to the closure of S. Furthermore, we have the following generalization of the triangle inequality:

${\displaystyle d(x,S)\leq d(x,y)+d(y,S),}$

which in particular shows that the map ${\displaystyle x\mapsto d(x,S)}$ is continuous.

Given two subsets S and T of M, we define their Hausdorff distance to be

${\displaystyle d_{H}(S,T)=\max\{\sup\{d(s,T):s\in S\},\sup\{d(t,S):t\in T\}\}}$ where ${\displaystyle \sup }$ represents the supremum.

In general, the Hausdorff distance dH(S,T) can be infinite. Two sets are close to each other in the Hausdorff distance if every element of either set is close to some element of the other set.

The Hausdorff distance dH turns the set K(M) of all non-empty compact subsets of M into a metric space. One can show that K(M) is complete if M is complete. (A different notion of convergence of compact subsets is given by the Kuratowski convergence.)

One can then define the Gromov–Hausdorff distance between any two metric spaces by considering the minimal Hausdorff distance of isometrically embedded versions of the two spaces. Using this distance, the class of all (isometry classes of) compact metric spaces becomes a metric space in its own right.

## Product metric spaces

If ${\displaystyle (M_{1},d_{1}),\ldots ,(M_{n},d_{n})}$ are metric spaces, and N is the Euclidean norm on Rn, then ${\displaystyle {\Big (}M_{1}\times \ldots \times M_{n},N(d_{1},\ldots ,d_{n}){\Big )}}$ is a metric space, where the product metric is defined by

${\displaystyle N(d_{1},...,d_{n}){\Big (}(x_{1},\ldots ,x_{n}),(y_{1},\ldots ,y_{n}){\Big )}=N{\Big (}d_{1}(x_{1},y_{1}),\ldots ,d_{n}(x_{n},y_{n}){\Big )},}$

and the induced topology agrees with the product topology. By the equivalence of norms in finite dimensions, an equivalent metric is obtained if N is the taxicab norm, a p-norm, the max norm, or any other norm which is non-decreasing as the coordinates of a positive n-tuple increase (yielding the triangle inequality).

Similarly, a countable product of metric spaces can be obtained using the following metric

${\displaystyle d(x,y)=\sum _{i=1}^{\infty }{\frac {1}{2^{i}}}{\frac {d_{i}(x_{i},y_{i})}{1+d_{i}(x_{i},y_{i})}}.}$

An uncountable product of metric spaces need not be metrizable. For example, ${\displaystyle \mathbf {R} ^{\mathbf {R} }}$ is not first-countable and thus isn't metrizable.

### Continuity of distance

It is worth noting that in the case of a single space ${\displaystyle (M,d)}$, the distance map ${\displaystyle d\colon M\times M\rightarrow R^{+}}$ (from the definition) is uniformly continuous with respect to any of the above product metrics ${\displaystyle N(d,d)}$, and in particular is continuous with respect to the product topology of ${\displaystyle M\times M}$.

## Quotient metric spaces

If M is a metric space with metric d, and ~ is an equivalence relation on M, then we can endow the quotient set M/~ with the following (pseudo)metric. Given two equivalence classes [x] and [y], we define

${\displaystyle d'([x],[y])=\inf\{d(p_{1},q_{1})+d(p_{2},q_{2})+\dotsb +d(p_{n},q_{n})\}}$

where the infimum is taken over all finite sequences ${\displaystyle (p_{1},p_{2},\dots ,p_{n})}$ and ${\displaystyle (q_{1},q_{2},\dots ,q_{n})}$ with ${\displaystyle [p_{1}]=[x]}$, ${\displaystyle [q_{n}]=[y]}$, ${\displaystyle [q_{i}]=[p_{i+1}],i=1,2,\dots ,n-1}$. In general this will only define a pseudometric, i.e. ${\displaystyle d'([x],[y])=0}$ does not necessarily imply that ${\displaystyle [x]=[y]}$. However for nice equivalence relations (e.g., those given by gluing together polyhedra along faces), it is a metric. Moreover if M is a compact space, then the induced topology on M/~ is the quotient topology.

The quotient metric d is characterized by the following universal property. If ${\displaystyle f:(M,d)\longrightarrow (X,\delta )}$ is a metric map between metric spaces (that is, ${\displaystyle \delta (f(x),f(y))\leq d(x,y)}$ for all x, y) satisfying f(x)=f(y) whenever ${\displaystyle x\sim y,}$ then the induced function ${\displaystyle {\overline {f}}\colon M/\sim \longrightarrow X}$, given by ${\displaystyle {\overline {f}}([x])=f(x)}$, is a metric map ${\displaystyle {\overline {f}}\colon (M/\sim ,d')\longrightarrow (X,\delta ).}$

A topological space is sequential if and only if it is a quotient of a metric space.[8]

## Generalizations of metric spaces

• Every metric space is a uniform space in a natural manner, and every uniform space is naturally a topological space. Uniform and topological spaces can therefore be regarded as generalizations of metric spaces.
• If the distance function takes values in the extended real number line R∪{+∞}, but otherwise satisfies all four conditions, then it is called an extended metric and the corresponding space is called an ${\displaystyle \infty }$-metric space. If the distance function takes values in some (suitable) ordered set (and the triangle inequality is adjusted accordingly), then we arrive at the notion of generalized ultrametric.[10]
• Approach spaces are a generalization of metric spaces, based on point-to-set distances, instead of point-to-point distances.

### Metric spaces as enriched categories

The ordered set ${\displaystyle (\mathbb {R} ,\geq )}$ can be seen as a category by requesting exactly one morphism ${\displaystyle a\to b}$ if ${\displaystyle a\geq b}$ and none otherwise. By using ${\displaystyle +}$ as the tensor product and ${\displaystyle 0}$ as the identity, it becomes a monoidal category ${\displaystyle R*}$. Every metric space ${\displaystyle (M,d)}$ can now be viewed as a category ${\displaystyle M*}$ enriched over ${\displaystyle R*}$:

See the paper by F.W. Lawvere listed below.

## Notes

1. {{#invoke:citation/CS1|citation |CitationClass=book }}
2. Open problems on embeddings of finite metric spaces, edited by Jirīı Matoušek, 2007
3. Searcóid, p. 107.
4. PlanetMath: a compact metric space is second countable
5. Rudin, Mary Ellen. A new proof that metric spaces are paracompact. Proceedings of the American Mathematical Society, Vol. 20, No. 2. (Feb., 1969), p. 603.
6. Template:Planetmath reference
7. Goreham, Anthony. Sequential convergence in Topological Spaces. Honours' Dissertation, Queen's College, Oxford (April, 2001), p. 14
8. Pascal Hitzler and Anthony Seda, Mathematical Aspects of Logic Programming Semantics. Chapman and Hall/CRC, 2010.
9. Pascal Hitzler and Anthony Seda, Mathematical Aspects of Logic Programming Semantics. Chapman and Hall/CRC, 2010.

## References

• Lawvere, F. William, "Metric spaces, generalized logic, and closed categories", [Rend. Sem. Mat. Fis. Milano 43 (1973), 135—166 (1974); (Italian summary)

This is reprinted (with author commentary) at Reprints in Theory and Applications of Categories Also (with an author commentary) in Enriched categories in the logic of geometry and analysis. Repr. Theory Appl. Categ. No. 1 (2002), 1–37.