A Lawvere metric space is a Cost-category.
Sources: 7 Sketches Definition 2.53, Examples 2.54, 2.72, 2.76, Exercises 2.55, 2.58, 2.73, 2.78; Remark 2.97; [Law73].
Unpacking: a -category has a set of points and for each a hom-object , satisfying
(a) , i.e. ; (b) , the triangle inequality.
Compared with a Metric Space, symmetry and "" are dropped and infinite distances allowed — a “very compact definition that packs a punch”. Examples: with ; effort in hilly terrain; regions with the asymmetric Hausdorff Distance; any -weighted graph via shortest paths.
Dictionary
| enriched notion | metric notion |
|---|---|
| -functor with | 1-Lipschitz (distance non-increasing) map (Example 2.72) |
| skeletal dagger -category | extended metric space (7S Exercise 2.73) |
| -product | , the / Manhattan metric (7S Exercise 2.78: , not ) |
| Change of Base along | the preorder ” iff ”, e.g. “is a part of” for regions (7S Exercise 2.67) |
| change of base along | the preorder ” is reachable from “ |
| presentation by a -weighted graph | shortest-path distances, computed by min-plus matrix powers |
| -category | finite-distance Lawvere metric space (7S Exercise 2.55) |
| -profunctor | a distance-like relation between two spaces (Chapter 4) |
Lawvere’s paper [Law73] goes further, e.g. Cauchy completeness in categorical terms.
Docs: Vignette: monoidal preorders & SMCs
Builds on: Cost (CostPre), Enriched Category (VCategory) — run those notes’ Julia code first.
# a finite Lawvere metric space as a matrix of distances over Cost
X = VCategory(CostPre(), [:x, :y, :z], [0.0 4 3; 3 0 6; 7 4 0]) # Eq. (2.57)
is_vcategory(X) # true: zeros on the diagonal, triangle inequality holds
# from a weighted graph via min-plus matrix powers (see Matrix Multiplication in a Quantale)
M = [0.0 4 3; 3 0 Inf; Inf 4 0]
minplus(A, B) = [minimum(A[i, k] + B[k, j] for k in axes(A, 2)) for i in axes(A, 1), j in axes(B, 2)]
d = minplus(M, M); minplus(d, M) == d # stabilizes at the distance matrix-- The symmetric case is Mathlib's `PseudoEMetricSpace`; the general Lawvere case is a
-- category enriched in the monoidal (order-dual) ENNReal. By hand:
structure LawvereMetric (X : Type) where
d : X → X → ENNReal
d_self : ∀ x, d x x = 0
triangle : ∀ x y z, d x z ≤ d x y + d y z-- a Lawvere metric space is a Cost-enriched category
type Lawvere o = VCat Cost o
realLawvere :: [Double] -> Lawvere Double
realLawvere pts = VCat pts (\x y -> Fin (abs (y - x)))