Documentation

CslibFrontier.Computability.Circuit.Prefix.OptimalDepth.SegmentTree

Spine decomposition and segment tree construction on prefix DAGs #

Left-spine decomposition (spine_decomposition), interval-tree extraction (exists_wireIntervalTree), and unfolded segment distribution trees (buildSegTree) with uniqueness of firstInput paths (countWireInSeg_le_one, buildSegTree_counts) and fanout budget accounting (seg_fanout_bound, seg_root_fanout_bound) [Ser25a].

Main definitions #

Main results #

References #

theorem Cslib.Circuits.Prefix.range'_eq_range'_iff {a₁ len₁ a₂ len₂ : ℕ} (h1 : 1 ≤ len₁) (heq : List.range' a₁ len₁ = List.range' a₂ len₂) :
a₁ = a₂ ∧ len₁ = len₂

Nonempty contiguous integer ranges List.range' coincide iff their starts and lengths do.

First input wire wires 0 read by a {mul, id} gate line.

Every gate has depth strictly greater than its firstInput wire.

def Cslib.Circuits.Prefix.segHasOut {N : ℕ} (c : PrefixCircuit N) (a b : ℕ) (w : Wire N c.size) :

Whether wire w is designated as an external output for some index in [a, b).

@[irreducible]
def Cslib.Circuits.Prefix.segActive {N : ℕ} (c : PrefixCircuit N) (a b : ℕ) (root w : Wire N c.size) :

Whether wire w reaches an external output in [a, b) along non-root firstInput edges.

def Cslib.Circuits.Prefix.segChildren {N : ℕ} (c : PrefixCircuit N) (a b : ℕ) (root w : Wire N c.size) :

Active non-root gates whose firstInput is w.

theorem Cslib.Circuits.Prefix.mem_segChildren_iff {N : ℕ} (c : PrefixCircuit N) (a b : ℕ) (root w : Wire N c.size) (g : Fin c.size) :
g ∈ segChildren c a b root w ↔ Wire.gate g ≠ root ∧ firstInput (c.program.lines g) = w ∧ segActive c a b root (Wire.gate g) = true

Membership characterization of segChildren c a b root w.

theorem Cslib.Circuits.Prefix.segActive_iff {N : ℕ} (c : PrefixCircuit N) (a b : ℕ) (root w : Wire N c.size) :
segActive c a b root w = true ↔ segHasOut c a b w = true ∨ ∃ (g : Fin c.size), g ∈ segChildren c a b root w

A wire is segActive iff it carries a segment output or has an active segment child.

theorem Cslib.Circuits.Prefix.segChildren_rank_lt {N : ℕ} (c : PrefixCircuit N) (a b : ℕ) (root w : Wire N c.size) (i : Fin (segChildren c a b root w).length) :
w.rank < (Wire.gate (segChildren c a b root w)[i]).rank

Every gate in segChildren c a b root w has rank strictly greater than w.rank.

inductive Cslib.Circuits.Prefix.ReachesInSeg {N : ℕ} (c : PrefixCircuit N) (a b : ℕ) (root : Wire N c.size) :
Wire N c.size → Wire N c.size → Prop

Reachability along segChildren edges inside a principal-chain segment.

theorem Cslib.Circuits.Prefix.ReachesInSeg.top_inversion {N : ℕ} {c : PrefixCircuit N} {a b : ℕ} {root w u : Wire N c.size} (h : ReachesInSeg c a b root w u) :
u = w ∨ ∃ g ∈ segChildren c a b root w, ReachesInSeg c a b root (Wire.gate g) u

Unpacks a ReachesInSeg path from w into u = w or a step through segChildren.

theorem Cslib.Circuits.Prefix.ReachesInSeg.segActive_of {N : ℕ} {c : PrefixCircuit N} {a b : ℕ} {root z u : Wire N c.size} (hz : segActive c a b root z = true) (h : ReachesInSeg c a b root z u) :
segActive c a b root u = true

segActive propagates forward along ReachesInSeg.

@[irreducible]
def Cslib.Circuits.Prefix.countWireInSeg {N : ℕ} (c : PrefixCircuit N) (a b : ℕ) (root target w : Wire N c.size) :

Multiplicity with which target is visited in the unfolded tree from w.

theorem Cslib.Circuits.Prefix.countWireInSeg_eq_one_of_reaches {N : ℕ} {c : PrefixCircuit N} {a b : ℕ} {root target w : Wire N c.size} (h : ReachesInSeg c a b root w target) :
countWireInSeg c a b root target w = 1

Any wire reachable from w via ReachesInSeg has multiplicity 1 in countWireInSeg.

theorem Cslib.Circuits.Prefix.reaches_of_countWireInSeg_ne_zero {N : ℕ} {c : PrefixCircuit N} {a b : ℕ} {root target w : Wire N c.size} (h : countWireInSeg c a b root target w ≠ 0) :
ReachesInSeg c a b root w target

Nonzero multiplicity in countWireInSeg implies ReachesInSeg.

theorem Cslib.Circuits.Prefix.countWireInSeg_le_one {N : ℕ} (c : PrefixCircuit N) (a b : ℕ) (root target w : Wire N c.size) :
countWireInSeg c a b root target w ≤ 1

Every wire has multiplicity at most 1 in countWireInSeg.

theorem Cslib.Circuits.Prefix.seg_fanout_bound {N : ℕ} (c : PrefixCircuit N) (a b : ℕ) (root w : Wire N c.size) :
((segChildren c a b root w).length + if segHasOut c a b w = true then 1 else 0) ≤ wireFanout c w

Active segment children plus segment output indicator at w do not exceed wireFanout.

theorem Cslib.Circuits.Prefix.seg_root_fanout_bound {N : ℕ} (c : PrefixCircuit N) (a b : ℕ) (root : Wire N c.size) (sg : Fin c.size) (hsg_fi : firstInput (c.program.lines sg) = root) (hsg_not : sg ∉ segChildren c a b root root) :
((segChildren c a b root root).length + if segHasOut c a b root = true then 1 else 0) + 1 ≤ wireFanout c root

At the segment root, reserving the next principal-chain gate sg leaves budget ≤ k - 1.