# mathlibdocumentation

category_theory.category.default

# Categories #

Defines a category, as a type class parametrised by the type of objects.

## Notations #

Introduces notations

• X ⟶ Y for the morphism spaces,
• f ≫ g for composition in the 'arrows' convention.

Users may like to add f ⊚ g for composition in the standard convention, using

local notation f  ⊚ :80 g:80 := category.comp g f    -- type as \oo

@[class]
structure category_theory.category_struct (obj : Type u) :
Type (max u (v+1))
• to_quiver : quiver obj
• id : Π (X : obj), X X
• comp : Π {X Y Z : obj}, (X Y)(Y Z)(X Z)

A preliminary structure on the way to defining a category, containing the data, but none of the axioms.

Instances
@[class]
structure category_theory.category (obj : Type u) :
Type (max u (v+1))
• to_category_struct :
• id_comp' : (∀ {X Y : obj} (f : X Y), 𝟙 X f = f) . "obviously"
• comp_id' : (∀ {X Y : obj} (f : X Y), f 𝟙 Y = f) . "obviously"
• assoc' : (∀ {W X Y Z : obj} (f : W X) (g : X Y) (h : Y Z), (f g) h = f g h) . "obviously"

The typeclass category C describes morphisms associated to objects of type C. The universe levels of the objects and morphisms are unconstrained, and will often need to be specified explicitly, as category.{v} C. (See also large_category and small_category.)

Instances
@[simp]
theorem category_theory.category.id_comp {obj : Type u} [c : category_theory.category obj] {X Y : obj} (f : X Y) :
𝟙 X f = f
@[simp]
theorem category_theory.category.comp_id {obj : Type u} [c : category_theory.category obj] {X Y : obj} (f : X Y) :
f 𝟙 Y = f
@[simp]
theorem category_theory.category.assoc {obj : Type u} [c : category_theory.category obj] {W X Y Z : obj} (f : W X) (g : X Y) (h : Y Z) :
(f g) h = f g h
def category_theory.large_category (C : Type (u+1)) :
Type (u+1)

A large_category has objects in one universe level higher than the universe level of the morphisms. It is useful for examples such as the category of types, or the category of groups, etc.

def category_theory.small_category (C : Type u) :
Type (u+1)

A small_category has objects and morphisms in the same universe level.

theorem category_theory.eq_whisker {C : Type u} {X Y Z : C} {f g : X Y} (w : f = g) (h : Y Z) :
f h = g h

postcompose an equation between morphisms by another morphism

theorem category_theory.whisker_eq {C : Type u} {X Y Z : C} (f : X Y) {g h : Y Z} (w : g = h) :
f g = f h

precompose an equation between morphisms by another morphism

