definition example theorem proof
Let be objects of a Category . A product of and is an object with projections , such that for every object with , there is a unique morphism with and . A category has products if every pair has one.
” is the best object-equipped-with-morphisms-to--and-: any other such object maps to it uniquely” — a universal property; dotted arrows denote the unique morphism.
Sources: 7 Sketches Definition 3.86, Examples 3.87, 3.89, 3.94, Exercises 3.88, 3.90, 3.91, 3.97; Kittenlab Lecture 13 (“Products and typed products”); DaoFP Chapter 5 (“Product Types”, “Cartesian Category”, “Tuple Arithmetic”), §9.4 (“Product as a universal span”), §10.2 (“The product adjunction”), §10.5; CTfS §2.4.1 (Definition 2.4.1.1, Lemma 2.4.1.10, Examples 2.4.1.2–2.4.1.18), Definition 4.5.1.8, Examples 4.5.1.2–4.5.1.17
Examples
- : the cartesian product with , (Example 3.87; picture of as a grid). In with , : with and — “the same problem as storing a matrix in linear memory” (Kittenlab).
- Preorder: the product is the Meet (7S Exercise 3.88); in the intersection (Kittenlab).
- Graphs: , with componentwise sources and targets (Kittenlab Lecture 13); all C-sets likewise, pointwise.
- : the Product Category (Example 3.89); : the Product Preorder.
- Julia:
Tuple{A,B}; Haskell:(a, b)withfst,sndand(&&&)(DaoFP: the cartesian category of types). - In a Slice Category : the Pullback (“typed product”, Kittenlab).
Examples from Category Theory for Scientists
- A grid of dots (CTfS Example 2.4.1.2): is a grid, and the projections read off the column and the row. “Suppose each person in a classroom picks an element of and an element of — isn’t picking a column and a row the same as picking a point of the grid?” That is the universal property, which we “need to see as completely intuitive” (CTfS Example 2.4.1.11). Punnett squares in genetics are products of the parents’ possible genotypes; a tensile test produces points of extension × force.
- Olog labels (CTfS §2.4.1.17): the product of boxes and is “a pair where is and is ”, with projections “yields, as ” and “yields, as “. A car owner has as primary car a car; pairing “is a person” with “owns, as primary, a car” gives a map into “a pair (person, car)”, which “has as associated utility” a dollar value (CTfS Example 2.4.1.18).
- Equations (CTfS Exercise 2.4.1.8): in , the square vs. does not commute (distributivity is , not ); is the identity but is not. The swap is , its own inverse (CTfS Exercise 2.4.1.15); the graph of is (CTfS Exercise 4.5.1.15).
- Preferences (CTfS Exercise 4.5.1.3): the product of a partial order on songs and one on artworks orders pairs “componentwise” — a reasonable but cautious guess, as it never trades a better song for a worse painting. In the product of and is . Products need not exist (two rays through the origin have no meet) and need not be unique (all points of a circle can be products), but are always unique up to unique isomorphism (CTfS Examples 4.5.1.11–4.5.1.12).
- In : is the commutative square with 9 morphisms — “it is a minor miracle that the categorical product somehow knows that this square should commute” (CTfS Example 4.5.1.17).
Three descriptions
- Universal cone: a product is a Terminal Object in the category of spans (7S Exercise 3.91); hence a Limit of the Diagram indexed by the discrete two-object category (Example 3.94), and unique up to unique isomorphism.
- Representability: , i.e. — “product as a universal span” (DaoFP §9.4); naturality of the isomorphism encodes the commuting triangles.
- Adjunction: with the Diagonal Functor; the counit is (DaoFP §10.2, 10.5).
Properties (DaoFP Chapter 5)
- Functoriality: makes a Bifunctor (
bimap). - Tuple arithmetic: (symmetry), (associativity), (unit) — a category with all finite products is a Cartesian Category, a special Symmetric Monoidal Category; in a CCC.
- Logic: is conjunction (Curry–Howard: a proof of both). Records are named products.
- Duality: the Coproduct is the product in (“we can flip all arrows in the definition”); exponentials are right adjoint to (Currying); the product distributes over sums in a bicartesian closed category.
Docs: FinSets · Limits & colimits — Kittenlab Lecture 13
# Kittenlab Lecture 13: products in skeletal FinSet by index arithmetic
struct FinSet′; n::Int end
product_set(A::FinSet′, B::FinSet′) = FinSet′(A.n * B.n)
proj1(A, B) = k -> div(k - 1, B.n) + 1
proj2(A, B) = k -> rem(k - 1, B.n) + 1
pair_index(A, B) = (i, j) -> (i - 1) * B.n + jCatlab version (run in a fresh Julia session — Catlab exports its own compose, id, FinFunction, …):
# Catlab
using Catlab
P = product(FinSet(2), FinSet(3))
apex(P) # FinSet(6)
π1, π2 = legs(P) # projections
f = FinFunction([1, 2, 1], 2); g = FinFunction([3, 3, 2], 3)
h = pair(P, f, g) # ⟨f, g⟩ : FinSet(3) → FinSet(6)
force(compose(h, π1)) == f && force(compose(h, π2)) == g # true#check CategoryTheory.Limits.prod -- X ⨯ Y (notation), with prod.fst, prod.snd, prod.lift
#check CategoryTheory.Limits.prod.lift -- ⟨f, g⟩
#check CategoryTheory.Limits.prod.lift_fst
#check CategoryTheory.Limits.BinaryFan -- cones over a pair
-- in Type: X ⨯ Y ≅ X × Y
#check CategoryTheory.Limits.Types.binaryProductIso-- DaoFP Chapter 5: the product type with projections and the universal pairing
fst' :: (a, b) -> a
fst' (a, _) = a
snd' :: (a, b) -> b
snd' (_, b) = b
pairing :: (c -> a) -> (c -> b) -> (c -> (a, b)) -- ⟨f, g⟩, Control.Arrow's (&&&)
pairing f g c = (f c, g c)
bimapP :: (a -> a') -> (b -> b') -> (a, b) -> (a', b') -- functoriality
bimapP f g (a, b) = (f a, g b)