Lectures onType Theory
Chapter 159
Chapter 159Core route

Symmetric Monoidal Categories and Graphical Linear Semantics

Take the file program of section 18.3. A term Γ; f1:File, f2:File  closef1readf2 : 1(FileBytes) uses two independently owned handles, once each. Suppose its meaning is a map out of a product [[File]]×[[File]] in a category with finite products. Then the diagonal Δ:XX×X exists, and composing with it produces a map out of one handle that behaves as if it owned two: [[closef1readf2]]Δ. The typing rule T-TensorI forbids exactly that term, since Δ1Δ2 is defined only for disjoint domains. A terminal object is no better: it provides X1 for every X, a map that discards a live handle, and the calculus has no such term either.

So a semantics of λlin may not interpret the comma of a linear context as a categorical product. It needs a binary operation on objects that carries no diagonal and no projection. This chapter derives that operation from the equations the file program forces, and then makes the resulting calculus graphical.

The operation forced by rebracketing

Write XY for the object interpreting two independently owned resources, with no assumption yet beyond its existence on objects. Three demands follow immediately from the syntax.

Definition 159.1 — Tensor data

A tensor on a category C consists of a functor :C×CC, an object I, and three families of isomorphisms αX,Y,Z:(XY)Z  X(YZ),λX:IXX,ρX:XIX, each natural in every argument.

Functoriality is not decoration: it is the statement that a linear function may be applied inside a tensor without disturbing the other component. In the running example, readid is the map that reads the first handle and leaves the second untouched, and functoriality is (gf)(gf)=(gg)(ff),idXidY=idXY, which says that operating on the two components in either order or simultaneously gives the same thing.

Example 159.2 — Naturality is a program equation

Let f:=close and g:=read. The two terms let xy=(ff1)(gf2) in and(fg) applied after regrouping are equal by T-TensorI and the β-rule for tensor. Semantically this is naturality of α: the square αX,Y,Z((fg)h)=(f(gh))αX,Y,Z commutes for all f,g,h. Naturality is therefore checked before any coherence axiom is stated: it is a consequence of the calculus, not an assumption about pictures.

Proposition 159.3 — The pentagon is forced

Suppose C carries tensor data and that for every four objects the two composites ((WX)Y)Z  W(X(YZ)) built from α agree. Then the pentagon identity αW,X,YZαWX,Y,Z=(idWαX,Y,Z)αW,XY,Z(αW,X,YidZ) holds; conversely the pentagon identity implies the agreement.

Proof of Proposition 159.3 — The pentagon is forced

Proof. There are exactly five ways to move one pair of parentheses at a time from ((WX)Y)Z to W(X(YZ)), and they form a pentagon whose two sides are the two displayed composites: the left side reassociates the outer two brackets and then the inner, the right side reassociates innermost first. The hypothesis says the two sides are equal, which is the identity. The converse is immediate. ◻

Proposition 159.4 — The triangle is forced

If the two composites (XI)YXY built from α,ρ,λ agree, then (idXλY)αX,I,Y=ρXidY, and conversely.

Proof of Proposition 159.4 — The triangle is forced

Proof. The two composites are the two sides of the displayed equation; there are no others, since each of ρ and λ can be applied in exactly one position. ◻

Definition 159.5 — Monoidal category

A monoidal category is a category with tensor data (definition 159.1) satisfying the pentagon (proposition 159.3) and the triangle (proposition 159.4).

Lemma 159.6 — Two derived unit equations

In a monoidal category, λI=ρI and idXλY determines λXY through α.

Proof of Lemma 159.6 — Two derived unit equations

Proof. For the first, apply the triangle at X=I and use naturality of λ at λY to cancel α; the two resulting arrows III agree. For the second, naturality of λ in its argument gives λXY=(λXidY)α1, and the triangle rewrites the right-hand side as stated. ◻

Exchange, and why symmetry is a further axiom

Two independently owned handles may be presented in either order; a semantics must therefore relate XY and YX.

Definition 159.7 — Braiding and symmetry

