Documentation

Complexity.Computability.Circuit.Frontier.Compiler

Structural properties and cycle-rank bounds for compiled circuit networks #

Complexity/Computability/Circuit/Frontier/Compiler/Network.lean compiles a circuit c with m outputs into a multigraph (Compiler.graph c) and a constraint network (Compiler.network c I Acc), proves exactness and uniqueness of satisfying assignments, and establishes the cut-splicing lemma Compiler.eval_splice.

This file proves the graph-theoretic and counting properties of Compiler.graph c:

Main definitions #

Main results #

References #

The shape of the graph #

The graph has no loops.

theorem Cslib.Circuits.Frontier.Compiler.ncard_slot_le {σ : Signature} {n m : ℕ} {c : Circuit σ n m} {r : ℕ} (hfan : c.FanInAtMost r) (w : Wire n c.size) :
{a : Slot c | Wire.gate (↑a).fst = w}.ncard ≤ r

A gate has at most r argument slots when the fan-in is at most r.

theorem Cslib.Circuits.Frontier.Compiler.eq_of_feeder_eq_junction {σ : Signature} {n m : ℕ} {c : Circuit σ n m} {j₁ j₂ j : Junction c} :
feeder j₁ = Vertex.junction j → feeder j₂ = Vertex.junction j → j₁ = j₂

Two junctions fed by the same junction are equal.

theorem Cslib.Circuits.Frontier.Compiler.maxDegreeLE {σ : Signature} {n m : ℕ} {c : Circuit σ n m} {r : ℕ} (hr : 2 ≤ r) (hfan : c.FanInAtMost r) :
(graph c).MaxDegreeLE (r + 1)

The degrees are bounded. When the gates have fan-in at most r ≥ 2, every vertex has degree at most r + 1: a gate vertex has its argument edges and one outgoing edge, a junction has three edges, and input vertices and output vertices have one. For fan-in two the graph is subcubic.

Connectivity #

The junctions of a signal are joined to its vertex along their chain.

Every junction is joined to the vertex of its signal.

The vertex of a signal is joined to each of its consumers.

The vertex of every signal is joined to the vertex of some output.

Every vertex is joined to the vertex of some output.

The graph is connected when some vertex is joined to every output vertex.

The graph of a circuit with one output is connected.

theorem Cslib.Circuits.Frontier.Compiler.exists_reachable_of_eval_ne {σ : Signature} {n m : ℕ} {c : Circuit σ n m} {U : Type u_1} {I : Interpretation σ U} {o : Fin m} {i : Fin n} {x y : Fin n → U} (hxy : ∀ (k : Fin n), k ≠ i → x k = y k) (hne : c.eval I x o ≠ c.eval I y o) :

An output depending on an input is joined to it. If changing only the input i changes the output o of a circuit, then the input i is read by its network, and its vertex is joined to the vertex of the output o.

Counting #

theorem Cslib.Circuits.Frontier.Compiler.read_network {σ : Signature} {n m : ℕ} {c : Circuit σ n m} {U : Type u_1} (I : Interpretation σ U) (Acc : Fin m → Set U) :
(network c I Acc).read = {i : Fin n | Reach c (Wire.input i)}

The inputs read by the network are the reachable inputs.

theorem Cslib.Circuits.Frontier.Compiler.ncard_readAt_le {σ : Signature} {n m : ℕ} {c : Circuit σ n m} {U : Type u_1} (I : Interpretation σ U) (Acc : Fin m → Set U) (v : Vertex c) :
((network c I Acc).readAt v).ncard ≤ 1

Each vertex reads at most one input.

theorem Cslib.Circuits.Frontier.Compiler.readIn_network {σ : Signature} {n m : ℕ} {c : Circuit σ n m} {U : Type u_1} (I : Interpretation σ U) (Acc : Fin m → Set U) (W : Set (Vertex c)) :
(network c I Acc).readIn W = {i : Fin n | ∃ (hi : Reach c (Wire.input i)), Vertex.signal ⟨Wire.input i, hi⟩ ∈ W}

The inputs read in a set of vertices are the reachable inputs whose vertex lies in it.

Signals are reachable inputs and reachable gates.

