Skip to content

Arrow Instances

The standard arrow instances over the V-enriched category of finite sets: VRel, Function, and Stochastic.

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. compose is the V-Rel >> operator; arr is the identity embedding; first is the parallel-product factory; left_arr is the coproduct functorial action; loop_arr is the V-algebra iterative trace on the recurrent component.
  • Function: restricts to deterministic V-relations (functions with point-mass tensors). Pure-functional operations.
  • Stochastic: stochastic-matrix arrows where first, left_arr, and loop_arr are the corresponding row-stochastic realisations.

VRel didactic-model

VRel(*, name: str = 'VRel')

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 the V-algebra iterative trace.

Function didactic-model

Function(*, name: str = 'Function')

Bases: Model

Deterministic V-relation arrow (point-mass tensors only).

Restricts VRel to morphisms whose tensors are 0/1-valued (function graphs). All operations preserve determinism — composition of deterministic relations is deterministic; first and left_arr are the standard functorial actions; loop_arr is the least-fixed-point trace, computed by iterating the recurrent component until a fixed point is reached.

loop_arr

loop_arr(f: Morphism, C: SetObject) -> Morphism

Least-fixed-point trace for deterministic functions.

Iterates the loop c_{n+1} := f.second_projection(a, c_n) until c_{n+1} == c_n. In V-Rel terms this coincides with the algebra-iterative trace when f is function-shaped.

Source code in src/quivers/arrows/instances.py
def loop_arr(self, f: Morphism, C: SetObject) -> Morphism:
    """Least-fixed-point trace for deterministic functions.

    Iterates the loop ``c_{n+1} := f.second_projection(a, c_n)``
    until ``c_{n+1} == c_n``. In V-Rel terms this coincides with
    the algebra-iterative trace when ``f`` is function-shaped.
    """
    return _trace_v_rel(f, C)

app

app(A: SetObject, B: SetObject) -> Morphism

ArrowApply.app for Function — the standard evaluation.

Source code in src/quivers/arrows/instances.py
def app(self, A: SetObject, B: SetObject) -> Morphism:
    """ArrowApply.app for Function — the standard evaluation."""
    return _evaluation_morphism(A, B)

Stochastic didactic-model

Stochastic(*, name: str = 'Stochastic')

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 / coproduct-product lifts; loop_arr is the sampled / cartesian trace summed over the recurrent dimension.

loop_arr

loop_arr(f: Morphism, C: SetObject) -> Morphism

Cartesian trace: marginalise the recurrent component.

trace(f)(a, b) = ∑_c f((a, c), (b, c)) — the row-stochastic analogue of the V-Rel iterative trace.

Source code in src/quivers/arrows/instances.py
def loop_arr(self, f: Morphism, C: SetObject) -> Morphism:
    """Cartesian trace: marginalise the recurrent component.

    ``trace(f)(a, b) = ∑_c f((a, c), (b, c))`` — the row-stochastic
    analogue of the V-Rel iterative trace.
    """
    return _trace_v_rel(f, C)