A braiding is a natural isomorphism γX,Y:XYYX satisfying the two hexagons αY,Z,XγX,YZαX,Y,Z=(idYγX,Z)αY,X,Z(γX,YidZ),αZ,X,Y1γXY,ZαX,Y,Z1=(γX,ZidY)αX,Z,Y1(idXγY,Z). It is a symmetry when γY,XγX,Y=idXY. A symmetric monoidal category is a monoidal category with a symmetry.

Proposition 159.8 — Braided but not symmetric

There is a braided monoidal category in which γX,XγX,XidXX.

Proof of Proposition 159.8 — Braided but not symmetric

Proof. Let B have one object with the unique operation, and let homB(,) be the group Z under addition, with composition addition and on arrows also addition. This is a strict monoidal category: associativity and units are the group laws. Put γ:=1Z. Naturality is automatic, since the group is abelian; both hexagons reduce to 1+0+0=0+0+1, which holds. But γγ=20=id. So the braiding is not a symmetry: a crossing composed with itself is a nontrivial arrow, not the identity. ◻

Remark 159.9 — What the counterexample models

In a braided setting the two ways of exchanging two resources — passing the first in front of the second, or behind — are different arrows. For linear programs no such distinction is available: the calculus of definition 18.5 identifies a linear context with a finite map, so exchange is equality of maps and applying it twice is the identity. Hence the symmetric axiom, and not merely the braided one, is what λlin requires.

Free constructions and normal forms

Definition 159.10 — Typed signature

A signature S consists of a set of generating objects and, for each pair of finite lists X,Y of generating objects, a set of generating arrows f:XY.

Construction 159.11 — The free strict symmetric monoidal category

Let FS(S) have as objects the finite lists of generating objects, with concatenation and I the empty list. Arrows are generated by the fS, the identities, a symmetry γX,Y for each pair of lists, composition and , modulo the equations of a strict symmetric monoidal category — associativity and units on the nose, functoriality of , naturality of γ, the hexagons and the symmetry axiom.

Theorem 159.12 — Normal form and decidable equality

Every arrow of FS(S) is equal to one of the form σk(gkid)  σ1(g1id)σ0, in which each gi is a single generator and each σi is a permutation built from symmetries; and two such forms denote the same arrow if and only if they have the same sequence of generators up to the equivalence generated by exchanging adjacent generators acting on disjoint parts of the list together with the induced permutation. Consequently equality of arrows in FS(S) is decidable when S is finite and the arrows are given by finite expressions.

Proof of Theorem 159.12 — Normal form and decidable equality

Proof. Existence. Any expression is a composite of layers, each of which is a tensor of generators, identities and symmetries. Using functoriality of , split a layer containing two generators into two consecutive layers, one generator each; using naturality of γ, move every symmetry past a generator layer, at the cost of relabelling which positions the generator acts on. Repeating drives all symmetries into the interleaving permutations σi, giving the displayed form. The procedure terminates because each step strictly decreases the number of generators occurring in a common layer, and the number of layers is bounded by the number of generators.

Uniqueness. Interpret FS(S) in the category whose objects are lists and whose arrows XY are pairs of a sequence of generators and a bijection recording positions — this is a symmetric monoidal category, and the interpretation sends the displayed normal form to its own data. Hence two normal forms with different generator sequences up to the stated equivalence have different images and are not equal. Conversely, exchanging adjacent generators on disjoint positions is derivable from functoriality, so the equivalence is sound.

Decidability. Normalisation is effective and the equivalence on generator sequences is decidable, being generated by finitely many adjacent exchanges on a finite sequence. ◻

Remark 159.13 — Scope of the coherence used

Theorem 159.12 is a statement about the free strict symmetric monoidal category on a signature, which is all this chapter needs: every arrow of a monoidal category is, by proposition 159.3 and proposition 159.4, equal to one in which the bracketing is immaterial, so the strict free category computes the equations of the non-strict one. The stronger topological coherence theorems — that a diagram of a certain shape in the plane determines an arrow up to isotopy — are not proved here and are not used; where a diagram below is called a proof, it is because it abbreviates a composite already shown equal by the equations above.

String diagrams

Definition 159.14 — Diagrams

