Mechanized Category Theory

Our research lab has a library of mechanized category theory in Agda that I help maintain, cubical-categorical-logic.

Cubical categorical logic

Lessons from Mechanizing Categorical Logic in Cubical Agda onpls-2026-talk

We present cubical-categorical-logic, a library of formalized category theory in Cubical Agda. The library’s core idea is to treat syntax as a free categorical structure whose dependent eliminator is stated via (displayed) universal properties. From the same reusable components we have proven canonicity and conservativity results across several type theories, as well as the coherence theorem for monoidal categories. In this talk, we discuss these applications and reflect on Cubical Agda as a host for mechanized metatheory, where it is sometimes a boon and sometimes a bane.
Slides

Further, there are plenty of notes and thoughts related to category theory more broadly. Although, these thoughts are often formalized, the formalization is currently not much represented in these notes. Instead, they just talk about math.

Category theory

Predecessors simplify later predecessors-simplify-later

A predecessor of π‘₯ is a top element of its strict downset: a strict morphism 𝜌:𝑝→π‘₯ through which every strict morphism into π‘₯ factors uniquely. Equivalently, π–²π—π—‹π—‚π–Όπ—π–£π—ˆπ—π—‡(π‘₯)≅𝗒𝑝 β€” the downset is representable.

The Yoneda lemma then collapses later to evaluation:

βŠ³π‘ƒ(π‘₯)=π–―π—Œπ—π’žοΈ€(π–²π—π—‹π—‚π–Όπ—π–£π—ˆπ—π—‡(π‘₯),𝑃)β‰…π–―π—Œπ—π’žοΈ€(𝗒𝑝,𝑃)≅𝑃(𝑝),

with 𝗇𝖾𝗑𝗍 becoming restriction along 𝜌. The name is from the naturals: every strict map into 𝑛+1 factors through 𝑛→𝑛+1, so on πœ” β€” in the topos of trees β€” later is just the shift

βŠ³π‘ƒ(0)β‰…βŠ€,βŠ³π‘ƒ(𝑛+1)≅𝑃(𝑛),

and a LΓΆb step is a base value together with a rule producing the value at 𝑛+1 from the value at 𝑛.

When this predecessor exists, we can give a simpler description of later, as in the topos of trees, but this may not be possible in all direct categories.

Algebras as a displayed category algebras-displayed

Fix an endofunctor 𝐹:π’žοΈ€β†’π’žοΈ€. The 𝐹-algebras form a displayed category AlgStr(𝐹) over π’žοΈ€.

Over an object π‘₯, a displayed object of AlgStr(𝐹) is a structure map

π›Όβˆˆπ’žοΈ€(𝐹π‘₯,π‘₯).

Over 𝑓:π‘₯→𝑦, a displayed morphism from 𝛼 to 𝛽 is the proposition that 𝑓 is an algebra homomorphism:

𝛼⋆𝑓=𝐹𝑓⋆𝛽.

The total category Alg(𝐹)=∫AlgStr(𝐹) is the category of 𝐹-algebras.

The co-Eilenberg–Moore category as a displayed category co-eilenberg-moore-displayed

A comonad on π’žοΈ€ is a monad π‘Š on π’žοΈ€op. Everything about its coalgebras is then inherited from the Eilenberg–Moore construction, instantiated at the opposite category β€” nothing is defined twice.

Algebras of π‘Š over π’žοΈ€op are coalgebras π›Ύβˆˆπ’žοΈ€(π‘₯,π‘Šπ‘₯) of the underlying endofunctor, and the monad algebra laws, read in π’žοΈ€op, are the comonad coalgebra laws β€” the unit and multiplication of π‘Š, viewed in π’žοΈ€, are the counit πœ€ and comultiplication 𝛿:

π›Ύβ‹†πœ€π‘₯=𝗂𝖽π‘₯𝛾⋆𝛿π‘₯=π›Ύβ‹†π‘Šπ›Ύ.

The co-Eilenberg–Moore category is the opposite of the total category:

coEM(π‘Š)=(EM(π‘Š))op.

Coalgebras as a displayed category coalgebras-displayed

Fix an endofunctor 𝐹:π’žοΈ€β†’π’žοΈ€. Coalgebras require no new construction: a coalgebra is an algebra in the opposite category. Define

CoalgStr(𝐹)=AlgStr(𝐹op),

a displayed category over π’žοΈ€op, where 𝐹op:π’žοΈ€opβ†’π’žοΈ€op is 𝐹 acting on the opposite category.

Concretely, over an object π‘₯ a displayed object is a structure map

π›Ύβˆˆπ’žοΈ€(π‘₯,𝐹π‘₯).

The category of coalgebras is the opposite of the total category:

Coalg(𝐹)=(∫CoalgStr(𝐹))op.

The outer opposite returns morphisms to the direction of π’žοΈ€: a morphism (π‘₯,𝛾)β†’(𝑦,𝛿) is a map 𝑓:π‘₯→𝑦 with

𝑓⋆𝛿=𝛾⋆𝐹𝑓.

Definition. The comparison functor of an adjunction comparison-functor

An adjunction πΉβŠ£π‘ˆ with 𝐹:π’žοΈ€β†’π’ŸοΈ€ and π‘ˆ:π’ŸοΈ€β†’π’žοΈ€ induces a monad 𝑇=π‘ˆβˆ˜πΉ on π’žοΈ€. Write πœ€:πΉβˆ˜π‘ˆβ‡’π–¨π–½ for the counit of the adjunction. Every object 𝑑 of π’ŸοΈ€ then induces a 𝑇-algebra carried by the object π‘ˆπ‘‘, witnessed by the map

π‘ˆπœ€π‘‘:π‘ˆπΉπ‘ˆπ‘‘β†’π‘ˆπ‘‘.

This assignment extends to a functor into the Eilenberg–Moore category,

𝐾:π’ŸοΈ€β†’EM(𝑇),

the comparison functor of the adjunction.

Dually, an adjunction induces a comonad on the other side and a comparison into the co-Eilenberg–Moore category. When these comparisons are equivalences we say that the adjunction πΉβŠ£π‘ˆ is (co)monadic.

Definition. Direct categories direct-category

A well-founded order is a set 𝐷 with a proposition-valued transitive relation < admitting no infinite descent: every element is accessible. Write π‘Žβ‰€π‘ for (π‘Ž<𝑏)∨(π‘Ž=𝑏).

A direct structure on a category π’žοΈ€ over (𝐷,<) is a functor

deg:π’žοΈ€β†’(𝐷,≀)

into the well-founded order viewed as a poset category. The functor organizes two pieces of data at once: an ordering on the objects, and the invariant that morphisms respect it β€” 𝑓:π‘₯→𝑦 forces degπ‘₯≀deg𝑦.

A direct structure equips the objects with a well-founded strict relation

π‘₯β‰Ίπ‘¦βŸΊdegπ‘₯<deg𝑦.

Intuitively, direct categories are the right generalization of well-foundedness to the categorical setting: a direct category is essentially one whose underlying graph is a directed acyclic graph, layered by degree, so that data at an object may be defined by recursion from data at all objects strictly below it.

The degrees order the objects, while the morphisms of π’žοΈ€ say how an object sits over its predecessors.

Definition. Earlier on presheaves earlier-presheaf

Later takes a limit over smaller indices. Dually, the earlier modality takes a colimit over larger indices: an element of βŠ²π‘ƒ at π‘₯ is a 𝑃-element sitting at some object 𝑦 strictly above π‘₯, carried down along a chosen morphism π‘₯→𝑦.

Earlier is left adjoint to later:

⊲⊣⊳

Under this adjunction, 𝗇𝖾𝗑𝗍:π‘ƒβ†’βŠ³π‘ƒ corresponds to

𝗉𝗋𝖾𝗏:βŠ²π‘ƒβ†’π‘ƒ,

.

The Eilenberg–Moore category as a displayed category eilenberg-moore-displayed

Fix a monad (𝑇,πœ‚,πœ‡) on π’žοΈ€. Its Eilenberg–Moore category arises in two displayed layers. The first layer is the displayed category of algebras AlgStr(𝑇) of the underlying endofunctor.

The second layer, EMStr(𝑇), is displayed over the total category Alg(𝑇). Over an algebra (π‘₯,𝛼) the displayed objects are the propositions that 𝛼 satisfies the monad algebra laws:

πœ‚π‘₯⋆𝛼=𝗂𝖽π‘₯πœ‡π‘₯⋆𝛼=𝑇𝛼⋆𝛼.

The Eilenberg–Moore category is the total category of the tower:

EM(𝑇)=∫EMStr(𝑇).

Definition. Initial algebra initial-algebra

Fix an endofunctor 𝐹:π’žοΈ€β†’π’žοΈ€. An initial 𝐹-algebra, written πœ‡πΉ, is an initial object of the category of algebras Alg(𝐹).

