A notion of trace is generally definable for maps in a compact closed category (even more generally in a traced monoidal category), and here the idea is to categorify this to the context of compact closed bicategories, in particular the bicategory of bimodules between small categories.
Let be a compact closed symmetric monoidal category, with monoidal product and monoidal unit . The trace of an endomorphism is the composite
where is a unit and is a counit of appropriate adjunctions (note that the symmetry makes the dual both a right and left adjoint of : the adjunctions are ambidextrous). In the classical case where is the category of finite-dimensional vector spaces with its usual monoidal structure, this gives the usual trace of an endomorphism; in particular, for , this defines .
The same idea applies to compact closed symmetric monoidal bicategories. In particular, it applies to the bicategory Prof whose objects are small categories, whose 1-morphisms are profunctors , i.e., functors
and whose 2-morphisms are natural transformations between profunctors. The bicategory is a cartesian bicategory and hence symmetric monoidal under , and is also compact closed: the dual of a category in this case is just the opposite category , and the unit and counit profunctors
are given by and . Composing these (according to the coend formula for profunctor composition) yields
and this is the trace of the identity in (which as a functor is also given by ); this coend is called the trace of the category . It could also reasonably be called, by analogy with the vector space case, the dimension of the category . The trace of a general endoprofunctor on is the coend
which generalizes the trace of linear functions:
(where the matrix entries are computed with respect to any basis).
The foregoing discussion can be generalized to the case of bimodules between small categories enriched in a cocomplete symmetric monoidal closed category , where the dimension of a small -category is the object of given by the enriched coend
We calculate the trace or dimension of FinSet, the category of finite sets. The calculation is quite down-to-earth: the relevant coend is just the quotient of the set of all endofunctions between finite sets, modulo the equivalence relation generated by the stipulation whenever and are functions between finite sets.
Let be a finite endofunction, and let
be its epi-mono factorization. Then ; if we think of as the image , then can be viewed as the restriction
and this process iterates. The sequence of epis
eventually stabilizes (after finitely many steps) to a finite set on which restricts to a surjective endofunction, which is a bijection since we are dealing with finite sets. Thus every is -equivalent to a permutation .
Furthermore, given two permutations and such that is witnessed by a chain of function equalities
one may show (using and similarly ) that
which implies that is invertible and , or . Conversely, if , then for we have and , so .
In other words, the trace of the category of finite sets is isomorphic to the trace of the underlying groupoid of finite sets and bijections, where the equivalence classes with respect to are the conjugacy classes of permutations, given by cycle types. In this way, the trace of is naturally identified with the class of finite Young diagrams.