intros.
apply Rle_trans with (n * 2 * Rsum (map (Rinv ∘ INR) (nats 2 (pred n)))).
apply C_bounded_by_harmonic.
apply Rmult_le_compat_l.
apply Rmult_le_pos...
destruct n.
simpl...
simpl pred.
replace (Rsum (map (Rinv ∘ INR) (nats 2 n))) with (Rsum (map (Rinv ∘ INR) (nats 1 (S n))) - 1).
Focus 2.
simpl.
unfold compose at 1.
simpl.
rewrite Rinv_1.
field.
replace (INR (log2ceil (S n))) with (S (log2ceil (S n)) - 1).
unfold Rminus.
apply Rplus_le_compat_r.
apply harmonic.upper_bound.
rewrite S_INR.
field.
Qed.
(* What remains is to show that the average cost of qs is bounded by C: *)

(* Specifications: *)
Lemma C_bounds_avg_qs_cost: forall l, Ravg (map (INR ∘ cost ∘ qs) (perms l)) <= C (length l).
Proof with auto with real.