Section contents.
Variables (ee: E) (ol: list ee).
Proof with auto with real.
intros.
repeat rewrite <- Rplus_assoc.
rewrite Rplus_0_r.
rewrite plus_comm.
replace
(2 * / INR (S (j - i)) * INR (i - b) + 1 + 1 + 2 * / INR (S (j - i)) * INR (n + b - j)) with
(2 * / INR (S (j - i)) * (INR (i - b) + INR (n + b - j)) + 2).
rewrite <- plus_INR.
replace ((i - b + (n + b - j))%nat) with ((S n - S (j - i))%nat) by omega.
rewrite minus_INR.
field.
split...
omega.
field...
Qed.

Theorem qs_comp_prob: forall i j: Index ee ol, lt i j -> forall l b, IndexSeq b l ->
monoid_expec (U.ijcount i j) (U.qs (e:=ee) (ol:=ol) l) <= 2 / INR (S (j - i)).