An operad (also multicategory / coloured operad; Leinster [Lei04]) consists of
(i) a collection of types (objects, colours); (ii) for each tuple of types, a set of operations of that arity — think “boxes with input ports of types and output type ”, or functions of arguments; (iii) substitution : plug an -ary operation into the -th argument of an -ary one to get an -ary operation; (iv) identities ,
satisfying generalized associativity and identity laws. Operads are a “meta-compositional structure”: whereas free and presented structures tailor instances of preorders, categories or props, operads tailor the algebraic structures themselves. “Making tea is a 2-ary operation: you need warm water and tea leaves.”
Sources: 7 Sketches §6.5 (Rough Definition 6.91, Examples 6.92–6.94, Definition 6.97, Rough Definition 6.98, Exercise 6.96), §6.6; [May72; Lei04; RS13; Spi13; VSL15]; Catlab (
oapplyfor operad algebras on wiring diagrams); CTfS §5.4 (Warning 5.4.0.5, Definition 5.4.1.1, Examples 5.4.1.2–5.4.1.3, Definitions 5.4.1.6, 5.4.1.8, Applications 5.4.2.1–5.4.2.10)
Examples
- (Example 6.93): types are sets, operations are functions of variables, substitution plugs one function into an argument of another, identities are identity functions.
- (Example 6.94): types , operations of arity are cospans in , substitution by Pushout, identity cospans. An operation is drawn as an Undirected Wiring Diagram: inner circles with ports, an outer circle with ports, and junction nodes; e.g. Eq. (6.95) is an operation of arity with apex . Substitution = inserting one wiring diagram into a circle of another (7S Exercise 6.96). This is the operadic analogue of with the left/right distinction removed: “circuits just have a single boundary interface, not domains and codomains” (Eqs. 6.89–6.90).
- From any Symmetric Monoidal Category (Definition 6.97): the underlying operad has types , operations , substitution . Monoidal functors give operad functors.
- Context-free grammars are to operads as graphs are to categories (Example 6.92): syntactic categories (noun, determiner, noun phrase, sentence) are types, production rules are generating operations, and a grammar presents a free operad [HMP98].
- Operads of wiring diagrams with constraints (e.g. no “passing wires”, needed for feedback in dynamical systems [VSL15]); the operad of cobordisms; “there is an operad for operads” ([Lei04, 2.2.23]).
Operads for self-similarity (Category Theory for Scientists §5.4)
CTfS (which, warning of the clash with the classical one-object usage, says operad for multicategory) stresses operads as a language for self-similar, hierarchical structure — agents made of agents, materials made of materials.
- Little squares (CTfS Example 5.4.1.3): one type ; an operation is a placement of non-overlapping squares inside a square; substitution places tiny squares inside each small square and rescales. With several shapes (squares, circles, triangles) as types one gets a coloured version (CTfS Exercise 5.4.1.4).
- Materials (CTfS Applications 5.4.2.1–5.4.2.2): a tendon is collagen fibres assembled in series and then in parallel; each fibre is fibrils assembled likewise, and so on down to tropocollagen molecules. An operad models the arrangements; an algebra says which actual materials fill each slot, another algebra which strengths they can have, and a morphism of algebras — assigning a strength to every material compatibly with all arrangements — is “a very precise goal for the field of material mechanics”.
- Relations and wiring diagrams (CTfS Examples 5.4.2.4, 5.4.2.8): the operad whose operations are relations , composed by fiber products; the operad of wiring diagrams, whose objects are “circles with cables”, each cable carrying a set of values (e.g. or ), composed by pushouts. Sending a circle to the product of its cables’ value sets is an operad morphism : a phenomenon experienced by an entity is a choice of value on every cable. Applications: an entity survives (or a bureaucracy allows) exactly those phenomena that each sub-entity allows; connectomes and supply chains; Radul–Sussman propagator networks.
- Every category is an operad with only unary operations, and “just like a schema is a category presentation, one can present operads by generators and relations; an algebra on an operad corresponds to an instance on a schema” (CTfS Remark 5.4.1.9).
Operad functors (Rough Definition 6.98): a map of types and maps preserving substitution and identities. Algebras are operad functors : ways to fill the boxes of a wiring-diagram grammar.
Operads conclude the “informal hierarchy of compositional structures: preorders, categories, monoidal categories, operads”.
Docs: Relational programs / UWDs · Wiring diagrams
using Catlab, Catlab.WiringDiagrams
# operations of the operad Cospan as undirected wiring diagrams (Exercise 6.96)
f = UndirectedWiringDiagram(2) # outer arity 2
add_box!(f, 2); add_box!(f, 2) # two inner circles with two ports each
add_junctions!(f, 3)
set_junction!(f, [1, 2, 2, 3]) # box1 ports ↦ j1, j2 ; box2 ports ↦ j2, j3
set_junction!(f, [1, 3], outer=true) # f ∈ Cospan(2, 2; 2)
g = UndirectedWiringDiagram(0) # g ∈ Cospan(2, 2, 2; 0): a closed triangle
add_box!(g, 2); add_box!(g, 2); add_box!(g, 2)
add_junctions!(g, 3)
set_junction!(g, [1, 2, 2, 3, 3, 1])
gf = ocompose(g, 1, f) # substitution g ∘₁ f, arity (2, 2, 2, 2; 0)
nboxes(gf), length(ports(gf, outer=true)) # (4, 0)-- Mathlib does not (yet) have a general operad/multicategory library; the operad underlying a
-- symmetric monoidal category has operations Hom (C₁ ⊗ ⋯ ⊗ Cₙ) D.-- an untyped operad: n-ary operations with substitution ∘_i (schematic)
class Operad op where
arity :: op -> Int
identity :: op -- arity 1
subst :: op -> Int -> op -> op -- g ∘_i f: plug f into the i-th argument of g
-- the operad of functions: newtype Fn = Fn ([Double] -> Double) with arity tracked separately