Section contents.
Variable X: Set.
Variable Xle: X -> X -> Prop.
Variable XleDec: forall x y, { Xle x y } + { Xle y x }.
Let leb: X -> X -> IdMonad.M bool := fun x y => unsum_bool (XleDec x y).
Proof with auto.
intro. pattern l, (qs leb l).
apply qs_rect...
intros.
simpl.
apply Permutation.Permutation_cons_app.
apply Permutation.perm_trans with (filter (leb h) t ++ filter (gt leb h) t).
apply complementary_filter_perm.
apply Permutation.perm_trans with (qs leb (filter (leb h) t) ++ qs leb (filter (gt leb h) t)).
apply Permutation.Permutation_app...
apply Permutation.Permutation_app_swap.
Qed.
Variable PO: Relation_Definitions.preorder X Xle.

Lemma  qs_correct: forall l, vec.sorted Xle (vec.from_list (qs leb l)).