Login
You're viewing the functional.cafe public feed.
  • Sep 8, 2026, 9:04 PM

    A coend is a gadget to glue two profunctors together.
    A profunctor is a gadget to glue categories together.
    A category is a gadget to glue pairs of objects together.

    So... there's a cherry tree C above, and some dark blueberry shrubs D at our feet. A spider named P (friends call him Pavuk) has cast a thread p(c,d) from a cherry c to a darkberry d.

    This picture seems kind of enough to understand coends, but let's have a look at a property of profunctors that helps motivate how we might end up having many arrows in each resulting set.

    Our example will be the hom-profunctor. It maps pairs of objects c,d from categories C and D to sets of arrows:

    P: (C^op,D)->Set
    p(c,d) = hom(c,d)

    Now this picture really is enough to understand why P's first argument is contravariant! C^op is the opposite of C, with all arrows reversed. Check this out:

    I have p(c,d) and I now want to connect different objects p(c',d') with help of arrows from C and D. These would work:

    f: c'->c
    g: d->d'

    See how they point in opposite directions? The first arrow f needs to connect to the tail of p(c,d), the second to its head!

    We say that f and g can be lifted to a profunctor p(c',d').

    And here we come to the heart, the axiomatic description of what a profunctor is:

    dimap: (C->C,D->D,P)->P
    dimap(f,g,p(a,b))

    P is a profunctor when we have a dimap implementation.

    Do you also have an itch to write p(c,d) using an arrow? Also, what about hom(c,d)?:

    p(c,d) = c->d = hom(c,d)

    You can tell we are doing category theory, because I keep invoking new words like excuses. You can tell, because all those words end up saying almost the same.

    1/3

    💬 1🔄 0⭐ 0

Replies

  • Sep 8, 2026, 9:05 PM

    Please, no more poetry, what's a coend?!

    It's what we need to do to combine two sets of arrows p(c,d) and q(d,e).

    (q o p)(c,e) = S^d p(c,d)×q(d,e)

    The composition q after p (q o p) should give a profunctor that returns all possible ways to get from c to e.

    Then the set of combined arrows has an element for every p(c,d) times every arrow in q(d,e).

    Note the superscript d on the integral sign S? It's a variable running over all of D. Now that's another way to make sets of arrows? Didn't I just introduce hom-sets for that? I think we need sets as output, and hence should make sure we can handle them as input, too. However, I still feel somewhat confused in this regard.

    There's, of course, an axiomatic way to describe coends. You need to implement these:

    i_x: P(x,x)->S^a P(a,a)
    α_x: P(x,x)->s

    so there is a unique function h such that

    α_x = h o i_x

    While I might have successfully butchered copy pasting that definition from @bartosz blog post, I have no idea how to make use of it. – It features profunctors where C and D are the same. You can keep composing those, whereas we would have to contend following at most one of Pavuk's threads on any of our ways from C to D.

    I might also struggle a little to answer this one: Isn't a profunctor just a functor? – It certainly is a functor if I look at the arrow in P's type:

    P: C^op,D -> Set

    But it is not a functor F of this type:

    F: C->D

    The consistency requirements for profunctors are weaker.

    2/3

    💬 1🔄 0⭐ 0
  • Sep 8, 2026, 9:07 PM

    Anyways, let's look at a more delightful area for confusion. Remember Einstein summation?

    (pq)^i_k =
    p^i_j · q^j_k =
    sum_j p^i_j · q^j_k

    This summation looks a lot like our coend notation! In fact, that is exactly the kind of thing you would model using coends. It also explains why we might need different coends: there are variations of Einstein summation that introduce minus signs in interesting ways, or only sum components that are ordered in a certain way. That's something you might encounter if you wanted to read Rindler and Penrose's books on spinors.

    So, finally, I can answer what made me go through all of this: Using an integral sign for coends is either fabulously bad notation, or absolutely ingenious. What is it?

    LINKS

    Here's where it started:

    mathstodon.xyz/@RefurioAnachro

    I spent a lot of time staring at @BartoszMilewski's blog posts here:

    bartoszmilewski.com/2019/03/27
    bartoszmilewski.com/2017/03/29

    Thank you, Bartosz! Also, special thanks to @johncarlosbaez for valuable hints!

    3/end

    💬 0🔄 0⭐ 3