Documentation

Std.WP.Monad.Instances

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 #

@[instance_reducible]
instance Std.WP.Id.wpInst {α : Type u} :

Id's WP interpretation: Prop assertions and no exceptions.

Equations
@[instance_reducible]

Id is a WPMonad with Prop assertions and no exceptions.

Equations
  • One or more equations did not get rendered due to their size.
@[instance_reducible]
instance Std.WP.ExceptT.wpInst {m : Type u → Type z} {EPred : Type u_1} {ε α : Type u} {Pred : Type v} [Assertion Pred] [Assertion EPred] [WP (m (Except ε α)) (Except ε α) Pred EPred] :
WP (ExceptT ε m α) α Pred ((εPred) × EPred)

ExceptT's WP interpretation: lift the base interpretation by adding an exception postcondition layer.

Equations
@[instance_reducible]
instance Std.WP.ExceptT.instWPMonad {m : Type u → Type z} {EPred : Type u_1} {ε : Type u} {Pred : Type v} [Monad m] [Assertion Pred] [Assertion EPred] [WPMonad m Pred EPred] :
WPMonad (ExceptT ε m) Pred ((εPred) × EPred)

ExceptT lifts a WPMonad instance by adding an exception postcondition layer.

Equations
@[simp]
theorem Std.WP.ExceptT.wp_apply_eq {m : Type u → Type z} {α ε : Type u} {Pred : Type u_1} {EPred : Type u_2} [Monad m] [Assertion Pred] [Assertion EPred] [WPMonad m Pred EPred] (x : ExceptT ε m α) (post : αPred) (epost : (εPred) × EPred) :
wp x post epost = wp x.run (Lean.Order.pushExcept post epost.fst) epost.snd
@[instance_reducible]
instance Std.WP.OptionT.wpInst {m : Type u → Type z} {EPred : Type u_1} {α Pred : Type u} [Assertion Pred] [Assertion EPred] [WP (m (Option α)) (Option α) Pred EPred] :
WP (OptionT m α) α Pred ((UnitPred) × EPred)

OptionT's WP interpretation: lift the base interpretation by adding a Unit exception postcondition layer.

Equations
@[instance_reducible]
instance Std.WP.OptionT.instWPMonad {m : Type u → Type z} {EPred : Type u_1} {Pred : Type u} [Monad m] [Assertion Pred] [Assertion EPred] [WPMonad m Pred EPred] :
WPMonad (OptionT m) Pred ((UnitPred) × EPred)

OptionT lifts a WPMonad instance by adding a Unit exception postcondition layer.

Equations
@[simp]
theorem Std.WP.OptionT.wp_apply_eq {m : Type u → Type z} {α Pred : Type u} {EPred : Type u_1} [Monad m] [Assertion Pred] [Assertion EPred] [WPMonad m Pred EPred] (x : OptionT m α) (post : αPred) (epost : (UnitPred) × EPred) :
wp x post epost = wp x.run (Lean.Order.pushOption post epost.fst) epost.snd
@[instance_reducible]
instance Std.WP.StateT.wpInst {m : Type u → Type z} {α : Type u} {EPred : Type v} {σ : Type u} {Pred : Type w} [Assertion Pred] [Assertion EPred] [WP (m (α × σ)) (α × σ) Pred EPred] :
WP (StateT σ m α) α (σPred) EPred

StateT's WP interpretation: lift the base interpretation by adding a state argument.

Equations
@[instance_reducible, instance 100]
instance Std.WP.StateT.instWPMonad {m : Type u → Type z} {EPred : Type v} {σ : Type u} {Pred : Type w} [Monad m] [Assertion Pred] [Assertion EPred] [WPMonad m Pred EPred] :
WPMonad (StateT σ m) (σPred) EPred

StateT lifts a WPMonad instance by adding a state argument.

Equations
@[simp]
theorem Std.WP.StateT.wp_apply_eq {m : Type u → Type z} {Pred : Type u_1} {EPred : Type u_2} {α σ : Type u} [Monad m] [Assertion Pred] [Assertion EPred] [WPMonad m Pred EPred] (x : StateT σ m α) (post : ασPred) (epost : EPred) (s : σ) :
wp x post epost s = wp (x.run s) (fun (x : α × σ) => match x with | (a, s) => post a s) epost
@[instance_reducible]
instance Std.WP.ReaderT.wpInst {m : Type u → Type z} {EPred : Type u_1} {α ρ : Type u} {Pred : Type v} [Assertion Pred] [Assertion EPred] [WP (m α) α Pred EPred] :
WP (ReaderT ρ m α) α (ρPred) EPred

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.
@[instance_reducible]
instance Std.WP.ReaderT.instWPMonad {m : Type u → Type z} {EPred : Type u_1} {ρ : Type u} {Pred : Type v} [Monad m] [Assertion Pred] [Assertion EPred] [WPMonad m Pred EPred] :
WPMonad (ReaderT ρ m) (ρPred) EPred

ReaderT lifts a WPMonad instance by adding a reader argument.

Equations
@[simp]
theorem Std.WP.ReaderT.wp_apply_eq {m : Type u → Type z} {Pred : Type u_1} {EPred : Type u_2} {α ρ : Type u} [Monad m] [Assertion Pred] [Assertion EPred] [WPMonad m Pred EPred] (x : ReaderT ρ m α) (post : αρPred) (epost : EPred) (r : ρ) :
wp x post epost r = wp (x.run r) (fun (a : α) => post a r) epost

Type Alias Instances #

WPMonad instances for concrete monads that are type aliases for transformer stacks.

@[instance_reducible]
instance Std.WP.Option.wpInst {α : Type u} :
WP (Option α) α Prop (UnitProp)

Option's WP interpretation: Prop assertions and a Unit-indexed exception postcondition.

Equations
@[instance_reducible]

Option is a WPMonad with Prop assertions and a Unit-indexed exception postcondition.

Equations
  • One or more equations did not get rendered due to their size.
@[instance_reducible]
instance Std.WP.Except.wpInst {ε : Type u_1} {α : Type u} :
WP (Except ε α) α Prop (εProp)

Except ε's WP interpretation: Prop assertions and an ε-indexed exception postcondition.

Equations
@[instance_reducible]
instance Std.WP.Except.instWPMonad {ε : Type u_1} :
WPMonad (Except ε) Prop (εProp)

Except ε is a WPMonad with Prop assertions and an ε-indexed exception postcondition.

Equations
@[instance_reducible]
instance Std.WP.EStateM.wpInst {ε σ α : Type} :
WP (EStateM ε σ α) α (σProp) (εσProp)

EStateM ε σ's WP interpretation combining state and exceptions.

Equations
  • One or more equations did not get rendered due to their size.
@[instance_reducible]
instance Std.WP.EStateM.instWPMonad {ε σ : Type} :
WPMonad (EStateM ε σ) (σProp) (εσProp)

EStateM ε σ is a WPMonad combining state and exceptions.

Equations