Monad morphisms and weakest precondition interpretations #
A WP m ps is a WPMonad m ps if the interpretation WP.wp is also a monad morphism, that is,
it preserves pure and bind.
class
Std.Do.WPMonad
(m : Type u → Type v)
(ps : outParam PostShape)
[Monad m]
extends LawfulMonad m, Std.Do.WP m ps :
Type (max (u + 1) v)
A monad with weakest preconditions (WP) that is also a monad morphism, preserving pure and
bind.
In practice, mvcgen is not useful for reasoning about programs in a monad that is without a
WPMonad instance. The specification lemmas for Pure.pure and Bind.bind, as well as those for
operators like Functor.map, require that their monad have a WPMonad instance.
- seq_assoc {α β γ : Type u} (x : m α) (g : m (α → β)) (h : m (β → γ)) : h <*> (g <*> x) = Function.comp <$> h <*> g <*> x
WP.wppreservespure.WP.wppreservesbind.
Instances
instance
Std.Do.EStateM.instWPMonad
{ε σ : Type u_1}
:
WPMonad (EStateM ε σ) (PostShape.except ε (PostShape.arg σ PostShape.pure))
Equations
instance
Std.Do.Except.instWPMonad
{ε : Type u_1}
:
WPMonad (Except ε) (PostShape.except ε PostShape.pure)
Equations
Equations
instance
Std.Do.State.instWPMonad
{σ : Type u_1}
:
WPMonad (StateM σ) (PostShape.arg σ PostShape.pure)
Equations
instance
Std.Do.Reader.instWPMonad
{ρ : Type u_1}
:
WPMonad (ReaderM ρ) (PostShape.arg ρ PostShape.pure)