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.

Lemma expand_sumOver_ijs n (f: nat * nat -> R):
RsumOver (ijs n) f =
RsumOver (nats 0 n) (fun j => RsumOver (nats 0 j) (fun i => f (i, j))).