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: optics - grates


view this post on Zulip Bruno Gavranović (May 24 2021 at 16:12):

I'm trying to understand the definition of a grate in the Profunctor optics: a categorical update paper (Proposition 3.31).

Namely, the variances of the monoidal actions used here seem to be wrong. If I look at the 2nd line of the isomorphism in the screenshot, I see the that variable CC bound in the coend is used twice, but both times with the same variance. However, a coend requires bivariance.
Screenshot_20210524_170902.png

How do I understand this?

view this post on Zulip Reid Barton (May 24 2021 at 16:36):

Comparing Def 3.30 to the type signature above it, I guess Def 3.30 is wrong (the \bullet should be some kind of cotensor, contravariant in the CC argument)...?

view this post on Zulip Bruno Gavranović (May 24 2021 at 17:00):

Hmm, I suppose so. I'll have to unpack what this really means. Even with this information, it's kind of strange to see both CC's appear on the left side of the hom...

view this post on Zulip Bruno Gavranović (May 24 2021 at 17:15):

On second thought, I'm not sure if that's correct, @Reid Barton . For instance, take a look at Prop. 3.2 in the same paper which defines Lenses.

Screenshot_20210524_180734.png

They use two covariant functors in two variables. One would think that's wrong as well, but I now think that that the actual contravariance in the first line of the coend arises as follows.

The functor D(,T):DopSet\mathcal{D}(- , T) : \mathcal{D}^{op}\to \mathcal{Set} is contravariant, and what happens is that we first apply BB to \bullet to get a functor (B):CD(- \bullet B) : \mathcal{C} \to \mathcal{D} which we then "op", i.e. we take (B)op:CopDop(- \bullet B)^{op} : \mathcal{C}^{op} \to \mathcal{D}^{op} and plug it into the functor at the beginning of this paragraph.

Does that seem reasonable?

If so, then I am still pretty confused about the flow of information in a grate, and the lack of explicit variance in the paper isn't helping.

view this post on Zulip Reid Barton (May 24 2021 at 17:20):

I agree 3.2 is fine.

view this post on Zulip Reid Barton (May 24 2021 at 17:22):

