induction n.
rewrite Ceq...
apply Rmult_le_reg_l with (/ S n)...
repeat rewrite <- Rmult_assoc.
rewrite Rinv_l...
rewrite Rmult_1_l.
destruct n.
simpl.
rewrite Ceq.
simpl.
rewrite Ravg_single.
rewrite Ceq.
fourier.
simpl pred in *.
rewrite nats_Sw'.
rewrite map_app, Rsum_app, map_single, Rsum_single.
set (bla := S n) in *.
rename n into m. rename bla into n.
assert (0 < n). subst n. replace 0 with (INR O)...
apply Rmult_le_reg_l with n...
rewrite Rmult_plus_distr_l.
rewrite Rmult_plus_distr_l.
rewrite plus_comm...
simpl plus...
unfold compose at 2.
rewrite <- (Rmult_assoc n 2).
fold n.
apply Rle_trans with (C n + n * (2 * / S n))...
rewrite (C_S (S n)).
simpl pred.
repeat rewrite <- Rmult_assoc.
rewrite Rmult_plus_distr_l.
unfold Rdiv.
repeat rewrite <- Rmult_assoc.
rewrite Rplus_comm.
apply Rplus_le_compat.
rewrite <- (Rmult_1_l (C n)) at 2.
apply Rmult_le_compat_r...
apply C_nonneg.
repeat rewrite S_INR.
replace (n * / (n + 1) * (n + 1 + 1) * / (n + 1)) with ((n * n + n + n) * / (n * n + n + n + 1)).
apply Rlt_le.
apply Rdiv_lt_1...
field...
split...
apply Rgt_not_eq.
unfold Rgt.
apply Rle_lt_trans with (n * n + n + n)...
apply Rmult_le_compat_r...
rewrite (Rmult_comm n 2).
apply Rmult_le_compat_r...
rewrite <- (Rmult_1_l 2) at 2.
apply Rmult_le_compat_r...
apply Rlt_le...
apply Rdiv_lt_1...
Qed.
(* Consequently, we can use an existing result about the harmonic series to get the n*log(n) bound for C: *)
Require harmonic.

Lemma C_log_bound n: C n <= n * 2 * log2ceil n.
Proof with auto with real.