19 | {-------------------------------------------------------------------------------
20 | {-------------------------------------------------------------------------------
21 | Instead going in and defining full-blown definitions of dependent actegories with units and coherences we instead leverage the main definition in the background and only instantiate cases, manually:
22 | one for parametric functions and one for parametric additive dependent lenses.
23 | We instantiate them using same names in different namespaces, and leverage Idris' name resolution mechanisms to allow the user to use the same name and
24 | reduce cognitive load
25 | -------------------------------------------------------------------------------}
26 | -------------------------------------------------------------------------------}
33 | ||| Infix notation for non-dependent parametric functions
34 | ||| We interpret the extra "-" as a mental symbol for "flat",
35 | ||| i.e. "non-dependent"
40 | ||| Parametric functions
41 | ||| "Usual" dependent para on sets and functions
46 | ||| Infix notation for dependent parametric functions
47 | ||| We interpret the crossed line as a parameter coming in from the top
99 | ||| Get the parameter of a non-dependent parametric function
119 | ||| DParametric dependent lenses
120 | ||| Not really used in this repo
140 | Scalar
173 | ||| Used in this repo, as all neural networks are additive dependent lenses
178 | ||| Infix notation for additive parametric dependent lenses
209 | ||| A predicate witnessing that a parametric additive dependent lens has
210 | ||| a non-dependent (constant) parameter.
231 | = !%+ \p => (!%+ \x => (f.fwd (x ** p) ** \b' => fst (f.bwd (x ** p) b')) ** \l => foldr (\(x ** b') => pc.Plus p (snd (f.bwd (x ** p) b'))) (pc.Zero p) l)
239 | ||| Convert a morphism from product container to one from DepHancockProduct
240 | ||| This witnesses the isomorphism (a >< p) ≅ DepHancockProduct a (const p)
251 | %hide Data.Container.Base.Morphism.Definition.DependentLenses.(=%>)
253 | -- public export
254 | -- dependentMap : {t : a -> Type} -> (f : (x : a) -> t x) ->
255 | -- Vect n a -> Vect n (x : a ** t x)
256 | -- dependentMap f [] = []
257 | -- dependentMap f (x :: xs) = (x ** f x) :: dependentMap f xs
258 | --
259 | -- public export infixr 10 <$^>
260 | -- public export
261 | -- (<$^>) : {t : a -> Type} -> (f : (x : a) -> t x) ->
262 | -- Vect n a -> Vect n (x : a ** t x)
263 | -- (<$^>) f xs = dependentMap f xs
266 | -- composePara_rhs_1 : (p : Vect n Type) -> (q : Vect m Type)
267 | -- -> (a -> All Prelude.id p -> b)
268 | -- -> (b -> All Prelude.id q -> c)
269 | -- -> (a -> All Prelude.id (p ++ q) -> c)
270 | -- composePara_rhs_1 [] [] f g a [] = ?composePara_rhs_1_rhs_2
271 | -- composePara_rhs_1 [] (q :: ws) f g a (pq :: pqs) = ?composePara_rhs_1_rhs_3
272 | -- composePara_rhs_1 (p :: ps) q f g a pq = ?composePara_rhs_1_rhs_1
273 | --
274 | -- composePara : Para a n b -> Para b m c -> Para a (n + m) c
275 | -- composePara (MkPara p f) (MkPara q g) = MkPara (p ++ q) (composePara_rhs_1 p q f g)