definition example theorem proof

For any object of a Category the covariant representable functor on is

sending and to post-composition . A functor is representable if for some , its representing object (or representative); dually for presheaves, . “We say ’ is a representative for ’ meaning we have picked a specific isomorphism.”

Sources: Kittenlab Lecture 8 (“Representable Functors”, “Representatives of functors”), 10 (“Representables revisited”), 11, 12; DaoFP §8.4, §9.8 (“Representable Functors”, “The guessing game”, “Representable functors in programming”), Exercises 9.8.1–9.8.5; 7 Sketches Exercise 1.66 (preorder case: ); CTfS §5.2.1.3 (Definition 5.2.1.4, Example 5.2.1.5), Lemma 5.2.1.7, Exercise 4.3.3.6

Examples of representables

  • is the one-vertex graph, the one-edge graph (Kittenlab Lecture 8); in , is a single species and one species, one transition, one arc (Lecture 10).
  • (pairs); on graphs gives the length- paths.
  • For a path category of a DAG, is the set of paths , computable by dynamic programming (Lecture 10); for the path graph, if else , so iff .

Functors represented by an object

  • is represented by : via ; the naturality “toblerone” is (Lecture 10). The constant singleton functor on is represented by .
  • is represented by the Coproduct ; in general a representing object of is the coproduct (Lecture 8). Representing gives the Coequalizer (Lecture 11); representing gives the Colimit (Lecture 9). Dually limits, products (DaoFP Exercise 9.8.1).
  • The singleton functor is representable iff has an Initial Object (DaoFP Exercise 9.8.2); the constant functor is represented by the initial object, “the logarithm of 1” (DaoFP Exercise 9.8.4).
  • Non-example: on , has no representative since ; on it does (Lecture 10). Lists are not representable (“no logarithm of a sum”), but a list functor is a sum of representables (DaoFP Exercise 9.8.5); infinite streams are represented by .

Representables in databases: the SIRS (Category Theory for Scientists)

For a schema and a table , the instance is “as free as possible subject to having one row in table “. CTfS gives the recipe (Example 5.2.1.5): write a new row in table ; for every foreign key add a row "" to ; repeat for every blank cell. For the schema with arrows , , , , the representable has

tablerows
—
(with , , )
,
,

Spivak calls this the schematically implied reference spread (SIRS) of ; its rows are labelled nulls / Skolem variables, and indeed , the left pushforward of a one-row table along . The Yoneda Lemma then says that every actual row of an instance determines a unique map of instances : the row’s SIRS is filled in with actual data. In the table element of a set representable functor of CTfS’s Set/-Set dictionary (Category of Sets), representables play the role of points. For graphs, maps from the one-arrow graph to are the arrows of (CTfS Exercise 4.3.3.6).

Properties

Uniqueness. Representing objects are unique up to isomorphism: implies — a corollary of the Yoneda Lemma (Kittenlab Lecture 12). “This gives us a very powerful tool for constructing objects in a category: look for representatives of functors into , and if they exist, they must be unique” — the basis of Kittenlab’s treatment of universal properties (“composing objects” by first giving a specification , Lecture 11). DaoFP: “the representing object is like a logarithm of the functor” — is represented by , and in a closed category. Representables are “dense” among presheaves: every presheaf is a Colimit of representables (DaoFP §9.8, §17).

The guessing game (DaoFP §9.8): one theorist hides an object; the other probes it with objects and receives the sets and, for arrows, functions between them. The answers define a presheaf whose representing object is the secret — unless the opponent invents a non-representable “fantastic beast”, “often as interesting as the real ones”. Kittenlab’s version: identifying a person at a party by whom they talked to.

In programming (DaoFP): class Representable f where type Key f; tabulate :: (Key f -> x) -> f x; index :: f x -> (Key f -> x) — tabulate turns a function into a lookup table (memoization), index looks up. Stream is representable by Nat, Pair x x by Bool (DaoFP Exercise 9.8.3).

Docs: FinSets · Limits & colimits · C-set morphisms · Graphs — Kittenlab Lecture 8, Lecture 12

Builds on: Category (FinFunction) — run that note’s Julia code first.

# Kittenlab Lecture 8: Hom(X,-) × Hom(Y,-) ≅ Hom(X+Y,-) in FinSet
struct Left{T}; val::T end
struct Right{T}; val::T end
disjoint_union(X::AbstractSet{S}, Y::AbstractSet{T}) where {S,T} =
  Set{Union{Left{S}, Right{T}}}([Left.(collect(X))..., Right.(collect(Y))...])
 
copair(f::FinFunction{X,Z}, g::FinFunction{Y,Z}) where {X,Y,Z} =            # Hom(X,-)×Hom(Y,-) → Hom(X+Y,-)
  FinFunction{Union{Left{X},Right{Y}},Z}(disjoint_union(f.dom, g.dom), g.codom,
    Dict(vcat([Left(x) => f(x) for x in f.dom], [Right(y) => g(y) for y in g.dom])))
unpack(xs, ys, h) = (FinFunction(xs, h.codom, Dict(x => h(Left(x)) for x in xs)),      # inverse
                     FinFunction(ys, h.codom, Dict(y => h(Right(y)) for y in ys)))

Catlab version (run in a fresh Julia session — Catlab exports its own compose, id, FinFunction, …):

# Catlab: representable C-sets and the Yoneda bijection
using Catlab
yV = representable(Graph, :V)         # one vertex
yE = representable(Graph, :E)         # one edge
G = cycle_graph(Graph, 4)
length(homomorphisms(yE, G)) == ne(G) # true
#check CategoryTheory.Functor.Representable     -- F : Cᵒᵖ ⥤ Type v is representable by some X
#check CategoryTheory.Functor.Corepresentable   -- F : C ⥤ Type v ≅ coyoneda.obj (op X)
#check CategoryTheory.Functor.reprX             -- the representing object
#check CategoryTheory.coyoneda                  -- x ↦ Hom(x, -)
{-# LANGUAGE TypeFamilies #-}
-- DaoFP §9.8
class Representable f where
  type Key f
  tabulate :: (Key f -> x) -> f x
  index    :: f x -> (Key f -> x)
 
data Pair x = Pair x x
instance Representable Pair where
  type Key Pair = Bool
  tabulate g = Pair (g True) (g False)
  index (Pair a b) = \k -> if k then a else b
 
data Stream a = Stm a (Stream a)
data Nat = Z | S Nat
instance Representable Stream where
  type Key Stream = Nat
  tabulate g = tab Z where tab n = Stm (g n) (tab (S n))
  index stm = \n -> ind n stm
    where ind Z (Stm a _) = a
          ind (S k) (Stm _ as) = ind k as