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

(* Specifications: *)
Lemma clos_refl_trans (A: Type) (R: A -> A -> Prop) t1 t2 t3: (R t1 t2 -> R t2 t3 -> R t1 t3) -> clos_refl R t1 t2 -> clos_refl R t2 t3 -> clos_refl R t1 t3.
Lemma Forall2_eq_clos_refl (A:Type) (R: A -> A -> Prop) (l1 :list A) : Forall2 (clos_refl R) l1 l1.
Lemma Forall_In_l (A : Type) (P : A -> Prop) x xs: Forall P xs -> In x xs -> P x.
Lemma Forall2_In_l (A B : Type) (R : A -> B -> Prop) x xs ys : Forall2 R xs ys -> In x xs -> exists y, In y ys /\ R x y.
Lemma Forall2_In_r (A B : Type) (R : A -> B -> Prop) y xs ys : Forall2 R xs ys -> In y ys -> exists x, In x xs /\ R x y.
Lemma Forall2_conj (A B : Type) (R1 R2 : A -> B -> Prop) xs ys : Forall2 R1 xs ys -> Forall2 R2 xs ys -> Forall2 (fun x y => R1 x y /\ R2 x y) xs ys.
Lemma Forall2_trans (A: Type) (R: A -> A -> Prop) xs ys zs : (forall x y z, In x xs -> In y ys -> In z zs -> R x y -> R y z -> R x z) -> Forall2 R xs ys -> Forall2 R ys zs -> Forall2 R xs zs.
Lemma Forall2_length A B (R : A -> B -> Prop) xs ys : Forall2 R xs ys -> length xs = length ys.
Lemma Forall2_map (A:Type) (B:Type): forall l f g (R:B->B->Prop), (forall (x:A), In x l -> R (f x) (g x)) -> Forall2 R (map f l) (map g l).
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).
Lemma Forall2_forall A (d: A) (R: A -> A -> Prop) (xs ys: list A) : Forall2 R xs ys -> forall i, i < length xs -> R (nth i xs d) (nth i ys d).