Unfolding the universal property: an initial algebra is an algebra (πœ‡πΉ,in) such that every algebra (π‘₯,𝛼) admits a unique morphism fold𝛼:πœ‡πΉβ†’π‘₯ satisfying

in⋆(fold𝛼)=𝐹(fold𝛼)⋆𝛼.

Definition. Later on families later-family

Conjugation with the adjunction between presheaves and families π‘ˆβŠ£Cofree lets us induce a later construction on families from the one on presheaves,

⊳Fam=π‘ˆβˆ˜βŠ³βˆ˜Cofree:Fam(π’žοΈ€)β†’Fam(π’žοΈ€).

Concretely, later on families evaluates to

⊳Fam𝐴(π‘₯)β‰…βˆπ‘¦β‰Ίπ‘₯Β βˆπ‘“:𝑦→π‘₯𝐴(𝑦)

Definition. Later on presheaves later-presheaf

The later modality for presheaves on a direct category is given by the presheaf of natural transformations

out of the strict downset.

(βŠ³π‘ƒ)(π‘₯)=π–―π—Œπ—π’žοΈ€(π–²π—π—‹π—‚π–Όπ—π–£π—ˆπ—π—‡(π‘₯),𝑃).

An element of βŠ³π‘ƒ at π‘₯ is a coherent choice of 𝑃-elements at all objects strictly smaller than π‘₯.

Restriction in βŠ³π‘ƒ along 𝑓:𝑦→π‘₯ precomposes with the induced map π–²π—π—‹π—‚π–Όπ—π–£π—ˆπ—π—‡(𝑦)β†’π–²π—π—‹π—‚π–Όπ—π–£π—ˆπ—π—‡(π‘₯). At an object of minimal degree the strict downset is empty, so βŠ³π‘ƒ is trivial there.

Via functoriality, every presheaf restricts to smaller indices. Thus we may define the map

𝗇𝖾𝗑𝗍:π‘ƒβ†’βŠ³π‘ƒ

that sends an element 𝑝 over π‘₯ to the family of all its restrictions along morphisms from strictly lower objects.

Theorem. LΓΆb induction on families lob-family

Like later on families, the recursion principle for families is inherited from that on presheaves. Given a family 𝐴 and a step

πœ‘π‘₯:⊳Fam𝐴(π‘₯)→𝐴(π‘₯)for each π‘₯,

the construction is a chain of transpositions with LΓΆb for presheaves used in the middle:

Just as for presheaves, the fixed point constructed above is unique: the two transpositions are bijections, and the presheaf-level fixed point is already unique.

Theorem. LΓΆb induction for presheaves on a direct category lob-presheaf

Let π’žοΈ€ be a direct category and 𝑃 a presheaf on it. Every map

πœ‘:βŠ³π‘ƒβ†’π‘ƒ

has a fixed point: a global element π—…ΓΆπ–»πœ‘:βŠ€β†’π‘ƒ with

π—…ΓΆπ–»πœ‘=π—…ΓΆπ–»πœ‘β‹†π—‡π–Ύπ—‘π—β‹†πœ‘,

and this fixed point is unique.

The hypothesis says: the value of 𝑃 at any object is determined by its values over the strict past β€” πœ‘ turns a coherent family over the strict downset of π‘₯ into a value at π‘₯. The proof is recursion along the well-founded β‰Ί: at each π‘₯, the section already constructed over the past assembles into an element of (βŠ³π‘ƒ)(π‘₯), and πœ‘ extends it to π‘₯.

Definition. Locally contractive endofunctors locally-contractive-functor

Write π‘‹β‡’π‘Œ for the presheaf of morphisms π‘‹β†’π‘Œ. An endofunctor 𝐹 on presheaves is locally contractive when its action on morphisms factors through later: there is a map

𝐹𝛿:⊳(π‘‹β‡’π‘Œ)β†’(πΉπ‘‹β‡’πΉπ‘Œ)

Definition. Monadicity and comonadicity monadicity-comonadicity

An adjunction πΉβŠ£π‘ˆ with 𝐹:π’žοΈ€β†’π’ŸοΈ€ and π‘ˆ:π’ŸοΈ€β†’π’žοΈ€ induces a monad 𝑇=π‘ˆβˆ˜πΉ on π’žοΈ€, and a comparison functor

𝐾:π’ŸοΈ€β†’EM(𝑇)

sending each object of π’ŸοΈ€ to the 𝑇-algebra it carries.

The functor π‘ˆ is monadic when 𝐾 is an equivalence: the adjunction exhibits π’ŸοΈ€ as objects of π’žοΈ€ equipped with algebraic structure for 𝑇, the Eilenberg–Moore category.

Comonadicity is monadicity in the opposite category: a left adjoint 𝐿:π’ŸοΈ€β†’π’žοΈ€ with right adjoint 𝑅 induces a comonad π‘Š=πΏβˆ˜π‘… on π’žοΈ€, a comparison π’ŸοΈ€β†’coEM(π‘Š) into the co-Eilenberg–Moore category, and 𝐿 is comonadic when this comparison is an equivalence.

The adjoint triple between presheaves and families presheaf-family-adjoint-triple

A family over π’žοΈ€ is a set 𝐴(π‘₯) for each object π‘₯, with no action of morphisms. Families form a category Fam(π’žοΈ€): a morphism 𝐴→𝐡 is a function 𝐴(π‘₯)→𝐡(π‘₯) for each π‘₯.

Forgetting the restriction maps of a presheaf gives a functor

π‘ˆ:π–―π—Œπ—π’žοΈ€β†’Fam(π’žοΈ€).

It has both a left and a right adjoint,

FreeβŠ£π‘ˆβŠ£Cofree.

The two adjoints demonstrate different means of forcing a family to be functorial. The right adjoint universally quantifies over morphisms in,

Cofree(𝐴)(π‘₯)=βˆπ‘¦π’žοΈ€(𝑦,π‘₯)→𝐴(𝑦),

with restriction along 𝑓 given by precomposition. The left adjoint instead existentially quantifiers over morphisms out:

Free(𝐴)(π‘₯)=βˆ‘π‘¦π’žοΈ€(π‘₯,𝑦)×𝐴(𝑦),

with restriction acting on the first component. (For Free we ask that π’žοΈ€ have a set of objects, so that this sum is a set and thus Free defines a presheaf.)

Theorem. Presheaves are monadic and comonadic over families presheaves-monadic-comonadic-over-families

The adjoint triple FreeβŠ£π‘ˆβŠ£Cofree induces a monad 𝑇=π‘ˆβˆ˜Free and a comonad π‘Š=π‘ˆβˆ˜Cofree on Fam(π’žοΈ€).

Both comparison functors are equivalences: presheaves are the Eilenberg–Moore algebras of 𝑇 and the co-Eilenberg–Moore coalgebras of π‘Š,

π–―π—Œπ—π’žοΈ€β‰ƒEM(𝑇)π–―π—Œπ—π’žοΈ€β‰ƒcoEM(π‘Š).

So presheaves are both monadic and comonadic over families.

Reading the algebra structure concretely: a 𝑇-algebra on a family 𝐴 is a map βˆ‘π‘¦π’žοΈ€(π‘₯,𝑦)×𝐴(𝑦)→𝐴(π‘₯) for each π‘₯, subject to the monad algebra laws β€” that is, exactly a functorial action of restriction.

The comonadic reading is the same structure seen from the element’s side: a π‘Š-coalgebra is a map 𝐴(π‘₯)β†’βˆπ‘¦π’žοΈ€(𝑦,π‘₯)→𝐴(𝑦), giving each value its restriction along every morphism into π‘₯. Where the monad says restriction acts on values, the comonad says a value already carries all of its restrictions β€” and the coalgebra laws say it does so coherently.

Definition. Proper and maximal sieves proper-maximal-sieve

The representable 𝗒π‘₯ is itself a sieve on π‘₯. A sieve on π‘₯ is proper when it is not equal to the representable.

Say that a proper sieve is maximal when it contains all other proper sieves as a sub-sieve.

Definition. Sieves sieve

A sieve on an object π‘₯ of π’žοΈ€ is a subobject of the representable presheaf 𝗒π‘₯: a presheaf 𝑆 with a monic morphism 𝑆↣𝗒π‘₯. Sieves are a generalization from the notion of ideal found in ring theory to category theory.

A morphism 𝑓:𝑦→π‘₯ belongs to 𝑆, written π‘†βˆ‹π‘“, when 𝑓 lies in the image of the inclusion at 𝑦. Because 𝑆 is a presheaf and the inclusion is natural, membership is closed under precomposition:

π‘†βˆ‹π‘“β‡’π‘†βˆ‹π‘”β‹†π‘“for every 𝑔:𝑧→𝑦.

A sieve is thus a β€œdownward closed” collection of morphisms into π‘₯.

Sieves on π‘₯ are ordered by refinement: π‘†βŠ†π‘‡ when every morphism belonging to 𝑆 belongs to 𝑇.

Theorem. Maximality of the strict downset among proper sieves strict-downset-maximal

