Dependent optics II: Optics via forcing costates

Posted on October 16, 2025

(X-posted on the CyberCat Institute blog)

I’ve been putting this series of posts off for a long time, although nowhere near as long as we’ve been putting off the corresponding paper.

For anyone who knows anything about my research between 2021 and 2024, dependent optics need no introduction. A team consisting of (in alphabetical order) Dylan Braithwaite, Matteo Capucci, Bruno Gavranović, Eigil Rischel and me put everything we had into the problem of unifying dependent lenses and monoidal optics, for 2 years. We had so many false solutions that “we solved dependent optics!” became a meme, and then we solved it. But by then, time had caught up with us and between us we did not collectively have the ability, energy and motivation to write the paper.

The construction became obscure folklore because we talked about it in various places, for example in this seminar I gave early this year. I am writing this series of posts to upgrade it from folklore to merely grey literature. The reason I put off starting the series for so long is one of the same reasons blocking the writing of the paper: some of the introductory material is some of the most difficult to write. It has been such a long time that I no longer know how to adequately explain why the problem is so difficult. Additionally, one of the current blockers to a paper is figuring out how our construction relates to the one in Vertechi’s paper. So, I have made the outrageous choice to start this blog series with part II, and put off writing part I until the end.

The goal of this post is to reconstruct simple optics in the way that turned out to generalise correctly.

A refresher on optics

So that we are all starting from the same place I will give the standard construction of optics, from this paper and this paper.

If we have a symmetric monoidal category 𝒞\mathcal C, its category of optics 𝐎𝐩𝐭𝐢𝐜(𝒞)\mathbf{Optic} (\mathcal C) has as objects pairs of objects of 𝒞\mathcal C, and morphisms given by elements of the coend 𝐎𝐩𝐭𝐢𝐜(𝒞)((XX),(YY))=M:𝒞𝒞(X,MY)×𝒞(MY,X) \mathbf{Optic} (\mathcal C) \left( \binom{X'}{X}, \binom{Y'}{Y} \right) = \int^{M : \mathcal C} \mathcal C (X, M \otimes Y) \times \mathcal C (M \otimes Y', X')

A couple of notes on this:

  1. If the assumption that 𝒞\mathcal C is symmetric is dropped this construction still does something, but it does the wrong thing (I may write a future blog post on this point). Symmetry turns out to be necessary for what follows anyway, so I am assuming it here.
  2. I am writing my objects with the backwards pass over the forwards pass, for consistency with the fibrational notation for dependent lenses.

If 𝒞\mathcal C is cartesian monoidal, then 𝐎𝐩𝐭𝐢𝐜(𝒞)\mathbf{Optic} (\mathcal C) is isomorphic to the category 𝐋𝐞𝐧𝐬(𝒞)\mathbf{Lens} (\mathcal C) of simply-typed lenses. This fact will be important in later posts.

More generally, if we have a span of strong symmetric monoidal functors 𝒞LR𝒟\mathcal C \overset{L}\leftarrow \mathcal M \overset{R}\rightarrow \mathcal D (or equivalently symmetric monoidal actions of \mathcal M on 𝒞\mathcal C and 𝒟\mathcal D - I may also write a future post on this point) then the category of mixed optics 𝐎𝐩𝐭𝐢𝐜(𝒞,𝒟)\mathbf{Optic}_\mathcal M (\mathcal C, \mathcal D) has as objects pairs of objects of 𝒞\mathcal C and 𝒟\mathcal D, and morphisms given by elements of the coend 𝐎𝐩𝐭𝐢𝐜(𝒞,𝒟)((XX),(YY))=M:𝒞(X,L(M)Y)×𝒟(R(M)Y,X) \mathbf{Optic}_\mathcal M (\mathcal C, \mathcal D) \left( \binom{X'}{X}, \binom{Y'}{Y} \right) = \int^{M : \mathcal M} \mathcal C (X, L (M) \otimes Y) \times \mathcal D (R (M) \otimes Y', X')

In both cases, the category of optics is itself a symmteric monoidal category, given on objects by pairwise monoidal product of the underlying categories.

The bicategory of optics

