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 sketch the calculation of 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
This argument shows that the trace of the category of finite sets is isomorphic to the trace of the underlying groupoid of finite sets and bijections. Here the equivalence classes with respect to are the conjugacy classes of permutations; in this way, the trace can be identified with the class of finite Young diagrams.