English
Reaffirmation that FreeAbelianGroup is a LawfulMonad.
Русский
Повторное утверждение: Свободная абелева группа — законная моNada.
LaTeX
$$$ \text{LawfulMonad}(\text{FreeAbelianGroup})$$$
Lean4
instance : LawfulMonad FreeAbelianGroup.{u} :=
LawfulMonad.mk' (id_map := fun x ↦
FreeAbelianGroup.induction_on' x (FreeAbelianGroup.map_zero id) (map_pure id)
(fun x ih ↦ by rw [FreeAbelianGroup.map_neg, ih]) fun x y ihx ihy ↦ by rw [FreeAbelianGroup.map_add, ihx, ihy])
(pure_bind := fun x f ↦ pure_bind f x) (bind_assoc := fun x f g ↦
FreeAbelianGroup.induction_on' x (by iterate 3 rw [zero_bind]) (fun x ↦ by iterate 2 rw [pure_bind])
(fun x ih ↦ by iterate 3 rw [neg_bind] <;> try rw [ih]) fun x y ihx ihy ↦ by
iterate 3 rw [add_bind] <;> try rw [ihx, ihy])