Zulip Chat Archive
Stream: mathlib4
Topic: LawfulMonad
Reid Barton (Dec 23 2022 at 17:03):
The default definitions of seqLeft
and seqRight
have changed relative to Lean 3, which makes constructing instances of LawfulApplicative
or LawfulMonad
nontrivial. I posted a brief analysis at https://github.com/leanprover-community/mathlib4/pull/1178#issuecomment-1364114605
Reid Barton (Dec 23 2022 at 17:10):
I think we should add some lemmas somewhere that prove the seqLeft_eq
and seqRight_eq
laws, given sufficient lawfulness hypotheses -- not sure quite how they should look, yet.
Mario Carneiro (Dec 23 2022 at 17:20):
There is a smart constructor for LawfulMonad in std
Mario Carneiro (Dec 23 2022 at 17:22):
usage is like:
import Std.Classes.LawfulMonad
instance : LawfulMonad Option := LawfulMonad.mk'
(id_map := fun x => by cases x <;> rfl)
(pure_bind := fun x f => rfl)
(bind_assoc := fun x f g => by cases x <;> rfl)
(bind_pure_comp := fun f x => by cases x <;> rfl)
and the fields default in the same way as the lean 3 is_lawful_monad
Last updated: Dec 20 2023 at 11:08 UTC