Documentation

PolyFun.ITree.Events.StateFacts

Laws for state interpretation #

Exact computation rules for ITree.interpState and ITree.runState. State operations take one silent step, ordinary ITree steps are preserved, and external events remain visible.

@[simp]
theorem ITree.interpState_pure {σ : Type uσ} {E : PFunctor.{uEA, uσ}} {α : Type uα} (s : σ) (r : α) :
@[simp]
theorem ITree.interpState_step {σ : Type uσ} {E : PFunctor.{uEA, uσ}} {α : Type uα} (s : σ) (t : ITree (StateE σ + E) α) :
@[simp]
theorem ITree.interpState_get {σ : Type uσ} {E : PFunctor.{uEA, uσ}} {α : Type uα} (s : σ) (k : σ → ITree (StateE σ + E) α) :
@[simp]
theorem ITree.interpState_put {σ : Type uσ} {E : PFunctor.{uEA, uσ}} {α : Type uα} (s s' : σ) (k : PUnit.{uσ + 1} → ITree (StateE σ + E) α) :
@[simp]
theorem ITree.interpState_query_external {σ : Type uσ} {E : PFunctor.{uEA, uσ}} {α : Type uα} (s : σ) (e : E.A) (k : E.B e → ITree (StateE σ + E) α) :
(query (Sum.inr e) k).interpState s = query e fun (b : E.B e) => (k b).interpState s
theorem ITree.interpState_bind {σ : Type uσ} {E : PFunctor.{uEA, uσ}} {α : Type uα} {β : Type uβ} (t : ITree (StateE σ + E) α) (k : α → ITree (StateE σ + E) β) (s : σ) :
(t.bind k).interpState s = (t.interpState s).bind fun (p : σ × α) => (k p.2).interpState p.1

State interpretation is the canonical state-transformer monad morphism.

@[simp]
theorem ITree.runState_eq_interpState {σ : Type uσ} {E : PFunctor.{uEA, uσ}} {α : Type uα} (t : ITree (StateE σ + E) α) (s : σ) :