Documentation

Std.Do.Internal.Ensures.Def

Internal.Ensures and Internal.MayReturn #

Internal.Ensures p x characterizes the postconditions of a monadic action x: it holds iff every value returned by x satisfies p. The witness is a Subtype-refined action y : m {a // p a} that is bind-faithful w.r.t. x.

Internal.MayReturn x a is the strongest postcondition of x evaluated at a: a is in every postcondition of xa is reachable as a value of x.

structure Std.Do.Internal.ErasesTo {α : Type u} {m : Type u → Type v} [Bind m] {P : αProp} (x : m { b : α // P b }) (y : m α) :

{lean}ErasesTo x y says the property-tagged {name}x is bind-faithful to {name}y: binding {name}x and forgetting the property agrees with binding {name}y.

  • bind_eq {β : Type u} (k : αm β) : (do let ax k a.val) = y >>= k

    The bind-faithful equation: binding x and projecting agrees with binding y.

Instances For
    structure Std.Do.Internal.Ensures {m : Type u → Type v} [Bind m] {α : Type u} (P : αProp) (x : m α) :

    Ensures p x says every value returned by x satisfies p. The witness is a Subtype-refined monadic action that is bind-faithful w.r.t. x.

    Instances For
      structure Std.Do.Internal.MayReturn {m : Type u → Type v} [Bind m] {α : Type u} (x : m α) (a : α) :

      MayReturn x a says a is in every postcondition of x, equivalently that a is a value returnable from x. (The strongest postcondition, evaluated at a.)

      Instances For
        structure Std.Do.Internal.IsAttach {m : Type u → Type v} [Bind m] (attach : α : Type u⦄ → (x : m α) → m { a : α // MayReturn x a }) :

        IsAttach attach says attach tags each value of x with its MayReturn proof in a bind-faithful way.

        • erases {α : Type u} (x : m α) : ErasesTo (attach x) x

          For each x, the attached version is bind-faithful with x.

        Instances For