Documentation

CslibFrontier.Computability.Complexity.Problems.UDistance

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:

Main definitions #

References #

An instance of distance in an undirected graph: an undirected connectivity instance and a natural number bound K.

  • The undirected graph, with its source and target.

  • bound : ℕ

    The distance bound K, encoded in binary.

theorem Cslib.Complexity.encUDistance_graph_polyTime {γ✝ : Type} {encIn✝ : γ✝ ↪ List Bool} {g✝ : γ✝ → UDistanceInstance} :
theorem Cslib.Complexity.encUDistance_mk_inO {γ : Type} {encIn : γ ↪ List Bool} {x0 : γ → USTCONInstance} {T0 S0 x1 T1 S1 : γ → ℕ} (h0 : Turing.MultiTapeTM.ComputableInO x0 encIn encUSTCON T0 S0) (h1 : Turing.MultiTapeTM.ComputableInO x1 encIn Turing.MultiTapeTM.encNat T1 S1) :
Turing.MultiTapeTM.ComputableInO (fun (x : γ) => { graph := x0 x, bound := x1 x }) encIn encUDistance (fun (x : γ) => T0 x + T1 x) fun (x : γ) => S0 x + S1 x
theorem Cslib.Complexity.encUDistance_mk_budget {γ : Type} {encIn : γ ↪ List Bool} {budget : γ → ℕ} {x0 : γ → USTCONInstance} {x1 : γ → ℕ} (h0 : Turing.MultiTapeTM.ComputableInSpace x0 encIn encUSTCON budget) (h1 : Turing.MultiTapeTM.ComputableInSpace x1 encIn Turing.MultiTapeTM.encNat budget) :
Turing.MultiTapeTM.ComputableInSpace (fun (x : γ) => { graph := x0 x, bound := x1 x }) encIn encUDistance budget
@[reducible, inline]

The tuple of the fields of encUDistance.

A framed encUSTCON graph followed by the binary digits (encNat) of the bound.

theorem Cslib.Complexity.encUDistance_graph_budget {γ✝ : Type} {encIn✝ : γ✝ ↪ List Bool} {S✝ : γ✝ → ℕ} {g✝ : γ✝ → UDistanceInstance} :
Turing.MultiTapeTM.ComputableInSpace g✝ encIn✝ encUDistance S✝ → Turing.MultiTapeTM.ComputableInSpace (fun (c : γ✝) => (g✝ c).graph) encIn✝ encUSTCON S✝
theorem Cslib.Complexity.encUDistance_bound_budget {γ✝ : Type} {encIn✝ : γ✝ ↪ List Bool} {S✝ : γ✝ → ℕ} {g✝ : γ✝ → UDistanceInstance} :

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").

Distance exactly K: the instances whose terminals are at distance bound. This is the shortest-distance reading of Goldreich's January 2007 draft, Exercise 5.24, "exactly", not the literal "a path of exactly bound edges" (see the module docstring).

A pendant target: the instance with one more vertex n, the arcs of I, one arc from t to n, and target n.

Between old vertices, the pendant instance has the arcs of I.

The only arc into the new vertex comes from t.

No arc leaves the new vertex.

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.

theorem Cslib.Complexity.STCONInstance.undirected_adj (I : STCONInstance) (a b : Fin I.n) :
I.undirected.adj a b = (decide (a ≠ b) && (I.adj a b || I.adj b a))

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.

Distance at most K is bounded directed connectivity on the directed graph.

Distance less than K: the pendant target is reached within K arcs exactly when the distance is less than K.

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.