← back to geometry

Metric Spaces

Wikipedia (wpMetric space) · CC BY-SA 4.0

A metric space is a set X equipped with a function d : X × X → [0, ∞) that measures distance. Four axioms: d(x,y) ≥ 0 (non-negativity), d(x,y) = 0 iff x = y (identity of indiscernibles), d(x,y) = d(y,x) (symmetry), and d(x,z) ≤ d(x,y) + d(y,z) (triangle inequality). Every geometry you know is a special case.

The four axioms

A distance function (or metric) must satisfy four properties. These are not optional: drop any one and you get a different, weaker structure (pseudometric, quasimetric, semimetric). The triangle inequality is the one that does the most work. It says detours never shorten the trip.

Scheme

Open balls

The open ball B(x, r) is the set of all points within distance r of x. Open balls are the building blocks of the topology induced by the metric. In Euclidean space they are circles. In taxicab space they are diamonds. The metric determines the shape of "nearness."

Euclidean: circles B(x, r) = circle Taxicab: diamonds B(x, r) = diamond

Four metrics on the same set

The same set of points can carry different metrics. Each metric defines a different notion of distance, different open balls, and different convergent sequences. The set does not change. The structure does.

Scheme

Hausdorff distance

The Hausdorff distance measures how far apart two sets are. It is the greatest distance any point in one set has to travel to reach the other set. If H(A, B) = 0, the closures of A and B are equal. Hausdorff distance turns the collection of compact subsets of a metric space into a metric space itself.

Scheme

Metric space as enriched category

A metric space is a category enriched over ([0, ∞], ≥, +). Objects are points. The hom-value from x to y is d(x, y). Identity says d(x, x) = 0. Composition says d(x, z) ≤ d(x, y) + d(y, z), which is exactly the triangle inequality. Lawvere noticed this in 1973: a metric space is what you get when you replace "arrows exist or not" (Bool-enriched) with "arrows have a cost" ([0, ∞]-enriched).

Scheme
Neighbors

Geometry chapters

Cross-references

Foundations (Wikipedia)

Translation notes

The enriched-category perspective comes from Lawvere's 1973 paper "Metric spaces, generalized logic, and closed categories." Milewski covers enriched categories in chapter 22 of Category Theory for Programmers, where the running example is exactly this: Bool-enrichment gives preorders, [0,∞]-enrichment gives metric spaces. The Hausdorff distance example uses finite sets for computability; the general definition uses suprema over arbitrary sets.