The wiring graph of a binary circuit #
Fix a program over the full binary basis and an output gate. The reachable
wires are the output gate and, recursively, the argument wires of reachable
gates. The wiring graph has a vertex for every reachable wire and, for a
signal feeding f ≥ 2 gate slots, f - 1 copy vertices of degree three
through which the signal is routed. Its edges are the slots of reachable
gates and the incoming edge of every copy vertex.
Each edge carries one bit. A gate vertex checks that its outgoing edge carries
the gate's function of its two slot bits, the output gate checks that this
value is 1, and a copy vertex checks that all its incident edges agree. An
input vertex has no check; its outgoing edge is the port of the variable.
The main results are
network_computes: an input is accepted by the circuit exactly when some edge assignment satisfies every check and every port;loopless,maxDegreeLE_three,connected: the multigraph hypotheses of the graph-ordering lemma;card_edge_add_card_signal,card_slot,card_signal,card_copy_le: the edge and vertex counts, givingM - N = s' - n'fors'reachable gates andn'reachable inputs.
A wire is reachable when it is the output gate or an argument of a reachable gate.
- out
{n s : ℕ}
{p : Program Binary.signature n s}
{out : Fin s}
: Reach p out (Wire.gate out)
The output gate is reachable.
- arg
{n s : ℕ}
{p : Program Binary.signature n s}
{out g : Fin s}
(a : Fin 2)
: Reach p out (Wire.gate g) → Reach p out ((p.lines g).wires a)
An argument of a reachable gate is reachable.
Instances For
The reachable wires: the signals of the wiring graph.
Equations
- Algebraic.Cutwidth.Wiring.Signal p out = { w : Cslib.Circuits.Wire n s // Algebraic.Cutwidth.Wiring.Reach p out w }
Instances For
The argument slots of reachable gates.
Equations
- Algebraic.Cutwidth.Wiring.Slot p out = { t : Fin s × Fin 2 // Algebraic.Cutwidth.Wiring.Reach p out (Cslib.Circuits.Wire.gate t.1) }
Instances For
Reachability is decided classically; the graph is a proof object.
Equations
Equations
- Algebraic.Cutwidth.Wiring.instFintypeSlot p out = Subtype.fintype fun (t : Fin s × Fin 2) => Algebraic.Cutwidth.Wiring.Reach p out (Cslib.Circuits.Wire.gate t.1)
The signal read by a slot.
Instances For
The gate owning a slot.
Equations
- Algebraic.Cutwidth.Wiring.slotGate p out t = ⟨Cslib.Circuits.Wire.gate (↑t).1, ⋯⟩
Instances For
The slots fed by a signal.
Equations
- Algebraic.Cutwidth.Wiring.slots p out w = {t : Algebraic.Cutwidth.Wiring.Slot p out | Algebraic.Cutwidth.Wiring.slotSignal p out t = w}
Instances For
The number of slots fed by a signal.
Equations
- Algebraic.Cutwidth.Wiring.fanout p out w = (Algebraic.Cutwidth.Wiring.slots p out w).card
Instances For
A signal feeding f ≥ 2 slots is routed through f - 1 copy vertices.
Equations
- Algebraic.Cutwidth.Wiring.Copy p out = ((w : Algebraic.Cutwidth.Wiring.Signal p out) × Fin (Algebraic.Cutwidth.Wiring.fanout p out w - 1))
Instances For
Vertices: reachable wires and copy vertices.
Equations
- Algebraic.Cutwidth.Wiring.Vertex p out = (Algebraic.Cutwidth.Wiring.Signal p out ⊕ Algebraic.Cutwidth.Wiring.Copy p out)
Instances For
Edges: slots of reachable gates and the incoming edges of copy vertices.
Equations
- Algebraic.Cutwidth.Wiring.Edge p out = (Algebraic.Cutwidth.Wiring.Slot p out ⊕ Algebraic.Cutwidth.Wiring.Copy p out)
Instances For
The position of a slot among the slots of its signal.
Equations
- Algebraic.Cutwidth.Wiring.slotIndex p out t = ↑((Algebraic.Cutwidth.Wiring.slots p out (Algebraic.Cutwidth.Wiring.slotSignal p out t)).equivFin ⟨t, ⋯⟩)
Instances For
Slots of one signal are determined by their positions.
The copy vertex at which a slot is attached, when its signal has fan-out at least two: slots in order, with the last two slots sharing the last copy.
Equations
- Algebraic.Cutwidth.Wiring.copyIndex p out t = min (Algebraic.Cutwidth.Wiring.slotIndex p out t) (Algebraic.Cutwidth.Wiring.fanout p out (Algebraic.Cutwidth.Wiring.slotSignal p out t) - 2)
Instances For
The first endpoint of an edge: the signal vertex or copy vertex supplying it.
Equations
Instances For
The second endpoint of an edge: the gate reading a slot, or the copy vertex.
Equations
- Algebraic.Cutwidth.Wiring.snd p out (Sum.inl t) = Sum.inl (Algebraic.Cutwidth.Wiring.slotGate p out t)
- Algebraic.Cutwidth.Wiring.snd p out (Sum.inr c) = Sum.inr c
Instances For
The signal carried by an edge.
Equations
- Algebraic.Cutwidth.Wiring.signal p out (Sum.inl t) = Algebraic.Cutwidth.Wiring.slotSignal p out t
- Algebraic.Cutwidth.Wiring.signal p out (Sum.inr ⟨w, k⟩) = w
Instances For
The first outgoing edge of a signal with positive fan-out: the incoming edge of its first copy vertex, or its unique slot.
Equations
- One or more equations did not get rendered due to their size.
Instances For
The value a gate's operation takes on the bits of its two slots.
Equations
Instances For
The local check of a vertex. A reachable gate requires its outgoing edge,
if any, to carry its operation applied to its slot bits, the output gate
requires that value to be 1, and a copy vertex requires all its outgoing
edges to carry the bit of its incoming edge. Input vertices have no check.
Equations
- One or more equations did not get rendered due to their size.
- Algebraic.Cutwidth.Wiring.Check p out (Sum.inr c) x✝ = ∀ (e : Algebraic.Cutwidth.Wiring.Edge p out), Algebraic.Cutwidth.Wiring.fst p out e = Sum.inr c → x✝ e = x✝ (Sum.inr c)
Instances For
The variables read by the circuit: the reachable input wires.
Equations
- Algebraic.Cutwidth.Wiring.read p out = {j : Fin n | Algebraic.Cutwidth.Wiring.Reach p out (Cslib.Circuits.Wire.input j)}
Instances For
The vertex of an input variable.
Equations
- One or more equations did not get rendered due to their size.
Instances For
The edge carrying an input variable.
Equations
- One or more equations did not get rendered due to their size.
Instances For
The wiring graph as a constraint network.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Semantics #
The value of a gate is its operation applied to the values of its argument wires.
The bits carried by the edges under the circuit's own evaluation.
Equations
- Algebraic.Cutwidth.Wiring.traceAssignment p out x e = p.trace Algebraic.Binary.interpretation x ↑(Algebraic.Cutwidth.Wiring.signal p out e)
Instances For
The evaluation of an accepted input satisfies every check and every port.
Under a satisfying assignment, the incoming edge of every copy vertex of a signal carries the bit of the signal's first outgoing edge.
Under a satisfying assignment, every edge carrying a signal with positive fan-out carries the bit of the signal's first outgoing edge.
Under a satisfying assignment, every edge carries the circuit's value of its signal.
The wiring network accepts exactly the inputs accepted by the circuit.
Graph properties #
No edge joins a vertex to itself.
The edges leaving a vertex.
Equations
- Algebraic.Cutwidth.Wiring.outEdges p out v = {e : Algebraic.Cutwidth.Wiring.Edge p out | Algebraic.Cutwidth.Wiring.fst p out e = v}
Instances For
The edges entering a vertex.
Equations
- Algebraic.Cutwidth.Wiring.inEdges p out v = {e : Algebraic.Cutwidth.Wiring.Edge p out | Algebraic.Cutwidth.Wiring.snd p out e = v}
Instances For
A slot attached to a copy vertex has its position at least the copy's.
Every vertex has at most three incident edges.
The output gate's vertex.
Equations
- Algebraic.Cutwidth.Wiring.root p out = Sum.inl ⟨Cslib.Circuits.Wire.gate out, ⋯⟩
Instances For
Every copy vertex is joined to its signal vertex along the copy chain.
Every reachable wire is joined to the output gate.
The wiring graph is connected.
Counting vertices and edges #
The reachable gates.
Equations
- Algebraic.Cutwidth.Wiring.ReachableGate p out = { g : Fin s // Algebraic.Cutwidth.Wiring.Reach p out (Cslib.Circuits.Wire.gate g) }
Instances For
Edges plus signals equal vertices plus slots: both sides count every copy once.
Every reachable gate has two slots.
The signals are the reachable inputs and the reachable gates.
There are fewer copy vertices than slots.
The vertex count is at most n + 3 s.
Edges minus vertices is reachable gates minus reachable inputs, as reals.