Call a direct structure reflecting when every morphism between objects of equal degree is a split epimorphism. In a reflecting direct category, every non-invertible-in-degree morphism strictly raises degree, and the strict downset is as large as a proper sieve can be:

If the direct structure is reflecting, then every proper sieve 𝑆 on π‘₯ refines into the strict downset:

π‘†βŠ†π–²π—π—‹π—‚π–Όπ—π–£π—ˆπ—π—‡(π‘₯).

Suppose π‘“βˆˆπ‘† with 𝑓:𝑦→π‘₯ of equal degree. By reflection 𝑓 has a section 𝑠, and closure under precomposition gives 𝑠⋆𝑓=𝗂𝖽π‘₯βˆˆπ‘†, contradicting properness.

So every morphism in 𝑆 strictly raises degree. That is, every morphism in 𝑆 is also a member of π–²π—π—‹π—‚π–Όπ—π–£π—ˆπ—π—‡(π‘₯).

Definition. The strict downset sieve of a direct category strict-downset-sieve

Let π’žοΈ€ carry a direct structure. The strict downset π–²π—π—‹π—‚π–Όπ—π–£π—ˆπ—π—‡(π‘₯) of an object π‘₯ is the presheaf of morphisms into π‘₯ from strictly lower objects:

π–²π—π—‹π—‚π–Όπ—π–£π—ˆπ—π—‡(π‘₯)(𝑦)={𝑓:𝑦→π‘₯βˆ£π‘¦β‰Ίπ‘₯},

with restriction by precomposition β€” well defined since degrees are non-decreasing, so precomposing can only stay strictly below.

The evident inclusion π–²π—π—‹π—‚π–Όπ—π–£π—ˆπ—π—‡(π‘₯)β†£γ‚ˆπ‘₯ makes π–²π—π—‹π—‚π–Όπ—π–£π—ˆπ—π—‡(π‘₯) a sieve on π‘₯. It is moreover a proper sieve, as it exlcudes the identity.

Definition. Terminal coalgebra terminal-coalgebra

Fix an endofunctor 𝐹:π’žοΈ€β†’π’žοΈ€. A terminal 𝐹-coalgebra, written 𝜈𝐹, is a terminal object of the category of coalgebras Coalg(𝐹) β€” equivalently, an initial algebra for 𝐹op.

Unfolding the universal property: a terminal coalgebra is a coalgebra (𝜈𝐹,out) such that every coalgebra (π‘₯,𝛾) admits a unique morphism unfold𝛾:π‘₯β†’πœˆπΉ satisfying

(unfold𝛾)⋆out=𝛾⋆𝐹(unfold𝛾).

Well-founded posets are thin direct categories well-founded-poset-as-thin

Every poset forms a thin category. Similarly, if the poset is well-founded then it induces a thin direct category.

Definition. Category category

A category π’žοΈ€ consists of

  1. A type of objects π’žοΈ€0
  2. For each pair of objects π‘₯,𝑦:π’žοΈ€0 a set of morphisms π’žοΈ€(π‘₯,𝑦). We may simply write a morphism with an arrow, denote 𝑓:π’žοΈ€(π‘₯,𝑦) as 𝑓:π‘₯→𝑦 or π‘₯→𝑓𝑦 or similar
  3. A composition operation on morphisms. For 𝑓:π‘₯→𝑦 and 𝑔:𝑦→𝑧, there is a morphism 𝑓⋆𝑔:π‘₯→𝑧
  4. For each π‘₯:π’žοΈ€0, an identity morphism 𝗂𝖽π‘₯:π‘₯β†’π‘₯
  5. Left-unitality of composition: for all 𝑓:π‘₯→𝑦, an equality

    𝗂𝖽𝖫𝑓:𝗂𝖽π‘₯⋆𝑓=𝑓
  6. Right-unitality of composition: for all 𝑓:π‘₯→𝑦, an equality

    𝗂𝖽𝖱𝑓:𝑓⋆𝗂𝖽𝑦=𝑓
  7. Associativity of composition: for all 𝑓:π‘₯→𝑦, 𝑔:𝑦→𝑧, β„Ž:𝑧→𝑀, an equality

    π–Ίπ—Œπ—Œπ—ˆπ–Όπ‘“,𝑔,β„Ž:(𝑓⋆𝑔)β‹†β„Ž=𝑓⋆(π‘”β‹†β„Ž)

Concretely, the definition above is meant to model the one used in the Cubical standard library [1].

However, the notion of category is flexible. Depending on the context, we may be talking of small, locally small, wild, or any other kind of category that may augment which things we require to be (homotopy) sets, which things we require to be small types, etc. For the most part, the same idea of a category will apply across all of these settings.

Definition. Bicategory bicategory

A bicategory is a notion of weak 2-category that arises as a category weakly enriched in categories. That is, instead of having hom sets, between any two objects a bicategory has hom categories such that the enriched category laws hold up to invertible 2-cell rather than strictly.

A bicategory 𝒦︀ consists of

  1. A type of objects 𝒦︀0, or 0-cells
  2. For all π‘₯,𝑦:𝒦︀0, a category 𝒦︀1(π‘₯,𝑦). We may elide the subscript and simply write this as 𝒦︀(π‘₯,𝑦). Refer to the objects of 𝒦︀(π‘₯,𝑦) as 1-cells between π‘₯ and 𝑦, and we may write 𝑓:𝒦︀(π‘₯,𝑦) as 𝑓:π‘₯→𝑦 or π‘₯→𝑓𝑦. For 𝑓,𝑔:𝒦︀(π‘₯,𝑦), refer to the morphisms in 𝒦︀(π‘₯,𝑦) between 𝑓 and 𝑔 as 2-cells and write the morphism 𝛼:(𝒦︀(π‘₯,𝑦))(𝑓,𝑔) as 𝛼:𝑓⇒𝑔 or 𝑓⇒𝛼𝑔
  3. For each π‘₯:𝒦︀0, an identity 1-cell 1π‘₯:𝒦︀(π‘₯,π‘₯)
  4. For all π‘₯,𝑦,𝑧:𝒦︀0, a composition functor 𝒦︀⋆π‘₯,𝑦,𝑧:𝒦︀(π‘₯,𝑦)×𝒦︀(𝑦,𝑧)→𝒦︀(π‘₯,𝑧). For 1-cells 𝑓:π‘₯→𝑦 and 𝑔:𝑦→𝑧, write their composite as 𝑓⋆𝑔:π‘₯→𝑧
  5. For all 𝑀,π‘₯,𝑦,𝑧:𝒦︀0, a natural isomorphism, the associator 𝛼 between the two composite functors 𝒦︀(𝑀,π‘₯)×𝒦︀(π‘₯,𝑦)×𝒦︀(𝑦,𝑧)→𝒦︀(𝑀,𝑧) that compose the leftmost, respectively rightmost, pair first:

    𝒦︀⋆𝑀,𝑦,π‘§βˆ˜(𝒦︀⋆𝑀,π‘₯,𝑦×id)⇒𝒦︀⋆𝑀,π‘₯,π‘§βˆ˜(id×𝒦︀⋆π‘₯,𝑦,𝑧)

    Its component at 1-cells 𝑓,𝑔,β„Ž is the invertible 2-cell

    𝛼𝑓,𝑔,β„Ž:(𝑓⋆𝑔)β‹†β„Žβ‡’π‘“β‹†(π‘”β‹†β„Ž)
  6. For all π‘₯,𝑦:𝒦︀0, natural isomorphisms, the left unitor πœ† and right unitor 𝜌, each between an endofunctor of 𝒦︀(π‘₯,𝑦) and the identity functor:

    𝒦︀⋆π‘₯,π‘₯,π‘¦βˆ˜βŸ¨1π‘₯,idβŸ©β‡’id𝒦︀⋆π‘₯,𝑦,π‘¦βˆ˜βŸ¨id,1π‘¦βŸ©β‡’id

    where 1π‘₯ and 1𝑦 in the pairings βŸ¨βˆ’,βˆ’βŸ© denote the constant functors at the identity 1-cells. The components at a 1-cell 𝑓:𝒦︀(π‘₯,𝑦) are the invertible 2-cells

    πœ†π‘“:1π‘₯β‹†π‘“β‡’π‘“πœŒπ‘“:𝑓⋆1𝑦⇒𝑓
  7. such that for all 𝑓:𝒦︀(π‘₯,𝑦) and 𝑔:𝒦︀(𝑦,𝑧) the triangle below commutes in 𝒦︀(π‘₯,𝑧):

  8. and such that for all composable 1-cells 𝑓,𝑔,β„Ž,π‘˜ the pentagon below commutes:

Definition. Monad in a bicategory monad-in-a-bicategory

Fix a bicategory 𝒦︀, with composition ⋆, identity 1-cells 1π‘₯, associator 𝛼, and unitors πœ†,𝜌. A monad in 𝒦︀ internalises the usual notion of monad: it is an endo-1-cell carrying a multiplication and a unit that satisfy the monoid laws up to the coherence cells of the bicategory.

