In mathematics, a metric space is a set together with a metric on the set. The metric is a function that defines a concept of ''distance'' between any two members of the set, which are usually called points. The metric satisfies a few simple properties. Informally:
* the distance from $A$ to $B$ is zero if and only if $A$ and $B$ are the same point,
* the distance between two distinct points is positive,
* the distance from $A$ to $B$ is the same as the distance from $B$ to $A$, and
* the distance from $A$ to $B$ is less than or equal to the distance from $A$ to $B$ via any third point $C$.
A metric on a space induces topological properties like open and closed sets, which lead to the study of more abstract topological spaces.
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. Some of non-geometric metric spaces include spaces of finite strings (finite sequences of symbols from a predefined alphabet) equipped with e.g. a Hamming's or Levenshtein distance, a space of subsets of any metric space equipped with Hausdorff distance, a space of real functions integrable on a unit interval with an integral metric $d(f,g)=\backslash int\_^\backslash left\backslash vert\; f(x)-g(x)\backslash right\backslash vert\backslash ,dx$ or probabilistic spaces on any chosen metric space equipped with Wasserstein metric.

** History **

In 1906 Maurice Fréchet introduced metric spaces in his work ''Sur quelques points du calcul fonctionnel''. However the name is due to Felix Hausdorff.

** Definition **

A metric space is an ordered pair $(M,d)$ where $M$ is a set and $d$ is a metric on $M$, i.e., a function
:$d\backslash ,\backslash colon\; M\; \backslash times\; M\; \backslash to\; \backslash mathbb$
such that for any $x,\; y,\; z\; \backslash in\; M$, the following holds:
:
Given the above three axioms, we also have that $d(x,y)\; \backslash ge\; 0$ for any $x,\; y\; \backslash in\; M$. This is deduced as follows:
:
The function $d$ is also called ''distance function'' or simply ''distance''. Often, $d$ is omitted and one just writes $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. If the distance between two points is zero, the two points are indistinguishable from one-another. Many of the examples below can be seen as concrete versions of this general idea.

** Examples of metric spaces **

