24 | %hide Base.Object.Instances.Const
25 | %hide Data.Vect.Quantifiers.All.index
26 | %hide Base.Morphism.Instances.State.State
27 | %hide Base.Morphism.Instances.Costate.Costate
30 | ||| If we model the idea of a container (S !> P) as a box
31 | ||| ┌──────┐
32 | ||| │ s:S │
33 | ||| ├──────┤
34 | ||| │ Ps │
35 | ||| └──────┘
36 | ||| then `pushDown` is interpreted as pushing down the container,
37 | ||| pruning anything that goes out of the box, and using `Unit` for
38 | ||| anything new that appears:
39 | ||| ┌──────┐
40 | ||| │ Unit │
41 | ||| ├──────┤
42 | ||| │ s:S │
43 | ||| └──────┘
44 | ||| Ps
45 | ||| For additive containers we need to take the free commutative monoid
58 | where
84 | ||| This is also the categorical product since our containers are additive
118 | ||| These do not exist for ordinary containers!
119 | ||| Here we need `c` not to be erased since we're using its monoid structure
148 | ||| Left unit inverse: c =%+> Scalar >+@ c
153 | ||| Right unit inverse: c =%+> c >@ I
165 | ||| Associator, "un-flatten" direction. NOT definable as a total lens in
166 | ||| general: the forward would have to produce the target's outer index
167 | ||| `g : List (aPos ** bPos) -> c.Shp`, i.e. collapse a whole list of
168 | ||| (a,b)-positions into a single c-shape. All we have is one c-shape per
169 | ||| element (`index (f aPos) bPos`), and c-shapes carry no monoid/default,
170 | ||| so the empty-list case has no answer. This is the precise sense in which
171 | ||| the free composition product is only laxly (one-directionally) associative.
200 | ||| Not an isomorphism, arising from duoidal structure between >@ and ><
225 | ||| "State" as defined in https://arxiv.org/abs/2403.13001 and open games
226 | |||
227 | ||| ┌─────────────┐
228 | ||| │ ├──► (x : c.Shp)
229 | ||| │ State │
230 | ||| │ ├◄── c.Pos x
231 | ||| └─────────────┘
245 | ||| "Costate" as defined in https://arxiv.org/abs/2403.13001 and open games
246 | |||
247 | ||| ┌─────────────┐
248 | ||| (x : c.Shp) ──►┤ │
249 | ||| │ Costate │
250 | ||| c.Pos x ◄──┤ │
251 | ||| └─────────────┘
315 | ||| Mean squared error
322 | ||| Select a shape from All to produce an Any at the given index
323 | ||| Same as `index i (allAnies shapes)` but reduces better
330 | ||| Extract the position from an AnyPos at a given index
339 | -- parameters (f : Type -> Type)
340 | -- ||| These are all of the morphisms in the cokleisli category of (f <!> -)
341 | -- public export
342 | -- MonLens : Cont -> Cont -> Type
343 | -- MonLens c d = (f <!> c) =%> d
344 | --
345 | -- public export
346 | -- counit : Monad f => f <!> c =%> c
347 | -- counit = !% \x => (x ** pure)
348 | --
349 | -- public export
350 | -- cojoin : Monad f => (f <!> c) =%> (f <!> (f <!> c))
351 | -- cojoin = !% \x => (x ** join)
354 | -- public export
355 | -- record FCoAlgCont (f : Type -> Type) where
356 | -- constructor MkFCoAlgCont
357 | -- carrier : Cont
358 | -- coalg : (a : carrier.Shp) -> f (carrier.Pos a) -> carrier.Pos a
360 | -- public export
361 | -- coAlgMorphism : (c, d : FCoAlgCont f) -> Type
362 | -- coAlgMorphism c d = c.carrier =%> d.carrier
363 | --
364 | -- convert : FCoAlgCont List -> AddCont
365 | -- convert (MkFCoAlgCont carrier coalg) = MkAddCont
366 | -- carrier
367 | -- {mon=(MkI $ \s => MkComMonoid
368 | -- (\l, r => coalg s [l, r])
369 | -- (coalg s []))}