Digraph extensions for Mathlib #
General-purpose definitions on top of Mathlib's Digraph: directed walks
and simple paths, depth (longest simple-path length on a finite graph),
IsAcyclic, the edgeFinset of a digraph with decidable adjacency on a
finite vertex type, and deleteEdges.
The depth measure is exported together with its general bounds, public for
downstream reuse and as upstreaming candidates: pathLength_bddAbove
(simple-path lengths are bounded by the vertex count), depth_le_card
(depth ≤ Fintype.card V), one_le_depth (a nonempty graph has positive
depth), and depth_deleteEdges_empty (deleting the empty edge set preserves
depth). These hold for every finite digraph, with no acyclicity assumption.
This file lives in Complexitylib/Mathlib/ because it extends a Mathlib
type in its home (root) namespace — the one sanctioned exception to the
Complexity root-namespace rule. Its contents are candidates for
upstreaming to Mathlib.
Depth-reduction-specific machinery (canonical labeling, acyclicity
arguments, edge partitions by first-differing bit, etc.) lives in
Complexitylib.Circuits.Internal.Valiant.
G.IsDirectedWalk p says that p : Fin m → V is a directed walk
in the digraph G: consecutive vertices are joined by an edge.
Instances For
G.IsPath p says that p : Fin m → V is a simple directed
path: an injective directed walk.
Equations
- G.IsPath p = (G.IsDirectedWalk p ∧ Function.Injective p)
Instances For
A finite digraph's simple-path depth is at most its number of vertices.
The directed edge set of a digraph with decidable adjacency on a finite vertex type.
Equations
- G.edgeFinset = {p : V × V | G.Adj p.1 p.2}
Instances For
Equations
The simple-path set of G.deleteEdges ∅ agrees with that of G,
so the two graphs have the same depth.
The canonical labeling of G: the length — node count — of a
longest simple directed path ending at v. Parameterized by edge
count n, with the outer + 1 converting to node count; the
single-vertex path ![v] always witnesses n = 0, so the label is
automatically at least 1.