(** * 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] *)
(** ** [iter] *)
Instance eq_itree_iter {E A B} :
@Proper ((A -> itree E (A + B)) -> A -> itree E B)
((eq ==> eq_itree eq) ==> pointwise_relation _ (eq_itree eq))
iter.
Instance eutt_iter {E A B} :
@Proper ((A -> itree E (A + B)) -> A -> itree E B)
(pointwise_relation _ (eutt eq) ==> pointwise_relation _ (eutt eq))
iter.
Definition eutt_iter_gen {F A B R S} :
@Proper ((A -> itree F (A + B)) -> A -> itree F B)
((R ==> eutt (sum_rel R S)) ==> R ==> (eutt S))
KTree.iter.
Instance eq2_ktree_iter {E A B} :
@Proper (ktree E A (A + B) -> ktree E A B)
(eq2 ==> eq2)
iter.
Instance IterUnfold_ktree {E} : IterUnfold (ktree E) sum.
Instance IterNatural_ktree {E} : IterNatural (ktree E) sum.
Instance IterDinatural_ktree {E} : IterDinatural (ktree E) sum.

Lemma iter_codiagonal_ktree {E A B} (f : ktree E A (A + (A + B))) (a0 : A)
: iter (iter f) a0
≅ iter (fun a =>
r <- f a ;;
match r with
| inl a' => Ret (inl a')
| inr (inl a') => Ret (inl a')
| inr (inr b) => Ret (inr b)
end) a0.