lens
- definition
- a lens
- (f#f):(A−A+)⇆(B−B+)
- in a cartesian category C consists of
- a passforward map f:A+→B+
- sending information downstream
- a passback map f#:A+×B−→A−
- sending information back upstream
- it allows to use the value in A+, used by the downstreaming, to calculate how to pass information back upstream
- compose: lenses compose
- given
- (f#f):(A−A+)⇆(B−B+)
- (g#g):(B−B+)⇆(C−C+)
- we define their composite (g#g)∘(f#f), with
- passforward given by g∘f
- passback given by
- (a+,c−)↦f#(a+,g#(f(a+),c−))
- failed to execute js (detail: String("InternalError: stack overflow"))
(a^{+}, c^{-})
\mapsto
\underbrace{ f^{\#}\left( a^{+}, \underbrace{ g^{\#}(\underbrace{ f(a^{+}) }_{ b^{+} }, c^{-}) }_{ b^{-} } \right) }_{ a^{-} }
category of lenses LensC
- let C be a cartesian category, then the category LensC has:
- objects: pairs (A−A+) of objects in C, called arenas
- morphisms: the lenses
- (f#f):(A−A+)⇆(B−B+)
- identity lens
- (π2id):(A−A+)⇆(A−A+)
- where π2:A+×A−→A− is the projection
- the composition is giving by lens composition
- it’s named for its morphisms (lenses) rather than objects (arenas)
- the category of charts, has arenas as objects but the morphisms are not lenses
- double category ArenaC, combining the category of lenses and category of charts, is named after its objects
Proposition: Functoriality of Lens
- Every cartesian functor F:C→D induces a functor (FF):LensC→LensD, given by
- (FF)(f#f):(Ff#∘μ−1Ff)
- where μ=(Fπ1,Fπ2):F(X×Y)→∼FX×FY is the isomorphism witnessing that F preserves products
Parallel product ⊗
- put two arenas in parallel
- (A1B1) and (A2B2)
- we just take their product in our cartesian category C
- (A1B1)⊗(A2B2):=(A1×A2B1×B2)
- parallel product for morphisms in Lens
- given
- (f#f):(A1B1)⇆(C1D1)
- (g#g):(A2B2)⇆(C2D2)
- their parallel product is defined by
- (f#f)⊗(g#g):=(A1×A2B1×B2)⇆(C1×C2D1×D2)
- it has
- passforward f×g
- passback
- ((b1,b2),(c1,c2))↦(f#(b1,c1),g#(b2,c2))
- in terms of morphism, this is
- (B1×B2)×(C1×C2)→∼(B1×C1)×(B2×C2)⟶f#×g#A1×A2
- together with (11), this gives LensC the structure of a monoidal category
- Proposition
- for cartesian functor F:C→D, the induced functor (FF):LensC→LensD
- preserves the monidal product ⊗, ie, it’s strong monidal with respect to the parallel product
- reference: 1.3.2.4 of Categorical System Theory
related