Ltac prog_assoc_r :=
    eapply comp_spec_eq_trans_r; [ idtac | eapply comp_spec_assoc].(* A bounded repeat based on fold. *)
Definition repeatMax(A : Set)(eqd : EqDec A)(c : Comp A)(P : A -> bool) def (n : nat):=
  compFold _ (fun a' i => if (P a') then (ret a') else c) def (allNatsLt n).

Theorem compFold_eq : forall (A1 A2 : Set) P (ls1 : list A1) (ls2 : list A2), list_pred P ls1 ls2 -> forall (B : Set)(eqd : EqDec B) (c1 : B -> A1 -> Comp B) (c2: B -> A2 -> Comp B), (forall acc a1 a2, P a1 a2 -> In a1 ls1 -> In a2 ls2 -> comp_spec eq (c1 acc a1) (c2 acc a2) ) -> forall init, comp_spec eq (compFold _ c1 init ls1) (compFold _ c2 init ls2).