Section prodl.
Fixpoint prodl (l : list nat) : nat :=
match l with
| nil => 1
| n :: l' => n * prodl l'
end.
End prodl.
Definition clos_refl {A : Type} (R : A -> A -> Prop) (x y : A) : Prop :=
R x y \/ x = y.
Inductive Exists2 {A B} (R: A -> B -> Prop) : list A -> list B -> Prop :=
| Exists2_cons_hd : forall x xs y ys, R x y -> Exists2 R (x::xs) (y::ys)
| Exists2_cons_tl : forall x xs y ys, Exists2 R xs ys -> Exists2 R (x::xs) (y::ys).
Hint Constructors Exists2.
Fixpoint revflatten {A: Type} (xss: list (list A)) : list A :=
match xss with
| []       => []
| xs::xss' => revflatten xss' ++ xs
end.

Lemma Permutation_flat_map_ext A B  : forall l (f g : A -> list B),
(forall x, In x l -> Permutation (f x) (g x)) -> Permutation (flat_map f l) (flat_map g l).