WPMonad Instances #
The weakest precondition interpretation of the base monads and of the monad transformers.
A monad that throws carries the exception postcondition itself. A transformer stacks a product
layer on the exception postcondition of the monad below it, and EStack⟨⟩ closes the stack.
Pre-defined instances #
WPMonad Id Prop EStack⟨⟩— pure computations.WPMonad (StateT σ m) (σ → Pred) EPred— stateful computations.WPMonad (ExceptT ε m) Pred ((ε → Pred) × EPred)— computations with exceptions.WPMonad (OptionT m) Pred ((Unit → Pred) × EPred)— computations with early termination.WPMonad (ReaderT ρ m) (ρ → Pred) EPred— reader computations.WPMonad Option Prop (Unit → Prop)— concrete early termination.WPMonad (Except ε) Prop (ε → Prop)— concrete exception type.WPMonad (EStateM ε σ) (σ → Prop) (ε → σ → Prop)— concrete error-state monad.
Id's WP interpretation: Prop assertions and no exceptions.
ExceptT's WP interpretation: lift the base interpretation by adding an exception
postcondition layer.
Equations
- Std.WP.ExceptT.wpInst = { wpTrans := fun (x : ExceptT ε m α) => (Std.WP.WP.wpTrans x.run).pushExceptT, wp_trans_monotone := ⋯ }
ExceptT lifts a WPMonad instance by adding an exception postcondition layer.
Equations
- Std.WP.ExceptT.instWPMonad = { toLawfulMonad := ⋯, toWP := fun (x : Type ?u.4) => inferInstance, pure_le_wp_pure := ⋯, bind_le_wp_bind := ⋯ }
OptionT's WP interpretation: lift the base interpretation by adding a Unit exception
postcondition layer.
Equations
- Std.WP.OptionT.wpInst = { wpTrans := fun (x : OptionT m α) => (Std.WP.WP.wpTrans x.run).pushOptionT, wp_trans_monotone := ⋯ }
OptionT lifts a WPMonad instance by adding a Unit exception postcondition layer.
Equations
- Std.WP.OptionT.instWPMonad = { toLawfulMonad := ⋯, toWP := fun (x : Type ?u.3) => inferInstance, pure_le_wp_pure := ⋯, bind_le_wp_bind := ⋯ }
StateT's WP interpretation: lift the base interpretation by adding a state argument.
Equations
- Std.WP.StateT.wpInst = { wpTrans := fun (x : StateT σ m α) => Lean.Order.PredTrans.pushArg fun (x_1 : σ) => Std.WP.WP.wpTrans (x.run x_1), wp_trans_monotone := ⋯ }
StateT lifts a WPMonad instance by adding a state argument.
Equations
- Std.WP.StateT.instWPMonad = { toLawfulMonad := ⋯, toWP := fun (x : Type ?u.4) => inferInstance, pure_le_wp_pure := ⋯, bind_le_wp_bind := ⋯ }
ReaderT's WP interpretation: lift the base interpretation by adding a reader argument.
Equations
- One or more equations did not get rendered due to their size.
ReaderT lifts a WPMonad instance by adding a reader argument.
Equations
- Std.WP.ReaderT.instWPMonad = { toLawfulMonad := ⋯, toWP := fun (x : Type ?u.4) => inferInstance, pure_le_wp_pure := ⋯, bind_le_wp_bind := ⋯ }
Type Alias Instances #
WPMonad instances for concrete monads that are type aliases for transformer stacks.
Except ε is a WPMonad with Prop assertions and an ε-indexed exception postcondition.
Equations
- Std.WP.Except.instWPMonad = { toLawfulMonad := ⋯, toWP := fun (x : Type ?u.1) => inferInstance, pure_le_wp_pure := ⋯, bind_le_wp_bind := ⋯ }
EStateM ε σ is a WPMonad combining state and exceptions.
Equations
- Std.WP.EStateM.instWPMonad = { toLawfulMonad := ⋯, toWP := fun (x : Type) => inferInstance, pure_le_wp_pure := ⋯, bind_le_wp_bind := ⋯ }