Set Implicit Arguments.
Definition ijs (n: nat): list (nat * nat) :=
concat (map (fun j => map (fun i => (i, j)) (nats 0 j)) (nats 0 n)).
Proof with auto with arith.
unfold ijs.
intros.
apply In_concat with (map (fun x: nat => (x, j)) (nats 0 j)).
apply (in_map (fun i: nat => (i, j))).
apply In_nats...
apply (in_map (fun j0: nat => map (fun i0: nat => (i0, j0)) (nats 0 j0))).
apply In_nats...
Qed.
Proof with auto.
unfold ijs.
simpl.
intros.
destruct (In_concat_inv _ _ H). clear H.
destruct H0.
destruct (In_map_inv H0). clear H0.
destruct H1.
subst.
destruct (In_map_inv H). clear H.
destruct H0.
inversion H.
subst.
split.
destruct (In_nats_inv _ _ _ H0)...
destruct (In_nats_inv _ _ _ H1)...
Qed.
Proof with auto with real.
unfold ijs.
intros.
rewrite RsumOver_concat_map.
unfold RsumOver.
rewrite (map_ext (fun j => RsumOver (map (fun i => (i, j)) (nats 0 j)) f) (fun j => RsumOver (nats 0 j) (fun i => f (i, j))))...
intro.
unfold RsumOver.
rewrite map_map...
Qed.
Require harmonic.

Lemma sumOver_ijs_bound n:
RsumOver (ijs n) (fun ij => 2 / INR (S (snd ij - fst ij))) <= 2 * INR n * INR (S (log2ceil n)).