# Composition of spans as a morphism of profunctors

Let $\bf C$ be a category with pullbacks. Define $Span\colon (A,B)\mapsto \{ (X,f,g)\mid A\xleftarrow{f}X\xrightarrow{g}B\}$ and notice that it is a profunctor $s\colon \bf C^\text{op}\rightsquigarrow C$, namely a functor $\bf C\times C\to Sets$:

• $h\colon B\to B'$ induce $s(A,h)\colon \big(A\xleftarrow{f}X\xrightarrow{g}B\big)\mapsto \big( A\xleftarrow{f}X\xrightarrow{hg}B'\big)$;
• $k\colon A\to A'$ induce $s(k,B)\colon \big(A\xleftarrow{f}X\xrightarrow{g}B\big)\mapsto \big( A'\xleftarrow{kf}X\xrightarrow{g}B\big)$.

Similarly there is a cospan profucntor $Cospan =c\colon \bf C \rightsquigarrow C^\text{op}$.

Problem (click): Composition of spans, defined via a suitable pullback, gives $Span(\bf C)$ the structure of a bicategory, and can be interpreted as a morphism of profunctors $s\diamond c\diamond s\Rightarrow s$, where $\diamond$ is the composition law $$\phi\diamond\psi(A,B) := \int^X \phi(A,X)\times \psi(X,B)$$ I'm stuck in trying to explicitly write the content of the coend $$\int^{X}\int^Y s(A,X)\times c(X,Y)\times s(Y,B)$$ Even the slightest help is welcome, thanks for your time. Unfortunately I'm not able to find any reference about that result which is only sketched in the linked notes.

-
Would you need to use some sort of Fubini type result (and iterated coends, rather than a single one as your last displayed equation)? –  David Roberts May 24 '13 at 1:43
I edited the OP, maybe that notation is confusing. –  tetrapharmakon May 24 '13 at 7:06
@tetrapharmakon, it is easier, to write the natural family of morphisms $s(A,X) \times c(X,Y) \times s(Y,B) \rightarrow s(A,B)$ –  Michal R. Przybylek May 24 '13 at 14:21
I'm totally aware that the typical object in the coend is $(A\leftarrow U\to X,X\to V\leftarrow Y, Y\leftarrow W\to B)$, so the only thing to do now is to compose $A\leftarrow U\to V\leftarroe W\to B$, and then pulling back to obtain a span $A\leftarrow P\to B$, but I'm not able to find that this operation, defined as $\coprod_{XY}s(A,X)c(X,Y)s(Y,B)\to s(A,B)$, indeed passes to the quotient (maybe because the equivalence relation defining the coend seems quite involved to write down). –  tetrapharmakon May 25 '13 at 9:30