Lean4
/-- The cofork constructed is a colimit. This shows that any algebra is a (reflexive) coequalizer of
free algebras.
-/
def beckAlgebraCoequalizer : IsColimit (beckAlgebraCofork X) :=
Cofork.IsColimit.mk' _ fun s =>
by
have h₁ : (T : C ⥤ C).map X.a ≫ s.π.f = T.μ.app X.A ≫ s.π.f := congr_arg Monad.Algebra.Hom.f s.condition
have h₂ : (T : C ⥤ C).map s.π.f ≫ s.pt.a = T.μ.app X.A ≫ s.π.f := s.π.h
refine ⟨⟨T.η.app _ ≫ s.π.f, ?_⟩, ?_, ?_⟩
· dsimp
rw [Functor.map_comp, Category.assoc, h₂, Monad.right_unit_assoc,
show X.a ≫ _ ≫ _ = _ from T.η.naturality_assoc _ _, h₁, Monad.left_unit_assoc]
· ext
simpa [← T.η.naturality_assoc, T.left_unit_assoc] using T.η.app ((T : C ⥤ C).obj X.A) ≫= h₁
· intro m hm
ext
dsimp only
rw [← hm]
apply (X.unit_assoc _).symm