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 mrec_as_interp {T} (d : D T) :
mrec ctx d ≈ interp (mrecursive ctx) (ctx _ d).