definition theorem example

Let have finite colimits and be a symmetric monoidal functor, the decoration functor. An -decorated cospan is a Cospan in together with an element , the decoration. Intuition (): is the set of legal decorations on a set of nodes — e.g. all circuit diagrams with vertex set — and are the left and right external ports (terminals) mapping into the nodes.

Composition. Given and , compose the cospans by Pushout and decorate the new apex with

first put the two decorations side by side with , then glue along the identifications specified by using the copairing of the pushout maps. Monoidal product: coproduct cospans decorated by — “stacking”.

Theorem 6.77. There is a Hypergraph Category with the objects of and morphisms (equivalence classes of) -decorated cospans; its symmetric monoidal and hypergraph structures come from . With the constant functor one recovers (7S Exercise 6.78).

Sources: 7 Sketches §6.4.2–6.4.3 (Definition 6.75, Eq. 6.76, Theorem 6.77, Exercises 6.78–6.88), §6.6; [Fon15; Fon18; BF15; BFP16; BP17]; generalization: structured cospans (Catlab).

Open electric circuits (§6.4.3)

Fix a set of components . A -circuit is a Graph with a labelling (edge directions are an artifact of the representation; 7S Exercise 6.79). The decoration functor sends to the set of -circuits on , and to — merging nodes (7S Exercise 6.80); takes the disjoint union of two circuits (Eq. 6.81, 7S Exercise 6.82). Morphisms of are open circuits: a cospan plus a circuit on nodes, e.g. the battery (Eq. 6.83, 7S Exercise 6.84). Composing two open circuits pushes out over the shared terminal and glues the circuits (7S Exercise 6.86 recomputes Eq. 6.74); monoidal product stacks (Eq. 6.87); closing off with the Frobenius cup and cap decorated by empty circuits gives a closed circuit (7S Exercise 6.88) — the light-switch circuit of §6.1.

Decorated cospans yield “an explicit category equipped with Frobenius structures that get around the strictures of domains and codomains”; -algebras are more general (they produce every hypergraph prop), and the functor is such an algebra (Example 6.100). Circuit semantics (e.g. the relation between boundary potentials and currents for passive linear circuits) is a further hypergraph functor to [BF15].

Docs: FinSets · Structured cospans · ACSets API · Theories & presentations

using Catlab
# Catlab implements decorated / structured cospans; open graphs and open Petri nets are built-in examples.
# Open circuits as structured cospans of labelled graphs: the "decoration" is the graph on the apex.
@present SchCircuit <: SchGraph begin
  Label::AttrType
  label::Attr(E, Label)
end
@acset_type Circuit(SchCircuit, index=[:src, :tgt])
const OpenCircuitOb, OpenCircuit = OpenACSetTypes(Circuit, :V)      # feet are finite sets mapping to nodes
battery = @acset Circuit{Symbol} begin V = 2; E = 1; src = [1]; tgt = [2]; label = [:battery] end
open_battery = OpenCircuit{Symbol}(battery, FinFunction([1], 2), FinFunction([2], 2))   # 1 → 2 ← 1, Eq. (6.83)
resistor = @acset Circuit{Symbol} begin V = 2; E = 1; src = [1]; tgt = [2]; label = [:ohm5] end
open_res = OpenCircuit{Symbol}(resistor, FinFunction([1], 2), FinFunction([2], 2))
composite = compose(open_battery, open_res)          # glue along the shared terminal (pushout)
apex(composite)                                       # a Circuit with 3 nodes and 2 labelled edges
-- an F-decorated cospan: a cospan of finite sets with a decoration on the apex
data DecoratedCospan dec = DecoratedCospan
  { leftLeg :: [Int], rightLeg :: [Int]   -- functions A → N, B → N as lists of node indices
  , nodes :: Int, decoration :: dec }
-- a C-circuit decoration on n nodes: labelled edges
data Circuit = Circuit { edges :: [(Int, Int, String)] }
-- composition: pushout of the middle feet, then relabel node indices in both circuits and take the union