The category of sets, :
(i) is the collection of all sets; (ii) ; (iii) the identity is ; (iv) composition is .
Unitality and associativity hold, so is a category — “the most important category in mathematics”.
Sources: 7 Sketches Definition 3.24, Remark 3.26, Example 3.29, Exercise 3.25, §3.5.3, §7.2; Kittenlab Lecture 3 (“sets” as predicates; , the category of Julia types); DaoFP §8.1 (“Category of sets”), §10.11; CTfS Chapter 2 (“The category of sets”: all of it is “an investigation of our first category”), Example 4.1.1.3, §5.2.1 (the dictionary between and -)
Properties and role
-
Isomorphisms are bijections; monos are injections, epis are surjections. (7S Exercise 3.25); — the Exponential Object .
-
The Terminal Object is any singleton ; the Initial Object is ; products are cartesian products, coproducts disjoint unions; all finite limits are computed by the tuple formula of Finite Limits in Set, and all colimits exist too: is complete and cocomplete (DaoFP §9.5). It is cartesian closed and a Topos (7 Sketches Chapter 7: ” as an exemplar topos”).
-
Categories are exactly -enriched categories (Remark 3.26): the hom-sets live in , so “the study of yields insights into categories”. Functors are C-sets / database instances / co-presheaves; representables and the Yoneda Lemma live here.
-
Sets are discrete categories (DaoFP: “a set is a category with no structure”), and databases on the schema (7 Sketches §3.3.1: “sets are databases whose schema consists of a single vertex”, one-column tables / controlled vocabularies).
-
as a template (CTfS §5.2.1). For any schema/category the category of instances is a Topos, so “just about every consideration we made for sets holds for instances on any schema”:
in in set, function instance, natural transformation element representable functor empty set initial object natural numbers object (co)limits, exponentials, “familiar” arithmetic the same, computed pointwise (Arithmetic of Sets) power set , characteristic functions power object , characteristic maps surjections, injections epimorphisms, monomorphisms -
is not small (there is no set of all sets) but locally small (all hom-sets are sets); Kittenlab: there is a set of all computable sets. DaoFP: programming is modeled “to the lowest approximation” in — but there are more set functions than algorithms, and some algorithms diverge.
Docs: Sets — Kittenlab Lecture 3
Builds on: Set (ComputableSet) — run that note’s Julia code first.
# Kittenlab Lecture 3: a set is a predicate `Any -> Bool`; morphisms are Julia callables
struct TypeSet <: ComputableSet; T::Type end
Base.in(x, χ::TypeSet) = x isa χ.T
# A → B is the set of callables f with f(a) ∈ B for all a ∈ A (not checkable for infinite A)Catlab version (run in a fresh Julia session — Catlab exports its own compose, id, FinFunction, …):
# Catlab: SetOb / SetFunction model Set (types as sets), FinSet models FinSet
using Catlab
X = TypeSet(Int) # the set of Ints as an object of Set
f = SetFunction(x -> x + 1, X, X)
compose(f, f)(1) # 3open CategoryTheory
#check (Type u) -- the category of types (sets in universe u)
example : Category (Type u) := inferInstance -- types.instCategory: Hom X Y := X → Y
#check @CategoryTheory.mono_iff_injective
#check @CategoryTheory.epi_iff_surjective
#check @CategoryTheory.types.terminal -- PUnit; initial: PEmpty-- Hask: objects are types, morphisms are functions; composition is (.), identity is id
-- (Hask is only approximately Set: laziness, bottom, and non-total functions differ.)
newtype Hask a b = Hask (a -> b)