Search Knowledge

© 2026 LIBREUNI PROJECT

Category Theory

Category Theory

Category theory formalizes mathematical structure and its concepts in terms of a collection of objects and arrows (morphisms).

Categories and Morphisms

A category C\mathcal{C} consists of:

  • A class ob(C)ob(\mathcal{C}) of objects.
  • A class hom(C)hom(\mathcal{C}) of morphisms (arrows) between objects.
  • A composition law \circ that is associative and has identity morphisms.

Examples include Set (sets and functions), Grp (groups and homomorphisms), and Top (topological spaces and continuous maps).

python
1class Category:
2 def __init__(self, name):
3 self.name = name
4 self.objects = set()
5 self.morphisms = {} # (A, B) -> list of f
6 
7 def add_object(self, obj):
8 self.objects.add(obj)
9 
10 def add_morphism(self, source, target, name):
11 if (source, target) not in self.morphisms:
12 self.morphisms[(source, target)] = []
13 self.morphisms[(source, target)].append(name)
14 
15# Modeling a simple Finite Category
16C = Category("SimpleFinite")
17C.add_object("A")
18C.add_object("B")
19C.add_morphism("A", "B", "f")
20C.add_morphism("B", "B", "id_B")
21 
22print(f"Objects in {C.name}: {C.objects}")
23print(f"Morphisms: {C.morphisms}")

Functors

A Functor F:CDF: \mathcal{C} \to \mathcal{D} is a mapping that preserves the category structure:

  1. It maps objects in C\mathcal{C} to objects in D\mathcal{D}.
  2. It maps morphisms f:ABf: A \to B in C\mathcal{C} to morphisms F(f):F(A)F(B)F(f): F(A) \to F(B) in D\mathcal{D}.
  3. It preserves identity and composition.

What is a 'covariant' functor?

Natural Transformations

A natural transformation provides a way of transforming one functor into another while respecting the internal structure of the categories involved. It is often described as a “morphism between functors.”

In the category Set, what is the 'Initial Object'?

Yoneda Lemma

The Yoneda Lemma suggests that an object is entirely determined by its relationships (morphisms) with other objects in the category. This is a foundational result that allows one to embed any category into a category of functors.