Lean4
/-- The adjunction between the cofree and forgetful constructions for Eilenberg-Moore coalgebras
for a comonad.
-/
@[simps! unit counit]
def adj : G.forget ⊣ G.cofree :=
Adjunction.mkOfHomEquiv
{
homEquiv := fun X Y =>
{ toFun := fun f =>
{ f := X.a ≫ G.map f
h := by simp [← Coalgebra.coassoc_assoc] }
invFun := fun g => g.f ≫ G.ε.app Y
left_inv := fun f => by
dsimp
rw [Category.assoc, G.ε.naturality, Functor.id_map, X.counit_assoc]
right_inv := fun g => by
ext1; dsimp
rw [Functor.map_comp, g.h_assoc, cofree_obj_a, Comonad.right_counit]
apply comp_id } }