Categories of optics arise naturally as quotients of bicategories, and this gives a more refined view that will be crucial. With the same setup for mixed optics, we build a symmetric monoidal bicategory 𝟐𝐎𝐩𝐭𝐢𝐜(𝒞,𝒟)\mathbf{2Optic}_\mathcal M (\mathcal C, \mathcal D). Its 0-cells are again pairs of objects of 𝒞\mathcal C and 𝒟\mathcal D, its 1-cells (XX)(YY)\binom{X'}{X} \to \binom{Y'}{Y} are triples (M:,f:XL(M)Y,f:R(M)YX) \left( M : \mathcal M, f : X \to L (M) \otimes Y, f' : R (M) \otimes Y' \to X' \right) and its 2-cells are morphisms MMM \to M' of \mathcal M making the resulting diagrams commute.

There are 2 universal ways to turn a bicategory into a category. By far the more common way is to quotient out invertible 2-cells, which turns out to be the same thing (at least for an appropriately weak notion of enrichment) as change of enrichment basis U*:𝐂𝐚𝐭𝐂𝐚𝐭𝐒𝐞𝐭𝐂𝐚𝐭U^* : \mathbf{Cat}-\mathbf{Cat} \to \mathbf{Set}-\mathbf{Cat} along the functor U:𝐂𝐚𝐭𝐒𝐞𝐭U : \mathbf{Cat} \to \mathbf{Set} that takes each category to its set of isomorphism classes.

There is another functor π0:𝐂𝐚𝐭𝐒𝐞𝐭\pi_0 : \mathbf{Cat} \to \mathbf{Set} that instead takes each category to its set of connected components, quotienting out reachability, or equivalently adding all formal inverses before quotienting out isomorphism. (They are related by a string of adjunctions between 𝐒𝐞𝐭\mathbf{Set} and 𝐂𝐚𝐭\mathbf{Cat}, but I don’t remember the details of that right now.) This is not often seen because most categories encountered in practice - for example any category with either an initial or a terminal object - are connected and sent to the 1-element set by π0\pi_0. But the hom-categories of 𝟐𝐎𝐩𝐭𝐢𝐜(𝒞,𝒟)\mathbf{2Optic}_\mathcal M (\mathcal C, \mathcal D) are not connected, and in fact:

Lemma: There is an isomorphism of symmetric monoidal categories π0*(𝟐𝐎𝐩𝐭𝐢𝐜(𝒞))𝐎𝐩𝐭𝐢𝐜(𝒞,𝒟)\pi_0^* \left( \mathbf{2Optic} (\mathcal C) \right) \cong \mathbf{Optic}_\mathcal M (\mathcal C, \mathcal D).

Proving that all of this actually coheres with the symmetric monoidal structure is a very minor part of what still needs to be done, that will probably take weeks of effort.

Parametrisation

Given a strong symmetric monoidal functor F:𝒞F : \mathcal M \to \mathcal C (or more generally an action of \mathcal M on 𝒞\mathcal C), we can form a symmetric monoidal bicategory 𝐏𝐚𝐫𝐚(𝒞)\mathbf{Para}_\mathcal M (\mathcal C) of \mathcal M-parametrised morphisms of 𝒞\mathcal C. Its 0-cells are the 0-cells of 𝒞\mathcal C, its 1-cells XYX \to Y are pairs (M:,f:F(M)XY) (M : \mathcal M, f : F (M) \otimes X \to Y) and its 2-cells are morphisms MMM \to M' making the resulting diagram commute.

𝐏𝐚𝐫𝐚(𝒞)\mathbf{Para}_\mathcal M (\mathcal C) is locally fibred over \mathcal M: every hom-category is equipped with a fibration 𝐏𝐚𝐫𝐚(𝒞)(X,Y)\mathbf{Para}_\mathcal M (\mathcal C) (X, Y) \to \mathcal M compatible with the other structure.

There is a dual construction 𝐂𝐨𝐩𝐚𝐫𝐚(𝒞)\mathbf{Copara}_\mathcal M (\mathcal C) whose 1-cells are pairs of MM and XF(M)YX \to F (M) \otimes Y. This has a local opfibration structure 𝐂𝐨𝐩𝐚𝐫𝐚(𝒞)(X,Y)\mathbf{Copara}_\mathcal M (\mathcal C) (X, Y) \to \mathcal M.

Here is a construction of optics that is a major contributor to the feeling of how close-knit the foundations of categorical cybernetics are, but is not the construction we are looking for: the hom-category 𝟐𝐎𝐩𝐭𝐢𝐜(𝒞,𝒟)((XX),(YY))\mathbf{2Optic}_\mathcal M (\mathcal C, \mathcal D) \left( \binom{X'}{X}, \binom{Y'}{Y} \right) is the pullback in 𝐂𝐚𝐭\mathbf{Cat} of this opfibration and fibration: 𝐂𝐨𝐩𝐚𝐫𝐚(𝒞)(X,Y)𝐏𝐚𝐫𝐚(𝒟)(Y,X) \mathbf{Copara}_\mathcal M (\mathcal C) (X, Y) \rightarrow \mathcal M \leftarrow \mathbf{Para}_\mathcal M (\mathcal D) (Y', X')

Forcing costates

Suppose we have a symmetric monoidal category 𝒞\mathcal C and a lax symmetric monoidal presheaf K:𝒞op𝐒𝐞𝐭K : \mathcal C^\mathrm{op} \to \mathbf{Set} to the cartesian monoidal category of sets. The lax monoidal structure is given by a unit e:K(I)e : K (I) and a laxator :K(X)×K(Y)K(XY) \nabla : K (X) \times K (Y) \to K (X \otimes Y) We want to formally adjoin, or force, all of the elements x:K(X)x : K (X) to 𝒞\mathcal C as costates x:XIx : X \to I, modulo all of the evident equations arising from the structure of KK.

We take the category of elements K\int K, whose objects are pairs (X:𝒞,x:K(X))(X : \mathcal C, x : K (X)) and whose morphisms are morphisms XYX \to Y making the resulting diagram commute. K\int K is a symmetric monoidal category with the monoidal unit (I,e)(I, e) and the monoidal product (X,x)(Y,y)=(XY,xy)(X, x) \otimes (Y, y) = (X \otimes Y, x \nabla y), and is equipped with a strong symmetric monoidal fibration K𝒞\int K \to \mathcal C.

We form the symmetric monoidal bicategory 𝐂𝐨𝐩𝐚𝐫𝐚K(𝒞)\mathbf{Copara}_{\int K} (\mathcal C) for this functor. Its 0-cells are objects of 𝒞\mathcal C, its 1-cells XYX \to Y are triples (M:𝒞,m:K(M),f:XMY) (M : \mathcal C, m : K (M), f : X \to M \otimes Y) and its 2-cells are morphisms MMM \to M' of \mathcal M making the resulting diagrams commute.

The hom-categories 𝐂𝐨𝐩𝐚𝐫𝐚K(𝒞)(X,Y)\mathbf{Copara}_{\int K} (\mathcal C) (X, Y) are once again not connected. Here is the sledgehammer theorem:

Theorem (Hermida & Tennent, dualised and reformulated). 𝒞[K]=π0*(𝐂𝐨𝐩𝐚𝐫𝐚K(𝒞))\mathcal C [K] = \pi_0^* \left( \mathbf{Copara}_{\int K} (\mathcal C) \right) is the smallest symmetric monoidal category that contains 𝒞\mathcal C and contains a morphism x:XIx : X \to I for each element x:K(X)x : K (X) modulo the evident equations.

I’ve talked about this construction before in its original dual form for forcing states from a copresheaf rather than costates from a presheaf, in this post, to add iteration to categories of optics. The pictures in that post are helpful for understanding how this construction works.

From adaptors to optics

We will now apply this theorem to construct categories of optics.

Given a symmetric monoidal category 𝒞\mathcal C, we can form the symmetric monoidal category 𝐀𝐝𝐭(𝒞)=𝒞×𝒞op\mathbf{Adt} (\mathcal C) = \mathcal C \times \mathcal C^\mathrm{op} with the pairwise monoidal product. We call the morphisms of this category adaptors, and think of them as optics whose backwards pass does not use its forwards input. There is an embedding 𝐀𝐝𝐭(𝒞)𝐎𝐩𝐭𝐢𝐜(𝒞)\mathbf{Adt} (\mathcal C) \to \mathbf{Optic} (\mathcal C) that is identity on objects and always chooses M=IM = I.

The hom functor of 𝒞\mathcal C is a presheaf hom:𝐀𝐝𝐭(𝒞)op=𝒞op×𝒞𝐒𝐞𝐭\hom : \mathbf{Adt} (\mathcal C)^\mathrm{op} = \mathcal C^\mathrm{op} \times \mathcal C \to \mathbf{Set}, and it is lax symmetric monoidal. (It is strong monoidal if and only if 𝒞\mathcal C is cartesian monodial.) It turns out that if we take Adt(𝒞)\mathrm{Adt} (\mathcal C) and adjoin a morphism (XX)(II)\binom{X'}{X} \to \binom{I}{I} for every underlying morphism XXX \to X', we get exactly the category of optics:

Lemma: There is an isomorphism of symmetric monoidal bicategories 𝐂𝐨𝐩𝐚𝐫𝐚hom(𝐀𝐝𝐭(𝒞))𝟐𝐎𝐩𝐭𝐢𝐜(𝒞)\mathbf{Copara}_{\int \hom} (\mathbf{Adt} (\mathcal C)) \cong \mathbf{2Optic} (\mathcal C), and therefore an isomorphism of symmetric monoidal categories 𝐀𝐝𝐭(𝒞)[hom]𝐎𝐩𝐭𝐢𝐜(𝒞)\mathbf{Adt} (\mathcal C) [\hom] \cong \mathbf{Optic} (\mathcal C).

This also works for general mixed optics. Suppose we have a span of strong symmetric monoidal functors 𝒞LR𝒟\mathcal C \overset{L}\leftarrow \mathcal M \overset{R}\rightarrow \mathcal D. We form a lax symmetric monoidal functor K:𝒞op×𝒟𝐒𝐞𝐭K : \mathcal C^\mathrm{op} \times \mathcal D \to \mathbf{Set} by K(XX)=M:𝒞(X,L(M))×𝒟(R(M),Y) K \binom{X'}{X} = \int^{M : \mathcal M} \mathcal C (X, L (M)) \times \mathcal D (R (M), Y) Then:

Lemma: There is an isomorphism of symmetric monoidal bicategories 𝐂𝐨𝐩𝐚𝐫𝐚K(𝒞×𝒟op)𝟐𝐎𝐩𝐭𝐢𝐜(𝒞,𝒟)\mathbf{Copara}_{\int K} (\mathcal C \times \mathcal D^\mathrm{op}) \cong \mathbf{2Optic}_\mathcal M (\mathcal C, \mathcal D), and therefore an isomorphism of symmetric monoidal categories (𝒞×𝒟op)[K]𝐎𝐩𝐭𝐢𝐜(𝒞,𝒟)(\mathcal C \times \mathcal D^\mathrm{op}) [K] \cong \mathbf{Optic}_\mathcal M (\mathcal C, \mathcal D).

If 𝒞\mathcal C is cartesian monoidal then of course we also have an isomorphism 𝐋𝐞𝐧𝐬(𝒞)𝐀𝐝𝐭(𝒞)[hom]\mathbf{Lens} (\mathcal C) \cong \mathbf{Adt} (\mathcal C) [\hom]. It will be useful to write a direct proof of this fact instead of cutting the equations 𝐀𝐝𝐭(𝒞)[hom]𝐎𝐩𝐭𝐢𝐜(𝒞)𝐋𝐞𝐧𝐬(𝒞)\mathbf{Adt} (\mathcal C)[\hom] \cong \mathbf{Optic} (\mathcal C) \cong \mathbf{Lens} (\mathcal C), but I will put this off until a later post as a practice run for the main theorem of dependent optics.

Now we can reformulate the dependent optics question: given appropriate structure on 𝒞\mathcal C we need to construct a symmetric monoidal category 𝐃𝐀𝐝𝐭(𝒞)\mathbf{DAdt} (\mathcal C) of dependent adaptors and a lax symmetric monoidal presheaf K:𝐃𝐀𝐝𝐭(𝒞)op𝐒𝐞𝐭K : \mathbf{DAdt} (\mathcal C)^\mathrm{op} \to \mathbf{Set} with the property that 𝐃𝐀𝐝𝐭(𝒞)[K]𝐃𝐋𝐞𝐧𝐬(𝒞)\mathbf{DAdt} (\mathcal C) [K] \cong \mathbf{DLens} (\mathcal C) is the category of dependent lenses in 𝒞\mathcal C. (Of course we have to rule out trivial solutions like taking KK to be the terminal presheaf.) This is what we will do over this series of posts.