Skip to content

Commit

Permalink
chore(category/abelian/pseudoelements): localize expensive typeclass (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
semorrison committed Sep 12, 2021
1 parent 995f481 commit a7d872f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
2 changes: 2 additions & 0 deletions src/category_theory/abelian/diagram_lemmas/four.lean
Expand Up @@ -57,6 +57,8 @@ variables {V : Type u} [category.{v} V] [abelian V]
local attribute [instance] preadditive.has_equalizers_of_has_kernels
local attribute [instance] object_to_sort hom_to_fun

open_locale pseudoelement

namespace category_theory.abelian

variables {A B C D A' B' C' D' : V}
Expand Down
11 changes: 10 additions & 1 deletion src/category_theory/abelian/pseudoelements.lean
Expand Up @@ -200,7 +200,14 @@ quotient.sound $ (pseudo_zero_aux R _).2 rfl
/-- The zero pseudoelement is the class of a zero morphism -/
def pseudo_zero {P : C} : P := ⟦(0 : P ⟶ P)⟧

instance {P : C} : has_zero P := ⟨pseudo_zero⟩
/--
We can not use `pseudo_zero` as a global `has_zero` instance,
as it would trigger on any type class search for `has_zero` applied to a `coe_sort`.
This would be too expensive.
-/
def has_zero {P : C} : has_zero P := ⟨pseudo_zero⟩
localized "attribute [instance] category_theory.abelian.pseudoelement.has_zero" in pseudoelement

instance {P : C} : inhabited (pseudoelement P) := ⟨0

lemma pseudo_zero_def {P : C} : (0 : pseudoelement P) = ⟦(0 : P ⟶ P)⟧ := rfl
Expand All @@ -213,6 +220,8 @@ by { rw ←pseudo_zero_aux P a, exact quotient.eq }

end zero

open_locale pseudoelement

/-- Morphisms map the zero pseudoelement to the zero pseudoelement -/
@[simp] theorem apply_zero {P Q : C} (f : P ⟶ Q) : f 0 = 0 :=
by { rw [pseudo_zero_def, pseudo_apply_mk], simp }
Expand Down

0 comments on commit a7d872f

Please sign in to comment.