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.
This is a vague question, I'm just wondering if anyone's thought about it or has any random insights.
There is a notion of "Generalised lenses" or "-lenses" or "Grothendieck lenses", explained in David Spivak's Generalized Lens Categories via Functors . This gives a very general notion of lens, but often it's desirable to impose some extra 'laws' on the lenses it produces.
Here are some examples:
in a Cartesian category, if we take to be a particular functor that maps an object to the category of -parametrised morphisms, then we obtain the usual category of lenses. However, depending on the application, it can be desirable to impose the traditional lens laws (PutGet, GetPut and PutPut) or some variation of them.
In the paper linked above, Spivak obtains "dependent lenses" by taking to be a different functor. These dependent lenses are very closely related to polynomial functors, but, at least if I understood correctly, they're not quite the same. Polynomial functors are like dependent lenses that obey an additional law, given by the left-hand square in the diagram below, which is from David Spivak's Poly: An abundant categorical setting for mode-dependent dynamics
(I don't think this law arises automatically from the construction in the generalized lenses paper, but I could be wrong and I'm happy to be corrected if so.)
I'm not 100% sure that all three of these "laws" are really the same kind of thing. But it seems striking and perhaps a bit unsatisfying that we can obtain lenses from a functor by performing this slick construction, but then having done that we often actually want a subcategory of the result, which has to be defined explicitly by adding these extra conditions. So I was wondering if there might be some deeper way to see where various kinds of laws we might want to impose come from. In other words, might there be some variation of the Grothendieck construction approach where not only the lenses but also their laws "pop out" of the construction in some way?
Construction 1 and 2 are exactly the same, dependent lenses do not satisfy an extra law
But you can add another example, similar to that of exact Bayesian lenses (and I suspect it's no coincidence): cartesian differential categories can be represented as subcategories of lenses, namely those lenses whose backward part is linear in a certain sense
It was polynomial functors that I thought satisfied an extra law, rather than dependent lenses. Here's the description of dependent lenses from 'Generalised Lens Categories'
Polynomial functors fit this description but they also have to obey the extra law that this diagram commutes:
This is because in the polynomial functor case can be thought of as a collection of functions mapping each fibre of to a corresponding fibre of . Without this extra condition they can map to any element of , not just the corresponding fibre of .
Is it just that dependent lenses do also end up obeying this law as well? I haven't gone through all the details of deriving them from the Grothendieck construction yet, which is why I was a bit unsure about this example.
First of all this is a beautiful example of the microcosm principle. In Johnson, Rosebrugh and Wood's Lenses, fibrations and universal translations by we learn that we can see split Grothendieck (op)fibrations as categorified lenses, and here we learn that they are also categories of generalized prelenses.
Secondly, I have been thinking a lot about laws for "outlaw lenses" lately. This thinking is still in a state of flux, but it seems to be closely tied to what I am calling "secant categories". For a category , the secant category has
There is an obvious functor back to that should be a fibration.
The normal lens laws for "very well-behaved lenses" or what I usually just call "lenses" come from the objects in this category that look like indiscrete categories and represent the notion of "an update is total replacement". There are a lot of other objects in this category though and they each give a notion of lens that respects the identity and composition in that object.
(I don't have the full list of references to hand, but if anyone ends up doing archaeology on this post, the notion of "secant category" was inspired by both tangent categories and the notion of "change structure" in the functional programming literature seen at, e.g. https://bentnib.org/posts/2015-04-23-incremental-lambda-calculus-and-parametricity.html )
(EDIT: It also occurs to me that I have heard something tangentially about someone claiming cofunctors as generalized lenses; it would be surprising if this didn't turn out to be the same insight as that.)
To relate it back, I think these laws will follow naturally when we see what the "update data" in the lens is being used for in each of these examples.
It seems that indeed Bryce Clarke (also on this server; not sure if I should ping or not) put these pieces together before I did:
I can't seem to figure out the purpose of in Definition 19 (top of Section 4, the key definition of an internal lens), though; without it an internal lens reduces to merely a cofunctor, which seems neater.
Nathaniel Virgo said:
It was polynomial functors that I thought satisfied an extra law, rather than dependent lenses. Here's the description of dependent lenses from 'Generalised Lens Categories'
Polynomial functors fit this description but they also have to obey the extra law that this diagram commutes:
This is because in the polynomial functor case can be thought of as a collection of functions mapping each fibre of to a corresponding fibre of . Without this extra condition they can map to any element of , not just the corresponding fibre of .
Is it just that dependent lenses do also end up obeying this law as well? I haven't gone through all the details of deriving them from the Grothendieck construction yet, which is why I was a bit unsure about this example.
Yeah I'm pretty sure that's also satisfied by dependent lenses. The excerpt you mention doesn't state the commutativity condition again, but that's implied by their definition as a Grothendieck construction.
James Deikun said:
First of all this is a beautiful example of the microcosm principle. In Johnson, Rosebrugh and Wood's Lenses, fibrations and universal translations by we learn that we can see split Grothendieck (op)fibrations as categorified lenses, and here we learn that they are also categories of generalized prelenses.
This is very cool indeed!
James Deikun said:
It seems that indeed Bryce Clarke (also on this server; not sure if I should ping or not) put these pieces together before I did:
- Clarke, Bryce. "Internal lenses as functors and cofunctors." arXiv preprint arXiv:2009.06835 (2020).
I can't seem to figure out the purpose of in Definition 19 (top of Section 4, the key definition of an internal lens), though; without it an internal lens reduces to merely a cofunctor, which seems neater.
The tells us that every morphism in the source category determines a morphism in the view category (rather than just on objects / states). This axiom really allows us to understand the Put action as a lift of morphisms. While there is lots one can do with cofunctors, (delta) lenses generally have much nicer properties (lots of research has been done in this direction, but there is still plenty to do!).
Choosing between cofunctors and delta lenses really comes down to what level of generality you need. Both have a (forwards) assignment on objects. Cofunctors have a backwards lifting on morphisms, and delta lenses also have a forwards assignment on morphisms. It's worth mentioning that there are many nice relationships between delta lenses and cofunctors too; for example, in a recent paper I show it is possible to construct a cofree delta lens from every cofunctor.
Hm, there is certainly a use for being able to lower updates to the view as well as lifting them from it; but on the other hand cofunctors are much nicer objects in other ways as well, and for the project of bringing lawfulness to "bimorphic lenses" I'm not at all sure lowering updates is always possible over there. Having worked on FRP and incremental database views I can see how nice delta lenses would be in those particular applications though ...
One way to think about this that I'd just like to throw out there is: vectors push forward, forms pull back. If you think of a type as a space, then if your 'delta' is a vector the appropriate map is a functor, if it is a form your appropriate map is a cofunctor. If your type is a Riemannian space with an identification between vectors and forms via the metric, then wouldn't the appropriate map be something like a delta lens? This suggests there could be space for all three of these things in the world. (Though for functors there was never much danger ...)
This seems as good a place to ask as any:
I'm looking for a citation to back up the assertion that "morphisms of polynomial functors are lenses". Is there a usual one?
The equivalence of categories between [polynomials, natural transformations] and [containers, morphisms of containers] appears first in whatever is the first paper on containers. Then you look at the definition of morphisms of containers and say "well, duh, it's the same as a lens"
Hmm okay. Thanks.
I might just shuffle this into an "among other things".
I do have to read more about containers though :)