---
tag: 063W5JMY85
kind: definition
name: Metric space
msc: ["54E35"]
defines: 0VKD1TP7F3
uses: [0XHDTE5YMZ, 08J2M1JYAG, 0C81YBVTWH]
sources:
  - url: https://en.wikipedia.org/wiki/Metric_space
    locator: Definition
---

## Definition

Let $X$ be a set.
A metric on $X$ is a [[function|0XHDTE5YMZ]] $d \colon X \times X \to \mathbb{R}$ with these properties, for all $x, y, z \in X$:

1. $d(x, x) = 0$.
2. If $x \neq y$, then $d(x, y) > 0$.
3. $d(x, y) = d(y, x)$.
4. $d(x, z) \le d(x, y) + d(y, z)$.

A metric space is a pair $(X, d)$, where $X$ is a set and $d$ is a metric on $X$.
The number $d(x, y)$ is the distance between $x$ and $y$.

## Remarks

Property 4 is the [[triangle inequality for a metric|01M6CW9VM6]].
The properties give $d(x, y) \ge 0$ for all $x, y$: take $z = x$ in property 4 and use property 3.
The set $\mathbb{R}$ with $d(x, y) = |x - y|$ is a metric space: this is the [[usual metric on the real line|0KXJTZSW9B]].
If you remove property 2, you get a [[pseudometric space|0H3W614GEC]].

## Explanations

### L1 human

A metric is a rule that gives a distance to each pair of points.
The four properties are the facts that you expect from distances on a map.
For example, the road distance between towns is not always a metric, because one-way roads can break symmetry.
