Internal helpers for Valiant's Depth Reduction Lemma #
Proof machinery supporting Valiant.depth_reduction. The public
statement and high-level wrapper live in Complexitylib.Circuits.Valiant; the basic
digraph definitions used below — IsDirectedWalk, IsPath, canonicalLabel,
depth, edgeFinset, deleteEdges — live in Complexitylib.Mathlib.Digraph.
This file collects the canonical labeling argument (legality and depth
bounds for canonicalLabel), the edge partition by first-differing bit,
the averaging step, and the relabeling-after-removal bound.
Acyclicity and legal labelings #
A legal labeling of a digraph is a map to the naturals that is strictly increasing along every edge.
Equations
- Complexity.Valiant.IsLegalLabeling G ℓ = ∀ (u v : V), G.Adj u v → ℓ u < ℓ v
Instances For
Every canonical label is at least 1: immediate from the outer
+ 1 in the definition.
The canonical label is bounded above by the graph's simple-path depth.
Canonical labeling is legal in acyclic graphs. Any simple path
ending at u followed by the edge (u,v) is a strictly longer simple
path ending at v (using acyclicity to ensure v does not already
appear in the path).
Depth bound from a legal labeling. Along any directed path,
labels are strictly increasing, hence distinct. So depth(G) is at
most the number of distinct labels used by any legal labeling.
Partitioning edges by first-differing bit #
Under IsAcyclic G and G.depth ≤ 2 ^ k, each canonical label
G.canonicalLabel v lies in {1,...,2^k}, so after subtracting 1
its k-bit binary representation is well-defined. For each edge
(u,v), since canonical labels are strictly increasing, the k-bit
reps of ℓ(u)-1 and ℓ(v)-1 differ, and we can identify the
leftmost (MSB) bit at which they first disagree.
firstDifferBit k a b is the 1-indexed MSB position at which the
k-bit binary representations of a and b first disagree, or 0
if the two k-bit representations coincide. The MSB of a XOR b (as
indexed by Nat.log2 from the LSB) gives the position of first
difference; converting to 1-indexed-from-MSB gives k - Nat.log2.
Instances For
Edges whose canonical-label endpoints' k-bit binary
representations first disagree at MSB position i.
Equations
- Complexity.Valiant.levelEdges G k i = {e ∈ G.edgeFinset | Complexity.Valiant.firstDifferBit k (G.canonicalLabel e.1 - 1) (G.canonicalLabel e.2 - 1) = i}
Instances For
Partition. When G is acyclic and G.depth ≤ 2 ^ k, every
edge lies in exactly one level E_i for i ∈ {1,...,k}.
Averaging. There is a choice of r levels whose total edge
count is at most r * S / k (equivalently, k * total ≤ r * S).
Relabeling after removal. After removing the edges in levels
I (assuming G acyclic), the map sending each vertex to its
canonical label with the I-th bits deleted is a legal labeling of
the remaining graph; its image has at most 2 ^ (k - I.card) values,
so the remaining depth is bounded by that.