theorem category_theory.eq_of_comp_left_eq {C : Type u} {X Y : C} {f g : X Y} (w : ∀ {Z : C} (h : Y Z), f h = g h) :
f = g
theorem category_theory.eq_of_comp_right_eq {C : Type u} {Y Z : C} {f g : Y Z} (w : ∀ {X : C} (h : X Y), h f = h g) :
f = g
theorem category_theory.eq_of_comp_left_eq' {C : Type u} {X Y : C} (f g : X Y) (w : (λ {Z : C} (h : Y Z), f h) = λ {Z : C} (h : Y Z), g h) :
f = g
theorem category_theory.eq_of_comp_right_eq' {C : Type u} {Y Z : C} (f g : Y Z) (w : (λ {X : C} (h : X Y), h f) = λ {X : C} (h : X Y), h g) :
f = g
theorem category_theory.id_of_comp_left_id {C : Type u} {X : C} (f : X X) (w : ∀ {Y : C} (g : X Y), f g = g) :
f = 𝟙 X
theorem category_theory.id_of_comp_right_id {C : Type u} {X : C} (f : X X) (w : ∀ {Y : C} (g : Y X), g f = g) :
f = 𝟙 X
theorem category_theory.comp_dite {C : Type u} {P : Prop} [decidable P] {X Y Z : C} (f : X Y) (g : P → (Y Z)) (g' : ¬P → (Y Z)) :
f dite P (λ (h : P), g h) (λ (h : ¬P), g' h) = dite P (λ (h : P), f g h) (λ (h : ¬P), f g' h)
theorem category_theory.dite_comp {C : Type u} {P : Prop} [decidable P] {X Y Z : C} (f : P → (X Y)) (f' : ¬P → (X Y)) (g : Y Z) :
dite P (λ (h : P), f h) (λ (h : ¬P), f' h) g = dite P (λ (h : P), f h g) (λ (h : ¬P), f' h g)
@[class]
structure category_theory.epi {C : Type u} {X Y : C} (f : X Y) :
Prop
• left_cancellation : ∀ {Z : C} (g h : Y Z), f g = f hg = h

A morphism f is an epimorphism if it can be "cancelled" when precomposed: f ≫ g = f ≫ h implies g = h.

Instances
@[class]
structure category_theory.mono {C : Type u} {X Y : C} (f : X Y) :
Prop
• right_cancellation : ∀ {Z : C} (g h : Z X), g f = h fg = h

A morphism f is a monomorphism if it can be "cancelled" when postcomposed: g ≫ f = h ≫ f implies g = h.

Instances
@[protected, instance]
def category_theory.category_struct.id.epi {C : Type u} (X : C) :
@[protected, instance]
def category_theory.category_struct.id.mono {C : Type u} (X : C) :
theorem category_theory.cancel_epi {C : Type u} {X Y Z : C} (f : X Y) {g h : Y Z} :
f g = f h g = h
theorem category_theory.cancel_mono {C : Type u} {X Y Z : C} (f : X Y) {g h : Z X} :
g f = h f g = h
theorem category_theory.cancel_epi_id {C : Type u} {X Y : C} (f : X Y) {h : Y Y} :
f h = f h = 𝟙 Y
theorem category_theory.cancel_mono_id {C : Type u} {X Y : C} (f : X Y) {g : X X} :
g f = f g = 𝟙 X
theorem category_theory.epi_comp {C : Type u} {X Y Z : C} (f : X Y) (g : Y Z)  :
@[instance]
theorem category_theory.mono_comp {C : Type u} {X Y Z : C} (f : X Y) (g : Y Z)  :
theorem category_theory.mono_of_mono {C : Type u} {X Y Z : C} (f : X Y) (g : Y Z) [category_theory.mono (f g)] :
theorem category_theory.mono_of_mono_fac {C : Type u} {X Y Z : C} {f : X Y} {g : Y Z} {h : X Z} (w : f g = h) :
theorem category_theory.epi_of_epi {C : Type u} {X Y Z : C} (f : X Y) (g : Y Z) [category_theory.epi (f g)] :
theorem category_theory.epi_of_epi_fac {C : Type u} {X Y Z : C} {f : X Y} {g : Y Z} {h : X Z} (w : f g = h) :
@[protected, instance]
def category_theory.ulift_category (C : Type u)  :
Equations

We now put a category instance on any preorder.

Because we do not allow the morphisms of a category to live in Prop, unfortunately we need to use plift and ulift when defining the morphisms.

As convenience functions, we provide hom_of_le and le_of_hom to wrap and unwrap inequalities.

@[protected, instance]
def preorder.small_category (α : Type u) [preorder α] :

The category structure coming from a preorder. There is a morphism X ⟶ Y if and only if X ≤ Y.

Because we don't allow morphisms to live in Prop, we have to define X ⟶ Y as ulift (plift (X ≤ Y)). See category_theory.hom_of_le and category_theory.le_of_hom.

Equations
def category_theory.hom_of_le {α : Type u} [preorder α] {U V : α} (h : U V) :
U V

Express an inequality as a morphism in the corresponding preorder category.

Equations
@[simp]
theorem category_theory.hom_of_le_refl {α : Type u} [preorder α] {U : α} :
@[simp]
theorem category_theory.hom_of_le_comp {α : Type u} [preorder α] {U V W : α} (h : U V) (k : V W) :
theorem category_theory.le_of_hom {α : Type u} [preorder α] {U V : α} (h : U V) :
U V

Extract the underlying inequality from a morphism in a preorder category.

@[simp]
theorem category_theory.le_of_hom_hom_of_le {α : Type u} [preorder α] {a b : α} (h : a b) :
_ = h
@[simp]
theorem category_theory.hom_of_le_le_of_hom {α : Type u} [preorder α] {a b : α} (h : a b) :