Category Theory
Zulip Server
Archive

You're reading the public-facing archive of the Category Theory Zulip server.
To join the server you need an invite. Anybody can get an invite by contacting Matteo Capucci at name dot surname at gmail dot com.
For all things related to this archive refer to the same person.


Stream: learning: questions

Topic: Tensor product as coend


view this post on Zulip Nathaniel Virgo (Nov 22 2020 at 12:29):

I'm trying to get my head around ends and coends. I like to learn from examples, which are weirdly hard to find for this topic, but I did find one in CWM (on p. 226):

image.png

This makes a vague sort of qualitative sense to me. I don't know anything about modules, but I guess I can just replace "ring" with "field" and "module" with "vector space" and everything will be the same (except I guess the op^\mathrm{op} won't matter any more, because a field in this context is a commutative monoid with an extra operation defined on it, and commutative monoids are their own opposites).

However, I'm a bit confused. It makes sense to me that a module (or a vector space) is a functor from RR to Ab\mathbf{Ab} in the sense described. But surely the tensor product of two vector spaces ought to be another vector space, which means I'd expect it also to be a functor from RR to Ab\mathbf{Ab}. The coend "integrates out" the dependence on RR, so it doesn't give a functor from RR to Ab\mathbf{Ab} but only an Abelian group. This makes it hard for me to see how the object MM can be the tensor product of AA and BB.

Can anyone figure out what my confusion is and help me resolve it?

view this post on Zulip Matteo Capucci (he/him) (Nov 22 2020 at 12:42):

Nathaniel Virgo said:

However, I'm a bit confused. It makes sense to me that a module (or a vector space) is a functor from RR to Ab\mathbf{Ab} in the sense described. But surely the tensor product of two vector spaces ought to be another vector space, which means I'd expect it also to be a functor from RR to Ab\mathbf{Ab}.

This is almost true. The tensor product of two RR-modules is not, in general, an RR-module! This is because the tensor kills the right module structure of the first module and the left module structure of the second module, because you want bilinearity.
In symbols: if AA is a (R,S)(R, S)-bimodule (i.e., a left RR-module and a right SS-module) and BB is a (S,T)(S, T)-bimodule, then you can form their SS-tensor product ASBA \otimes_S B which has the structure of a (R,T)(R, T)-bimodule (notice the SS-module structure was killed).

view this post on Zulip Matteo Capucci (he/him) (Nov 22 2020 at 12:44):

If RR is commutative though, every left RR-module is also a right RR-module (because R=RopR = R^{op}), and thus carries the structure of a (R,R)(R,R)-bimodule. This means that the category of RR-modules is monoidal with respect to R\otimes_R.

view this post on Zulip Matteo Capucci (he/him) (Nov 22 2020 at 12:47):

Back to the true question: why is RAZBR \mapsto A \otimes_{\Bbb Z} B (also this notation is extremely confusing: the RR I just wrote is the single, dummy object of the one-object category RR) a functor Rop×RAbR^{op} \times R \to Ab? Well, because AZBA \otimes_{\Bbb Z} B is an (R,R)(R,R)-bimodule! :laughing:
In practical terms, there's an action of RR both on the left and the right.

view this post on Zulip Matteo Capucci (he/him) (Nov 22 2020 at 12:48):

If you look at the cowedge diagram, you see what it means: if you choose an element rRr \in R, you can use it to multiply an element abAZBa \otimes b \in A \otimes_{\Bbb Z} B on the left or on the right

view this post on Zulip Fabrizio Genovese (Nov 22 2020 at 12:51):

Matteo Capucci said:

If you look at the cowedge diagram, you see what it means: if you choose an element rRr \in R, you can use it to multiply an element abAZBa \otimes b \in A \otimes_{\Bbb Z} B on the left or on the right

