Cohesive Systems logoCOHESIVE SYSTEMS

Search Cohesive Systems

Ready

Search Cohesive Systems

Find product pages, building blocks, technical articles, and graph definitions.

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 xx to yy, while an enriched one asks what getting from xx to yy is worth.

Lawvere observed that a metric space is a category in disguise. Write d(x,y)d(x, y) for the distance from xx to yy. Two laws are required:

d(x,x)=0d(x,z)≤d(x,y)+d(y,z)\begin{aligned} d(x, x) &= 0 \\ d(x, z) &\le d(x, y) + d(y, z) \end{aligned}

The first law plays the role of an identity arrow: staying put costs nothing. The second plays the role of composition: going from xx to zz by way of yy bounds the direct distance. Everything else usually required of a metric is dropped.

  • No symmetry. d(x,y)d(x, y) need not equal d(y,x)d(y, x). One-way latency, causal order, and directed dependencies are asymmetric.
  • Distinct points may be at distance zero. Points with d(x,y)=d(y,x)=0d(x, y) = d(y, x) = 0 are indistinguishable by distance without being identical.
  • Infinite distance is allowed. d(x,y)=∞d(x, y) = \infty means yy cannot be reached from xx.

These relaxations are what make the notion fit systems. In the Boolean case, d(a,b)=0d(a, b) = 0 when aa happens before or is bb and ∞\infty 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 VV together with:

  • a way to compose values along a path, written ⊗\otimes;
  • 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 ⊕\oplus.

A VV-enriched category assigns a value C(x,y)∈V\mathcal{C}(x, y) \in V to each pair of points, with the unit no worse than C(x,x)\mathcal{C}(x, x) and the composite C(x,y)⊗C(y,z)\mathcal{C}(x, y) \otimes \mathcal{C}(y, z) no better than C(x,z)\mathcal{C}(x, z). 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 [0,∞][0, \infty], 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 ⊗\otimes that has a unit and distributes over arbitrary joins on both sides:

a⊗⋁ibi=⋁i(a⊗bi)(⋁ibi)⊗a=⋁i(bi⊗a)a \otimes \bigvee_i b_i = \bigvee_i (a \otimes b_i) \qquad \Big(\bigvee_i b_i\Big) \otimes a = \bigvee_i (b_i \otimes a)

The join is the choice among alternatives, ⊕\oplus 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 [0,∞][0, \infty] with the order reversed, so that smaller distances are higher, join is inf⁡\inf, 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 ⇒\Rightarrow such that

a⊗b≤c  ⟺  a≤(b⇒c)a \otimes b \le c \iff a \le (b \Rightarrow c)

Implication answers what a remaining step may still contribute, given what one step provides and what the whole path must achieve. With cost, b⇒cb \Rightarrow c is the budget left for the rest of a path after a step of cost bb against a target of cc. An enrichment with an implication is closed, the closed categories of Lawvere's title.

Every quantale has an implication, because composition distributes over joins:

b⇒c=⋁{ a∣a⊗b≤c }b \Rightarrow c = \bigvee \{\, a \mid a \otimes b \le c \,\}

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:

a∧b≤c  ⟺  a≤(b⇒c)a \wedge b \le c \iff a \le (b \Rightarrow c)

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 n≥2n \ge 2 values carries 2n−22^{n-2} commutative quantale structures with bottom 00 and unit 11, 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 {0,during,1}\{0, \mathsf{during}, 1\} 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:

VVImplication b⇒cb \Rightarrow c
Booleans¬b∨c\lnot b \lor c
Capacity∞\infty if b≤cb \le c, otherwise cc
Costmax⁡(c−b,0)\max(c - b, 0)
Reliabilitymin⁡(1,c/b)\min(1, c / b)
Languagesleft and right quotients of cc by bb

Examples

VVValuesAlong a path ⊗\otimesAmong alternatives ⊕\oplusUnitReading
Booleans{⊥,⊤}\{\bot, \top\}∧\land∨\lor⊤\topreachability, preorder, happened-before
Cost[0,∞][0, \infty]++min⁡\min00shortest path, latency, Lawvere metric
Ultrametric[0,∞][0, \infty]max⁡\maxmin⁡\min00minimax path, worst single hop
Capacity[0,∞][0, \infty]min⁡\minmax⁡\max∞\inftywidest path, bottleneck bandwidth
Reliability[0,1][0, 1]×\timesmax⁡\max11most reliable path, availability
Languagessets of wordsconcatenationunion{ε}\{\varepsilon\}the set of paths as a regular expression
Intervals[l,u][l, u] with 0≤l≤u0 \le l \le uinterval additioninterval hull, or intersection[0,0][0, 0]bounded elapsed time

Interval Arithmetic

Intervals record uncertainty about a measure rather than a single value. An interval [l,u][l, u] on an edge says that getting from one point to the other takes at least ll and at most uu. Along a path, interval arithmetic adds the bounds:

[l1,u1]⊗[l2,u2]=[l1+l2,  u1+u2][l_1, u_1] \otimes [l_2, u_2] = [l_1 + l_2,\; u_1 + u_2]

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 min⁡\min and the triangle inequality is the ordinary d(a,b)+d(b,c)≥d(a,c)d(a, b) + d(b, c) \ge d(a, c). An upper bound must cover every path: alternatives combine by max⁡\max and the inequality reverses, d(a,b)+d(b,c)≤d(a,c)d(a, b) + d(b, c) \le d(a, c). If all paths from xx to yy take at most 5 seconds and all paths from yy to zz at most 7, the paths from xx to zz through yy take at most 12. A path through another point ww with bounds 4 and 9 still allows 13, so the bound from xx to zz 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, [min⁡(l1,l2),max⁡(u1,u2)][\min(l_1, l_2), \max(u_1, u_2)]. 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: [max⁡(l1,l2),min⁡(u1,u2)][\max(l_1, l_2), \min(u_1, u_2)]. An empty intersection means the constraints are inconsistent.

The first reading is a quantale: it pairs the lower-bound quantale, with min⁡\min, and the upper-bound quantale, with max⁡\max, and addition distributes over both. The second is not, because adding a step does not distribute over intersection. With A=[0,1]A = [0, 1], B1=[0,0]B_1 = [0, 0], and B2=[1,1]B_2 = [1, 1], the sum A+(B1∩B2)A + (B_1 \cap B_2) is empty while (A+B1)∩(A+B2)=[1,1](A + B_1) \cap (A + B_2) = [1, 1]. 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 min⁡\min 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 a∗=⋁n≥0ana^{*} = \bigvee_{n \ge 0} a^{n}, 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 xx determines the function d(−,x)d(-, x) 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 VV.

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