A diagram over a signature S consists of a finite set of boxes, each labelled by a generator f:XY and carrying |X| input ports and |Y| output ports typed accordingly; a list of free input ports and a list of free output ports; and a bijection wiring each output port (of a box or free input) to exactly one input port (of a box or free output) with matching type, such that the directed graph on boxes induced by the wiring is acyclic. Two diagrams are equal when there is a type-preserving bijection of boxes and ports respecting the wiring. Sequential composition plugs the free outputs of one into the free inputs of another; parallel composition places two diagrams side by side and concatenates the free lists.

Theorem 159.15 — Soundness and completeness for the free fragment

Sending a diagram to the arrow of FS(S) obtained by reading it in any order compatible with the acyclic structure is well defined, and it is a bijection between diagrams from X to Y and arrows XY of FS(S).

Proof of Theorem 159.15 — Soundness and completeness for the free fragment

Proof. Well defined. Two compatible orders differ by transpositions of adjacent boxes acting on disjoint ports, and by theorem 159.12 those give equal arrows.

Surjective. Given a normal form, build the diagram with one box per generator, wired according to the interleaving permutations.

Injective. A diagram is recovered from the normal form of its arrow: by the uniqueness clause of theorem 159.12 the arrow determines the sequence of generators up to disjoint exchange and the accompanying bijection on positions, which is exactly the data of the wiring up to the bijection allowed in definition 159.14. ◻

Remark 159.16 — What a picture is allowed to prove

Theorem 159.15 licenses one kind of argument: two diagrams that are equal as combinatorial objects denote equal arrows, and conversely. It licenses nothing about deformations of a drawing on paper — an ambient isotopy argument requires a topological coherence theorem, which remark 159.13 does not supply. Where a proof below reasons diagrammatically, the diagram is used as notation for a normal form.

Closure, and the interpretation of the linear calculus

The tensor interprets the comma of a linear context. Linear implication needs one more operation.

Definition 159.17 — Monoidal closed

A symmetric monoidal category is closed when for every object Y the functor Y has a right adjoint Y; that is, there are natural bijections Λ: homC(XY,Z)  homC(X,YZ), with counit evY,Z:(YZ)YZ.

Lemma 159.18 — The two inverse laws

In a symmetric monoidal closed category, ev(Λ(f)idY)=f for every f:XYZ, and Λ(ev(gidY))=g for every g:XYZ.

Proof of Lemma 159.18 — The two inverse laws

Proof. The first is the triangle identity of the adjunction at f, the second its mate; naturality of Λ in X is what makes both statements hold for all f and g rather than for the identity alone. ◻

Definition 159.19 — Interpretation of λ _ lin

Fix a symmetric monoidal closed category C and an object [[b]] for each atomic type. Extend by [[1]]:=I,[[AB]]:=[[A]][[B]],[[AB]]:=[[A]][[B]], and interpret a linear context Δ=x1:A1,,xn:An by [[A1]][[An]], bracketed to the right. A derivation of Γ;Δe:A with Γ empty is interpreted by an arrow [[Δ]][[A]]: T-LVar by an identity; T-TensorI by of the two subarrows precomposed with the associativity and symmetry isomorphism realising the split Δ1Δ2; T-TensorE by composing with the subarrow for e1 in the first component; T-LolliI by Λ; T-LolliE by ev after of the two subarrows; and T-OneI, T-OneE by λ and ρ.

Lemma 159.20 — Independence of the split isomorphism

The isomorphism [[Δ]][[Δ1]][[Δ2]] used in definition 159.19 is uniquely determined by the split Δ=Δ1Δ2.

Proof of Lemma 159.20 — Independence of the split isomorphism

Proof. Any two such isomorphisms are built from α, λ, ρ and γ and induce the same permutation of the variables, since both realise the same split. Two arrows of FS(S) built from structural isomorphisms with the same underlying permutation are equal by the uniqueness clause of theorem 159.12, which has no generators to distinguish them. The claim then transfers to C along the interpretation of the free category. ◻

Theorem 159.21 — Semantic substitution and soundness

Let Γ be empty throughout. If Δ1e1:A and Δ2,x:Ae2:C then [[e2[e1/x]]]=[[e2]](id[[Δ2]][[e1]])s, where s is the split isomorphism of lemma 159.20. Consequently, if ee by the β- and η-rules of definition 18.4 then [[e]]=[[e]].

