Definition clos_refl {A : Type} (R : A -> A -> Prop) (x y : A) : Prop :=
  R x y \/ x = y.

Lemma Forall2_flat_map (A B C D: Type) (R: C -> D -> Prop) (f: A -> list C) (g: B -> list D) (xs: list A) (ys: list B) : Forall2 (fun x y => Forall2 R (f x) (g y)) xs ys -> Forall2 R (flat_map f xs) (flat_map g ys).