A monad in 𝒦︀ consists of

  1. a 0-cell π‘₯, the object the monad acts on;
  2. an endo-1-cell 𝑑:𝒦︀(π‘₯,π‘₯);
  3. a multiplication 2-cell πœ‡:𝑑⋆𝑑⇒𝑑;
  4. a unit 2-cell πœ‚:1π‘₯⇒𝑑;
  5. such that πœ‡ is associative: the following diagram of 2-cells commutes in 𝒦︀(π‘₯,π‘₯), where the top map is the associator that rebrackets the threefold composite:

  6. and such that πœ‡ and πœ‚ satisfy the unit laws: the following two diagrams commute in 𝒦︀(π‘₯,π‘₯), where the hypotenuses are the left and right unitors:

Taking 𝒦︀ to be the bicategory of categories, functors, and natural transformations recovers an ordinary monad on a category: 𝑑 is the endofunctor, πœ‡ the multiplication, and πœ‚ the unit, with the coherence cells all identities.

Definition. Free Monoidal Category over a Set free-monoidal-category

Fix a set 𝑋. The objects of the free monoidal category over 𝑋, π–₯π—‹π–Ύπ–Ύπ–¬π—ˆπ—‡(𝑋), are generated inductively by the elements of 𝑋 and a unit element 𝐼 over a binary operation βŠ—. The morphisms are given by a quotient-inductive type. They are generated by associators, unitors, and identity over composition and parallel action over βŠ— then quotiented by associativity and composition equation to satisfy the category laws, equations constraining the associators/unitors to be natural isomorphisms, and pentagon/triangle equations to satiate the axioms of a monoidal category.

Definition 0.1. Global Elimination Principle for the Free Monoidal Category free-monoidal-category-elimination

Given any displayed monoidal category 𝑀𝙳 over π–₯π—‹π–Ύπ–Ύπ–¬π—ˆπ—‡(𝑋) with an interpretation πœ„:𝑋⇝𝑀𝙳, we may construct a global section π–₯π—‹π–Ύπ–Ύπ–¬π—ˆπ—‡(𝑋)→𝑀𝙳. We refer to this as the global elimination principle of π–₯π—‹π–Ύπ–Ύπ–¬π—ˆπ—‡(𝑋).

Definition. Global Elimination Principle for the Free Monoidal Category free-monoidal-category-elimination

Given any displayed monoidal category 𝑀𝙳 over π–₯π—‹π–Ύπ–Ύπ–¬π—ˆπ—‡(𝑋) with an interpretation πœ„:𝑋⇝𝑀𝙳, we may construct a global section π–₯π—‹π–Ύπ–Ύπ–¬π—ˆπ—‡(𝑋)→𝑀𝙳. We refer to this as the global elimination principle of π–₯π—‹π–Ύπ–Ύπ–¬π—ˆπ—‡(𝑋).

Products of Categories as Total Categories product-as-total-category

Given categories π’žοΈ€ and π’ŸοΈ€, π’žοΈ€Γ—π’ŸοΈ€ is equivalent to the total category of weakening.

Definition. Quiver quiver

A quiver is just a directed graph presented via a type of objects, a type of edges, and two projection functions that pick out source and target of an edge.

Definition. Thin Category thin-category

A category 𝐢 is thin if there is at most one morphism between any two objects.

Definition. Element of a Presheaf element-of-presheaf

An element of a presheaf 𝑃 at an object 𝑐 is an element π‘₯ of the set 𝑃𝑐.

Definition. Universal Element of a Presheaf universal-element

A universal element of a presheaf 𝑃 on a category 𝐢 is an element π‘₯βˆˆπ‘ƒπ‘, where 𝑐 is some object of 𝐢, demonstrating that 𝑃 is representable by 𝑐.

π‘ƒβ‰…γ‚ˆπ‘

(Slightly) more concretely, a universal element is captured by the following three pieces of data

  • An object 𝑐 of 𝐢
  • An element π‘₯βˆˆπ‘ƒπ‘
  • A proof that the map sending a morphism 𝑓:𝑏→𝑐 to (𝑃𝑓)(π‘₯) is an equivalence

This third point states that morphisms from 𝑏 into 𝑐 are uniquely determined by an element of 𝑃 at the domain 𝑏.

Or equivalently, universal elements are terminal in the category of elements.

What is a universal property, really? universal-property

Universal properties are a convenient method for defining an object in a category up to isomorphism. Rather than giving a concrete, bottom-up construction of an object, we can instead uniquely specify its behavior.

Consider the example of products in a category 𝐢. We say that the product of 𝑐 and 𝑑 is any object 𝑝 of 𝐢 such that the following diagram commutes.

We say that 𝑝 satisfies the universal property of the product of 𝑐 and 𝑑.

Surely this matches our set-based intuition of what a product should behave like. Similarly, we can sketch out constructions of other universal properties like initial objects, terminal objects, exponentials, etc. However, what is precisely meant by the term universal property?

The notion of a universal property is made precise by the notion of a universal element of a presheaf. That is, an object satisfies a universal property if we can build a universal element of the appropriate presheaf at that object.

Let’s look at the universal element characterization of the products example. Note that a map into a product is determined by a map into each component. To map into 𝑐×𝑑, we need both a map into 𝑐 and a map into 𝑑, as in the above diagram. That is, to build a map 𝑏→𝑐×𝑑, we must simultaneously provide elements of γ‚ˆπ‘ and γ‚ˆπ‘‘ at 𝑏.

Using the product of presheaves, this means we are providing a single element of the presheaf (γ‚ˆπ‘)Γ—(γ‚ˆπ‘‘). Quite nicely, the universal element of this presheaf provides the object of 𝐢 that is the product of 𝑐 and 𝑑. The universal element, provided that it exists, contains the following data:

  • An object 𝑝
  • An element π‘₯∈(γ‚ˆπ‘Γ—γ‚ˆπ‘‘)𝑝
  • A proof that the map sending 𝑓:𝑏→𝑝 to a pair of maps 𝑓1:𝑏→𝑐, 𝑓2:𝑏→𝑑 is an equivalence. Therefore, any element of γ‚ˆπ‘Γ—γ‚ˆπ‘‘ factors through π‘₯

Recall that the product of presheaves is computed pointwise in the category of sets, so if we expand the type of the element π‘₯ above we find that π‘₯ is a pair of maps 𝑝→𝑐 and 𝑝→𝑑.

(γ‚ˆπ‘Γ—γ‚ˆπ‘‘)𝑝≅(γ‚ˆπ‘π‘)Γ—(γ‚ˆπ‘‘π‘)

The first part of this pair is precisely πœ‹1. Correspondingly, the second part of this pair is πœ‹2. Finally, the universality of the element π‘₯ (i.e. the proof that any other element factors through π‘₯) captures our commutative diagram from above.

This is a very rough sketch of what a universal property is, and has elided for now an important application of the Yoneda lemma. In any case, all a universal property is really saying is that a particular presheaf is representable; and, rather elegantly, a universal element of a presheaf is convenient packaging of that representability proof.

In summary, universal properties are not as ad-hoc as they may initially seem, and the language of presheaves provides a reusable and precise definition that can be instantiated to describe a very large class of properties.

Definition. Constant Presheaf constant-presheaf

The constant presheaf of a set 𝑋 on a category 𝐢 is a functor Ξ”(𝑋):πΆπ‘œπ‘β†’π’πžπ­ such that

Ξ”(𝑋)𝑐≔𝑋

I often call this the discrete presheaf for 𝑋, but I don’t know if that’s standard.

Finite Cardinal Arithmetic in a Topos finite-cardinal-arithmetic-topos

In a topos with a natural numbers object (𝑁,𝑧,𝑠), you can define finite cardinals as objects that arise as the pullback along a morphism 𝑝:βŠ€β†’π‘ of the generic finite cardinal. Write [𝑝] for the cardinal corresponding to 𝑝.

The above characterization is a little obtuse and does warrant some more explanation. One way to make it more concrete is that [𝑧]=βŠ₯ and [π‘ βˆ˜π‘›]=βŠ€βŠ•[𝑛], and that finite cardinals warrant a nice induction principle. If 𝑃 is a property expressible in the internal language such that βŠ₯ satisfies 𝑃, and that whenever 𝐴 satisfies 𝑃 then βŠ€βŠ•π΄ satisfies 𝑃; then every finite cardinal satisfies 𝑃. That is, 𝑃 forms a (𝑧,𝑠)-closed subobject of 𝑁 and thus 𝑃 is all of 𝑁.

My working mental model is in a presheaf topos, where the natural numbers object can be defined explicitly as Ξ”(β„•).

Definition 0.2. Constant Presheaf constant-presheaf

The constant presheaf of a set 𝑋 on a category 𝐢 is a functor Ξ”(𝑋):πΆπ‘œπ‘β†’π’πžπ­ such that

Ξ”(𝑋)𝑐≔𝑋