Yes, this is also the intuition behind opitcs as coends btw. You are taking pairs of morphisms (f,g)(f,g). Now you want to depict these as a comb, so you want to interpret ff as ``connected'' with gg. But what does this mean in practice? It means, string diagrammatically, that if f,gf,g are connected by a wire you can put another morphism on that wire and you can slide it freely towards ff or towards gg. This means that you want to identify pairs (f;h,g)(f ; h, g) and (f,h;g)(f, h' ;g) for whatever h,hh, h' for which these compositions make sense and typecheck, and this is precisely what the coend does for you

view this post on Zulip Fabrizio Genovese (Nov 22 2020 at 12:52):

(I don't know if this explanation makes things more clear or more confused, if it's the former I'm sorry D: )

view this post on Zulip Matteo Capucci (he/him) (Nov 22 2020 at 12:52):

Now you want this two actions to be the same, i.e. you want to homogeneize AZBA \otimes_{\Bbb Z} B with respect to the actions of RR. This means imposing r(ab)=(ab)rr \cdot (a \otimes b) = (a \otimes b) \cdot r (+ linearity), which is what gives you the RR-tensor of AA and BB.
That's what the coend says. Maybe a more explicit notation would have been:
rRr(AZB)r\int^{r \in R} r \cdot (A \otimes_{\Bbb Z} B) \cdot r

view this post on Zulip Matteo Capucci (he/him) (Nov 22 2020 at 12:53):

Fabrizio Genovese said:

Matteo Capucci said:

If you look at the cowedge diagram, you see what it means: if you choose an element rRr \in R, you can use it to multiply an element abAZBa \otimes b \in A \otimes_{\Bbb Z} B on the left or on the right

Yes, this is also the intuition behind opitcs as coends btw. You are taking pairs of morphisms (f,g)(f,g). Now you want to depict these as a comb, so you want to interpret ff as ``connected'' with gg. But what does this mean in practice? It means, string diagrammatically, that if f,gf,g are connected by a wire you can put another morphism on that wire and you can slide it freely towards ff or towards gg. This means that you want to identify pairs (f;h,g)(f ; h, g) and (f,h;g)(f, h' ;g) for whatever h,hh, h' for which these compositions make sense and typecheck, and this is precisely what the coend does for you

Indeed, the structure involved is the same: a left RR-module is just an object with a monoidal action from RR!

view this post on Zulip Nathaniel Virgo (Nov 22 2020 at 13:08):

Fabrizio Genovese said:

Yes, this is also the intuition behind opitcs as coends btw. You are taking pairs of morphisms (f,g)(f,g). Now you want to depict these as a comb, so you want to interpret ff as ``connected'' with gg. But what does this mean in practice? It means, string diagrammatically, that if f,gf,g are connected by a wire you can put another morphism on that wire and you can slide it freely towards ff or towards gg. This means that you want to identify pairs (f;h,g)(f ; h, g) and (f,h;g)(f, h' ;g) for whatever h,hh, h' for which these compositions make sense and typecheck, and this is precisely what the coend does for you

This is exactly what I'm really trying to understand - I sort of get this, but I'm trying to really get a hold of the formal details. (Just on the off chance: do you know of anywhere where coends are introduced with this kind of application in mind?)

view this post on Zulip Nathaniel Virgo (Nov 22 2020 at 13:21):

@Matteo Capucci thank you so much for this explanation, it's really helpful.

So to summarise, I should think of vector spaces not as RR-modules but as (R,R)(R,R)-bimodules. Then the coend is doing this sort of thing, to leave me with another (R,R)(R,R)-bimodule in the end. This makes sense to me.

image.png

(Don't ask me to say formally what this diagram is yet though.)

view this post on Zulip Matteo Capucci (he/him) (Nov 22 2020 at 13:24):

Yes, in a sense. The point is, when R is commutative every module is a bimodule. Just keep in mind this!

view this post on Zulip Matteo Capucci (he/him) (Nov 22 2020 at 13:25):

In the coend definition of profunctor optics, you have something more close to (R, S)-bimodules, that is, in general the left action is not the same as the right action, and might even come from a different ring

view this post on Zulip Reid Barton (Nov 22 2020 at 13:26):

Not every (R,R)(R, R)-bimodule is an RR-module in the commutative sense though, just the ones for which the left and right actions agree, i.e., rm=mrrm = mr

view this post on Zulip Reid Barton (Nov 22 2020 at 13:26):

This property is preserved by this tensor product of bimodules operation.

view this post on Zulip Fabrizio Genovese (Nov 22 2020 at 13:35):

Nathaniel Virgo said:

Fabrizio Genovese said:

Yes, this is also the intuition behind opitcs as coends btw. You are taking pairs of morphisms (f,g)(f,g). Now you want to depict these as a comb, so you want to interpret ff as ``connected'' with gg. But what does this mean in practice? It means, string diagrammatically, that if f,gf,g are connected by a wire you can put another morphism on that wire and you can slide it freely towards ff or towards gg. This means that you want to identify pairs (f;h,g)(f ; h, g) and (f,h;g)(f, h' ;g) for whatever h,hh, h' for which these compositions make sense and typecheck, and this is precisely what the coend does for you

This is exactly what I'm really trying to understand - I sort of get this, but I'm trying to really get a hold of the formal details. (Just on the off chance: do you know of anywhere where coends are introduced with this kind of application in mind?)

"Profunctor optics a categorical update" has this coend flavor imho

view this post on Zulip fosco (Nov 22 2020 at 13:35):

Indeed, it does! \int

view this post on Zulip Fabrizio Genovese (Nov 22 2020 at 13:36):

Anyway, see it like this: Think graphically. An optic is a comb, ok? Now you want a way to "formalize" this comb. You start noticing that if you cut the comb in half, you get two morphisms. So you may think "neat, I'll formalize the comb as a pair of morphisms". And then you have the problem I highlighted above: If you have a box living on one of the wires you split, on which side of the pair do you put it?

view this post on Zulip Fabrizio Genovese (Nov 22 2020 at 13:36):

The coend formalization says "it doesn't matter, because we identify the pairs that can be transformed one into the other by sliding such a box."

view this post on Zulip Fabrizio Genovese (Nov 22 2020 at 13:38):

This is probably the handwaviewst explanation of what's going on, but also the one that makes intuitively more sense in my opinion. Anyway @fosco is here and he's one of the authors of said paper, so... :smile:

view this post on Zulip Jules Hedges (Nov 22 2020 at 14:40):

The oldest paper where coend optics is written down is probably Riley's "categories of optics", but it was apparently functional programming folklore for a long time before that

view this post on Zulip fosco (Nov 22 2020 at 16:38):

I could say something on optics, but I'd rather comment on the original question posed by OP; I'll do it as soon as possible!

view this post on Zulip John Baez (Nov 22 2020 at 17:22):

Nathaniel Virgo said:

Matteo Capucci thank you so much for this explanation, it's really helpful.

So to summarise, I should think of vector spaces not as RR-modules but as (R,R)(R,R)-bimodules. Then the coend is doing this sort of thing, to leave me with another (R,R)(R,R)-bimodule in the end. This makes sense to me.

Digressing somewhat: a good physicist named Stephen Adler wrote a book Quaternionic Quantum Mechanics and Quantum Fields, where he tried to do quantum physics using "quaternionic Hilbert spaces", which are left modules over the quaternions. He got into a big mess when he tried to tensor these, as you must when combining quantum systems. He should have used bimodules!

You can do quantum mechanics using modules over the division algebras R\mathbb{R}, C\mathbb{C} or H\mathbb{H}, but since the quaternions H\mathbb{H} are noncommutative, if you want to tensor these modules you should probably use bimodules, and then you might as well think about things like (C,H)(\mathbb{C}, \mathbb{H})-bimodules where one division algebra acts on the left and the other acts on the right. I haven't gotten around to studying this very much yet, despite being a bit obsessed with division algebras in quantum mechanics.

view this post on Zulip Reid Barton (Nov 22 2020 at 17:42):

Does that mean that when you combine quantum systems in this setting, the order matters?

view this post on Zulip Nathaniel Virgo (Nov 23 2020 at 03:47):

Thinking more on the points about modules and vector spaces: does this mean there's a general theory that can be developed about ends and coends in the case where the source category is a commutative monoid? It seems like the story Matteo Capucci told only really depends on that.

So can we say that if TT is a commutative monoid (seen as a single-object category) and C\mathscr{C} is a monoidal category, then can we generalise "every vector space is really a bimodule" to "any functor F ⁣:TCF\colon T\to \mathscr{C} is really a functor F ⁣:Top×TCF\colon T^\text{op}\times T \to \mathscr{C}"? Then I guess we can then define a tensor product of such functors (if it exists) by a coend, which I guess would be written

(FTG)(s,u)=tTF(s,t)G(t,u).(F\otimes_T G)(s,u) = \int^{t\in T} F(s,t)\otimes G(t,u).

If that does work, what's the sense in which a functor TCT\to \mathscr{C} is "really" a functor Top×TCT^\text{op}\times T\to \mathscr{C}? (How do we formally construct one from the other?) And does this coend construction reduce to something simpler in this case? Sorry if this is a silly question.

view this post on Zulip Matteo Capucci (he/him) (Nov 23 2020 at 09:32):

Nathaniel Virgo said:

(FTG)(s,u)=tTF(s,t)G(t,u).(F\otimes_T G)(s,u) = \int^{t\in T} F(s,t)\otimes G(t,u).

I believe this should be

(FTG)()=TF()G().(F\otimes_T G)(\bullet) = \int^{\bullet \in T} F(\bullet)\otimes G(\bullet).

view this post on Zulip Matteo Capucci (he/him) (Nov 23 2020 at 10:36):

Matteo Capucci said:

rRr(AZB)r\int^{r \in R} r \cdot (A \otimes_{\Bbb Z} B) \cdot r

I now realized this is very bad notation, and quite wrong, since rr is a morphism

view this post on Zulip Matteo Capucci (he/him) (Nov 23 2020 at 11:26):

Nathaniel Virgo said:

So can we say that if TT is a commutative monoid (seen as a single-object category) and C\mathscr{C} is a monoidal category, then can we generalise "every vector space is really a bimodule" to "any functor F ⁣:TCF\colon T\to \mathscr{C} is really a functor F ⁣:Top×TCF\colon T^\text{op}\times T \to \mathscr{C}"?

I believe the answer to be yes, let's check. For clarity, let me call TT the monoid and BT\mathbf BT its delooping, i.e. the one-object (the object is \bullet) category whose only hom-set is TT.
A functor F:BTCF: \mathbf B T \to \mathscr C is the choice of an object XX of C\mathscr C and an homomorphism of monoids TEnd(X)T \to \mathrm{End}(X).
We can denote the action of tTt \in T on XX as tt \cdot -, so we say FF is a left action.
Now, since TT is commutative, BT=BTop\mathbf B T = \mathbf B T^{op}, we see that FF is also a right action, that is, a functor BTopC\mathbf B T^{op} \to \mathscr C picking again XX as the object but acting now on XX on the right, i.e. we write t- \cdot t for the endomorphism induced by tTt \in T.
Suppose now that C\mathscr C is monoidal. Then given G,T:BTCG, T : \mathbf B T \to \mathscr C, we can tensor it by putting together their target object using C\mathscr C's monoidal product, and then having one acting on the left and one on the right.
More precisely, we get an action of Top×T=T×TT^{op} \times T = T \times T embodied by a functor GTF:BT2CG \otimes_T F : \mathbf B T^2 \to \mathscr C. Notice that BT2=BTop×BT=BT×BT\mathbf B T^2 = \mathbf B T^{op} \times \mathbf B T = \mathbf B T \times \mathbf B T. The functor acts on objects by sending \bullet to G()F()G(\bullet) \otimes F(\bullet), and on morphisms by sending (s,t)(s,t) to sts \cdot - \otimes - \cdot t.
A bit of terminology: X:CX : \mathscr C with an action of TT is called a left TT-module in C\mathscr C. In other words, left TT-modules in C\mathscr C are functors BTC\mathbf BT \to \mathscr C. Unsurprisingly, they form a category, that we could denote by TCModT-\mathscr C\mathrm{Mod}. Morphisms are natural transformations. In the same vein, we get a category CModT\mathscr C\mathrm{Mod}-T of right TT-modules in C\mathscr C. A TT-bimodule in C\mathscr C is just a left and right TT-module, i.e. an object of C\mathscr C equipped with a left and right action of TT, i.e. a functor BTop×BTC\mathbf B T^{op} \times \mathbf B T \to \mathscr C.
Notice that CModTop=TCMod\mathscr C\mathrm{Mod}-T^{op} = T-\mathscr C\mathrm{Mod}, that is, left TT-modules are the same thing as right TopT^{op}-modules. Therefore, when TT is commutative, right and left modules are the same thing!

view this post on Zulip Matteo Capucci (he/him) (Nov 23 2020 at 11:31):

The last step is probably to show that you need the coend to define a functorial monoidal product in the category of bimodules, since their product otherwise ignores the actions 'in the middle', which then you need to quotient out.