Proof of Theorem 159.21 — Semantic substitution and soundness

Proof. Substitution. Induction on the derivation of e2. In the variable case e2=x and both sides are [[e1]] after the unit isomorphism. In the tensor-introduction case the linear context splits, x lies in exactly one part by the disjointness condition of definition 18.1, and the induction hypothesis applies there while the other component is untouched — this is functoriality of . In the abstraction case the claim follows from naturality of Λ in its first argument. In the application case it follows from naturality of ev, which is the counit of the adjunction. Lemma 159.20 guarantees that the structural isomorphisms produced by the two sides agree.

Soundness. Each reduction rule is now an equation already available. The β-rule for is the first law of lemma 159.18 combined with the substitution equation; the β-rule for is the substitution equation applied twice, using functoriality to see that the two components are substituted independently; the β-rule for 1 is naturality of λ; and the η-rule for is the second law of lemma 159.18. Compatibility with evaluation contexts is functoriality of and of composition. ◻

Example 159.22 — The file program, twice

Interpret File and Bytes by objects F and B, and take open:IF, read:FFB and close:FI as generators. The term let fb=read(open) in (closef)b is interpreted by the composite I open F read FB closeidB IB λB B. As a diagram in the sense of definition 159.14 it is a single line entering the open box, continuing into read, which has two output wires; the F-wire enters close and terminates, and the B-wire is the free output. The two readings agree by theorem 159.15. The program that forgets to close is the diagram with a dangling F-wire, which is not a diagram from I to B at all, because definition 159.14 requires every output port to be wired; the term is likewise not typable, because T-TensorE would leave f unused.

The unrestricted context

The interpretation of definition 159.19 assumed Γ empty. A variable in Γ may be used any number of times, including none, so its interpretation must admit duplication and discarding — exactly the maps a tensor lacks.

Proposition 159.23 — Declaring objects copyable is not enough

Suppose C is symmetric monoidal closed and X is an object equipped with d:XXX and e:XI satisfying the comonoid laws. Then X need not admit a natural such structure, and choosing one for each object of a subclass does not make the interpretation of T-UVar well defined unless the choice is natural in X and compatible with .

Proof of Proposition 159.23 — Declaring objects copyable is not enough

Proof. A comonoid structure on a single object is data, not a property, and different choices give different interpretations of a term that duplicates that variable twice in different orders — unless d is coassociative and cocommutative, which is part of the comonoid laws, and unless d is natural, which the hypothesis does not require. Without naturality the substitution equation of theorem 159.21 fails: substituting a term for a duplicated variable would have to commute d past the substituted arrow, and that is precisely a naturality square. Compatibility with is needed for the same reason at a variable of tensor type. ◻

Definition 159.24 — Linear–nonlinear adjunction

A linear–nonlinear adjunction consists of a cartesian closed category X, a symmetric monoidal closed category C, and a symmetric monoidal adjunction L:X  C :R,LR, in which L is strong monoidal — the comparisons L(A×B)LALB and L(1)I are isomorphisms — and R is lax monoidal.

Theorem 159.25 — The exponential comonad

Let LR be a linear–nonlinear adjunction and put !:=LR:CC. Then ! is a comonad, and every object !X carries natural maps contrX:!X!X!X,weakX:!XI making it a commutative comonoid, natural in X and compatible with the comonad structure.

Proof of Theorem 159.25 — The exponential comonad

Proof. ! is a comonad because it is LR for an adjunction, with counit the counit of the adjunction and comultiplication LηR. For the comonoid structure, X is cartesian, so every object A carries the diagonal ΔA:AA×A and the unique map A1, and these are natural and form a commutative comonoid. Apply L and use that L is strong monoidal: contrX:=(L(A×A)  LALA)L(ΔA),weakX:=(L(1)  I)L(!A), with A:=RX. Naturality is naturality of Δ and of the monoidal comparisons; the comonoid laws are the images under a strong monoidal functor of the corresponding laws in X, which hold because X is cartesian. Compatibility with the comonad structure is the statement that the comparisons are compatible with η and ε, which is part of a monoidal adjunction. ◻

Corollary 159.26 — Interpretation of the full calculus