I often call this the discrete presheaf for 𝑋, but I don’t know if that’s standard.

The finite cardinals with respect to Ξ”(β„•) can be characterized then as,

[0]≔βŠ₯
[π—Œπ—Žπ–Ό(𝑛)]β‰”βŠ€βŠ•[𝑛]

These obey nice algebraic properties.

[π‘›π‘š]β‰…[𝑛]Γ—[π‘š]
[𝑛+π‘š]β‰…[𝑛]βŠ•[π‘š]
[π‘›π‘š]β‰…[π‘š]β†’[𝑛]

Definition. Subobject subobject

In a category π’žοΈ€, a subobject of 𝑐 is an isomorphism class of monomorphisms into 𝑐.

Definition. Terminal Object terminal-object

An object 𝑐 in a category π’žοΈ€ is terminal if there is a unique morphism from any other object into it.

Because terminal objects are unique up to unique isomorphism (as are all universal objects) we often just write ⊀ to refer to the terminal object. Likewise, !:π‘‘β†’βŠ€ refers to the unique morphism into ⊀.

Definition. Equalizer equalizer

Let 𝑐 and 𝑑 be objects in a category π’žοΈ€ with two parallel morphisms 𝑓,𝑔:𝑐→𝑑. The equalizer of 𝑓 and 𝑔, if it exists, is the universal object π–Ύπ—Š with the following property:

  • There is a morphism πœ‹:π–Ύπ—Šβ†’π‘
  • π‘“βˆ˜πœ‹=π‘”βˆ˜πœ‹

Constructing Equalizers in Type Theory equalizers-in-type-theory

In the presence of Ξ£-types, one may construct all equalizers. Given types 𝐴 and 𝐡 with functions 𝑓,𝑔:𝐴→𝐡, the equalizer may be constructed as

π–Ύπ—Šπ‘“,π‘”β‰”βˆ‘π‘Ž:𝐴(𝑓(π‘Ž)=𝑔(π‘Ž))

Definition. Subobject Classifier subobject-classifier

Subsets 𝐴 of a set 𝑋 may classically be identified with a characteristic map πœ’π΄:π‘‹β†’π–»π—ˆπ—ˆπ—…. Intuitively, for every π‘₯:𝑋, πœ’π΄ gives a truth value to the statement β€œπ‘₯ is in the subset 𝐴”. In this manner, the domain of the characteristic map, π–»π—ˆπ—ˆπ—…, classifies the subsets of 𝑋.

Generalizing over this principle, in a category π’žοΈ€ an object Ξ© is a subobject classifier if maps into it from some object 𝑐 likewise uniquely identify a subobject of 𝑐.

We can understand Ξ© to behave like an object of truth values that are not necessarily boolean valued. A morphism 𝑝:𝑐→Ω can be thought of like a predicate on 𝑐. If 𝑐 were a set, this would precisely be the characteristic function on it. However, this idea can generalize beyond sets. For instance in the category of graphs, Ξ© is a cleverly constructed graph such that any graph homomorphism 𝑔→Ω into it picks out a unique subgraph of 𝑔.

There are always two (suggestively named) disjoint β€œpoints” of Ξ©, thought of as morphisms out of the terminal object π—π—‹π—Žπ–Ύ,π–Ώπ–Ίπ—…π—Œπ–Ύ:βŠ€β†’Ξ©. I think if we’re being careful, π—π—‹π—Žπ–Ύ may properly be the β€œsubobject classifier” but I always use the term to refer to Ξ© itself.

A subobject πœ™:𝑑β†ͺ𝑐 induces a unique characteristic morphism π‘πœ™:𝑐→Ω such that

π‘πœ™βˆ˜πœ™=π—π—‹π—Žπ–Ύβˆ˜!𝑑

Moreover, the appropriate square must be a pullback.

Definition. Closed Monoidal Structure closed-monoidal-category

A monoidal category is left closed if for each π‘ŒβˆˆπΆ, the functor βˆ’βŠ—π‘Œ:𝐢→𝐢 has a right adjoint π‘ŒβŠΈβˆ’:𝐢→𝐢 forming the left internal-hom out of π‘Œ.

That is, for all 𝑋,π‘Œ,𝑍, there is a natural isomorphism 𝐢[π‘‹βŠ—π‘Œ,𝑍]≅𝐢[𝑋,[π‘Œ,𝑍]]

There is an obvious right-handed variant π‘ŒβŸœβˆ’ that is right adjoint to π‘ŒβŠ—βˆ’.

If 𝐢 is both right and left closed, the monoidal category is simply called closed (or perhaps biclosed).

Definition. The Bicategory of Categories bicategory-of-categories

The bicategory of categories 𝖒𝖠𝖳 has

  • as 0-cells, categories (at a fixed pair of universe levels, for objects and for morphisms);
  • as hom-category 𝖒𝖠𝖳(π’žοΈ€,π’ŸοΈ€), the functor category [π’žοΈ€,π’ŸοΈ€], so 1-cells are functors and 2-cells are natural transformations;
  • as identity 1-cell, the identity functor;
  • as composition, 𝐹⋆𝐺=𝐺∘𝐹 on functors. On natural transformations 𝛽:𝐹⇒𝐹′ and 𝛾:𝐺⇒𝐺′ the horizontal composite is given directly by its components

    (𝛽⋆𝛾)𝑐=𝐺(𝛽𝑐)⋆𝛾𝐹′𝑐.

Every component of the left unitor, the right unitor and the associator is an identity morphism, and their inverses are identities too. So the only content of the triangle and pentagon is that composites of identities are identities.

𝖒𝖠𝖳 is still a bicategory and not a strict 2-category: Id∘𝐹 and 𝐹 agree on objects and on morphisms, but in the formalization they are not the same functor definitionally. The structure cells are there to name that agreement.

A monad in 𝖒𝖠𝖳 is an ordinary monad on a category, and a prestack is a pseudofunctor into 𝖒𝖠𝖳.

Definition. Category of Elements category-of-elements

Let 𝑃 be a presheaf on a category π’žοΈ€. The category of elements of 𝑃 is the displayed category over π’žοΈ€ whose displayed objects over 𝑐 are the elements π‘βˆˆπ‘ƒπ‘, and whose displayed morphisms over 𝑓:𝑐→𝑑 from 𝑝 to π‘ž are proofs that (𝑃𝑓)(π‘ž)=𝑝.

Since 𝑃𝑐 is a set, there is at most one displayed morphism over each 𝑓 between given elements: a morphism of elements is a morphism of π’žοΈ€ that happens to carry π‘ž back to 𝑝. Its total category is the classical category of elements βˆ«π‘ƒ, and a universal element of 𝑃 is exactly a terminal object of βˆ«π‘ƒ.

Definition. Corecursive algebra corecursive-algebra

Fix an endofunctor 𝐹:π’žοΈ€β†’π’žοΈ€. An algebra 𝛼:𝐹𝐡→𝐡 is corecursive when for every coalgebra 𝛾:𝑋→𝐹𝑋 there is exactly one hylomorphism from 𝛾 to 𝛼. Equivalently, the functor π–§π—’π—…π—ˆ(βˆ’,𝛼) of the hylomorphism profunctor is constantly a singleton. It is the dual of a recursive coalgebra: an 𝐹-algebra in π’žοΈ€ is corecursive exactly when it is recursive as an 𝐹op-coalgebra in π’žοΈ€op.

Example. If (𝜈𝐹,π—ˆπ—Žπ—) is a terminal coalgebra, then π—ˆπ—Žπ— is invertible and π—ˆπ—Žπ—βˆ’1:𝐹(𝜈𝐹)β†’πœˆπΉ is a corecursive algebra: a solution of β„Ž=π›Ύβ‹†πΉβ„Žβ‹†π—ˆπ—Žπ—βˆ’1 is the same thing as a solution of β„Žβ‹†π—ˆπ—Žπ—=π›Ύβ‹†πΉβ„Ž, that is, a coalgebra map into the terminal coalgebra, and there is exactly one, π—Žπ—‡π–Ώπ—ˆπ—…π–½π›Ύ.

Theorem. Day Convolution is Closed day-closed-structure

Let 𝒱︀ be a symmetric monoidal closed category that is complete and cocomplete. Let (π’žοΈ€,βŠ—π’žοΈ€,𝐼) be a small monoidal 𝒱︀-enriched category and 𝐴,𝐡 be 𝒱︀-enriched presheaves on π’žοΈ€. Define

(𝐴⊸𝐡)𝑐=βˆ«π‘’π΄π‘’βŠΈπ’±οΈ€π΅(π‘’βŠ—π’žοΈ€π‘).

Then, for Day convolution βŠ—Day,

π΄βŠ—Dayβˆ’βŠ£π΄βŠΈDayβˆ’.

Proof. Proof that Day Convolution is Closed day-closed-structure-proof

For 𝑋,𝐡:π’žοΈ€op→𝒱︀, the enriched hom in [π’žοΈ€op,𝒱︀] is given by the end:

