induction l.
intros.
inversion H1.
simpl.
rewrite Ravg_cons.
unfold Rdiv.
intros.
destruct (Rmult_0_inv H).
Focus 2.
elimtype False.
apply (Rinv_neq_0_compat (INR (S (length l))))...
assert (0 <= a).
apply H0...
assert (0 <= Ravg l).
apply Ravg_0_le...
assert (0 <= Ravg l * INR (length l)).
apply Rmult_le_pos...
destruct H1.
subst.
apply (Rplus_eq_0_l x (Ravg l * INR (length l)) H3 H5 H2).
apply IHl...
rewrite Rplus_comm in H2.
cset (Rplus_eq_0_l (Ravg l * INR (length l)) a H5 H3 H2).
destruct (Rmult_0_inv H6)...
destruct l.
inversion H1.
simpl @length in H7.
elimtype False.
apply (INR_S_ne_0 (length l))...
Qed.
Hint Resolve not_0_INR.

(* Specifications: *)
Lemma avg_filter_perms (T: Set) (f: list T -> R) (p: T -> bool) (t: list T):
Ravg (map (f ∘ filter p) (perms t)) =
Ravg (map f (perms (filter p t))).