# Space-time tradeoffs of lenses and optics via higher category theory

arXiv: https://arxiv.org/abs/2209.09351 · HTML: https://mlsanity.com/paper/2209.09351/

## Key facts

- Cited by 2 papers in the map (data through 14 Oct 2026).
- Builds on 14 of its 29 references that are in the map.
- First posted on arXiv 19 Sep 2022.

## Builds on (most cited first, 14 of 14)

- [Training Deep Nets with Sublinear Memory Cost](https://mlsanity.com/paper/1604.06174/) (2016)
- [Categorical Foundations of Gradient-Based Learning](https://mlsanity.com/paper/2103.01931/) (2021)
- [The simple essence of automatic differentiation](https://mlsanity.com/paper/1804.00746/) (2018)
- [Compositional game theory](https://mlsanity.com/paper/1603.04641/) (2016)
- [Lenses and Learners](https://mlsanity.com/paper/1903.03671/) (2019)
- [Profunctor Optics, a Categorical Update](https://mlsanity.com/paper/2001.07488/) (2020)
- [Value Iteration is Optic Composition](https://mlsanity.com/paper/2206.04547/) (2022)
- [Limits of bimorphic lenses](https://mlsanity.com/paper/1808.05545/) (2018)
- [Bayesian open games](https://mlsanity.com/paper/1910.03656/) (2019)
- [Diegetic Representation of Feedback in Open Games](https://mlsanity.com/paper/2206.12338/) (2022)
- [Profunctor Optics: Modular Data Accessors](https://mlsanity.com/paper/1703.10857/) (2017)
- [Functorial aggregation](https://mlsanity.com/paper/2111.10968/) (2021)
- [A category theory framework for Bayesian learning](https://mlsanity.com/paper/2111.14293/) (2021)
- [Lenses for Composable Servers](https://mlsanity.com/paper/2203.15633/) (2022)

## Built on by (most cited first, 2 of 2)

- [Position: Categorical Deep Learning is an Algebraic Theory of All Architectures](https://mlsanity.com/paper/2402.15332/) (2024)
- [Reinforcement Learning in Categorical Cybernetics](https://mlsanity.com/paper/2404.02688/) (2024)

## Abstract (arXiv)

Optics and lenses are abstract categorical gadgets that model systems with bidirectional data flow. In this paper we observe that the denotational definition of optics - identifying two optics as equivalent by observing their behaviour from the outside - is not suitable for operational, software oriented approaches where optics are not merely observed, but built with their internal setups in mind. We identify operational differences between denotationally isomorphic categories of cartesian optics and lenses: their different composition rule and corresponding space-time tradeoffs, positioning them at two opposite ends of a spectrum. With these motivations we lift the existing categorical constructions and their relationships to the 2-categorical level, showing that the relevant operational concerns become visible. We define the 2-category 2-Optic(C) whose 2-cells explicitly track optics' internal configuration. We show that the 1-category Optic(C) arises by locally quotienting out the connected components of this 2-category. We show that the embedding of lenses into cartesian optics gets weakened from a functor to an oplax functor whose oplaxator now detects the different composition rule. We determine the difficulties in showing this functor forms a part of an adjunction in any of the standard 2-categories. We establish a conjecture that the well-known isomorphism between cartesian lenses and optics arises out of the lax 2-adjunction between their double-categorical counterparts. In addition to presenting new research, this paper is also meant to be an accessible introduction to the topic.