βˆ«π‘((π΄βŠ—Day𝑋)π‘βŠΈπ’±οΈ€π΅π‘)β‰…βˆ«π‘((βˆ«π‘’,π‘£π’žοΈ€(𝑐,π‘’βŠ—π’žοΈ€π‘£)βŠ—π’±οΈ€π΄π‘’βŠ—π’±οΈ€π‘‹π‘£)βŠΈπ’±οΈ€π΅π‘)β‰…βˆ«π‘βˆ«π‘’,𝑣((π’žοΈ€(𝑐,π‘’βŠ—π’žοΈ€π‘£)βŠ—π’±οΈ€π΄π‘’βŠ—π’±οΈ€π‘‹π‘£)βŠΈπ’±οΈ€π΅π‘)β‰…βˆ«π‘’,𝑣((π΄π‘’βŠ—π’±οΈ€π‘‹π‘£)βŠΈπ’±οΈ€βˆ«π‘(π’žοΈ€(𝑐,π‘’βŠ—π’žοΈ€π‘£)βŠΈπ’±οΈ€π΅π‘))β‰…βˆ«π‘’,𝑣((π΄π‘’βŠ—π’±οΈ€π‘‹π‘£)βŠΈπ’±οΈ€π΅(π‘’βŠ—π’žοΈ€π‘£))β‰…βˆ«π‘£(π‘‹π‘£βŠΈπ’±οΈ€βˆ«π‘’(π΄π‘’βŠΈπ’±οΈ€π΅(π‘’βŠ—π’žοΈ€π‘£)))β‰…βˆ«π‘£(π‘‹π‘£βŠΈπ’±οΈ€(𝐴⊸𝐡)𝑣).

∎

Symmetrically, (𝐡⟜𝐴)𝑐=βˆ«π‘£π΄π‘£βŠΈπ’±οΈ€π΅(π‘βŠ—π’žοΈ€π‘£) and βˆ’βŠ—Dayπ΄βŠ£βˆ’βŸœπ΄, so the enriched presheaf category [π’žοΈ€op,𝒱︀] is biclosed [1].

Definition. Day Convolution day-convolution

Let 𝒱︀ be a symmetric monoidal closed category that is complete and cocomplete. Let (π’žοΈ€,βŠ—π’žοΈ€,𝐼) be a small monoidal 𝒱︀-enriched category. The Day convolution of 𝒱︀-enriched presheaves 𝐴,𝐡:π’žοΈ€op→𝒱︀ is the enriched presheaf

(π΄βŠ—Day𝐡)𝑐=βˆ«π‘’,π‘£π’žοΈ€(𝑐,π‘’βŠ—π’žοΈ€π‘£)βŠ—π’±οΈ€π΄π‘’βŠ—π’±οΈ€π΅π‘£,

with unit the representable π’žοΈ€(βˆ’,𝐼).

Day convolution makes the enriched presheaf category [π’žοΈ€op,𝒱︀] a monoidal category, symmetric when π’žοΈ€ is [1]. It is moreover closed.

Under the enriched Yoneda embedding the convolution of representables is representable, π’žοΈ€(βˆ’,π‘₯)βŠ—Dayπ’žοΈ€(βˆ’,𝑦)β‰…π’žοΈ€(βˆ’,π‘₯βŠ—π’žοΈ€π‘¦), so Day convolution is the cocontinuous extension of the tensor of π’žοΈ€.

As a Kan Extension

Equivalently, π΄βŠ—Day𝐡 is the left Kan extension of (𝑒,𝑣)β†¦π΄π‘’βŠ—π’±οΈ€π΅π‘£ along βŠ—π’žοΈ€op:π’žοΈ€opΓ—π’žοΈ€opβ†’π’žοΈ€op.

In π’πžπ­

When 𝒱︀=π’πžπ­, we recover the ordinary Day convolution of presheaves 𝐴,𝐡:π’žοΈ€opβ†’π’πžπ­, where the formula simplifies to:

(π΄βŠ—Day𝐡)𝑐=βˆ«π‘’,π‘£π’žοΈ€[𝑐,π‘’βŠ—π’žοΈ€π‘£]×𝐴𝑒×𝐡𝑣.

Definition. The Quotient and its Right Adjoint in Day Convolution day-quotient

Let 𝐢 be a small monoidal category. Recall that for presheaves 𝐴,𝐡:𝐢opβ†’π’πžπ­, the Day convolution provides a closed monoidal structure:

(π΄βŠ—π΅)(𝑐)=βˆ«π‘’,𝑣𝐢[𝑐,π‘’βŠ—π‘£]×𝐴(𝑒)×𝐡(𝑣)
(𝐴⊸𝐡)(𝑐)=βˆ«π‘’π΄(𝑒)→𝐡(π‘’βŠ—π‘)

which forms an adjunction π΄βŠ—βˆ’βŠ£π΄βŠΈβˆ’.

For covariant functors 𝐴:πΆβ†’π’πžπ­ and presheaves 𝐡:𝐢opβ†’π’πžπ­, we can define the quotient and its right adjoint, each of which is a presheaf on 𝐢:

(𝐷𝐴𝐡)(𝑐)=βˆ«π‘’π΄(𝑒)×𝐡(π‘’βŠ—π‘)
(𝐡𝐴)(𝑐)=βˆ«π‘’,𝑣𝐢[π‘’βŠ—π‘£,𝑐]β†’(𝐴(𝑒)→𝐡(𝑣))

These form the adjunction π·π΄βŠ£βˆ’π΄.

Definition. The Quotient and Residual Coincidence in Day Convolution day-quotient-coincidence

The Day quotient, 𝐷𝐴𝐡, takes 𝐴 to be a covariant functor and 𝐡 to be a contravariant one. While the residual 𝐴⊸𝐡 takes both to be contravariant.

This apparent variance mismatch disappears when we restrict to the groupoid core 𝐺=π–Όπ—ˆπ—‹π–Ύ(𝐢), where variance is trivialized since 𝐺≅𝐺op.

For any functor 𝐹:πΊβ†’π’πžπ­ on the core, we can freely extend it to both a presheaf and a covariant copresheaf on 𝐢 by left Kan extension along the respective inclusions 𝐺→𝐢op and 𝐺→𝐢:

π—†π—„π–―π—Œπ—(𝐹)(𝑐)=βˆ«π‘ βˆˆπΊπΆ[𝑐,𝑠]×𝐹(𝑠)
π—†π—„π–’π—ˆπ—‰π—Œπ—(𝐹)(𝑐)=βˆ«π‘ βˆˆπΊπΆ[𝑠,𝑐]×𝐹(𝑠)

By substituting these extensions into the definitions of the residual and the quotient, we obtain a general coincidence for any 𝐹:πΊβ†’π’πžπ­ and 𝐡:𝐢opβ†’π’πžπ­:

π—†π—„π–―π—Œπ—(𝐹)βŠΈπ΅β‰…π·π—†π—„π–’π—ˆπ—‰π—Œπ—(𝐹)𝐡

This equivalence states that computing the residual against the presheaf extension of 𝐹 is perfectly isomorphic to taking the quotient by its covariant extension.

The Representable Case

Instantiating the above theorem at a representable functor on the core, 𝐹=𝐺[π‘₯,βˆ’]: the co-Yoneda lemma says that the left Kan extensions compute to the representables on 𝐢:

π—†π—„π–―π—Œπ—(𝐺[π‘₯,βˆ’])≅𝐢[βˆ’,π‘₯]
π—†π—„π–’π—ˆπ—‰π—Œπ—(𝐺[π‘₯,βˆ’])≅𝐢[π‘₯,βˆ’]

Applying the general coincidence theorem, the left and right adjoints coincide precisely on (opposite-variance) representables:

(𝐢[βˆ’,π‘₯]⊸𝐡)(𝑐)≅𝐡(π‘₯βŠ—π‘)β‰…(𝐷𝐢[π‘₯,βˆ’]𝐡)(𝑐)

When 𝐢 is the discrete monoidal category of strings, this recovers the derivative of formal grammars.

In nominal sets, I suspect that this construction also describes name abstraction and the freshness quantifier, although I have not check all of the details of the proof.

Definition. Hylomorphism hylomorphism

Fix an endofunctor 𝐹:π’žοΈ€β†’π’žοΈ€, a coalgebra 𝛾:𝑋→𝐹𝑋 and an algebra 𝛼:𝐹𝐡→𝐡. A hylomorphism (or coalgebra-to-algebra morphism) from 𝛾 to 𝛼 is a morphism β„Ž:𝑋→𝐡 satisfying

β„Ž=π›Ύβ‹†πΉβ„Žβ‹†π›Ό.

Definition. The hylomorphism profunctor hylomorphism-profunctor

Fix an endofunctor 𝐹:π’žοΈ€β†’π’žοΈ€. Hylomorphisms form a profunctor from coalgebras to algebras,

