(** * Facts about [aloop] and [loop] *)
(* begin hide *)
Program
Classes.Morphisms
Setoids.Setoid
Relations.Relations.
Basics.Basics
Basics.CategoryOps
Basics.CategoryTheory
Basics.CategoryKleisli
Basics.CategoryKleisliFacts
Basics.Function
Core.ITreeDefinition
Core.ITreeMonad
Core.KTree
Eq.Eq
Eq.UpToTaus.
Local Open Scope itree.
(* end hide *)
(** ** [ITree.aloop] *)

Lemma bind_iter {E A B C} (f : A -> itree E (A + B)) (g : B -> itree E (B + C))
: forall x,
(ITree.iter f x >>= ITree.iter g)
≈ ITree.iter (fun ab =>
match ab with
| inl a => ITree.map inl (f a)
| inr b => ITree.map (bimap inr (id_ _)) (g b)
end) (inl x).