Arrow Instances¶
These instances implement arrow
operations (type class hierarchy) for ordinary
functions (Function), finite weighted relations (VRel), and stochastic transitions
(Stochastic) (Hughes, 2000). Composing functions passes one result to the next function.
Composing stochastic transitions averages the next output distribution over the intermediate
values, so each transition must be a normalized kernel.
instances
¶
Standard arrow instances for the typeclass tower.
Implements the arrow interfaces of quivers.arrows.typeclasses
against the V-enriched category of finite sets. Each instance carries
no per-instance state — every operation is a stateless construction
on the underlying Morphism algebra. The instances register
themselves against the relevant ABCs (Arrow, ArrowChoice,
ArrowApply, ArrowLoop) so isinstance works
transparently for the chart-parser's arrow-side dispatch.
Realisations:
VRel: the canonical V-enriched-relation arrow.composeis the V-Rel>>operator;arris the identity embedding;firstis the parallel-product factory;left_arris the coproduct functorial action;loop_arris finite diagonal contraction over the feedback component.Function: restricts to deterministic V-relations (functions with point-mass tensors). Pure-functional operations.Stochastic: stochastic-matrix arrows. Neither total finite functions nor normalized stochastic kernels have general diagonal-contraction feedback, soFunctionandStochasticdo not implementArrowLoop.
VRel
didactic-model
¶
Bases: Model
The V-enriched-relation arrow on finite sets.
Hom-sets are V-Rel morphisms; composition is the standard
>>; arr is the identity embedding (every V-Rel morphism
is an arrow); first is the parallel pair; left_arr is
the coproduct functorial action; loop_arr is finite diagonal contraction.
Function
didactic-model
¶
Bases: Model
Deterministic V-relation arrow (point-mass tensors only).
Restricts VRel to morphisms whose tensors are 0/1-valued
(function graphs). Composition, first, and left_arr preserve
determinism on this carrier. Arbitrary feedback can have several
fixed points or none, so this instance does not implement ArrowLoop.
app
¶
Stochastic
didactic-model
¶
Bases: Model
Stochastic-matrix arrows.
Each arrow is a Morphism whose tensor rows are
probability distributions. Operations preserve row-stochasticity:
composition is matrix multiplication; first and left_arr
are the tensor-product and coproduct lifts. Diagonal contraction
need not preserve row sums, so this instance does not implement
ArrowLoop.
Cited sources¶
John Hughes. Generalising Monads to Arrows. Science of Computer Programming, 37(1–3):67–111, 2000. URL: https://www.sciencedirect.com/science/article/pii/S0167642399000234, doi:10.1016/S0167-6423(99)00023-4.