Structural properties and cycle-rank bounds for compiled circuit networks #
CslibFrontier/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:
- Shape and connectivity. The graph is loopless (
loopless), has maximum degree at mostr + 1when gates have fan-in at mostr ≥ 2(maxDegreeLE), and is connected whenever the circuit has one output (connected). Cutting along the connected component of an output vertex shows that an output depending on an input is joined to the vertex of that input (exists_reachable_of_eval_ne). - Counting. With
Cconsumers,Wsignals andmoutputs, the graph has2 Cedges andW + C + mvertices, so its cycle rank isC - W - m + 1: the number of argument slots minus the number of signals, plus one. A gate of aritykhaskslots, so it contributesk - 1to the cycle rank, and a reachable input contributes-1. Gates of arity zero only lower the cycle rank and gates of arity one contribute0, so when the graph is connected its cycle rank is at most(r - 1) s + 1 - |read|forsmultiary gates (Circuit.multiarySize, hence also forCircuit.innerSize) and fan-in at mostr(cycleRank_add_ncard_read_le_multiarySize,cycleRank_add_ncard_read_le). The count holds inside every closed set of vertices, for instance a connected component (cycleRankOn_add_ncard_readIn_le_multiarySize,cycleRankOn_add_ncard_readIn_le), and the count of the whole graph is its case for the set of all vertices.
Main definitions #
Cslib.Circuits.Frontier.Compiler.InnerGate,Cslib.Circuits.Frontier.Compiler.InnerGateIn: reachable inner gates (positive arity), globally and within a vertex setW.
Main results #
Cslib.Circuits.Frontier.Compiler.loopless,Cslib.Circuits.Frontier.Compiler.connected: the graph is loopless, and connected when the circuit has one output.Cslib.Circuits.Frontier.Compiler.connected_of_reachable,Cslib.Circuits.Frontier.Compiler.exists_reachable_of_eval_ne: connectivity from a common vertex; an output depending on an input is joined to its vertex.Cslib.Circuits.Frontier.Compiler.maxDegreeLE: for fan-in at mostr ≥ 2, the degrees are at mostr + 1; for fan-in two the graph is subcubic.Cslib.Circuits.Frontier.Compiler.ncard_touching_add_ncard_readIn_le_multiarySize,Cslib.Circuits.Frontier.Compiler.cycleRankOn_add_ncard_readIn_le_multiarySize,Cslib.Circuits.Frontier.Compiler.ncard_touching_add_ncard_readIn_le,Cslib.Circuits.Frontier.Compiler.cycleRankOn_add_ncard_readIn_le: the edge and cycle-rank counts inside a closed set of vertices.Cslib.Circuits.Frontier.Compiler.cycleRank_add_ncard_read_le_multiarySize,Cslib.Circuits.Frontier.Compiler.cycleRank_add_ncard_read_le: the cycle rank and the number of inputs read add up to at most(r - 1) s + 1, wherescounts the multiary (or inner) gates.Cslib.Circuits.Frontier.Compiler.card_signal_le_innerSize,Cslib.Circuits.Frontier.Compiler.card_signal_le: there are at mostr s + m(hence at mostr * c.size + m) reachable signals.Cslib.Circuits.Frontier.Compiler.card_vertex_leandCslib.Circuits.Frontier.Compiler.card_edge_lebound the vertex count by2 r s + 3 mand the edge count by2 (r s + m).
References #
The shape of the graph #
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.
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 #
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.
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.
The count inside a closed set, charging only multiary gates. 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 multiary gates (arity ≥ 2); constant and unary
gates are free.
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.
The cycle rank of a closed set, charging only multiary gates. For fan-in at most r, the
cycle rank of a closed set of vertices W with at least |W| - 1 edges and the number of inputs
read in W add up to at most (r - 1) s + 1, where s counts the multiary gates.
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 #
The cycle rank, charging only multiary gates. 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 multiary gates (arity ≥ 2).
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.
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.