With ! as in theorem 159.25, extend definition 159.19 by [[!A]]:=![[A]] and interpret Γ;Δe:A by an arrow ![[Γ]][[Δ]][[A]], using contr for a variable of Γ used twice and weak for one used not at all. Then theorem 159.21 holds for the full calculus of definition 18.5.

Proof of Corollary 159.26 — Interpretation of the full calculus

Proof. The substitution induction acquires two new cases, both settled by naturality: duplicating a Γ-variable and then substituting equals substituting and then duplicating, by naturality of contr; and discarding commutes with substitution by naturality of weak. The rules for ! — introduction at a value and elimination by a let — are the unit and counit of the comonad, and their β-rule is a triangle identity. ◻

Definition 159.27 — Lax, oplax, strong

A functor F:CD between monoidal categories is lax monoidal when it carries mX,Y:FXFYF(XY) and mI:IFI, natural and compatible with α,λ,ρ; oplax when the comparisons point the other way; and strong when they are isomorphisms.

Example 159.28 — Three translations that fail differently

Let X be sets and functions with ×, and C a symmetric monoidal category. The functor sending a set A to a chosen coproduct of A copies of I is strong monoidal when C has coproducts distributing over . The forgetful functor R of definition 159.24 is lax and not strong: there is a map RX×RYR(XY) given by the adjunction, but no inverse, since a map into XY need not split. The functor sending a comonoid to its carrier is oplax: the comultiplication provides F(XY)FXFY, not the reverse. Each direction of failure is the direction in which the corresponding structural map exists.

Proposition 159.29 — Preservation equations for the interpretation

In a linear–nonlinear adjunction, the interpretation of corollary 159.26 satisfies [[!(AB)]][[!A]][[!B]]is not asserted,L(A×B)LALBis. Precisely: L strong monoidal is used exactly in the construction of contr and weak in theorem 159.25, and R lax monoidal is used exactly in verifying that the adjunction is monoidal.

Proof of Proposition 159.29 — Preservation equations for the interpretation

Proof. Inspect the proof of theorem 159.25: the comparisons of L are inverted there, and nowhere else; the comparisons of R appear only in the compatibility of unit and counit with the monoidal structure. The non-assertion is genuine: !(AB) and !A!B are related by a canonical map that need not be invertible, and no step above uses one. ◻

Four extensions this chapter does not make

Each of the following is a natural next demand on the file example, and each requires structure that has not been constructed.

An external category acting on the model. Suppose one wants a family of resources indexed by an external parameter, with the parameter category acting on C. This is an action of a monoidal category on a category, with its own coherence conditions; nothing above supplies it, and alone does not, since one of its arguments would have to leave C.

Feedback. A protocol that loops — read until end of file — asks for an operation taking f:XUYU to XY, hiding U. Such a trace satisfies its own axioms, and it is not derivable: in FS(S) the normal form of theorem 159.12 has no arrow of that shape, since every generator occurrence is on a directed path from a free input to a free output.

A bent input wire. Turning an input into an output asks for maps IXX and XXI satisfying the triangle equations. Their presence makes self-dual in a way that definition 159.17 does not provide: closure gives XI, not a dual with a unit.

Reversal. Reversing a computation asks for an involution on arrows fixing objects and compatible with . The file generators open, read, close have no such reversal, and definition 159.10 attaches none.

These four demands motivate the structures named monoidal action, trace, compact closure and dagger. Their rule tables and their proofs belong to the routes that construct them; nothing in this chapter may be used to assert that C has any of them.

Exercise 159.1

★☆☆ Normalize the two expressions ((XY)Z)W and X(Y(ZW)) to the same list using construction 159.11, and exhibit the two composites of proposition 159.3 between them, showing every object.

Exercise 159.2

★☆☆ Which of the following are diagrams over the file signature of example 159.22: a box read whose F-output is wired to its own F-input; a box close with an unwired input; a pair of read boxes whose outputs are both wired to a single close? For each, name the clause of definition 159.14 it violates or exhibit the arrow it denotes.

Exercise 159.3

★★☆ Translate the derivation of f1:File,f2:File(closef1)(readf2):1(FileBytes) into an arrow of C using definition 159.19, showing the split isomorphism explicitly, and draw the corresponding diagram with every wire typed.

Exercise 159.4

