Lean4
/-- The adjunction between the free and forgetful constructions for Eilenberg-Moore algebras for
a monad. cf Lemma 5.2.8 of [Riehl][riehl2017]. -/
@[simps! unit counit]
def adj : T.free ⊣ T.forget :=
Adjunction.mkOfHomEquiv
{
homEquiv := fun X Y =>
{ toFun := fun f => T.η.app X ≫ f.f
invFun := fun f =>
{ f := T.map f ≫ Y.a
h := by simp [← Y.assoc, ← T.μ.naturality_assoc] }
left_inv := fun f => by
ext
simp
right_inv := fun f => by
dsimp only [forget_obj]
rw [← T.η.naturality_assoc, Y.unit]
apply Category.comp_id } }