π–§π—’π—…π—ˆ:π–’π—ˆπ–Ίπ—…π—€(𝐹)op×𝖠𝗅𝗀(𝐹)β†’π’πžπ­,

where π–§π—’π—…π—ˆ((𝑋,𝛾),(𝐡,𝛼)) is the set of β„Ž:𝑋→𝐡 with β„Ž=π›Ύβ‹†πΉβ„Žβ‹†π›Ό.

The action is by composition. If 𝑔:(π‘Œ,𝛿)β†’(𝑋,𝛾) is a coalgebra morphism (𝑔⋆𝛾=𝛿⋆𝐹𝑔) and π‘˜:(𝐡,𝛼)β†’(𝐡′,𝛼′) is an algebra morphism (π›Όβ‹†π‘˜=πΉπ‘˜β‹†π›Όβ€²), then π‘”β‹†β„Žβ‹†π‘˜ is again a hylomorphism:

𝛿⋆𝐹(π‘”β‹†β„Žβ‹†π‘˜)⋆𝛼′=π›Ώβ‹†πΉπ‘”β‹†πΉβ„Žβ‹†π›Όβ‹†π‘˜=π‘”β‹†π›Ύβ‹†πΉβ„Žβ‹†π›Όβ‹†π‘˜=π‘”β‹†β„Žβ‹†π‘˜.

In these terms, a coalgebra 𝛾 is recursive when π–§π—’π—…π—ˆ(𝛾,βˆ’) is the terminal functor, and an algebra 𝛼 is corecursive when π–§π—’π—…π—ˆ(βˆ’,𝛼) is. For the inverse of an initial algebra the profunctor is representable, π–§π—’π—…π—ˆ(π—‚π—‡βˆ’1,βˆ’)≅𝖠𝗅𝗀(𝐹)(𝗂𝗇,βˆ’), and dually π–§π—’π—…π—ˆ(βˆ’,π—ˆπ—Žπ—βˆ’1)β‰…π–’π—ˆπ–Ίπ—…π—€(𝐹)(βˆ’,π—ˆπ—Žπ—) for a terminal coalgebra.

When every value of π–§π—’π—…π—ˆ is a singleton, every divide-and-conquer specification over 𝐹 has exactly one solution. This is what local contractivity guarantees.

Definition. Lax Functor lax-functor

A lax functor 𝐹:β„¬οΈ€β†’π’žοΈ€ between bicategories consists of

  1. a map on 0-cells, π‘₯↦𝐹π‘₯;
  2. for all π‘₯,𝑦, a functor 𝐹π‘₯,𝑦:ℬ︀(π‘₯,𝑦)β†’π’žοΈ€(𝐹π‘₯,𝐹𝑦), acting on 1-cells and 2-cells;
  3. a unit comparison, natural 2-cells 𝐹π‘₯0:1𝐹π‘₯⇒𝐹(1π‘₯);
  4. a composition comparison, 2-cells 𝐹𝑓,𝑔2:𝐹𝑓⋆𝐹𝑔⇒𝐹(𝑓⋆𝑔) natural in 𝑓 and 𝑔;
  5. such that three coherence laws hold, one for each structure cell of ℬ︀:

    • left unit: (𝐹0▷𝐹𝑓)⋆𝐹1,𝑓2⋆𝐹(πœ†π‘“)=πœ†πΉπ‘“;
    • right unit: (𝐹𝑓◁𝐹0)⋆𝐹𝑓,12⋆𝐹(πœŒπ‘“)=πœŒπΉπ‘“;
    • associativity: (𝐹𝑓,𝑔2β–·πΉβ„Ž)⋆𝐹𝑓⋆𝑔,β„Ž2⋆𝐹(𝛼𝑓,𝑔,β„Ž)=𝛼𝐹𝑓,𝐹𝑔,πΉβ„Žβ‹†(𝐹𝑓◁𝐹𝑔,β„Ž2)⋆𝐹𝑓,π‘”β‹†β„Ž2.

Here ⋆ between 2-cells is vertical composition, and πœƒβ–·β„Ž and β„Žβ—πœƒ are whiskerings.

Lax functors compose: (𝐺∘𝐹)0=𝐺0⋆𝐺(𝐹0) and (𝐺∘𝐹)𝑓,𝑔2=𝐺𝐹𝑓,𝐹𝑔2⋆𝐺(𝐹𝑓,𝑔2). The coherence laws of the composite follow from those of 𝐹 and 𝐺 and naturality of 𝐺2, without using the triangle or pentagon of any of the bicategories involved.

A lax functor whose comparison cells are invertible is a pseudofunctor.

Definition. Lax and Pseudonatural Transformations lax-natural-transformation

Let 𝐹,𝐺:β„¬οΈ€β†’π’žοΈ€ be lax functors. A lax natural transformation 𝜎:𝐹⇒𝐺 consists of

  1. for each 0-cell π‘₯, a 1-cell 𝜎π‘₯:𝐹π‘₯→𝐺π‘₯;
  2. for each 1-cell 𝑓:π‘₯→𝑦, a 2-cell filling the naturality square,

    πœŽπ‘“:πΉπ‘“β‹†πœŽπ‘¦β‡’πœŽπ‘₯⋆𝐺𝑓;
  3. such that πœŽπ‘“ is natural in 𝑓: for a 2-cell πœƒ:𝑓⇒𝑔, (πΉπœƒβ–·πœŽπ‘¦)β‹†πœŽπ‘”=πœŽπ‘“β‹†(𝜎π‘₯β—πΊπœƒ);
  4. and such that 𝜎 respects the comparison cells of 𝐹 and 𝐺: one law relating 𝜎1π‘₯ to 𝐹0, 𝐺0 and the unitors, and one relating πœŽπ‘“β‹†π‘” to πœŽπ‘“, πœŽπ‘”, 𝐹2, 𝐺2 and the associators.

A lax natural transformation is pseudonatural when every πœŽπ‘“ is invertible. As with pseudofunctors, this is a property, so the pseudonatural transformations 𝐹⇒𝐺 are a full subcategory of the category of lax transformations and modifications.

Between prestacks the 1-cells are taken to be pseudonatural. The reason is biuniversality: a transformation whose components 𝜎π‘₯ are all equivalences of categories is an equivalence of prestacks only if its naturality cells are invertible, and a biuniversal element should be exactly a representation of a prestack up to such an equivalence.

Definition. Locally Discrete Bicategory locally-discrete-bicategory

Every category π’žοΈ€ is a bicategory 𝖫𝖣(π’žοΈ€) with only identity 2-cells. Its 0-cells are the objects of π’žοΈ€, and the hom-category 𝖫𝖣(π’žοΈ€)(π‘₯,𝑦) is the discrete category on the set π’žοΈ€(π‘₯,𝑦): a 2-cell 𝑓⇒𝑔 is a proof that 𝑓=𝑔. Composition and identities are those of π’žοΈ€; the unitors and associator are the unit and associativity laws of π’žοΈ€. Since the homs of π’žοΈ€ are sets, any two parallel 2-cells are equal, so the triangle and pentagon hold trivially.

A functor 𝐹:π’žοΈ€β†’π’ŸοΈ€ gives a pseudofunctor 𝖫𝖣(𝐹):𝖫𝖣(π’žοΈ€)→𝖫𝖣(π’ŸοΈ€), whose comparison 2-cells are the functor laws of 𝐹.

The locally discrete bicategory is how ordinary indexed categories enter bicategorical language: a prestack on 𝖫𝖣(π’žοΈ€) is a pseudofunctor π’žοΈ€op→𝖒𝖠𝖳, and its Grothendieck construction is a displayed category over π’žοΈ€.

Definition. Monoidal Category monoidal-category

A monoidal category is a category π’žοΈ€ together with

  1. a functor βŠ—:π’žοΈ€Γ—π’žοΈ€β†’π’žοΈ€, the tensor product;
  2. an object 𝐼 of π’žοΈ€, the unit;
  3. natural isomorphisms

    𝛼π‘₯,𝑦,𝑧:(π‘₯βŠ—π‘¦)βŠ—π‘§β†’π‘₯βŠ—(π‘¦βŠ—π‘§)πœ†π‘₯:πΌβŠ—π‘₯β†’π‘₯𝜌π‘₯:π‘₯βŠ—πΌβ†’π‘₯

    the associator, left unitor and right unitor;

such that the triangle and the pentagon below commute for all objects 𝑀,π‘₯,𝑦,𝑧.

Definition. Nominal Sets nominal-set

Fix a countably infinite set of names 𝔸. A nominal set [1] is a set 𝑋 equipped with an action by the group of finite permutations 𝖯𝖾𝗋𝗆(𝔸), such that every element π‘₯βˆˆπ‘‹ has a finite support.

A finite set of names π‘†βŠ†π”Έ supports π‘₯ if any permutation fixing 𝑆 pointwise also fixes π‘₯. The intersection of all supports for π‘₯ is called the least support, denoted π—Œπ—Žπ—‰π—‰(π‘₯).

