# Category

open import Agda.Primitive using (Level; _β_; lsuc; lzero)

open import Types.product
open import Types.relations
open import Types.equality

module Category.category where

A category is the object of study in category theory. It can be thought of being a bunch of objects, which are associated by a bunch of arrows between those objects, with the arrows being composable and each object having unit arrows. This minimal structure ensures a multitude of object types studied in mathematics can fit the description.

A category β consists of:

1. A collection of objects $$x \in obj(β)$$
2. A collection of morphisms between those objects $$hom(π) = \{ f : a β b : a,b β β \}$$, called a βhomβ set

such that:

1. Morphisms compose:

If $f : a β b, g : b β c$ then $g β f : a β c$

1. Morphisms are associative:

$If~~ f : a β b,~ g : b β c ~~and~~ h : c β d ~~then~~ h β (g β f) = (h β g) β f$

1. Morphisms have identities: For every object x, there exists a morphism $$1β : x β x$$ called the identity morphism for x, such that for every morphism $$f : a β x$$ and every morphism $$g : x β b$$, we have $$1β β f = f$$ and $$g β 1β = g$$.
record Category (o β e : Level) : Set (suc (o β β β e)) where
infix  4 _β_ _β_
infixr 9 _β_

field
Obj : Set o                     -- objects
_β_ : Rel Obj β                 -- morphism
_β_ : β {A B} β Rel (A β B) e   -- equivalence of morphisms
id  : β {A} β (A β A)           -- identity

-- composition of morphisms
_β_ : β {A B C} β (B β C) β (A β B) β (A β C)

-- laws
-- satisfy associativity
assoc     : β {A B C D} {f : A β B} {g : B β C} {h : C β D} β (h β g) β f β h β (g β f)
-- satisfy identity
identityΛ‘ : β {A B} {f : A β B} β id β f β f
identityΚ³ : β {A B} {f : A β B} β f β id β f
-- has an equivalence for morphisms
equiv     : β {A B} β IsEquivalence (_β_ {A} {B})
-- composition is congruent on equivalence
β-resp-β  : β {A B C} {f h : B β C} {g i : A β B} β f β h β g β i β f β g β h β i

## Opposite Category

The machinery of category theory also admits a duality, like an object and its mirror image. The opposite or dual of a category $$β$$, denoted by $$βα΄Όα΅$$, is the same category, but with all morphisms in the opposite direction. All laws and machinery of category theory have their dual versions.

record Categoryα΄Όα΅ (o β e : Level) : Set (suc (o β β β e)) where
infix  4 _β_ _β_
infixr 9 _β_

field
Obj : Set o                     -- objects
_β_ : Rel Obj β                 -- morphism
_β_ : β {A B} β Rel (B β A) e   -- equivalence of morphisms
id  : β {A} β (A β A)           -- identity

-- composition of morphisms
_β_ : β {A B C} β (B β A) β (C β B) β (C β A)

-- laws
-- satisfy associativity
assoc     : β {A B C D} {f : A β B} {g : B β C} {h : C β D} β h β (g β f) β (h β g) β f
-- satisfy identity
identityΛ‘ : β {A B} {f : A β B} β id β f β f
identityΚ³ : β {A B} {f : A β B} β f β id β f
-- has an equivalence for morphisms
equiv     : β {A B} β IsEquivalence (_β_ {A} {B})
-- composition is congruent on equivalence
β-resp-β  : β {A B C} {f h : B β C} {g i : A β B} β g β i β f β h β g β f β i β h

## Examples

We can use various mathematical structures to construct categories out of. When defining a category, we have to decide what our objects and our morphisms would be and how would the morphisms compose. This decision has to be taken in a way that the conditions of being a category are satisfied (associativity, identity). We would then have a category of our chosen object.

### Category of Sets

A category of sets is the simplest of categories we can construct and the most intuitive to understand given we have been trained to think in terms of sets.

• Objects: Sets
• Morphisms: Total functions between sets
• Composition: Function composition

### Category of Groups

• Objects: Groups
• Morphisms: Group homomorphisms
• Composition: Composition of group homomorphisms

### Category of Rings

• Objects: Rings
• Morphisms: Ring homomorphisms
• Composition: Composition of ring homomorphisms

### Category of Topological Spaces

• Objects: Topological Spaces
• Morphisms: Continuous maps/functions between spaces
• Composition: Composition of continuous maps

Here are some other examples:

Category Objects Morphisms
Set sets total functions
Group groups group homomorphisms
Top topological spaces continuous functions
Vectβ vector spaces over field K linear transformations
Poset partially ordered sets order-preserving functions
TopVect topological vector spaces continuous linear maps
π differentiable manifolds differentiable maps
Banach spaces open subsets of Banach spaces differentiable maps
π vector bundles vector bundle maps

There are in fact infinitely many more and so we are going to move along now.

# Nerves of Categories

## Simplicial Complexes

Before explaining higher categories, let us look at a structure from algebraic topology called simplexes and simplicial complexes.

### Simplexes

A simplex is an n-dimensional βtriangleβ. Some examples of the first few dimensional simplices are:

• 0-simplex: point
• 1-simplex: line segment
• 2-simplex: triangle
• 3-simplex: tetrahedron

An n-dimensional simplex is also called an (n+1)-cell.

### Simplicial Complexes

A simplicial complex is a structure formed by gluing together a bunch of simplices. The gluing process has to follow a set of properties:

A set of simplices $$\mathcal{K}$$ is a simplicial complex if: - Every face of a simplex from $$\mathcal{K}$$ is also in $$\mathcal{K}$$ - Intersections of any two simplices is a face of both the simplices

A simplicial complex is of dimension n if the largest dimension of all the constituent simplices is n.

$dim(\mathcal{K}) = max(dim(Ο_i))$

Examples:

• Any n-ary tree is a simplicial complex
• An undirected acyclic graph is a 1-dimensional simplicial complex
• Any 1-D simplicial complex is a hypergraph
• Any n-dimensional convex hull is a simplicial complex
• Nerves of any category are simplicial complex
• The triangulation of a polygon in the plane is a simplicial complex

Simplicial complexes can be used to create or represent topological spaces and serve as a very useful tool. They can also be used to formalize algebraic constraints in geometric terms as well.

The Nerve N(β) of a category β is a simplicial complex constructed from objects as vertices of simplices and morphisms of β as the edges.

# Constructions of Categories

## Product Category

Given two (or more) categories, their cartesian product is also a category.

Given two categories β and π», their product is a category with: - Pairs (C, D) as objects such that C β β and D β π» - (f, g) as morphisms where - $$f : C_1 β C_2; C_i β β$$ - $$g : D_1 β D_2; D_i β π»$$ - composition of morphisms defined as $$(f_1, g_1) β (f_2, g_2) = (f_1 β f_2, g_1 β g_2)$$ - identities defined as $$1_{(C, D)} = (1_C, 1_D)$$

## Free Category

Free categories are a result of using a general pattern called βfree constructionsβ for building categories. The idea of free objects in mathematics can be related to all types of objects with algebraic structure, and provides a general method of constructing objects using a set of βconstructorβ objects. The process of construction proceeds as follows:

1. Take a set of objects to construct the free category with
2. Construct all possible combinations of these objects, in other words, the power set of the set of those objects. These form the algebraic object of interest
3. Define relations between every pair of objects according to the kind of algebraic object to construct