Weakest precondition interpretation #
This module defines the weakest precondition interpretation WP of monadic programs
in terms of predicate transformers PredTrans.
This interpretation forms the basis of our notion of Hoare triples. It is the main mechanism of this library for reasoning about monadic programs.
An instance WP m ps determines an interpretation wp⟦x⟧ of a program x : m α in terms of a
predicate transformer PredTrans ps α; The monad m determines ps : PostShape and hence
the particular shape of the predicate transformer.
This library comes with pre-defined instances for common monads and transformers such as
WP Id .pure, interpreting pure computationsx : Id αin terms of a function (isomorphic to)(α → Prop) → Prop.WP (StateT σ m) (.arg σ ps)given an instanceWP m ps, interpretingStateM σ αin terms of a function(α → σ → Prop) → σ → Prop.WP (ExceptT ε m) (.except ε ps)given an instanceWP m ps, interpretingExcept ε αin terms of(α → Prop) → (ε → Prop) → Prop.WP (EStateM ε σ) (.except ε (.arg σ .pure))interpretsEStateM ε σ αin terms of a function(α → σ → Prop) → (ε → σ → Prop) → σ → Prop.
These instances are all monad morphisms, a fact which is properly encoded and exploited
by the subclass WPMonad.
A weakest precondition interpretation of a monadic program x : m α in terms of a
predicate transformer PredTrans ps α.
The monad m determines ps : PostShape. See the module comment for more details.
Interpret a monadic program
x : m αin terms of a predicate transformerPredTrans ps α.
Instances
wp⟦x⟧ Q is defined as (WP.wp x).apply Q.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Equations
- One or more equations did not get rendered due to their size.
Instances For
Equations
- Std.Do.Id.instWP = { wp := fun {α : Type ?u.7} (x : Id α) => Std.Do.PredTrans.pure x.run }
Equations
- Std.Do.StateT.instWP = { wp := fun {α : Type ?u.30} (x : StateT σ m α) => Std.Do.PredTrans.pushArg fun (s : σ) => Std.Do.wp (x s) }
Equations
- Std.Do.ExceptT.instWP = { wp := fun {α : Type ?u.29} (x : ExceptT ε m α) => Std.Do.PredTrans.pushExcept (Std.Do.wp x) }
Equations
- Std.Do.OptionT.instWP = { wp := fun {α : Type ?u.25} (x : OptionT m α) => Std.Do.PredTrans.pushOption (Std.Do.wp x) }
Equations
- One or more equations did not get rendered due to their size.
Equations
Equations
Equations
Adequacy lemma for StateM.run.
Useful if you want to prove a property about an expression x defined as StateM.run prog s and
you want to use mvcgen to reason about prog.
Adequacy lemma for StateM.run'.
Useful if you want to prove a property about an expression x defined as StateM.run' prog s and
you want to use mvcgen to reason about prog.
Adequacy lemma for ReaderM.run.
Useful if you want to prove a property about an expression x defined as ReaderM.run prog r and
you want to use mvcgen to reason about prog.
Adequacy lemma for EStateM.run.
Useful if you want to prove a property about an expression x defined as EStateM.run prog s and
you want to use mvcgen to reason about prog.