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.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 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.

@[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

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

      There are two edges per consumer.

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

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

      The number of signals is at most r * c.size + m for fan-in at most r.

      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 {σ : 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.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.