The graph and constraint network of a circuit #
Fix a circuit c with m outputs over any signature, an interpretation I of the signature in
an alphabet U, and for each output o a set Acc o ⊆ U of accepting values. We build a
constraint network (Compiler.network c I Acc) whose accepted inputs are exactly those on which
every output o of the circuit lies in Acc o. A circuit deciding a set has one output; a
circuit computing a function accepts every value at each of its outputs.
Only the reachable wires matter: the outputs and, recursively, the wires read by reachable
gates (Reach). We call them signals (Signal). A signal is consumed by each argument slot of
a reachable gate that reads it (Slot), and each output is also consumed by its own output vertex
(Consumer). A circuit has unbounded fan-out, but a network of bounded degree cannot give a signal
one edge per consumer. So each signal w with consumers t₀, t₁, ... is routed through a chain of
junctions (Junction) j₀, j₁, ..., one per consumer:
w --- j₀ --- j₁ --- j₂ --- ...
| | |
t₀ t₁ t₂
Each junction has one feed edge from its predecessor in the chain (the signal itself for
j₀) and one deliver edge to its consumer. The constraints are:
- the vertex of an input
x_ireadsx_iand puts it on its outgoing edge; - the vertex of a gate
gputsgapplied to its incoming argument edges on its outgoing edge; - a junction puts its incoming value on both of its outgoing edges;
- the vertex of the output
orequires its incoming value to lie inAcc o.
Exactness (Compiler.satisfies_iff). The values of the circuit satisfy the network.
Conversely, in a satisfying assignment the junction constraints force all edges of a signal to
carry one value, and the gate constraints, read in program order, force that value to be the
value of the signal in the circuit (Compiler.eq_trace). So the satisfying assignment, if any,
is unique, and along any layout the read-once branching program of the network
(Cslib.Circuits.Frontier.Network.branchingProgram) is unambiguous
(Compiler.unambiguous_branchingProgram).
Outputs across a cut. If the runs of the circuit on two inputs x and y agree on the edge cut
of a set of vertices P, the separator lemma splices them: on an input that reads like x at P
and like y elsewhere, the outputs held in P are those of x and the others are those of y
(Compiler.eval_splice).
Graph-theoretic properties (looplessness, degree bounds, connectivity) and cycle-rank / read-count
inequalities are proved in Complexity/Computability/Circuit/Frontier/Compiler.lean.
Main definitions #
Cslib.Circuits.Frontier.Compiler.Reach,Cslib.Circuits.Frontier.Compiler.Signal,Cslib.Circuits.Frontier.Compiler.Slot,Cslib.Circuits.Frontier.Compiler.Consumer,Cslib.Circuits.Frontier.Compiler.Junction: reachable wires, argument slots, consumers, and fan-out junctions.Cslib.Circuits.Frontier.Compiler.Vertex,Cslib.Circuits.Frontier.Compiler.Edge,Cslib.Circuits.Frontier.Compiler.graph: the multigraph of a circuit.Cslib.Circuits.Frontier.Compiler.network: the constraint network of a circuit.
Main results #
Cslib.Circuits.Frontier.Compiler.satisfies_iff,Cslib.Circuits.Frontier.Compiler.accepted_network,Cslib.Circuits.Frontier.Compiler.satisfies_unique: exactness and uniqueness of satisfying assignments.Cslib.Circuits.Frontier.Compiler.unambiguous_branchingProgram: the branching program of every layout is unambiguous.Cslib.Circuits.Frontier.Compiler.eval_splice: splicing outputs across a vertex cut.
References #
Signals, consumers, and junctions #
A wire of a circuit is reachable when it is an output or is read by a reachable gate.
- output {σ : Signature} {n m : ℕ} {c : Circuit σ n m} (o : Fin m) : Reach c (c.outputs o)
The outputs are reachable.
- arg {σ : Signature} {n m : ℕ} {c : Circuit σ n m} {g : Fin c.size} (a : Fin (σ.Arity (c.program.lines g).op)) : Reach c (Wire.gate g) → Reach c ((c.program.lines g).wires a)
The wires read by a reachable gate are reachable.
Instances For
The consumer of a junction reads the signal of the junction.
The graph #
The vertices: one per signal, one per junction, and one per output.
- signal {σ : Signature} {n m : ℕ} {c : Circuit σ n m} (w : Signal c) : Vertex c
The vertex of a signal: an input vertex or a gate vertex.
- junction {σ : Signature} {n m : ℕ} {c : Circuit σ n m} (j : Junction c) : Vertex c
A junction.
- output {σ : Signature} {n m : ℕ} {c : Circuit σ n m} (o : Fin m) : Vertex c
The vertex of an output, which consumes it.
Instances For
No junction feeds itself.
The graph of a circuit: the signals, junctions and outputs, joined by the feed and deliver edges of the junctions.
Instances For
An edge entering the vertex of a signal delivers one of the argument slots of its gate.
The network #
The value that the vertex of a signal puts on its outgoing edge: the input itself for an input wire, and the operation of the gate applied to its incoming edges for a gate wire.
Instances For
The constraint at each vertex: the vertex of a signal emits the value of the signal, a junction copies its incoming value onto its outgoing edges, and the vertex of an output requires its incoming value to be accepting.
Instances For
An input is read only at the vertex of its signal.
A reachable input is read at the vertex of its signal.
The constraint network of a circuit, accepting at the output o the values in
Acc o.
Instances For
Exactness #
The values of the circuit satisfy the network: every edge carries the value of its signal.
In a satisfying assignment, the feed edges along the chain of junctions of a signal carry the value of its first edge.
In a satisfying assignment, every edge carries the value of the first edge of its signal.
In a satisfying assignment, the first edge of every signal carries its value in the circuit.
Uniqueness. A satisfying assignment puts on every edge the value of its signal in the circuit.
Exactness. An assignment satisfies the network exactly when every output of the circuit is accepted and the assignment puts on every edge the value of its signal in the circuit.
Exactness. The network accepts exactly the inputs on which every output o of the
circuit lies in Acc o.
Uniqueness. An input has at most one satisfying assignment.
The branching program of the network along any layout is unambiguous.
Outputs across a cut #
Outputs across a cut. In the network of a circuit computing a function, let the runs on
two inputs x and y agree on the edge cut of a set of vertices P, and let z read like x
at P and like y elsewhere. Then the outputs of z are those of x at the output vertices in
P, and those of y at the others.