Documentation

LeanPool.OrderMaintenance.Proof.Correct.Monad

Reasoning about Level F code #

Results #

def OrderMaintenance.Proof.Result.state {ε σ α : Type} :
EStateM.Result ε σ α → σ

Recover the reached state from a successful or failed state-monad result.

Equations
Instances For
    @[simp]
    theorem OrderMaintenance.Proof.Result.state_ok {ε σ α : Type} (a : α) (s : σ) :
    @[simp]
    theorem OrderMaintenance.Proof.Result.state_error {ε σ α : Type} (e : ε) (s : σ) :

    run lemmas #

    @[simp]
    theorem OrderMaintenance.Proof.run_bind {α β : Type} (m : Model.CM α) (f : α → Model.CM β) (s : Model.Core) :
    EStateM.run (m >>= f) s = match EStateM.run m s with | EStateM.Result.ok a s' => EStateM.run (f a) s' | EStateM.Result.error e s' => EStateM.Result.error e s'

    Frame preservation #

    Every run of m ends, normally or by a failed guard, in a state related to its start state by R; and m never hits Err.bug.

    Equations
    • One or more equations did not get rendered due to their size.
    Instances For

      A preorder on states, for Pres.

      Instances
        theorem OrderMaintenance.Proof.Pres.pure {R : Model.Core → Model.Core → Prop} [IsPre R] {α : Type} (a : α) :
        theorem OrderMaintenance.Proof.Pres.modify {R : Model.Core → Model.Core → Prop} {f : Model.Core → Model.Core} (h : ∀ (s : Model.Core), R s (f s)) :
        theorem OrderMaintenance.Proof.Pres.modifyGet {R : Model.Core → Model.Core → Prop} {α : Type} {f : Model.Core → α × Model.Core} (h : ∀ (s : Model.Core), R s (f s).snd) :
        theorem OrderMaintenance.Proof.Pres.bind {R : Model.Core → Model.Core → Prop} [IsPre R] {α β : Type} {m : Model.CM α} {f : α → Model.CM β} (hm : Pres R m) (hf : ∀ (a : α), Pres R (f a)) :
        Pres R (m >>= f)
        theorem OrderMaintenance.Proof.Pres.ite {R : Model.Core → Model.Core → Prop} {α : Type} {c : Prop} [Decidable c] {a b : Model.CM α} (ha : Pres R a) (hb : Pres R b) :
        Pres R (if c then a else b)
        theorem OrderMaintenance.Proof.Pres.forIn_list {R : Model.Core → Model.Core → Prop} [IsPre R] {β γ : Type} (l : List γ) (b : β) {f : γ → β → Model.CM (ForInStep β)} (hf : ∀ (x : γ) (b : β), Pres R (f x b)) :
        Pres R (forIn l b f)
        theorem OrderMaintenance.Proof.Pres.mapM_list {R : Model.Core → Model.Core → Prop} [IsPre R] {γ δ : Type} (l : List γ) {f : γ → Model.CM δ} (hf : ∀ (x : γ), Pres R (f x)) :
        Pres R (List.mapM f l)
        theorem OrderMaintenance.Proof.Pres.forM_list {R : Model.Core → Model.Core → Prop} [IsPre R] {γ : Type} (l : List γ) {f : γ → Model.CM PUnit} (hf : ∀ (x : γ), Pres R (f x)) :
        Pres R (l.forM f)
        theorem OrderMaintenance.Proof.Pres.forIn_array {R : Model.Core → Model.Core → Prop} [IsPre R] {β γ : Type} (a : Array γ) (b : β) {f : γ → β → Model.CM (ForInStep β)} (hf : ∀ (x : γ) (b : β), Pres R (f x b)) :
        Pres R (forIn a b f)
        theorem OrderMaintenance.Proof.Pres.mono {R : Model.Core → Model.Core → Prop} {α : Type} {R' : Model.Core → Model.Core → Prop} {m : Model.CM α} (h : Pres R m) (hR : ∀ (s t : Model.Core), R s t → R' s t) :
        Pres R' m

        Decompose a computation into primitive state updates, using the given lemmas for calls. Leaves goals of the form ∀ s, R s (f s) for the updates.

        Equations
        • One or more equations did not get rendered due to their size.
        Instances For

          run of reads followed by a continuation #

          theorem OrderMaintenance.Proof.run_pure_bind {β : Type} (s : Model.Core) {α : Type} (a : α) (k : α → Model.CM β) :
          EStateM.run (pure a >>= k) s = EStateM.run (k a) s
          @[simp]
          theorem OrderMaintenance.Proof.run_map_guard {β : Type} (s : Model.Core) {γ : Type} (g : γ → β) (msg : String) :