induction l.
simpl...
simpl...
destruct (cmp_cmp (Ecmp _ a p) c)...
simpl.
rewrite <- IHl...
Qed.

Lemma cost_qs l: cost (qs l) =
match l with
| nil => 0
| h :: t => length t + cost (qs (filter (Egtb h) t)) + cost (qs (filter (Eltb h) t))
end.