Instances For
    @[reducible, inline]

    The reachable inner gates: the reachable gates of positive arity.

    Instances For
      @[reducible, inline]
      abbrev Cslib.Circuits.Frontier.Compiler.InnerGateIn {σ : Signature} {n m : ℕ} (c : Circuit σ n m) (W : Set (Vertex c)) :

      The reachable inner gates whose vertex lies in W.

      Instances For

        The reachable inner gates are inner gates.

        The reachable inner gates in W are inner gates.

        There are at least as many reachable gates as reachable inner gates.

        theorem Cslib.Circuits.Frontier.Compiler.card_slot_le {σ : Signature} {n m : ℕ} {c : Circuit σ n m} {r : ℕ} (hfan : c.FanInAtMost r) (W : Set (Vertex c)) :

        There are at most r slots per reachable inner gate in W; constant gates have none.

        There are two edges per consumer.

        There is one vertex per signal, per consumer, and per output.

        The consumers are the argument slots of reachable gates and the outputs.

        Every signal has a consumer, so there are at least as many consumers as signals.

        Counting inside a closed set of vertices #

        Let W be a closed set of vertices, one with no edge leaving it. The edges at W are the feed and deliver edges of the junctions in W; the junctions in W are those of the consumers whose owner is in W, that is, the slots of the gates in W and the outputs in W; and the vertices of W are its signals, junctions, and outputs. A circuit with several outputs may have a disconnected graph, and the count applies to each component.

        theorem Cslib.Circuits.Frontier.Compiler.ncard_touching_add_ncard_readIn_le_card_innerGateIn {σ : Signature} {n m : ℕ} {c : Circuit σ n m} {U : Type u_1} (I : Interpretation σ U) (Acc : Fin m → Set U) {r : ℕ} (hfan : c.FanInAtMost r) {W : Set (Vertex c)} (hW : (graph c).edgeCut W = ∅) :
        ((graph c).touching W).ncard + ((network c I Acc).readIn W).ncard ≤ W.ncard + (r - 1) * Nat.card (InnerGateIn c W)

        The count inside a closed set, gate by gate. For fan-in at most r, the edges at a closed set of vertices W and the inputs read in W number at most (r - 1) s_W more than the vertices of W, where s_W counts the reachable inner gates in W.

        theorem Cslib.Circuits.Frontier.Compiler.ncard_touching_add_ncard_readIn_le {σ : Signature} {n m : ℕ} {c : Circuit σ n m} {U : Type u_1} (I : Interpretation σ U) (Acc : Fin m → Set U) {r : ℕ} (hfan : c.FanInAtMost r) {W : Set (Vertex c)} (hW : (graph c).edgeCut W = ∅) :
        ((graph c).touching W).ncard + ((network c I Acc).readIn W).ncard ≤ W.ncard + (r - 1) * c.innerSize

        The count inside a closed set. For fan-in at most r, the edges at a closed set of vertices W and the inputs read in W number at most (r - 1) s more than the vertices of W, where s counts the inner gates.

        theorem Cslib.Circuits.Frontier.Compiler.cycleRankOn_add_ncard_readIn_le {σ : Signature} {n m : ℕ} {c : Circuit σ n m} {U : Type u_1} (I : Interpretation σ U) (Acc : Fin m → Set U) {r : ℕ} (hfan : c.FanInAtMost r) {W : Set (Vertex c)} (hW : (graph c).edgeCut W = ∅) (hconn : W.ncard ≤ ((graph c).touching W).ncard + 1) :
        (graph c).cycleRankOn W + ((network c I Acc).readIn W).ncard ≤ (r - 1) * c.innerSize + 1

        The cycle rank of a closed set. For fan-in at most r, the cycle rank of a closed set of vertices W with at least |W| - 1 edges, for instance a connected component, and the number of inputs read in W add up to at most (r - 1) s + 1, where s counts the inner gates.

        Counting in the whole graph #

        theorem Cslib.Circuits.Frontier.Compiler.card_edge_add_ncard_read_le {σ : Signature} {n m : ℕ} {c : Circuit σ n m} {U : Type u_1} (I : Interpretation σ U) (Acc : Fin m → Set U) {r : ℕ} (hfan : c.FanInAtMost r) :

        The edge count. For fan-in at most r, the edges of the graph and the inputs read by the network number at most (r - 1) s more than the vertices, where s counts the inner gates. This is the count inside the closed set of all vertices.

        theorem Cslib.Circuits.Frontier.Compiler.cycleRank_add_ncard_read_le {σ : Signature} {n m : ℕ} {c : Circuit σ n m} {U : Type u_1} (I : Interpretation σ U) (Acc : Fin m → Set U) {r : ℕ} (hfan : c.FanInAtMost r) (hconn : (graph c).toSimpleGraph.Connected) :
        (graph c).cycleRank + (network c I Acc).read.ncard ≤ (r - 1) * c.innerSize + 1

        The cycle rank. For fan-in at most r, if the graph is connected (as it is for one output), its cycle rank and the number of inputs read by the network add up to at most (r - 1) s + 1, where s counts the inner gates.

        theorem Cslib.Circuits.Frontier.Compiler.card_vertex_le {σ : Signature} {n m : ℕ} {c : Circuit σ n m} {r : ℕ} (hfan : c.FanInAtMost r) :
        Nat.card (Vertex c) ≤ 2 * r * c.innerSize + 3 * m

        The number of vertices is at most 2 r s + 3 m for fan-in at most r, where s counts the inner gates and m the outputs.