★★☆ Prove one hexagon equation of definition 159.7 algebraically from naturality of γ and the pentagon, and then verify the same equation by comparing the two diagrams of definition 159.14 that the two sides denote. State which of the two arguments remark 159.16 permits as a proof.

Exercise 159.5

★★☆ Give categories separating, in order: cartesian from merely monoidal; monoidal from braided; braided from symmetric; and symmetric monoidal from symmetric monoidal closed. For each, name the structural map that exists on one side and not the other.

Boundary and seminar

The endpoint of this chapter is the symmetric monoidal closed interface together with the linear–nonlinear adjunction: definition 159.5, definition 159.7, theorem 159.12, theorem 159.15, definition 159.17, theorem 159.21, theorem 159.25 and corollary 159.26. The boundaries are these. The coherence used is the free-strict normal form of theorem 159.12 and nothing stronger; remark 159.13 and remark 159.16 say exactly what a diagram may be used for. The four structures of section 159.7 are motivated and not constructed. Enriched categories and general bicategories do not appear. And no argument of this chapter is used to modify the syntactic development of chapter 18: theorem 159.21 interprets that calculus and proves nothing new about it.

The proof base divides as follows. The mixed linear/nonlinear calculus, the adjunction of definition 159.24 and the derivation of the exponential comonad are Benton’s [Ben94]; the resource reading of the connectives is Girard’s [Gir87]; the coherence vocabulary and the pentagon and triangle of proposition 159.3, proposition 159.4 are Mac Lane’s [ML98a]; the exact soundness and completeness statement for the graphical language of closed symmetric monoidal categories is [RG26], and theorem 159.15 is stated here only at the free-strict signature it proves; the long proof-theoretic route from linear logic to monoidal semantics is [Mel09]; and the pedagogical synthesis relating these to computation is [BS09]. The mechanized coherence library and diagram editor of [Pou26] is a formal and practical comparison at its own monoidal signature; no theorem above depends on it.

[4]

Suggested first pass.

Begin with exercise 159.6, then exercise 159.7, and finish with exercise 159.9.

Exercise 159.6

★★★ Implement the normalisation procedure in the proof of theorem 159.12 by hand on an expression with four generators and two symmetries, recording each rewrite and the measure that decreases. Then exhibit two expressions with the same normal form and different-looking diagrams, and explain why theorem 159.15 does not make them different diagrams.

Exercise 159.7

★★★ Construct a concrete linear–nonlinear adjunction: take C to be the category of pointed sets with smash product and X to be sets, with L the “add a base point” functor. Verify that L is strong monoidal, compute !, and write out contr and weak explicitly. Then check the comonoid laws on a two-element set.

Exercise 159.8

★★★ Prove the claim made in section 159.7 that FS(S) admits no trace operator satisfying the usual naturality and vanishing axioms, by using the normal form of theorem 159.12 to show that every arrow’s generator occurrences lie on directed paths from inputs to outputs.

Exercise 159.9 — Practical: a typed diagram normalizer

★★★ Practical project.monoidal-diagram-normalizer Implement diagrams over a finite typed signature as in definition 159.14: boxes with typed ports, a wiring, and free input and output lists. The program must check well-formedness — every port wired exactly once, types matching, the box graph acyclic — compute the normal form of theorem 159.12, and decide equality of two diagrams by comparing normal forms. The invariant the program must maintain is that it never identifies two diagrams whose normal forms differ, and never distinguishes two that differ only by the port bijection allowed in definition 159.14. The program must print, for each named input, the well-formedness verdict with the violated clause named on failure, the normal form as a sequence of generator layers with its permutations, and an equality verdict for a pair. The acceptance test is: the file program of example 159.22 is accepted and its normal form has three generator layers in the order open,read,close; the variant that omits the close box is rejected with the unwired-port clause named; the two sides of one hexagon from exercise 159.4 normalize to the same form; and two diagrams differing only by exchanging two boxes on disjoint wires are reported equal, matching the uniqueness clause of theorem 159.12. A normalizer for finite diagrams is evidence on named inputs only: it proves neither theorem 159.12 nor theorem 159.15, and it says nothing about non-free monoidal categories.

Search the book

Type to search the local edition.