Definition triple0 A B C (t: A * B * C): A := fst (fst t).Definition triple1 A B C (t: A * B * C): B := snd (fst t).Definition triple2 A B C (t: A * B * C): C := snd t.Fixpoint rsplits T (l: list T): list (list T * T * list T) :=
  match l with
  | nil => nil
  | h :: t => (nil, h, t) :: map (fun p => (h :: triple0 p, triple1 p, triple2 p)) (rsplits t)
  end.

(* Specifications: *)
Lemma splits_rsplits (T: Set) (l: list T): splits l = map (fun p => (triple1 p, triple0 p ++ triple2 p)) (rsplits l).
Lemma elemsR_map': forall (A B: Type) (Ra: relation A) (Rb: relation B) (f : A -> B) (fR: forall x y, Ra x y -> Rb (f x) (f y)) (l l': list A), elemsR Ra l l' -> elemsR Rb (map f l) (map f l').
Lemma map_length_filter_permuted_splits T (l l': list T): Permutation l l' -> forall p, Permutation (map (fun x => length (filter (p (fst x)) (snd x))) (splits l)) (map (fun x => length (filter (p (fst x)) (snd x))) (splits l')).
Lemma perms_alt_perms T (l: list T): Permutation (perms l) (alt_perms l).