Day Convolution¶
Day convolution combines two presheaves over a
monoidal category by summing, for each requested output object, the contributions of every pair of
objects whose tensor product maps to it (Kelly, 1982)
(Day convolution). Ordinary convolution, which sums
over every way of splitting an index, is the case of a discrete monoid. Here presheaves and
morphisms are finite tensors, and the chosen
IdempotentSemiring fixes how the contributions combine, through its join.
day_convolution
¶
Day convolution for V-enriched presheaves.
Given a monoidal structure (C, ⊗, I) on a V-enriched category C, the Day convolution defines a monoidal structure on the presheaf category [C^op, V]. For two presheaves F, G: C^op → V, their Day convolution is:
(F ⊛ G)(C) = ∫^{A,B} C(C, A ⊗ B) ⊗ F(A) ⊗ G(B)
In our finite setting, this becomes a computable coend (join over
all pairs (A, B) such that A ⊗ B can map to C). The coend is a join,
so V must be a complete lattice (an IdempotentSemiring). The products
are contractions of quivers.core.wiring.EinsumWiring, so Day
convolution and wiring share one evaluation and its cost claim.
The unit for Day convolution is the representable presheaf at the monoidal unit: y(I)(C) = C(C, I).
This module provides:
day_convolution(): compute F ⊛ G
day_unit(): the unit presheaf for ⊛
day_convolution_profunctors(): Day convolution on profunctors
day_convolution
¶
day_convolution(f_values: Tensor, g_values: Tensor, objects: Sequence[SetObject], monoidal: MonoidalStructure, algebra: IdempotentSemiring, product_table: dict[tuple[int, int], tuple[int, Tensor]] | None = None) -> Tensor
Compute the Day convolution (F ⊛ G)(C) for each object C.
For finite discrete categories (no non-identity morphisms), the Day convolution simplifies to:
(F ⊛ G)(C) = ⋁_{A,B : A⊗B=C} F(A) ⊗ G(B)
With a product table that names, for each pair, the object C_k
with A_i ⊗ B_j ≅ C_k and the weight h = C(C_k, A_i ⊗ B_j):
(F ⊛ G)(C_k) = ⋁_{(i, j) ↦ k} h(i, j) ⊗ F(A_i) ⊗ G(B_j)
The products over the pairs are the contraction ab, a, b -> ab
of quivers.core.wiring.EinsumWiring (a, b -> ab without a
table), and the coend sums them over the fiber of each object, so the
work is 2 n^2 products and at most n f sums for n objects
and a largest fiber of f pairs, never n^3.
| PARAMETER | DESCRIPTION |
|---|---|
f_values
|
1D tensor of shape (n,) representing F evaluated at each object: F(objects[i]) = f_values[i].
TYPE:
|
g_values
|
1D tensor of shape (n,) representing G evaluated at each object: G(objects[i]) = g_values[i].
TYPE:
|
objects
|
The objects of the finite category (indexed 0..n-1).
TYPE:
|
monoidal
|
The monoidal structure providing ⊗ and I.
TYPE:
|
algebra
|
The enrichment algebra, a complete lattice.
TYPE:
|
product_table
|
Optional precomputed product table mapping (i, j) to (k, hom_tensor) where objects[i] ⊗ objects[j] ≅ objects[k] and hom_tensor is the scalar C(objects[k], objects[i] ⊗ objects[j]). A pair it omits contributes nothing. If None, uses identity hom (discrete category).
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Tensor
|
1D tensor of shape (n,) with (F ⊛ G)(objects[i]) at index i. |
| RAISES | DESCRIPTION |
|---|---|
TypeError
|
If the algebra is not an |
ValueError
|
If the value tensors have the wrong shape, or (without a
product table) the objects are not closed under |
Source code in src/quivers/enriched/day_convolution.py
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 | |
day_unit
¶
day_unit(objects: Sequence[SetObject], unit_index: int, algebra: IdempotentSemiring) -> Tensor
Create the unit presheaf for Day convolution.
The unit is the representable presheaf y(I) at the monoidal unit I. In the discrete case: y(I)(C) = I if C = I, else ⊥.
| PARAMETER | DESCRIPTION |
|---|---|
objects
|
The objects of the finite category.
TYPE:
|
unit_index
|
The index of the monoidal unit in the objects list.
TYPE:
|
algebra
|
The enrichment algebra, a complete lattice.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Tensor
|
1D tensor of shape (n,) representing the unit presheaf. |
| RAISES | DESCRIPTION |
|---|---|
TypeError
|
If the algebra is not an |
Source code in src/quivers/enriched/day_convolution.py
day_convolution_profunctors
¶
day_convolution_profunctors(p: Profunctor, q_prof: Profunctor, monoidal: MonoidalStructure, algebra: IdempotentSemiring) -> Profunctor
Day convolution of two profunctors.
Given profunctors P: A ↛ B and Q: C ↛ D, the Day convolution (with respect to the monoidal product) produces:
(P ⊛ Q): A⊗C ↛ B⊗D
with tensor:
(P ⊛ Q)(ac, bd) = P(a, b) ⊗ Q(c, d)
This is the external tensor product of profunctors, which extends the monoidal structure from C to Prof(C).
| PARAMETER | DESCRIPTION |
|---|---|
p
|
Left profunctor P: A ↛ B.
TYPE:
|
q_prof
|
Right profunctor Q: C ↛ D.
TYPE:
|
monoidal
|
The monoidal structure providing ⊗.
TYPE:
|
algebra
|
The enrichment algebra, a complete lattice.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Profunctor
|
The Day convolution P ⊛ Q: A⊗C ↛ B⊗D. |
| RAISES | DESCRIPTION |
|---|---|
TypeError
|
If the algebra is not an |
Source code in src/quivers/enriched/day_convolution.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.