Proof with auto.
intros.
rewrite <- map_map_comp.
rewrite (filter_perms p t).
rewrite map_concat_map.
set (((fact (length (filter (negb ∘ p) t)) * length (merges (filter p t) (filter (negb ∘ p) t))))%nat).
assert (n <> 0%nat).
subst n.
apply mult_ne_0.
apply fact_neq_0.
pose proof (merges_ne_nil (filter p t) (filter (negb ∘ p) t)).
destruct @merges...
discriminate.
clearbody n.
rewrite (map_ext_eq_mor (repeat_map_comm f n)).
set (perms (filter p t)).
assert (l <> nil).
subst l.
intro.
pose proof (length_perms (filter p t)).
rewrite H0 in H1.
simpl in H1.
apply (fact_neq_0 (length (filter p t)))...
clearbody l.
unfold Ravg.
rewrite map_length.
rewrite length_concat.
rewrite map_map_comp.
rewrite Rsum_concat.
rewrite map_map_comp.
rewrite (@add_same n).
rewrite map_length.
rewrite <- Combinators.compose_assoc.
rewrite <- map_map_comp.
rewrite (map_ext_eq_mor (Rsum_repeat n)).
rewrite Rsum_map_mult.
rewrite mult_INR.
field.
split...
destruct l...
simpl @length.
auto with arith.
intros.
apply in_map_iff in H1. destruct H1. destruct H1. subst...
apply length_repeat.
Qed.

Lemma Ravg_comp_map X
(f: X -> R) (m: list X -> R) (g: R -> R):
(forall a b, g (a * b) = g a * b) ->
(forall l, g (Rsum l) = Rsum (map g l)) ->
(forall l: list X, Ravg (map f l) = g (m l)) -> forall u,
Ravg (map (fun l => Ravg (map f l)) u) = g (Ravg (map m u)).