Lawvere Distance
A Lawvere distance assigns to each ordered pair of points a value saying how far it is from the first to the second. It is the motivating example for enrichment: an ordinary graph or category asks whether there is a way from to , while an enriched one asks what getting from to is worth.
Lawvere observed that a metric space is a category in disguise. Write for the distance from to . Two laws are required:
The first law plays the role of an identity arrow: staying put costs nothing. The second plays the role of composition: going from to by way of bounds the direct distance. Everything else usually required of a metric is dropped.
- No symmetry. need not equal . One-way latency, causal order, and directed dependencies are asymmetric.
- Distinct points may be at distance zero. Points with are indistinguishable by distance without being identical.
- Infinite distance is allowed. means cannot be reached from .
These relaxations are what make the notion fit systems. In the Boolean case, when happens before or is and otherwise. Concurrent events are then exactly the pairs at infinite distance in both directions.
Enrichment
The same pattern works with values other than distances. An enrichment needs a set of values together with:
- a way to compose values along a path, written ;
- a unit for that composition, the value of staying put;
- an order on values, with a way to choose the best of several alternatives, written .
A -enriched category assigns a value to each pair of points, with the unit no worse than and the composite no better than . An ordinary category is the case where the values are sets of arrows. A preorder is the case where the values are Booleans. A Lawvere metric space is the case where the values are distances in , composed by addition, where smaller is better.
Quantales
Made precise, the requirements above describe a quantale: a complete lattice of values with an associative composition that has a unit and distributes over arbitrary joins on both sides:
The join is the choice among alternatives, above, with the order chosen so that preferred values are higher. Distributivity says that extending every alternative by one step and then choosing the best gives the same result as choosing first and then extending. Completeness says that a best value exists even over infinitely many paths, such as the paths that go around a loop any number of times.
Quantales are the enrichment bases whose values are degrees rather than sets of arrows. Lawvere's distances form a quantale on with the order reversed, so that smaller distances are higher, join is , and composition is addition. Languages form a quantale that is not commutative, since concatenation depends on order.
Implication and Heyting Algebras
The values of an enrichment often behave like truth values, which is the sense of generalized logic in Lawvere's title. Distances are degrees of truth, and the triangle inequality is a rule of inference. For this reading the values need an implication: an operation such that
Implication answers what a remaining step may still contribute, given what one step provides and what the whole path must achieve. With cost, is the budget left for the rest of a path after a step of cost against a target of . An enrichment with an implication is closed, the closed categories of Lawvere's title.
Every quantale has an implication, because composition distributes over joins:
A quantale that is not commutative, such as languages, has two implications, one for extending a path on the left and one for extending it on the right.
A complete Heyting algebra, also called a frame, is a quantale in which composition is the meet:
Heyting algebras are the algebras of intuitionistic logic. They need not satisfy the law of excluded middle, so a proposition may be neither established nor refuted. The Booleans are the Heyting algebra in which excluded middle holds. Other examples include any complete chain, the open sets of a space read as observable properties, and the up-closed sets of a partial order read as properties that remain true once they become true. The last two connect enrichment to sheaves and to information that grows over time.
Heyting algebras are special even among small quantales. Pratt notes that a chain of values carries commutative quantale structures with bottom and unit , of which exactly one is a Heyting algebra. For three values, the Heyting structure underlies Gaifman's distinction between causal and incidental order, while the non-Heyting structure is the one Pratt imposes on for higher-dimensional automata, in which an event can be in progress.
In the examples below, Booleans, ultrametric, and capacity are Heyting algebras: their path composition is the meet. Cost, reliability, and languages are not, because addition, multiplication, and concatenation are not idempotent: taking the same step twice costs twice. They are quantales but not Heyting algebras, and their implications are:
| Implication | |
|---|---|
| Booleans | |
| Capacity | if , otherwise |
| Cost | |
| Reliability | |
| Languages | left and right quotients of by |
Examples
| Values | Along a path | Among alternatives | Unit | Reading | |
|---|---|---|---|---|---|
| Booleans | reachability, preorder, happened-before | ||||
| Cost | shortest path, latency, Lawvere metric | ||||
| Ultrametric | minimax path, worst single hop | ||||
| Capacity | widest path, bottleneck bandwidth | ||||
| Reliability | most reliable path, availability | ||||
| Languages | sets of words | concatenation | union | the set of paths as a regular expression | |
| Intervals | with | interval addition | interval hull, or intersection | bounded elapsed time |
Interval Arithmetic
Intervals record uncertainty about a measure rather than a single value. An interval on an edge says that getting from one point to the other takes at least and at most . Along a path, interval arithmetic adds the bounds:
The two bounds behave differently. A lower bound is a geodesic: the shortest path between two points bounds every path from below, so alternatives combine by and the triangle inequality is the ordinary . An upper bound must cover every path: alternatives combine by and the inequality reverses, . If all paths from to take at most 5 seconds and all paths from to at most 7, the paths from to through take at most 12. A path through another point with bounds 4 and 9 still allows 13, so the bound from to must be at least 13.
An interval combines both. Two readings of alternatives are useful.
- Every path may occur. The interval must cover all of them, so alternatives combine by the hull, . This is Pratt's reading. He orders intervals so that narrower intervals are stronger, the information order of interval arithmetic: a narrow interval says more about the elapsed time than a wide one.
- Every constraint must hold. When several paths constrain the same pair, as in a temporal constraint network, the bounds intersect: . An empty intersection means the constraints are inconsistent.
The first reading is a quantale: it pairs the lower-bound quantale, with , and the upper-bound quantale, with , and addition distributes over both. The second is not, because adding a step does not distribute over intersection. With , , and , the sum is empty while . Simple temporal networks therefore encode each interval as a pair of one-directional distances, an upper bound forward and a lower bound backward, and run shortest-path closure on those.
Intervals suit the clock uncertainty described in Time: an elapsed-time bound is honest about what an observer knows, and composing bounds along a path shows how uncertainty accumulates.
Closure: Gauss, Kleene, Floyd, and Warshall
A weighted graph lists direct edges. The enriched category it generates gives the best value over all paths between each pair, and the triangle inequality says that no shortcut remains. For distances this is all-pairs shortest paths. Shortest Paths and Matrix Multiplication describes how it is computed as matrix multiplication with for addition and for multiplication, and how replacing those operations yields Warshall's transitive closure, Kleene's regular expressions for automata, and Gauss's matrix inversion from the same algorithm.
Quantales make the computation well defined. The star , the best value over any number of trips around a loop, always exists, and distributivity justifies eliminating one intermediate point at a time.
Casley, Crew, Meseguer, and Pratt combine this algorithm with enriched categories to give a uniform account of parametrized time, in which each notion of time has a corresponding algebra of concurrent behavior. Event-state duality uses the same idea: time is a Lawvere distance between events, and information is a Lawvere distance between states.
Points as Distance Profiles
The Yoneda lemma has a direct metric form. A point determines the function giving every point's distance to it, and Lawvere showed that this map from points to functions preserves distance exactly. A point can therefore be identified with its profile of distances. This is the enriched version of identifying an element with the predicates it satisfies, with Boolean answers replaced by values in .
Modeling Checks
- What value does a relationship carry, and how does it compose along a path?
- When several paths connect the same pair, is the best one chosen, or must all of them hold?
- Is the relationship symmetric, or does direction matter?
- What does an infinite or empty value mean: unreachable, unordered, or inconsistent?
- Is a value a point estimate or a bound, and should it be represented as an interval?
Formal relations
refines: Enrichment and Order — Gives the metric case of enrichment, in which relationships carry composable values such as distance, cost, capacity, reliability, or time bounds rather than bare existence.
External References
- F. William Lawvere, Metric Spaces, Generalized Logic, and Closed Categories, Rendiconti del Seminario Matematico e Fisico di Milano 43, 1973. Reprinted in Reprints in Theory and Applications of Categories 1, 2002.
- Ross Casley, Roger F. Crew, José Meseguer, and Vaughan R. Pratt, Temporal Structures, Category Theory and Computer Science, LNCS 389, 1989. Revised in Mathematical Structures in Computer Science 1(2):179-213, 1991.
- Vaughan R. Pratt, Event-State Duality: The Enriched Case, CONCUR 2002, Sections 4 and 5.
- nLab, Lawvere metric space.
- nLab, quantale.
- nLab, Heyting algebra.