Section Facts.
Context {D E : Type -> Type} (ctx : D ~> itree (D +' E)).
(** Unfolding of [interp_mrec]. *)
Definition _interp_mrec {R : Type} (ot : itreeF (D +' E) R _) : itree E R :=
match ot with
| RetF r => Ret r
| TauF t => Tau (interp_mrec ctx t)
| VisF e k =>
match e with
| inl1 d => Tau (interp_mrec ctx (ctx _ d >>= k))
| inr1 e => Vis e (fun x => Tau (interp_mrec ctx (k x)))
end
end.
(** [mrec ctx] is equivalent to [interp (mrecursive ctx)], where [mrecursive] is defined as follows. *)
Definition mrecursive (f : D ~> itree (D +' E))
: (D +' E) ~> itree E :=
case_ (mrec f) ITree.trigger.
Global Instance eq_itree_mrec {R} :
Proper (eq_itree eq ==> eq_itree eq) (@interp_mrec _ _ ctx R).

Theorem interp_mrec_bind {U T} (t : itree _ U) (k : U -> itree _ T) :
interp_mrec ctx (ITree.bind t k) ≅
ITree.bind (interp_mrec ctx t) (fun x => interp_mrec ctx (k x)).