Definition body (v: list X) :=
    match v with
    | nil => ret nil
    | p :: t => partitionPart p t
    end.Definition raw_body_ext (l: list X) (qs qs': {l': list X | length l' < length l} -> M (list X)):
    (forall x y, proj1_sig x = proj1_sig y -> qs x = qs' y) -> raw_body l qs = raw_body l qs'.

(* Specifications: *)
Lemma bodies x0: raw_body x0 (fun y: {y: list X | length y < length x0} => qs _ cmp (proj1_sig y)) = body x0.
Lemma toBody (l: list X): qs _ cmp l = body l.
Lemma rect (Q: list X -> M (list X) -> Type): (Q nil (ret nil)) -> (forall h t, (forall y, length y <= length t -> Q y (qs _ cmp y)) -> Q (h :: t) (partitionPart h t)) -> forall x, Q x (qs _ cmp x).