Section CompLoop.
Variable A : Set.
Hypothesis eqd : EqDec A.
Variable c : A -> Comp A.
Hypothesis c_wf : forall a, well_formed_comp (c a).
Definition compLoop n (a : A) : Comp A :=
compFold _ (fun a n => c a) a (allNatsLt n).
intuition.
eapply compFold_wf; intuition.
Qed.
End CompLoop.
intuition.
Qed.

Theorem compLoop_S :
forall (A : Set)(eqda : EqDec A)(c : A -> Comp A) n a x,
evalDist (compLoop _ c (S n) a) x ==
evalDist (a0 <-$ c a; compLoop eqda c n a0) x.