But the types of a lens corresponding to Def 3.1 would be something like get :: s -> a, set :: (s, b) -> t. So here \bullet seems to correspond to pairing (which makes sense, as it's covariant in both arguments). Whereas in the grates section, an arrow appears instead in ((s -> a) -> b) -> t--I mean the one between s -> a and b.

view this post on Zulip Bruno Gavranović (May 24 2021 at 17:24):

I'll think about what you posted, but in the meantime I'll post what I started writing:

I really don't know how to interpret the flow of information in grates causally. Maybe it helps if I write down how I think of lenses/prisms.

In lenses, we take an input, then save a state and produce an output. When we get a result from the environment, we use it and the state we saved to produce an update.

In prisms, we take an input, then save a state or produce an output (i.e. query the environment). Depending on what we did, we either use an output from the environment or the saved state.

But in grates, I don't know what the story is. (the short description in the paper does not really help)

view this post on Zulip Bruno Gavranović (May 24 2021 at 17:36):

Reid Barton said:

But the types of a lens corresponding to Def 3.1 would be something like get :: s -> a, set :: (s, b) -> t. So here \bullet seems to correspond to pairing (which makes sense, as it's covariant in both arguments). Whereas in the grates section, an arrow appears instead in ((s -> a) -> b) -> t--I mean the one between s -> a and b.

Are you saying the \bullet is also something like an exponential? This is pretty strange, especially since they don't refer it in the paper as such:
Screenshot_20210524_183648.png
i.e. they call the other thing the exponential, but not \bullet.

view this post on Zulip Reid Barton (May 24 2021 at 17:36):

Also, since the exponential {,}\{-, -\} of C\mathbf{C} has type Cop×CC\mathbf{C}^\mathrm{op} \times \mathbf{C} \to \mathbf{C}, the first argument of \bullet also has to live in Cop\mathbf{C}^\mathrm{op} to match the general notion of an optic (2.1).

view this post on Zulip Reid Barton (May 24 2021 at 17:38):

\bullet could be the exponential for example if D=C\mathbf{D} = \mathbf{C}.

view this post on Zulip Reid Barton (May 24 2021 at 17:40):

It would be unusual to use a multiplication-like symbol like \bullet for an exponential/cotensor type operation though. So I'm guessing there was some kind of confusion on the author's side.

view this post on Zulip Reid Barton (May 24 2021 at 17:40):

I haven't heard of grates before either, so I can't help you there.

view this post on Zulip Verity Scheel (May 24 2021 at 17:44):

In the programming sense of grates, ((s -> a) -> b) -> t can be read as “having a function giving an element b for a given accessor (s -> a) produces a new container t”. The idea is the accessors (s -> a) index the (fixed number of) positions in the container whose shape is shared by s and t. These end up having to be representable functors, I believe, because they are containers with a fixed shape. I’m not familiar with the categorical interpretations of optics I’m afraid.

view this post on Zulip Verity Scheel (May 24 2021 at 17:48):

https://r6research.livejournal.com/28050.html

view this post on Zulip Bruno Gavranović (May 24 2021 at 18:36):

Reid Barton said:

It would be unusual to use a multiplication-like symbol like \bullet for an exponential/cotensor type operation though. So I'm guessing there was some kind of confusion on the author's side.

Perhaps someone from the profunctor gang can help us here? @Bryce Clarke , @fosco, @Mario Román, @Emily Pillmore ?

view this post on Zulip Bruno Gavranović (May 24 2021 at 18:38):

Nick Scheel said:

https://r6research.livejournal.com/28050.html

Thanks! This is one of those blog posts I've seen before, but they are very hard to understand for me...

view this post on Zulip Matteo Capucci (he/him) (May 24 2021 at 21:24):

Assume C=D\mathbf C = \mathbf D (thus =\bullet = \otimes). Assume we choose a representative (M,v,u)(M, v, u) for a grate α:(A,S)(B,T)\alpha : (A,S) \to (B,T). The view part vv is a map A{M,B}A \to \{M, B\}, while uu is a map MTSM \otimes T \to S.
I can think of the view part as returning a bunch of BB s ( :bee: ), a bunch indexed by MM. Then the update takes in an MM and a TT. One can use the MM to access a BB, using the map returned by vv. Then you have a BB and a TT and you can do your thing uu to get an SS

view this post on Zulip Matteo Capucci (he/him) (May 24 2021 at 21:29):

This also shows that MM is useless, since it can always be shortcut by evaluation. Indeed, the coend reduction shows that I can always assume M=AM=A, basically, so that the update receives a map f:{A,B}f :\{A, B\} and a TT. Then it evaluates ff with the state a:Aa : A coming from outside, and finally gets its BB.

view this post on Zulip Matteo Capucci (he/him) (May 24 2021 at 21:30):

So maybe an intuition for this is that the computation of BB is deferred: I never actually return BB to the environment, and I first ask for a continuation TT. Once I have it, I compute BB and I go on with the second part of the computation.

view this post on Zulip Matteo Capucci (he/him) (May 24 2021 at 21:30):

This prevents the environment from yielding a continuation that actually depends on BB, I think.

view this post on Zulip Matteo Capucci (he/him) (May 24 2021 at 21:31):

(I apologise for using a notational convention which probably different than everyone's here, certainly different from the categorical update paper)

view this post on Zulip Matteo Capucci (he/him) (May 24 2021 at 21:49):

I think this is what a grate looks like in string diagrams of closed categories:

view this post on Zulip Matteo Capucci (he/him) (May 24 2021 at 21:50):

pic

view this post on Zulip Matteo Capucci (he/him) (May 24 2021 at 21:50):

which is admittedly quite bad

view this post on Zulip Bruno Gavranović (May 24 2021 at 23:38):

Thanks Matteo! This is very helpful.

Matteo Capucci (he/him) said:

I can think of the view part as returning a bunch of BB s ( :bee: ), a bunch indexed by MM. Then the update takes in an MM and a TT. One can use the MM to access a BB, using the map returned by vv. Then you have a BB and a TT and you can do your thing uu to get an SS

Hmm, so I am stuck here. "Then the update takes in a MM". Where does that MM come from? Unlike with lenses or prisms, here in the forward pass we do not produce an MM, but rather we produce a thing that takes in a MM.

view this post on Zulip Bruno Gavranović (May 24 2021 at 23:47):

On that note, I'm not sure how to think of reparameterizations here. Say that your map u:MTSu : M \otimes T \to S is actually a composite (rT);u(r \otimes T) ; u' where r:MMr : M \to M' and u:MTSu' : M' \otimes T \to S

Then, since this is an optic, I expect to be able to slide that rr over to the forward pass and plug it into something that creates that MM. But there's no such thing: the only thing created in the forward pass is [M,B][M, B].

So this seems related to the question of variance from before, and I don't see a way how this can work.

view this post on Zulip Matteo Capucci (he/him) (May 25 2021 at 09:35):

Bruno Gavranovic said:

Thanks Matteo! This is very helpful.

Matteo Capucci (he/him) said:

I can think of the view part as returning a bunch of BB s ( :bee: ), a bunch indexed by MM. Then the update takes in an MM and a TT. One can use the MM to access a BB, using the map returned by vv. Then you have a BB and a TT and you can do your thing uu to get an SS

Hmm, so I am stuck here. "Then the update takes in a MM". Where does that MM come from? Unlike with lenses or prisms, here in the forward pass we do not produce an MM, but rather we produce a thing that takes in a MM.

Yeah, there's no MM coming around. But if it comes around we can do that. I know, it's a bit shaky :~

view this post on Zulip Matteo Capucci (he/him) (May 25 2021 at 09:38):

Bruno Gavranovic said:

On that note, I'm not sure how to think of reparameterizations here. Say that your map u:MTSu : M \otimes T \to S is actually a composite (rT);u(r \otimes T) ; u' where r:MMr : M \to M' and u:MTSu' : M' \otimes T \to S

Then, since this is an optic, I expect to be able to slide that rr over to the forward pass and plug it into something that creates that MM. But there's no such thing: the only thing created in the forward pass is [M,B][M, B].

So this seems related to the question of variance from before, and I don't see a way how this can work.

The action of such an rr on the forward part is [r,B]:[M,B][M,B][r,B] : [M', B] \to [M,B], given by precomposition. So sliding here means that v;[r,B]=vv' ; [r,B] = v and u=(rT);uu = (r \otimes T) ;u', I think.

view this post on Zulip Bruno Gavranović (May 26 2021 at 19:47):

Yesterday @Matteo Capucci (he/him) and me had some discussions in private and I think we concluded that this definition makes sense only when D=Cop\mathcal{D} = \mathcal{C}^{op}, otherwise the variances do not line up.

I'll just respond to the last message for completeness, to write some arguments I said.

Matteo Capucci (he/him) said:

Yeah, there's no MM coming around. But if it comes around we can do that. I know, it's a bit shaky :~

This really does not align with how I see optics: we need to say where the MM comes from. This is where the bivariance of the coend comes in.

Matteo Capucci (he/him) said:

The action of such an rr on the forward part is [r,B]:[M,B][M,B][r,B] : [M', B] \to [M,B], given by precomposition. So sliding here means that v;[r,B]=vv' ; [r,B] = v and u=(rT);uu = (r \otimes T) ;u', I think.

This can be unpacked and it can be seen that there's no sliding happening here. To get the usual optic equivalence relation, we need just one equation, of the form where rr appears once on the left side, and once on the right.

view this post on Zulip Mario Román (Jan 27 2022 at 10:10):

@Bruno Gavranovic. I think this is just missing an op in the action () ⁣:Cop×DD(\bullet) \colon \mathbf{C}^{op} \times \mathbf{D} \to \mathbf{D}.
This way, you have two actions from a common category, Cop\mathbf{C}^{op}. The coend computation remains unaltered.

I am quite sure I introduced that typo on the paper, so thank you very much for bringing this to my attention (please, do feel free to also email me for these :) I almost never open Zulip). As @Reid Barton said, using the bullet to denote a contravariant action is particularly confusing. I probably got confused when trying to copy the style of the rest of the definitions. In the previous "Profunctors and Traversals" the contravariance is right, so I must have introduced it when preparing the second paper.

The op will be added in the next version, the bullet will be changed to a more explanatory symbol. Thanks to both again!

view this post on Zulip Mario Román (Jan 27 2022 at 10:18):

grate.jpg

view this post on Zulip Bruno Gavranović (Jan 27 2022 at 10:42):

Ah, I was just thinking about this last night! Thanks, I'll have a look!

view this post on Zulip Bruno Gavranović (Jan 27 2022 at 10:43):

Mario Román said:

The op will be added in the next version, the bullet will be changed to a more explanatory symbol. Thanks to both again!

It's good to know that there's a next version planned. I'm looking forward to reading it

view this post on Zulip Bruno Gavranović (Jan 27 2022 at 12:02):

@Mario Román I am still confused about what grates do. I'm trying to compare them to lenses or prisms. If I take the the coend representation of a lens MC(S,M×A)×C(M×B,T)\int^M \mathcal{C}(S, M \times A) \times \mathcal{C}(M \times B, T), and think of it operationally, it tells me that I take in an SS, produce an MM and an AA, and then when receiving a BB, I take the previously produced MM too and use it to construct a TT.

But for grates, it seems that the first map C(S,[C,A])\mathcal{C}(S, [C, A]) doens't produce the residual CC, it waits for it as an input (via the tensor hom adjunction). Is that correct? If the first map is waiting for an input CC, that must mean that the second map produces it, and all-together it means that the operational view of a grate is different than that of a lens or a prism, since the information flows from the second map to the first.

Is what I'm saying correct?

view this post on Zulip Bruno Gavranović (Jan 27 2022 at 12:03):

All I'm trying to really do is have an operational, causal view of what a grate does. I.e. "where do I start", "what do I do" and "where do I end up". With lenses/prisms I start at SS, (always/possibly) use it construct the residual, and end up at TT. But with grates it seems different

view this post on Zulip Mario Román (Jan 28 2022 at 11:19):

Bruno Gavranovic said:

Mario Román I am still confused about what grates do. I'm trying to compare them to lenses or prisms. If I take the the coend representation of a lens MC(S,M×A)×C(M×B,T)\int^M \mathcal{C}(S, M \times A) \times \mathcal{C}(M \times B, T), and think of it operationally, it tells me that I take in an SS, produce an MM and an AA, and then when receiving a BB, I take the previously produced MM too and use it to construct a TT.

But for grates, it seems that the first map C(S,[C,A])\mathcal{C}(S, [C, A]) doens't produce the residual CC, it waits for it as an input (via the tensor hom adjunction). Is that correct? If the first map is waiting for an input CC, that must mean that the second map produces it, and all-together it means that the operational view of a grate is different than that of a lens or a prism, since the information flows from the second map to the first.

Is what I'm saying correct?

Sort of, yes. Although it is confusing for me to say that the second part of the optic produces that C. I think what you are saying describes a particular kind of grate where the second action is the left adjoint to the tensor: Lenses Flowing Back.

I can try to give an operational description of grates saying that they aggregate foci: Operational View of Grates. And if you want to see them as dual to lenses, the Van Laarhoven representation kind of says that: Van Laarhoven Lenses and Grates.

view this post on Zulip Matteo Capucci (he/him) (Jan 28 2022 at 16:25):

Yeah the Van Laarhoven representation helped me a lot to understand what grates do

view this post on Zulip Matteo Capucci (he/him) (Jan 28 2022 at 16:26):

Also the fact they are morphisms of 'Naperian containers', i.e. containers with a fixed shape. Together with the fact that ×\times, ++ and -^- combine to give polynomials, hence containers, made me realize grates are kind of degenerate dependent lenses

view this post on Zulip Bruno Gavranović (Jan 28 2022 at 22:17):

Grates are pretty mysterious! But becoming less so by the moment. Thanks @Mario Román for writing this up, it's immensely helpful.

I've got many thoughts about this, but I'll just give short remarks now and hopefully write something more concrete later.

And if you want to see them as dual to lenses

Prisms are often to considered "dual" of lenses. I suppose this is a "different duality". Prisms seem to be dual in what they do compared to lenses (+ instead of x), but how would you describe the grate duality?

the Van Laarhoven representation kind of says that: Van Laarhoven Lenses and Grates.

I find the remark about zipping interesting, but a bit confusing. Don't lenses also allow us to unzip? If we have a map A×ABA \times A \to B, we surely ought to be able to turn it to a map S×STS \times S \to T?

view this post on Zulip Matteo Capucci (he/him) (Jan 29 2022 at 08:59):

Prisms are often to considered "dual" of lenses. I suppose this is a "different duality". Prisms seem to be dual in what they do compared to lenses (+ instead of x), but how would you describe the grate duality?

++ is dual to ×\times as in 'reversing arrows' whereas exponentials are dual to ×\times as in 'right adjoint'

view this post on Zulip Bruno Gavranović (Jan 30 2022 at 10:43):

Wouldn't the right adjoint of ×\times give us linear lenses?

view this post on Zulip Matteo Capucci (he/him) (Jan 30 2022 at 13:12):

No, linear lenses are the same thing as lenses, just a different presentation that's possible when closed structure is around

view this post on Zulip Matteo Capucci (he/him) (Jan 30 2022 at 13:13):

Instead grates arise from using the closed structure as one of the actions itself

view this post on Zulip Bruno Gavranović (Jan 30 2022 at 15:47):

Right, that makes sense

view this post on Zulip Asad Saeeduddin (Jan 31 2022 at 19:17):

is it correct to say that grates represent the "powerhood" of an object? if so, is there some name for the analogous optic that represents the "copowerhood" of an object?

view this post on Zulip Asad Saeeduddin (Jan 31 2022 at 19:29):

in the case of both M = C = D = Set i believe this degenerates to the hom functor, which is perhaps what @Verity Scheel was pointing to