Documentation

CslibFrontier.Computability.Circuit.Descending

Computations with decreasing indices as straight-line programs #

A descending computation has a source at index 0 and, at each positive index i, a gate gates i reading the values at the d strictly smaller indices child i 0, …, child i (d - 1). Cslib.TreeEval.Ary.Descending unfolds such a computation into a tree. This file keeps the sharing instead: indices 0, …, g become the single input and the g gates of a straight-line program, so the computation DAG of the program is the dependency graph of the computation. The register and pebbling results for straight-line programs (Cslib.Circuits.Program.dag, Cslib.Circuits.Program.EvaluatesInRegisters) then apply to the computation directly.

Main definitions #

Main results #

One operation for each positive index i + 1, named by i; each reads d arguments.

The wire carrying index i among indices 0, …, g: index 0 is the input, index i + 1 the gate i. Indices beyond g are sent to the input; program only uses indices ≤ g.

def Cslib.Circuits.Descending.line {d : ℕ} (child : ℕ → Fin d → ℕ) (g j : ℕ) :
Line (signature d) 1 g

The gate at index j + 1, reading the wires of its children.

def Cslib.Circuits.Descending.program {d : ℕ} (child : ℕ → Fin d → ℕ) (g : ℕ) :

The descending computation on indices 0, …, g as a straight-line program with one input and g gates. Gate j computes index j + 1.

theorem Cslib.Circuits.Descending.node_succ {g i : ℕ} (h : i < g) :
node g (i + 1) = Wire.gate ⟨i, h⟩
theorem Cslib.Circuits.Descending.node_castSucc {g i : ℕ} (h : i ≤ g) :
(node g i).castSucc = node (g + 1) i

Widening the wire of an index ≤ g to g + 1 gates gives the wire of the same index.

theorem Cslib.Circuits.Descending.lines_program {d : ℕ} (child : ℕ → Fin d → ℕ) (hchild : ∀ (i : ℕ), 0 < i → ∀ (a : Fin d), child i a < i) {g : ℕ} (j : Fin g) :
(program child g).lines j = line child g ↑j

The widened lines of program are its gates.

def Cslib.Circuits.Descending.interpretation {d : ℕ} {U : Type u_1} (gates : ℕ → (Fin d → U) → U) :

The interpretation of signature d running gate gates (i + 1) at operation i.

theorem Cslib.Circuits.Descending.trace_node_zero {d : ℕ} (child : ℕ → Fin d → ℕ) {U : Type u_1} (gates : ℕ → (Fin d → U) → U) (source : U) (g : ℕ) :
(program child g).trace (interpretation gates) (fun (x : Fin 1) => source) (node g 0) = source

The trace at index 0 is the source.

theorem Cslib.Circuits.Descending.trace_node_succ {d : ℕ} (child : ℕ → Fin d → ℕ) {U : Type u_1} (gates : ℕ → (Fin d → U) → U) (source : U) (hchild : ∀ (i : ℕ), 0 < i → ∀ (a : Fin d), child i a < i) {g i : ℕ} (hi : i < g) :
(program child g).trace (interpretation gates) (fun (x : Fin 1) => source) (node g (i + 1)) = gates (i + 1) fun (a : Fin d) => (program child g).trace (interpretation gates) (fun (x : Fin 1) => source) (node g (child (i + 1) a))

The trace at a positive index applies its gate to the trace at its children.

theorem Cslib.Circuits.Descending.trace_node_eq {d : ℕ} (child : ℕ → Fin d → ℕ) {U : Type u_1} (gates : ℕ → (Fin d → U) → U) (source : U) (hchild : ∀ (i : ℕ), 0 < i → ∀ (a : Fin d), child i a < i) {v : ℕ → U} {g : ℕ} (hzero : v 0 = source) (hsucc : ∀ i < g, v (i + 1) = gates (i + 1) fun (a : Fin d) => v (child (i + 1) a)) {i : ℕ} (hi : i ≤ g) :
(program child g).trace (interpretation gates) (fun (x : Fin 1) => source) (node g i) = v i

Uniqueness. A function on indices that takes the source at 0 and satisfies the gate equations at the indices 1, …, g agrees with the trace on indices 0, …, g.

theorem Cslib.Circuits.Descending.dag_adj_node {d : ℕ} (child : ℕ → Fin d → ℕ) (hchild : ∀ (i : ℕ), 0 < i → ∀ (a : Fin d), child i a < i) {g i : ℕ} (hi : i < g) {u : Wire 1 g} :
(program child g).dag.Adj u (node g (i + 1)) ↔ ∃ (a : Fin d), node g (child (i + 1) a) = u

In the computation DAG, the predecessors of a positive index are its children.

theorem Cslib.Circuits.Descending.fanInAtMost_program {d : ℕ} (child : ℕ → Fin d → ℕ) (g : ℕ) :
(program child g).FanInAtMost d

Every gate of a descending computation reads d wires.