* The real numbers with the distance function $d(x,y)\; =\; |\; y\; -\; x\; |$ given by the absolute difference, and, more generally, Euclidean -space with the Euclidean distance, are complete metric spaces. The rational numbers with the same distance function also form a metric space, but not a complete one.
* The positive real numbers with distance function $d(x,y)\; =\backslash left|\; \backslash log(y/x)\; \backslash $ is a complete metric space.
* Any normed vector space is a metric space by defining $d(x,y)\; =\; \backslash lVert\; y\; -\; x\; \backslash rVert$, see also metrics on vector spaces. (If such a space is complete, we call it a Banach space.) Examples:
** The Manhattan norm gives rise to the Manhattan distance, where the distance between any two points, or vectors, is the sum of the differences between corresponding coordinates.
** The cyclic Mannheim metric or Mannheim distance is a modulo variant the Manhattan metric.
** The maximum norm gives rise to the Chebyshev distance or chessboard distance, the minimal number of moves a chess king would take to travel from $x$ to $y$.
* The British Rail metric (also called the “post office metric” or the “SNCF metric”) on a normed vector space is given by $d(x,y)\; =\; \backslash lVert\; x\; \backslash rVert\; +\; \backslash lVert\; y\; \backslash rVert$ for distinct points $x$ and $y$, and $d(x,x)\; =\; 0$. More generally $\backslash lVert\; \backslash cdot\; \backslash rVert$ can be replaced with a function $f$ taking an arbitrary set $S$ to non-negative reals and taking the value $0$ at most once: then the metric is defined on $S$ by $d(x,y)\; =\; f(x)\; +\; f(y)$ for distinct points $x$ and $y$, and The name alludes to the tendency of railway journeys to proceed via London (or Paris) irrespective of their final destination.
* If $(M,d)$ is a metric space and $X$ is a subset of then $(X,d)$ becomes a metric space by restricting the domain of $d$ to
* The discrete metric, where $d(x,y)\; =\; 0$ if $x=y$ and $d(x,y)\; =\; 1$ otherwise, is a simple but important example, and can be applied to all sets. This, in particular, shows that for any set, there is always a metric space associated to it. Using this metric, any point is an open ball, and therefore every subset is open and the space has the discrete topology.
* A finite metric space is a metric space having a finite number of points. Not every finite metric space can be isometrically embedded in a Euclidean space.
* The hyperbolic plane is a metric space. More generally:
** If $M$ is any connected Riemannian manifold, then we can turn $M$ into a metric space by defining the distance of two points as the infimum of the lengths of the paths (continuously differentiable curves) connecting them.
** If $X$ is some set and $M$ is a metric space, then, the set of all bounded functions $f\; \backslash colon\; X\; \backslash to\; M$ (i.e. those functions whose image is a bounded subset of $M$) can be turned into a metric space by defining $d(f,g)\; =\; \backslash sup\_\; d(f(x),g(x))$ for any two bounded functions $f$ and $g$ (where $\backslash sup$ is supremum). This metric is called the uniform metric or supremum metric, and If $M$ is complete, then this function space is complete as well. If ''X'' is also a topological space, then the set of all bounded continuous functions from $X$ to $M$ (endowed with the uniform metric), will also be a complete metric if ''M'' is.
** If $G$ is an undirected connected graph, then the set $V$ of vertices of $G$ can be turned into a metric space by defining $d(x,y)$ to be the length of the shortest path connecting the vertices $x$ and In geometric group theory this is applied to the Cayley graph of a group, yielding the word metric.
* Graph edit distance is a measure of dissimilarity between two graphs, defined as the minimal number of graph edit operations required to transform one graph into another.
* The Levenshtein distance is a measure of the dissimilarity between two strings $u$ and $v$, defined as the minimal number of character deletions, insertions, or substitutions required to transform $u$ into $v$. This can be thought of as a special case of the shortest path metric in a graph and is one example of an edit distance.
* Given a metric space $(X,d)$ and an increasing concave function $f\; \backslash colon$ such that $f(x)\; =\; 0$ if and only if $x=0$, then $f\; \backslash circ\; d$ is also a metric on $X$.
* Given an [[injective function $f$ from any set $A$ to a metric space $(X,d)$, $d(f(x),\; f(y))$ defines a metric on $A$.
* Using [[T-theory, the [[tight span of a metric space is also a metric space. The tight span is useful in several types of analysis.
* The set of all $m$ by $n$ [[matrix (mathematics)|matrices over some field (mathematics)|field is a metric space with respect to the rank distance $d(X,Y)\; =\; \backslash mathrm(Y\; -\; X)$.
* The Helly metric is used in game theory.

** 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 $x$ in a metric space $M$ we define the open ball of radius $r\; >\; 0$ (where $r$ is a real number) about $x$ as the set
:$B(x;r)\; =\; \backslash .$
These open balls form the base for a topology on ''M'', making it a topological space.
Explicitly, a subset $U$ of $M$ is called open if for every $x$ in $U$ there exists an $r\; >\; 0$ such that $B(x;r)$ is contained in $U$. The complement of an open set is called closed. A neighborhood of the point $x$ is any subset of $M$ that contains an open ball about $x$ as a subset.
A topological space which can arise in this way from a metric space is called a metrizable space.
A sequence ($x\_n$) in a metric space $M$ is said to converge to the limit $x\; \backslash in\; M$ if and only if for every $\backslash varepsilon>0$, there exists a natural number ''N'' such that $d(x\_n,x)\; <\; \backslash varepsilon$ for all $n\; >\; N$. Equivalently, one can use the general definition of convergence available in all topological spaces.
A subset $A$ of the metric space $M$ is closed if and only if every sequence in $A$ that converges to a limit in $M$ has its limit in $A$.

** Types of metric spaces **

Complete spaces

A metric space $M$ is said to be complete if every Cauchy sequence converges in $M$. That is to say: if $d(x\_n,\; x\_m)\; \backslash to\; 0$ as both $n$ and $m$ independently go to infinity, then there is some $y\backslash in\; M$ with $d(x\_n,\; y)\; \backslash to\; 0$. Every Euclidean space is complete, as is every closed subset of a complete space. The rational numbers, using the absolute value metric $d(x,y)\; =\; \backslash vert\; x\; -\; y\; \backslash 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 $X$ is a complete subset of the metric space $M$, then $X$ is closed in $M$. Indeed, a space is complete if and only if it is closed in any containing metric space. Every complete metric space is a Baire space.

Bounded and totally bounded spaces

A metric space $M$ is called bounded if there exists some number $r$, such that $d(x,y)\backslash leq\; r$ for all $x,y\backslash 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 $\backslash mathbb\; R\; ^n$ 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 $\backslash mathbb\; R\; ^n$ 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 $,1/math>\; with\; the\; absolute\; value\; metric,\; all\; metric\; spaces\; with\; finitely\; many\; points,\; and\; theCantor\; set.\; Every\; closed\; subset\; of\; a\; compact\; space\; is\; itself\; compact.\; A\; metric\; space\; is\; compact\; if\; and\; only\; if\; it\; is\; complete\; and\; totally\; bounded.\; This\; is\; known\; as\; theHeine\u2013Borel\; theorem.\; Note\; that\; compactness\; depends\; only\; on\; the\; topology,\; while\; boundedness\; depends\; on\; the\; metric.Lebesgue\text{\'}s\; number\; lemmastates\; that\; for\; every\; open\; cover\; of\; a\; compact\; metric\; space$ M$,\; there\; exists\; a\; "Lebesgue\; number"$ \backslash delta$such\; that\; every\; subset\; of$ M$ofdiameter$ r<\backslash delta$is\; contained\; in\; some\; member\; of\; the\; cover.\; Every\; compact\; metric\; space\; issecond\; countable,\; and\; is\; a\; continuous\; image\; of\; theCantor\; set.\; (The\; latter\; result\; is\; due\; toPavel\; AlexandrovandUrysohn.)$

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 $\backslash $ is compact. Proper spaces are locally compact, but the converse is not true in general.

Connectedness

A metric space $M$ is connected if the only subsets that are both open and closed are the empty set and $M$ itself. A metric space $M$ is path connected if for any two points $x,\; y\; \backslash in\; M$ there exists a continuous map $f\backslash colon,1\backslash to\; M$ with $f(0)=x$ and $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.

Pointed metric spaces

If $X$ is a metric space and $x\_0\backslash in\; X$ then $(X,x\_0)$ is called a ''pointed metric space'', and $x\_0$ is called a ''distinguished point''. Note that a pointed metric space is just a nonempty metric space with attention drawn to its distinguished point, and that any nonempty metric space can be viewed as a pointed metric space. The distinguished point is sometimes denoted $0$ due to its similar behavior to zero in certain contexts.

Types of maps between metric spaces

Suppose $(M\_1,d\_1)$ and $(M\_2,d\_2)$ are two metric spaces.

Continuous maps

The map $f\backslash ,\backslash colon\; M\_1\backslash to\; M\_2$ is continuous if it has one (and therefore all) of the following equivalent properties: ;General topological continuity: for every open set $U$ in $M\_2$, the preimage $f^/math>\; is\; open\; in$ M\_1$:This\; is\; the\; general\; definition\; ofcontinuity\; in\; topology.\; ;Sequential\; continuity:\; if$ (x\_n)$is\; a\; sequence\; in$ M\_1$that\; converges\; to$ x$,\; then\; the\; sequence$ (f(x\_n))$converges\; to$ f(x)$in$ M\_2$.\; :This\; issequential\; continuity,\; due\; toEduard\; Heine.\; ;\epsilon -\delta \; definition:\; for\; every$ x\backslash in\; M\_1$and\; every$ \backslash varepsilon>0$there\; exists$ \backslash delta>0$such\; that\; for\; all$ y$in$ M\_1$we\; have\; ::$ d\_1(x,y)<\backslash delta\; \backslash implies\; d\_2(f(x),f(y))<\; \backslash varepsilon.$:This\; uses\; the(\epsilon ,\; \delta )-definition\; of\; limit,\; and\; is\; due\; toAugustin\; Louis\; Cauchy.\; Moreover,$ f$is\; continuous\; if\; and\; only\; if\; it\; is\; continuous\; on\; every\; compact\; subset\; of$ M\_1$.\; Theimageof\; 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 $f\backslash ,\backslash colon\; M\_1\backslash to\; M\_2$ is uniformly continuous if for every $\backslash varepsilon>0$ there exists $\backslash delta>0$ such that :$d\_1(x,y)<\backslash delta\; \backslash implies\; d\_2(f(x),f(y))<\; \backslash varepsilon\; \backslash quad\backslash mbox\backslash quad\; x,y\backslash in\; M\_1.$ Every uniformly continuous map $f\backslash ,\backslash colon\; M\_1\backslash to\; M\_2$ is continuous. The converse is true if $M\_1$ is compact (Heine–Cantor theorem). Uniformly continuous maps turn Cauchy sequences in $M\_1$ into Cauchy sequences in $M\_2$. 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 real number $K>0$, the map $f\backslash ,\backslash colon\; M\_1\backslash to\; M\_2$ is ''K''-Lipschitz continuous if :$d\_2(f(x),f(y))\backslash leq\; K\; d\_1(x,y)\backslash quad\backslash mbox\backslash quad\; x,y\backslash in\; M\_1.$ Every Lipschitz-continuous map is uniformly continuous, but the converse is not true in general. If $K<1$, then $f$ is called a contraction. Suppose $M\_2=M\_1$ and $M\_1$ is complete. If $f$ is a contraction, then $f$ admits a unique fixed point (Banach fixed-point theorem). If $M\_1$ is compact, the condition can be weakened a bit: $f$ admits a unique fixed point if :$d(f(x),\; f(y))\; <\; d(x,\; y)\; \backslash quad\; \backslash mbox\; \backslash quad\; x\; \backslash ne\; y\; \backslash in\; M\_1$.

Isometries

The map $f\backslash ,\backslash colon\; M\_1\backslash to\; M\_2$ is an isometry if :$d\_2(f(x),f(y))=d\_1(x,y)\backslash quad\backslash mbox\backslash quad\; x,y\backslash 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\backslash ,\backslash colon\; M\_1\backslash to\; M\_2$ is a quasi-isometry if there exist constants $A\backslash geq1$ and $B\backslash geq0$ such that :$\backslash frac\; d\_2(f(x),f(y))-B\backslash leq\; d\_1(x,y)\backslash leq\; A\; d\_2(f(x),f(y))+B\; \backslash quad\backslash text\backslash quad\; x,y\backslash in\; M\_1$ and a constant $C\backslash geq0$ such that every point in $M\_2$ has a distance at most $C$ from some point in the image $f(M\_1)$. 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 $(M\_1,\; d\_1)$ and $(M\_2,\; d\_2)$: *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 Hausdorff spaces 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 :$d(x,S)\; =\; \backslash inf\backslash $ where $\backslash 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: :$d(x,S)\; \backslash leq\; d(x,y)\; +\; d(y,S),$ which in particular shows that the map $x\backslash mapsto\; d(x,S)$ is continuous. Given two subsets $S$ and $T$ of $M$, we define their Hausdorff distance to be :$d\_H(S,T)\; =\; \backslash max\; \backslash $ where $\backslash sup$ represents the supremum. In general, the Hausdorff distance $d\_H(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 $d\_H$ 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 $(M\_1,d\_1),\backslash ldots,(M\_n,d\_n)$ are metric spaces, and $N$ is the Euclidean norm on $\backslash mathbb\; R^n$, then $\backslash Bigl(M\_1\; \backslash times\; \backslash cdots\; \backslash times\; M\_n,\; N(d\_1,\backslash ldots,d\_n)\backslash Bigr)$ is a metric space, where the product metric is defined by :$N(d\_1,\backslash ldots,d\_n)\backslash Big((x\_1,\backslash ldots,x\_n),(y\_1,\backslash ldots,y\_n)\backslash Big)\; =\; N\backslash Big(d\_1(x\_1,y\_1),\backslash ldots,d\_n(x\_n,y\_n)\backslash 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 maximum 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 :$d(x,y)=\backslash sum\_^\backslash infty\; \backslash frac1\backslash frac.$ An uncountable product of metric spaces need not be metrizable. For example, $\backslash mathbb^\backslash mathbb$ is not first-countable and thus isn't metrizable.

Continuity of distance

In the case of a single space $(M,d)$, the distance map $d\backslash colon\; M\backslash times\; M\; \backslash to\; R^+$ (from the definition) is uniformly continuous with respect to any of the above product metrics $N(d,d)$, and in particular is continuous with respect to the product topology of $M\backslash times\; M$.

Quotient metric spaces

If ''M'' is a metric space with metric $d$, and $\backslash sim$ is an equivalence relation on $M$, then we can endow the quotient set $M/\backslash !\backslash sim$ with a pseudometric. Given two equivalence classes $/math>\; and$ /math>,\; we\; define\; :$ d\text{'}(=\; \backslash inf\backslash $where\; theinfimumis\; taken\; over\; all\; finite\; sequences$ (p\_1,\; p\_2,\; \backslash dots,\; p\_n)$and$ (q\_1,\; q\_2,\; \backslash dots,\; q\_n)$with$ \_1/math>,$ \_n/math>,$ \_i\_i=1,2,\backslash dots,\; n-1$.\; In\; general\; this\; will\; only\; define\; apseudometric,\; i.e.$ d\text{'}(=0$does\; not\; necessarily\; imply\; that$ /math>.\; However,\; for\; some\; equivalence\; relations\; (e.g.,\; those\; given\; by\; gluing\; together\; polyhedra\; along\; faces),$ d\text{'}$is\; a\; metric.\; The\; quotient\; metric$ d$is\; characterized\; by\; the\; followinguniversal\; property.\; If$ f\backslash ,\backslash colon(M,d)\backslash to(X,\backslash delta)$is\; ametric\; mapbetween\; metric\; spaces\; (that\; is,$ \backslash delta(f(x),f(y))\backslash le\; d(x,y)$for\; all$ x$,$ y$)\; satisfying$ f(x)=f(y)$whenever$ x\backslash sim\; y,$then\; the\; induced\; function$ \backslash overline\backslash ,\backslash colon\; M/\backslash !\backslash sim\backslash to\; X$,\; given\; by$ \backslash overline(=f(x)$,\; is\; a\; metric\; map$ \backslash overline\backslash ,\backslash colon\; (M/\backslash !\backslash sim,d\text{'})\backslash to\; (X,\backslash delta).$A\; topological\; space\; issequentialif\; and\; only\; if\; it\; is\; a\; quotient\; of\; a\; metric\; space.$$$$$

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. * Relaxing the requirement that the distance between two distinct points be non-zero leads to the concepts of a pseudometric space or a dislocated metric space. Removing the requirement of symmetry, we arrive at a quasimetric space. Replacing the triangle inequality with a weaker form leads to semimetric spaces. * If the distance function takes values in the extended real number line $\backslash mathbb\; R\backslash cup\backslash $, but otherwise satisfies the conditions of a metric, then it is called an ''extended metric'' and the corresponding space is called an ''$\backslash 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''. * Approach spaces are a generalization of metric spaces, based on point-to-set distances, instead of point-to-point distances. * A continuity space is a generalization of metric spaces and posets, that can be used to unify the notions of metric spaces and domains. * A partial metric space is intended to be the least generalisation of the notion of a metric space, such that the distance of each point from itself is no longer necessarily zero.

** Metric spaces as enriched categories **

The ordered set $(\backslash mathbb,\backslash geq)$ can be seen as a category by requesting exactly one morphism $a\backslash to\; b$ if $a\backslash geq\; b$ and none otherwise. By using $+$ as the tensor product and $0$ as the identity, it becomes a monoidal category $R^*$.
Every metric space $(M,d)$ can now be viewed as a category $M^*$ enriched over $R^*$:
* Set $\backslash operatorname(M^*):=M$
* For each $X,Y\backslash in\; M$ set $\backslash operatorname(X,Y):=d(X,Y)\backslash in\; \backslash operatorname(R^*)$
* The composition morphism $\backslash operatorname(Y,Z)\backslash otimes\; \backslash operatorname(X,Y)\backslash to\; \backslash operatorname(X,Z)$ will be the unique morphism in $R^*$ given from the triangle inequality $d(y,z)+d(x,y)\backslash geq\; d(x,z)$
* The identity morphism $0\backslash to\; \backslash operatorname(X,X)$ will be the unique morphism given from the fact that $0\backslash geq\; d(X,X)$.
* Since $R^*$ is a poset, all diagrams that are required for an enriched category commute automatically.
See the paper by F.W. Lawvere listed below.

** See also **

*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*

References

Further reading

* Victor Bryant, ''Metric Spaces: Iteration and Application'', Cambridge University Press, 1985, . * Dmitri Burago, Yu D Burago, Sergei Ivanov, ''A Course in Metric Geometry'', American Mathematical Society, 2001, . * Athanase Papadopoulos, ''Metric Spaces, Convexity and Nonpositive Curvature'', European Mathematical Society, First edition 2004, . Second edition 2014, .

Mícheál Ó Searcóid

''Metric Spaces''

Springer Undergraduate Mathematics Series

2006, . * 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) a

Also (with an author commentary) in Enriched categories in the logic of geometry and analysis. Repr. Theory Appl. Categ. No. 1 (2002), 1–37. *

** External links **

*

Far and near — several examples of distance functions

at [[cut-the-knot. {{Authority control [[Category:Metric spaces| [[Category:Mathematical analysis [[Category:Mathematical structures [[Category:Topology [[Category:Topological spaces

Complete spaces

A metric space $M$ is said to be complete if every Cauchy sequence converges in $M$. That is to say: if $d(x\_n,\; x\_m)\; \backslash to\; 0$ as both $n$ and $m$ independently go to infinity, then there is some $y\backslash in\; M$ with $d(x\_n,\; y)\; \backslash to\; 0$. Every Euclidean space is complete, as is every closed subset of a complete space. The rational numbers, using the absolute value metric $d(x,y)\; =\; \backslash vert\; x\; -\; y\; \backslash 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 $X$ is a complete subset of the metric space $M$, then $X$ is closed in $M$. Indeed, a space is complete if and only if it is closed in any containing metric space. Every complete metric space is a Baire space.

Bounded and totally bounded spaces

A metric space $M$ is called bounded if there exists some number $r$, such that $d(x,y)\backslash leq\; r$ for all $x,y\backslash 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 $\backslash mathbb\; R\; ^n$ 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 $\backslash mathbb\; R\; ^n$ 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 $,1/math>\; with\; the\; absolute\; value\; metric,\; all\; metric\; spaces\; with\; finitely\; many\; points,\; and\; theCantor\; set.\; Every\; closed\; subset\; of\; a\; compact\; space\; is\; itself\; compact.\; A\; metric\; space\; is\; compact\; if\; and\; only\; if\; it\; is\; complete\; and\; totally\; bounded.\; This\; is\; known\; as\; theHeine\u2013Borel\; theorem.\; Note\; that\; compactness\; depends\; only\; on\; the\; topology,\; while\; boundedness\; depends\; on\; the\; metric.Lebesgue\text{\'}s\; number\; lemmastates\; that\; for\; every\; open\; cover\; of\; a\; compact\; metric\; space$ M$,\; there\; exists\; a\; "Lebesgue\; number"$ \backslash delta$such\; that\; every\; subset\; of$ M$ofdiameter$ r<\backslash delta$is\; contained\; in\; some\; member\; of\; the\; cover.\; Every\; compact\; metric\; space\; issecond\; countable,\; and\; is\; a\; continuous\; image\; of\; theCantor\; set.\; (The\; latter\; result\; is\; due\; toPavel\; AlexandrovandUrysohn.)$

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 $\backslash $ is compact. Proper spaces are locally compact, but the converse is not true in general.

Connectedness

A metric space $M$ is connected if the only subsets that are both open and closed are the empty set and $M$ itself. A metric space $M$ is path connected if for any two points $x,\; y\; \backslash in\; M$ there exists a continuous map $f\backslash colon,1\backslash to\; M$ with $f(0)=x$ and $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.

Pointed metric spaces

If $X$ is a metric space and $x\_0\backslash in\; X$ then $(X,x\_0)$ is called a ''pointed metric space'', and $x\_0$ is called a ''distinguished point''. Note that a pointed metric space is just a nonempty metric space with attention drawn to its distinguished point, and that any nonempty metric space can be viewed as a pointed metric space. The distinguished point is sometimes denoted $0$ due to its similar behavior to zero in certain contexts.

Types of maps between metric spaces

Suppose $(M\_1,d\_1)$ and $(M\_2,d\_2)$ are two metric spaces.

Continuous maps

The map $f\backslash ,\backslash colon\; M\_1\backslash to\; M\_2$ is continuous if it has one (and therefore all) of the following equivalent properties: ;General topological continuity: for every open set $U$ in $M\_2$, the preimage $f^/math>\; is\; open\; in$ M\_1$:This\; is\; the\; general\; definition\; ofcontinuity\; in\; topology.\; ;Sequential\; continuity:\; if$ (x\_n)$is\; a\; sequence\; in$ M\_1$that\; converges\; to$ x$,\; then\; the\; sequence$ (f(x\_n))$converges\; to$ f(x)$in$ M\_2$.\; :This\; issequential\; continuity,\; due\; toEduard\; Heine.\; ;\epsilon -\delta \; definition:\; for\; every$ x\backslash in\; M\_1$and\; every$ \backslash varepsilon>0$there\; exists$ \backslash delta>0$such\; that\; for\; all$ y$in$ M\_1$we\; have\; ::$ d\_1(x,y)<\backslash delta\; \backslash implies\; d\_2(f(x),f(y))<\; \backslash varepsilon.$:This\; uses\; the(\epsilon ,\; \delta )-definition\; of\; limit,\; and\; is\; due\; toAugustin\; Louis\; Cauchy.\; Moreover,$ f$is\; continuous\; if\; and\; only\; if\; it\; is\; continuous\; on\; every\; compact\; subset\; of$ M\_1$.\; Theimageof\; 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 $f\backslash ,\backslash colon\; M\_1\backslash to\; M\_2$ is uniformly continuous if for every $\backslash varepsilon>0$ there exists $\backslash delta>0$ such that :$d\_1(x,y)<\backslash delta\; \backslash implies\; d\_2(f(x),f(y))<\; \backslash varepsilon\; \backslash quad\backslash mbox\backslash quad\; x,y\backslash in\; M\_1.$ Every uniformly continuous map $f\backslash ,\backslash colon\; M\_1\backslash to\; M\_2$ is continuous. The converse is true if $M\_1$ is compact (Heine–Cantor theorem). Uniformly continuous maps turn Cauchy sequences in $M\_1$ into Cauchy sequences in $M\_2$. 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 real number $K>0$, the map $f\backslash ,\backslash colon\; M\_1\backslash to\; M\_2$ is ''K''-Lipschitz continuous if :$d\_2(f(x),f(y))\backslash leq\; K\; d\_1(x,y)\backslash quad\backslash mbox\backslash quad\; x,y\backslash in\; M\_1.$ Every Lipschitz-continuous map is uniformly continuous, but the converse is not true in general. If $K<1$, then $f$ is called a contraction. Suppose $M\_2=M\_1$ and $M\_1$ is complete. If $f$ is a contraction, then $f$ admits a unique fixed point (Banach fixed-point theorem). If $M\_1$ is compact, the condition can be weakened a bit: $f$ admits a unique fixed point if :$d(f(x),\; f(y))\; <\; d(x,\; y)\; \backslash quad\; \backslash mbox\; \backslash quad\; x\; \backslash ne\; y\; \backslash in\; M\_1$.

Isometries

The map $f\backslash ,\backslash colon\; M\_1\backslash to\; M\_2$ is an isometry if :$d\_2(f(x),f(y))=d\_1(x,y)\backslash quad\backslash mbox\backslash quad\; x,y\backslash 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\backslash ,\backslash colon\; M\_1\backslash to\; M\_2$ is a quasi-isometry if there exist constants $A\backslash geq1$ and $B\backslash geq0$ such that :$\backslash frac\; d\_2(f(x),f(y))-B\backslash leq\; d\_1(x,y)\backslash leq\; A\; d\_2(f(x),f(y))+B\; \backslash quad\backslash text\backslash quad\; x,y\backslash in\; M\_1$ and a constant $C\backslash geq0$ such that every point in $M\_2$ has a distance at most $C$ from some point in the image $f(M\_1)$. 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 $(M\_1,\; d\_1)$ and $(M\_2,\; d\_2)$: *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 Hausdorff spaces 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 :$d(x,S)\; =\; \backslash inf\backslash $ where $\backslash 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: :$d(x,S)\; \backslash leq\; d(x,y)\; +\; d(y,S),$ which in particular shows that the map $x\backslash mapsto\; d(x,S)$ is continuous. Given two subsets $S$ and $T$ of $M$, we define their Hausdorff distance to be :$d\_H(S,T)\; =\; \backslash max\; \backslash $ where $\backslash sup$ represents the supremum. In general, the Hausdorff distance $d\_H(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 $d\_H$ 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 $(M\_1,d\_1),\backslash ldots,(M\_n,d\_n)$ are metric spaces, and $N$ is the Euclidean norm on $\backslash mathbb\; R^n$, then $\backslash Bigl(M\_1\; \backslash times\; \backslash cdots\; \backslash times\; M\_n,\; N(d\_1,\backslash ldots,d\_n)\backslash Bigr)$ is a metric space, where the product metric is defined by :$N(d\_1,\backslash ldots,d\_n)\backslash Big((x\_1,\backslash ldots,x\_n),(y\_1,\backslash ldots,y\_n)\backslash Big)\; =\; N\backslash Big(d\_1(x\_1,y\_1),\backslash ldots,d\_n(x\_n,y\_n)\backslash 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 maximum 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 :$d(x,y)=\backslash sum\_^\backslash infty\; \backslash frac1\backslash frac.$ An uncountable product of metric spaces need not be metrizable. For example, $\backslash mathbb^\backslash mathbb$ is not first-countable and thus isn't metrizable.

Continuity of distance

In the case of a single space $(M,d)$, the distance map $d\backslash colon\; M\backslash times\; M\; \backslash to\; R^+$ (from the definition) is uniformly continuous with respect to any of the above product metrics $N(d,d)$, and in particular is continuous with respect to the product topology of $M\backslash times\; M$.

Quotient metric spaces

If ''M'' is a metric space with metric $d$, and $\backslash sim$ is an equivalence relation on $M$, then we can endow the quotient set $M/\backslash !\backslash sim$ with a pseudometric. Given two equivalence classes $/math>\; and$ /math>,\; we\; define\; :$ d\text{'}(=\; \backslash inf\backslash $where\; theinfimumis\; taken\; over\; all\; finite\; sequences$ (p\_1,\; p\_2,\; \backslash dots,\; p\_n)$and$ (q\_1,\; q\_2,\; \backslash dots,\; q\_n)$with$ \_1/math>,$ \_n/math>,$ \_i\_i=1,2,\backslash dots,\; n-1$.\; In\; general\; this\; will\; only\; define\; apseudometric,\; i.e.$ d\text{'}(=0$does\; not\; necessarily\; imply\; that$ /math>.\; However,\; for\; some\; equivalence\; relations\; (e.g.,\; those\; given\; by\; gluing\; together\; polyhedra\; along\; faces),$ d\text{'}$is\; a\; metric.\; The\; quotient\; metric$ d$is\; characterized\; by\; the\; followinguniversal\; property.\; If$ f\backslash ,\backslash colon(M,d)\backslash to(X,\backslash delta)$is\; ametric\; mapbetween\; metric\; spaces\; (that\; is,$ \backslash delta(f(x),f(y))\backslash le\; d(x,y)$for\; all$ x$,$ y$)\; satisfying$ f(x)=f(y)$whenever$ x\backslash sim\; y,$then\; the\; induced\; function$ \backslash overline\backslash ,\backslash colon\; M/\backslash !\backslash sim\backslash to\; X$,\; given\; by$ \backslash overline(=f(x)$,\; is\; a\; metric\; map$ \backslash overline\backslash ,\backslash colon\; (M/\backslash !\backslash sim,d\text{'})\backslash to\; (X,\backslash delta).$A\; topological\; space\; issequentialif\; and\; only\; if\; it\; is\; a\; quotient\; of\; a\; metric\; space.$$$$$

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. * Relaxing the requirement that the distance between two distinct points be non-zero leads to the concepts of a pseudometric space or a dislocated metric space. Removing the requirement of symmetry, we arrive at a quasimetric space. Replacing the triangle inequality with a weaker form leads to semimetric spaces. * If the distance function takes values in the extended real number line $\backslash mathbb\; R\backslash cup\backslash $, but otherwise satisfies the conditions of a metric, then it is called an ''extended metric'' and the corresponding space is called an ''$\backslash 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''. * Approach spaces are a generalization of metric spaces, based on point-to-set distances, instead of point-to-point distances. * A continuity space is a generalization of metric spaces and posets, that can be used to unify the notions of metric spaces and domains. * A partial metric space is intended to be the least generalisation of the notion of a metric space, such that the distance of each point from itself is no longer necessarily zero.

References

Further reading

* Victor Bryant, ''Metric Spaces: Iteration and Application'', Cambridge University Press, 1985, . * Dmitri Burago, Yu D Burago, Sergei Ivanov, ''A Course in Metric Geometry'', American Mathematical Society, 2001, . * Athanase Papadopoulos, ''Metric Spaces, Convexity and Nonpositive Curvature'', European Mathematical Society, First edition 2004, . Second edition 2014, .

Mícheál Ó Searcóid

''Metric Spaces''

Springer Undergraduate Mathematics Series

2006, . * 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) a

Also (with an author commentary) in Enriched categories in the logic of geometry and analysis. Repr. Theory Appl. Categ. No. 1 (2002), 1–37. *

Far and near — several examples of distance functions

at [[cut-the-knot. {{Authority control [[Category:Metric spaces| [[Category:Mathematical analysis [[Category:Mathematical structures [[Category:Topology [[Category:Topological spaces