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

Commit 2d00ba4

Browse files
committed
feat(category_theory/limits): cleanup equalizers (#5214)
golf and make simp more powerful
1 parent b2f8c4c commit 2d00ba4

File tree

1 file changed

+37
-58
lines changed

1 file changed

+37
-58
lines changed

src/category_theory/limits/shapes/equalizers.lean

Lines changed: 37 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ Each of these has a dual.
3030
## Main statements
3131
3232
* `equalizer.ι_mono` states that every equalizer map is a monomorphism
33-
* `is_iso_limit_cone_parallel_pair_of_self` states that the identity on the domain of `f` is an equalizer
34-
of `f` and `f`.
33+
* `is_iso_limit_cone_parallel_pair_of_self` states that the identity on the domain of `f` is an
34+
equalizer of `f` and `f`.
3535
3636
## Implementation notes
3737
As with the other special shapes in the limits library, all the definitions here are given as
@@ -138,6 +138,19 @@ abbreviation cofork (f g : X ⟶ Y) := cocone (parallel_pair f g)
138138

139139
variables {f g : X ⟶ Y}
140140

141+
/-- A fork `t` on the parallel pair `f g : X ⟶ Y` consists of two morphisms `t.π.app zero : t.X ⟶ X`
142+
and `t.π.app one : t.X ⟶ Y`. Of these, only the first one is interesting, and we give it the
143+
shorter name `fork.ι t`. -/
144+
abbreviation fork.ι (t : fork f g) := t.π.app zero
145+
146+
/-- A cofork `t` on the parallel_pair `f g : X ⟶ Y` consists of two morphisms
147+
`t.ι.app zero : X ⟶ t.X` and `t.ι.app one : Y ⟶ t.X`. Of these, only the second one is
148+
interesting, and we give it the shorter name `cofork.π t`. -/
149+
abbreviation cofork.π (t : cofork f g) := t.ι.app one
150+
151+
@[simp] lemma fork.ι_eq_app_zero (t : fork f g) : t.ι = t.π.app zero := rfl
152+
@[simp] lemma cofork.π_eq_app_one (t : cofork f g) : t.π = t.ι.app one := rfl
153+
141154
@[simp, reassoc] lemma fork.app_zero_left (s : fork f g) :
142155
s.π.app zero ≫ f = s.π.app one :=
143156
by rw [←s.w left, parallel_pair_map_left]
@@ -175,38 +188,19 @@ def fork.of_ι {P : C} (ι : P ⟶ X) (w : ι ≫ f = ι ≫ g) : fork f g :=
175188
def cofork.of_π {P : C} (π : Y ⟶ P) (w : f ≫ π = g ≫ π) : cofork f g :=
176189
{ X := P,
177190
ι :=
178-
{ app := λ X, begin cases X, exact f ≫ π, exact π, end,
179-
naturality' := λ X Y f,
180-
begin
181-
cases X; cases Y; cases f; dsimp; simp,
182-
{ dsimp, simp, },
183-
{ exact w.symm },
184-
{ dsimp, simp, },
185-
end } }
186-
187-
/-- A fork `t` on the parallel pair `f g : X ⟶ Y` consists of two morphisms `t.π.app zero : t.X ⟶ X`
188-
and `t.π.app one : t.X ⟶ Y`. Of these, only the first one is interesting, and we give it the
189-
shorter name `fork.ι t`. -/
190-
abbreviation fork.ι (t : fork f g) := t.π.app zero
191-
192-
/-- A cofork `t` on the parallel_pair `f g : X ⟶ Y` consists of two morphisms
193-
`t.ι.app zero : X ⟶ t.X` and `t.ι.app one : Y ⟶ t.X`. Of these, only the second one is
194-
interesting, and we give it the shorter name `cofork.π t`. -/
195-
abbreviation cofork.π (t : cofork f g) := t.ι.app one
191+
{ app := λ X, walking_parallel_pair.cases_on X (f ≫ π) π,
192+
naturality' := λ i j f, by { cases f; dsimp; simp [w] } } } -- See note [dsimp, simp]
196193

197-
@[simp] lemma fork.ι_of_ι {P : C} (ι : P ⟶ X) (w : ι ≫ f = ι ≫ g) :
198-
fork.ι (fork.of_ι ι w) = ι := rfl
199-
@[simp] lemma cofork.π_of_π {P : C} (π : Y ⟶ P) (w : f ≫ π = g ≫ π) :
200-
cofork.π (cofork.of_π π w) = π := rfl
201-
202-
lemma fork.ι_eq_app_zero (t : fork f g) : fork.ι t = t.π.app zero := rfl
203-
lemma cofork.π_eq_app_one (t : cofork f g) : cofork.π t = t.ι.app one := rfl
194+
lemma fork.ι_of_ι {P : C} (ι : P ⟶ X) (w : ι ≫ f = ι ≫ g) :
195+
(fork.of_ι ι w).ι = ι := rfl
196+
lemma cofork.π_of_π {P : C} (π : Y ⟶ P) (w : f ≫ π = g ≫ π) :
197+
(cofork.of_π π w).π = π := rfl
204198

205199
@[reassoc]
206-
lemma fork.condition (t : fork f g) : forkt ≫ f = fork.ι t ≫ g :=
200+
lemma fork.condition (t : fork f g) : t.ι ≫ f = t.ι ≫ g :=
207201
by rw [t.app_zero_left, t.app_zero_right]
208202
@[reassoc]
209-
lemma cofork.condition (t : cofork f g) : f ≫ coforkt = g ≫ cofork.π t :=
203+
lemma cofork.condition (t : cofork f g) : f ≫ t.π = g ≫ t.π :=
210204
by rw [t.left_app_one, t.right_app_one]
211205

212206
/-- To check whether two maps are equalized by both maps of a fork, it suffices to check it for the
@@ -735,26 +729,18 @@ variables {C} [split_mono f]
735729
A split mono `f` equalizes `(retraction f ≫ f)` and `(𝟙 Y)`.
736730
Here we build the cone, and show in `split_mono_equalizes` that it is a limit cone.
737731
-/
732+
@[simps {rhs_md := semireducible}]
738733
def cone_of_split_mono : cone (parallel_pair (𝟙 Y) (retraction f ≫ f)) :=
739-
fork.of_ι f (by tidy)
740-
741-
@[simp] lemma cone_of_split_mono_π_app_zero : (cone_of_split_mono f).π.app zero = f := rfl
742-
@[simp] lemma cone_of_split_mono_π_app_one : (cone_of_split_mono f).π.app one = f ≫ 𝟙 Y := rfl
734+
fork.of_ι f (by simp)
743735

744736
/--
745737
A split mono `f` equalizes `(retraction f ≫ f)` and `(𝟙 Y)`.
746738
-/
747739
def split_mono_equalizes {X Y : C} (f : X ⟶ Y) [split_mono f] : is_limit (cone_of_split_mono f) :=
748-
{ lift := λ s, s.π.app zero ≫ retraction f,
749-
fac' := λ s,
750-
begin
751-
rintros (⟨⟩|⟨⟩),
752-
{ rw [cone_of_split_mono_π_app_zero],
753-
erw [category.assoc, ← s.π.naturality right, s.π.naturality left, category.comp_id], },
754-
{ erw [cone_of_split_mono_π_app_one, category.comp_id, category.assoc,
755-
← s.π.naturality right, category.id_comp], }
756-
end,
757-
uniq' := λ s m w, begin rw ←(w zero), simp, end, }
740+
fork.is_limit.mk' _ $ λ s,
741+
⟨s.ι ≫ retraction f,
742+
by { dsimp, rw [category.assoc, ←s.condition], apply category.comp_id },
743+
λ m hm, by simp [←hm]⟩
758744

759745
end
760746

@@ -766,26 +752,19 @@ variables {C} [split_epi f]
766752
A split epi `f` coequalizes `(f ≫ section_ f)` and `(𝟙 X)`.
767753
Here we build the cocone, and show in `split_epi_coequalizes` that it is a colimit cocone.
768754
-/
755+
@[simps {rhs_md := semireducible}]
769756
def cocone_of_split_epi : cocone (parallel_pair (𝟙 X) (f ≫ section_ f)) :=
770-
cofork.of_π f (by tidy)
771-
772-
@[simp] lemma cocone_of_split_epi_ι_app_one : (cocone_of_split_epi f).ι.app one = f := rfl
773-
@[simp] lemma cocone_of_split_epi_ι_app_zero : (cocone_of_split_epi f).ι.app zero = 𝟙 X ≫ f := rfl
757+
cofork.of_π f (by simp)
774758

775759
/--
776760
A split epi `f` coequalizes `(f ≫ section_ f)` and `(𝟙 X)`.
777761
-/
778-
def split_epi_coequalizes {X Y : C} (f : X ⟶ Y) [split_epi f] : is_colimit (cocone_of_split_epi f) :=
779-
{ desc := λ s, section_ f ≫ s.ι.app one,
780-
fac' := λ s,
781-
begin
782-
rintros (⟨⟩|⟨⟩),
783-
{ erw [cocone_of_split_epi_ι_app_zero, category.assoc, category.id_comp, ←category.assoc,
784-
s.ι.naturality right, functor.const.obj_map, category.comp_id], },
785-
{ erw [cocone_of_split_epi_ι_app_one, ←category.assoc, s.ι.naturality right,
786-
←s.ι.naturality left, category.id_comp] }
787-
end,
788-
uniq' := λ s m w, begin rw ←(w one), simp, end, }
762+
def split_epi_coequalizes {X Y : C} (f : X ⟶ Y) [split_epi f] :
763+
is_colimit (cocone_of_split_epi f) :=
764+
cofork.is_colimit.mk' _ $ λ s,
765+
⟨section_ f ≫ s.π,
766+
by { dsimp, rw [← category.assoc, ← s.condition, category.id_comp] },
767+
λ m hm, by simp [← hm]⟩
789768

790769
end
791770

0 commit comments

Comments
 (0)