The category of nominal sets is equivalent to the Schanuel topos. Under this equivalence, a nominal set 𝑋 corresponds to a functor π•€β†’π’πžπ­, where 𝕀 is the category of finite sets and injections, given by mapping a finite set of names 𝑑 to the set of elements supported by 𝑑:

𝑋(𝑑)={π‘₯βˆˆπ‘‹|π—Œπ—Žπ—‰π—‰(π‘₯)βŠ†π‘‘}

Definition. Nominal Sets as Day Quotients nominal-sets-quotient

In the Schanuel topos, the underlying category for Day convolution is 𝐢=𝕀op, where 𝕀 is the category of finite sets and injections.

Given a nominal set 𝑋, its presheaf action describes elements supported by 𝑑:

𝑋(𝑑)={π‘₯βˆˆπ‘‹|π—Œπ—Žπ—‰π—‰(π‘₯)βŠ†π‘‘}

Instead of taking 𝑋 a priori as a presheaf, we can view it as a finitely- supported 𝖯𝖾𝗋𝗆(𝔸)-set. We can restrict our attention to the groupoid core 𝐺=π–Όπ—ˆπ—‹π–Ύ(𝕀), asking for the support to be exactly the input:

𝑋𝑠={π‘₯βˆˆπ‘‹|π—Œπ—Žπ—‰π—‰(π‘₯)=𝑠}

This family 𝑋‒:πΊβ†’π’πžπ­ is functorial on finite sets and bijections.

By extending this functor along the inclusions described in Quotient Coincidence, we can extend 𝑋‒ to both a presheaf π—†π—„π–―π—Œπ—(𝑋‒) and a copresheaf π—†π—„π–’π—ˆπ—‰π—Œπ—(𝑋‒) on 𝐢. This suggests the equivalence:

π—†π—„π–―π—Œπ—(𝑋‒)βŠΈπ‘Œβ‰…π·π—†π—„π–’π—ˆπ—‰π—Œπ—(𝑋‒)π‘Œ

I suspect this allows us to describe name abstraction [𝑋]π‘Œ [1] β€”which ordinarily looks like an operation on two presheaves of the same varianceβ€”as the quotient of π‘Œ by the induced copresheaf π—†π—„π–’π—ˆπ—‰π—Œπ—(𝑋‒).

Concretely, [𝑋]π‘Œ is usually given by the quotient of the product by an equivalence relation:

[𝑋]π‘Œβ‰…π‘‹Γ—π‘ŒβˆΌ

where (π‘₯,𝑦)∼(πœ‹π‘₯,πœ‹π‘¦) for permutations πœ‹ fixing π—Œπ—Žπ—‰π—‰(𝑦)βˆ’π—Œπ—Žπ—‰π—‰(π‘₯).

On the other hand, the Day quotient computes to a coend:

(π·π—†π—„π–’π—ˆπ—‰π—Œπ—(𝑋‒)π‘Œ)(𝑐)=βˆ«π‘ π‘‹π‘ Γ—π‘Œ(π‘ βŠŽπ‘)

A priori, a coend over 𝑠 of the product π‘‹π‘ Γ—π‘Œ(π‘ βŠŽπ‘) is expressed as the quotient of a set of triples by an equivalence relation β‰ˆ:

{(𝑠,π‘₯,𝑦)|𝑠=π—Œπ—Žπ—‰π—‰(π‘₯),π—Œπ—Žπ—‰π—‰(𝑦)βŠ†π‘ βŠŽπ‘}/β‰ˆ

However, because the comprehension formula fixes 𝑠=π—Œπ—Žπ—‰π—‰(π‘₯), we reduce to a quotient of pairs:

{(π‘₯,𝑦)|π—Œπ—Žπ—‰π—‰(𝑦)βŠ†π—Œπ—Žπ—‰π—‰(π‘₯)βŠŽπ‘}/β‰ˆ

I suspect that this quotient will equate to the one given by [𝑋]π‘Œ, thus resolving the apparent issues with variance. I further suspect that one will need the sheaf condition (pullback-preservation) of nominal sets to establish this equivalence.

Definition. Opposite Bicategory opposite-bicategory

The opposite ℬ︀op of a bicategory ℬ︀ has the same 0-cells and reverses the 1-cells but not the 2-cells:

ℬ︀op(π‘₯,𝑦)=ℬ︀(𝑦,π‘₯).

Composition swaps its arguments, 𝑓⋆op𝑔=𝑔⋆𝑓. The left unitor of ℬ︀op is the right unitor of ℬ︀ and vice versa, and the associator of ℬ︀op is the inverse of the associator of ℬ︀, with its arguments reversed.

Since the 2-cells keep their direction, a lax functor 𝐹:β„¬οΈ€β†’π’žοΈ€ induces a lax (not oplax) functor ℬ︀opβ†’π’žοΈ€op with the same action on cells. Reversing the 2-cells instead gives the bicategory ℬ︀co, whose hom-categories are the opposites (ℬ︀(π‘₯,𝑦))op.

Duality saves work: a coherence lemma about ℬ︀ can often be obtained by instantiating a companion lemma at ℬ︀op, which swaps left and right.

Definition. Pseudofunctor pseudofunctor

A pseudofunctor 𝐹:β„¬οΈ€β†’π’žοΈ€ is a lax functor whose unit and composition comparisons

𝐹π‘₯0:1𝐹π‘₯⇒𝐹(1π‘₯)𝐹𝑓,𝑔2:𝐹𝑓⋆𝐹𝑔⇒𝐹(𝑓⋆𝑔)

are invertible 2-cells. So 𝐹 preserves identities and composition up to coherent isomorphism.

Being pseudo is a property of a lax functor: invertibility of a 2-cell is a proposition, since inverses are unique. The data of a pseudofunctor is exactly the data of a lax functor, and everything proved about lax functors applies to pseudofunctors unchanged. Pseudofunctors are closed under composition and identities, as lax functors are, because invertible 2-cells are closed under composition and under the action of a functor on hom-categories.

The main examples here are prestacks, pseudofunctors ℬ︀op→𝖒𝖠𝖳. When ℬ︀ is locally discrete on a category π’žοΈ€, these are the pseudofunctors π’žοΈ€op→𝖒𝖠𝖳 of fibred category theory.

Definition. Recursive coalgebra recursive-coalgebra

Fix an endofunctor 𝐹:π’žοΈ€β†’π’žοΈ€. A coalgebra 𝛾:𝑋→𝐹𝑋 is recursive when for every algebra 𝛼:𝐹𝐡→𝐡 there is exactly one hylomorphism β„Ž:𝑋→𝐡 from 𝛾 to 𝛼, that is, exactly one solution of

β„Ž=π›Ύβ‹†πΉβ„Žβ‹†π›Ό.

Equivalently, the functor π–§π—’π—…π—ˆ(𝛾,βˆ’) of the hylomorphism profunctor is constantly a singleton.

Recursiveness is a coalgebraic form of well-foundedness: 𝛾 decomposes each input into subproblems, and recursiveness says that every divide-and-conquer program built on this decomposition has a unique meaning, without mentioning an order on inputs. [1] use recursive coalgebras on categories of indexed families to obtain algorithms that are correct by the type of the map they compute.

Example. If (πœ‡πΉ,𝗂𝗇) is an initial algebra, then 𝗂𝗇 is invertible (Lambek’s lemma) and π—‚π—‡βˆ’1:πœ‡πΉβ†’πΉ(πœ‡πΉ) is a recursive coalgebra. Precomposing with the isomorphism 𝗂𝗇, the equation β„Ž=π—‚π—‡βˆ’1β‹†πΉβ„Žβ‹†π›Ό is equivalent to π—‚π—‡β‹†β„Ž=πΉβ„Žβ‹†π›Ό, which says β„Ž is an algebra map out of the initial algebra; there is exactly one, π–Ώπ—ˆπ—…π–½π›Ό.

The dual notion is a corecursive algebra.

Definition. The Schanuel Topos schanuel-topos

Let 𝕀 be the category of finite sets and injections. The Schanuel topos is the category of pullback-preserving functors 𝕀opβ†’π’πžπ­.

Equivalently, it is the category of nominal sets, which are sets equipped with an action by the group of permutations on a countable set of names 𝔸, such that every element has finite support.

Definition. Total Bicategory total-bicategory

The total bicategory of a displayed bicategory over 𝒦︀ packages the base and the displayed data together, one dimension up from the total category of a displayed category.

  • Its 0-cells are pairs of a 0-cell of 𝒦︀ and a displayed 0-cell over it.
  • Its hom-category from to is the total category of the displayed hom-category . So a 1-cell is a pair and a 2-cell is a pair .
  • Identities, composition, unitors and associator are pairs of the base structure and the displayed structure over it, and the triangle and pentagon hold because they hold in the base and, over that, in the displayed bicategory.

Projecting to first components is a pseudofunctor whose unit and composition comparisons are identity 2-cells.

mechanized-category-theory note entries/home/mechanized-category-theory.hel