induction ls_b; intuition.
simpl.
prog_simp.
simpl.
eapply comp_spec_ret.
trivial.
simpl.
prog_inline_first.
prog_at prog_inline rightc 1%nat.
simpl.
prog_at prog_ret rightc 2.
simpl.
prog_at prog_swap rightc 1%nat.
Ltac prog_assoc_r :=
eapply comp_spec_eq_trans_r; [ idtac | eapply comp_spec_assoc].
prog_assoc_r.
eapply comp_spec_seq; intuition.
Qed.
(* 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).

Lemma repeatMax_fold_true :
forall (A B: Set)(ls : list B)(eqd : EqDec A)(c : B -> Comp A)(P : A -> bool)(a : A),
P a = true ->
comp_spec eq
(compFold _ (fun acc b => if (P acc) then (ret acc) else (c b)) a ls)
(ret a).