Distances in undirected graphs #
A UDistanceInstance is an instance of undirected s–t connectivity (USTCONInstance, a
symmetric loopless adjacency matrix with two terminals) together with a natural number K. Exercise
5.24 of Goldreich's January 2007 draft ("determining distances in undirected graphs", printed
p. 198) asks whether there is a path of length at most K from s to t
(Cslib.Complexity.UDistanceAtMost), respectively exactly K (Cslib.Complexity.UDistanceEq).
The second set is an interpretation, not the literal question. Read literally, "a path of
length exactly K" asks for a simple path with K edges: on a triangle with adjacent terminals
there is one for K = 2, while the distance is 1. The exercise's title, its guideline for the
exact version (which uses NL = coNL, needed only for a lower bound on the distance) and
Exercise 5.27 support the shortest-distance reading, which UDistanceEq formalizes: the distance
is exactly K. Both sets are stated with Mathlib's extended distance SimpleGraph.edist, which is
⊤ between disconnected vertices, so disconnected pairs belong to neither. A walk of length at
most K shortens to a path of length at most K, so the first set is literally the source's.
Instances are encoded (Cslib.Complexity.encUDistance) as a framed encUSTCON word followed by
the binary digits of K; this is the layout of Cslib.Complexity.encBoundedSTCON on the directed
graph of the instance (Cslib.Complexity.UDistanceInstance.encBoundedSTCON_toBoundedSTCON).
This module proves the graph-theoretic facts behind the logarithmic-space reductions:
- At most
Kis bounded directed connectivity on the directed graph of the instance (Cslib.Complexity.UDistanceInstance.toBoundedSTCON_mem_iff). - Less than
K: appending a new vertex aftert, joined totby one arc (Cslib.Complexity.STCONInstance.pendant), turns "withinK - 1arcs tot" into "withinKarcs to the new vertex" for everyK, includingK = 0(Cslib.Complexity.UDistanceInstance.strict_mem_iff). The distance isKexactly when it is at mostKand not less thanK(Cslib.Complexity.UDistanceInstance.mem_UDistanceEq_iff). - Hardness: the guideline's layered graph of a directed instance
Jonnvertices is the undirected graph (Cslib.Complexity.STCONInstance.undirected) of the directed layered graphCslib.Complexity.BoundedSTCONInstance.layeredwithn + 1layers. Every walk from(0, s)to(n, t)has at leastnedges, and one withnedges climbs one layer per edge, following an arc ofJor staying at its vertex. Sotis reachable fromsexactly when the distance is at mostn, and exactly when it isn(Cslib.Complexity.STCONInstance.distanceInstance_mem_UDistanceAtMost_iff,Cslib.Complexity.STCONInstance.distanceInstance_mem_UDistanceEq_iff). The guideline uses|V|layers and the bound|V| - 1; one more layer avoids the casen = 0in the subtraction and changes nothing else.
Main definitions #
Cslib.Complexity.UDistanceInstance,Cslib.Complexity.encUDistance: instances and their encoding.Cslib.Complexity.UDistanceAtMost,Cslib.Complexity.UDistanceEq: distance at mostK, and exactlyK.Cslib.Complexity.STCONInstance.pendant: a new target aftert.Cslib.Complexity.STCONInstance.undirected: the undirected graph of a directed instance.Cslib.Complexity.STCONInstance.distanceInstance: the layered hardness instance.
References #
An instance of distance in an undirected graph: an undirected connectivity instance and a
natural number bound K.
- graph : USTCONInstance
The undirected graph, with its source and target.
- bound : ℕ
The distance bound
K, encoded in binary.
The tuple of the fields of encUDistance.
A framed encUSTCON graph followed by the binary digits (encNat) of the bound.
Distance at most K: the instances with a path of at most bound edges from s to t
(Goldreich's January 2007 draft, Exercise 5.24, "at most").
A pendant target: the instance with one more vertex n, the arcs of I, one arc from
t to n, and target n.
The pendant target is reached within k arcs exactly when t is reached within k - 1
arcs, for k ≥ 1; it is never reached within 0 arcs.
The undirected graph of a directed instance: distinct vertices are adjacent when there is an arc between them in either direction. The terminals are kept.
The entries of the undirected graph of a directed instance.
Adjacency in the undirected graph of a directed instance.
The layered hardness instance of Exercise 5.24: the undirected graph of the directed
layered graph with n + 1 layers (BoundedSTCONInstance.layered for the bound n), from
(0, s) to (n, t), with distance bound n.
The bounded directed connectivity instance on the directed graph of the instance.
The bounded directed instance asking for the pendant target after t within the bound.
The encoding of an instance is that of its bounded directed instance.
The encoding of an instance as a pair.
Distance at most K is bounded directed connectivity on the directed graph.
The distance is K exactly when it is at most K and the pendant target is not reached
within K arcs.
The layered hardness instance #
Hardness, "at most": t is reachable from s exactly when the hardness instance has
distance at most n.
Hardness, "exactly": t is reachable from s exactly when the hardness instance has
distance exactly n.