definition annotation

Wiring diagrams (string diagrams) are visual representations for building new relationships from old. Boxes are relationships, wires are objects/resources, and the diagram itself shows how relationships combine. Invented in the context of monoidal categories by Joyal and Street, they have long been used informally by engineers and scientists. Wires and boxes are icons; more icons appear as more structure is assumed.

Sources: 7 Sketches §2.2.2 (Eq. 2.13 “different styles”), §4.4.2, §5.2, §6.3.2, §6.5.1; DaoFP §15.1 (string diagrams for monads and adjunctions); Kittenlab Lecture 6 (directed port graphs, wiring diagrams as ACSets), 15 (undirected wiring diagrams as cospans); CTfS Examples 5.4.2.4, 5.4.2.8, Applications 5.4.2.5–5.4.2.10

Styles, by structure

structurediagram stylenote
Preordersingle-input, single-output boxes in serieschaining
Symmetric Monoidal Preorderboxes with many inputs/outputs in series and parallel; crossing wiresWiring Diagrams for Monoidal Preorders
+ discard axiomwires may terminatemanufacturing
+ copy axiomwires may splitinformatics
Categoryboxes with one input and one output in seriesmorphisms; the Free Category on a graph
Monoidal Categoryas for monoidal preorders, but boxes are named morphisms (§4.4.2)Symmetric Monoidal Category diagrams
Propboxes with inputs and outputs on the objects port graphs, signal flow graphs
Compact Closed Categorywires may bend backwards (cups and caps)Feas
Hypergraph Categorywires may split, merge, start and end freely (spiders)undirected wiring diagrams, cospans
Operadboxes nested inside boxes, composed by substitution-algebras, decorated cospans
2-categories / adjunctionsstring diagrams with regions for categories, strings for functors, dots for natural transformationsDaoFP §15.1

Soundness. A wiring diagram is a graphical proof: if all interior boxes are valid, the exterior box is valid (Wiring Diagrams for Monoidal Preorders). In a monoidal category two diagrams that are isotopic denote equal morphisms — the coherence theorem of Joyal–Street; for operads a wiring diagram is literally a morphism of the operad or .

The operad of wiring diagrams (Category Theory for Scientists §5.4.2)

CTfS’s operad : an object is a circle with finitely many cables, each carrying a set of values (black wires , red wires ); an operation ” is composed of in the following way” is a picture of circles inside a circle with cables joined, formalized by a jointly surjective cospan of cable sets; composition is substitution, computed by pushout. The semantics sends a circle to the set of value-assignments on its cables, and a wiring diagram to the relation between local and global assignments — an operad morphism into the operad of relations. Applications: an entity survives exactly the phenomena that each of its parts survives; a mind or an economy analyzed through its connectome or supply chain; Radul–Sussman propagator networks (Operad, Operad Algebra).

Wiring diagrams as data (Kittenlab Lecture 6)

A directed port graph is an ACSet on the schema with boxes, input ports, output ports and wires (source: an output port, target: an input port); a directed wiring diagram additionally has outer ports. Catlab’s WiringDiagram and UndirectedWiringDiagram implement these, and oapply evaluates an operad algebra on a diagram.

Docs: Relational programs / UWDs · Wiring diagrams · Vignette: wiring diagram basics — Kittenlab Lecture 6

using Catlab, Catlab.WiringDiagrams
# a directed wiring diagram with two boxes composed in series (Catlab.WiringDiagrams)
f = Box(:f, [:A], [:B]); g = Box(:g, [:B], [:C])
d = WiringDiagram([:A], [:C])
fv, gv = add_box!(d, f), add_box!(d, g)
add_wires!(d, [(input_id(d), 1) => (fv, 1), (fv, 1) => (gv, 1), (gv, 1) => (output_id(d), 1)])
nboxes(d), nwires(d)      # (2, 3)
 
# an undirected wiring diagram via the @relation macro (hypergraph style)
uwd = @relation (x, z) begin
  R(x, y); S(y, z)
end
-- a wiring diagram as a free symmetric monoidal expression (syntax tree)
data WD = Box String [String] [String]   -- name, input wires, output wires
        | Seq WD WD                      -- series composition
        | Par WD WD                      -- parallel composition
        | Id [String]
        | Swap String String