Ends and Coends¶
For a tensor with two occurrences of the same finite index, coend extracts the diagonal and
reduces it with the join of an IdempotentSemiring, and end reduces it with the meet. In the general
construction, an end or coend must also satisfy compatibility
equations for the morphisms of the indexing category (Kelly, 1982). Ends and coends states the
scope of the finite implementation.
ends_coends
¶
Ends and coends: general contraction principles for V-enriched categories.
The coend ∫^X F(X,X) computes the join (existential) over the diagonal of matched contravariant/covariant dimensions. The end ∫_X F(X,X) computes the meet (universal) over the diagonal.
These routines implement the (co)ends over a discrete indexing category,
where the compatibility conditions are vacuous: the coend is the join and
the end the meet over the diagonal. They are (co)ends when the join and
meet are those of a complete lattice, so the algebra must be an
IdempotentSemiring.
coend
¶
coend(tensor: Tensor, contra_dims: tuple[int, ...], co_dims: tuple[int, ...], algebra: IdempotentSemiring) -> Tensor
Compute coend ∫^X F(X,X) via diagonal extraction and join.
For each matched pair (contra_dims[i], co_dims[i]), restricts the tensor to the diagonal (where the contravariant and covariant indices agree) and then joins (existential quantification) over those matched dimensions.
| PARAMETER | DESCRIPTION |
|---|---|
tensor
|
The input tensor representing a bifunctor F(X, Y) with both contravariant and covariant occurrences of X.
TYPE:
|
contra_dims
|
Dimension indices for the contravariant occurrences of X.
TYPE:
|
co_dims
|
Dimension indices for the covariant occurrences of X. Must be same length as contra_dims, with matching sizes.
TYPE:
|
algebra
|
The enrichment algebra, a complete lattice.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Tensor
|
Result with matched dimension pairs removed via join. |
| RAISES | DESCRIPTION |
|---|---|
TypeError
|
If |
ValueError
|
If the dimension lists differ in length or size. |
Source code in src/quivers/enriched/ends_coends.py
end
¶
end(tensor: Tensor, contra_dims: tuple[int, ...], co_dims: tuple[int, ...], algebra: IdempotentSemiring) -> Tensor
Compute end ∫_X F(X,X) via diagonal extraction and meet.
Dual to coend: restricts to diagonal and applies meet (universal quantification) over matched dimensions.
| PARAMETER | DESCRIPTION |
|---|---|
tensor
|
The input tensor.
TYPE:
|
contra_dims
|
Dimension indices for contravariant occurrences.
TYPE:
|
co_dims
|
Dimension indices for covariant occurrences.
TYPE:
|
algebra
|
The enrichment algebra, a complete lattice.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Tensor
|
Result with matched dimension pairs removed via meet. |
| RAISES | DESCRIPTION |
|---|---|
TypeError
|
If |
ValueError
|
If the dimension lists differ in length or size. |
Source code in src/quivers/enriched/ends_coends.py
Cited sources¶
G. M. Kelly. Basic Concepts of Enriched Category Theory. Cambridge University Press, 1982. Reprinted in Reprints in Theory and Applications of Categories 10 (2005), 1–136. URL: https://www.tac.mta.ca/tac/reprints/articles/10/tr10abs.html.