Skip to content
This repository was archived by the owner on Jul 24, 2024. It is now read-only.

Commit c06fb67

Browse files
rwbartonjohoelzl
authored andcommitted
refactor(category_theory/category): split off has_hom
This gives a little more flexibility when defining a category, which will be used for opposite categories. It should also be useful for defining the free category on a graph.
1 parent 2c95d2a commit c06fb67

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

src/category_theory/category.lean

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,14 +33,17 @@ powerful tactics.
3333
def_replacer obviously
3434
@[obviously] meta def obviously' := tactic.tidy
3535

36+
class has_hom (obj : Type u) : Type (max u (v+1)) :=
37+
(hom : obj → obj → Type v)
38+
39+
infixr ` ⟶ `:10 := has_hom.hom -- type as \h
40+
3641
/--
3742
The typeclass `category C` describes morphisms associated to objects of type `C`.
3843
The universe levels of the objects and morphisms are unconstrained, and will often need to be
3944
specified explicitly, as `category.{v} C`. (See also `large_category` and `small_category`.)
4045
-/
41-
class category (obj : Type u) : Type (max u (v+1)) :=
42-
(hom : obj → obj → Type v)
43-
(infixr ` ⟶ `:10 := hom)
46+
class category (obj : Type u) extends has_hom.{v} obj : Type (max u (v+1)) :=
4447
(id : Π X : obj, X ⟶ X)
4548
(notation `𝟙` := id)
4649
(comp : Π {X Y Z : obj}, (X ⟶ Y) → (Y ⟶ Z) → (X ⟶ Z))
@@ -52,7 +55,6 @@ class category (obj : Type u) : Type (max u (v+1)) :=
5255

5356
notation `𝟙` := category.id -- type as \b1
5457
infixr ` ≫ `:80 := category.comp -- type as \gg
55-
infixr ` ⟶ `:10 := category.hom -- type as \h
5658

5759
-- `restate_axiom` is a command that creates a lemma from a structure field,
5860
-- discarding any auto_param wrappers from the type.

src/category_theory/opposites.lean

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,12 +103,12 @@ variable (C)
103103

104104
/-- `functor.hom` is the hom-pairing, sending (X,Y) to X → Y, contravariant in X and covariant in Y. -/
105105
definition hom : Cᵒᵖ × C ⥤ Type v₁ :=
106-
{ obj := λ p, @category.hom C _ p.1 p.2,
106+
{ obj := λ p, @has_hom.hom C _ p.1 p.2,
107107
map := λ X Y f, λ h, f.1 ≫ h ≫ f.2,
108108
map_id' := by intros; ext; dsimp [category_theory.opposite]; simp,
109109
map_comp' := by intros; ext; dsimp [category_theory.opposite]; simp }
110110

111-
@[simp] lemma hom_obj (X : Cᵒᵖ × C) : (functor.hom C).obj X = @category.hom C _ X.1 X.2 := rfl
111+
@[simp] lemma hom_obj (X : Cᵒᵖ × C) : (functor.hom C).obj X = @has_hom.hom C _ X.1 X.2 := rfl
112112
@[simp] lemma hom_pairing_map {X Y : Cᵒᵖ × C} (f : X ⟶ Y) :
113113
(functor.hom C).map f = λ h, f.1 ≫ h ≫ f.2 := rfl
114114

0 commit comments

Comments
 (0)