Inductive rel_map(A B : Type)(r : A -> B -> Prop) : list A -> list B -> Prop :=
| rm_nil : 
  rel_map r nil nil
| rm_step : 
  forall lsa lsb a b,
    rel_map r lsa lsb ->
    r a b ->
    rel_map r (a :: lsa) (b :: lsb).Inductive rel_map(A B : Type)(r : A -> B -> Prop) : list A -> list B -> Prop :=
| rm_nil : 
  rel_map r nil nil
| rm_step : 
  forall lsa lsb a b,
    rel_map r lsa lsb ->
    r a b ->
    rel_map r (a :: lsa) (b :: lsb).Inductive rel_map(A B : Type)(r : A -> B -> Prop) : list A -> list B -> Prop :=
| rm_nil : 
  rel_map r nil nil
| rm_step : 
  forall lsa lsb a b,
    rel_map r lsa lsb ->
    r a b ->
    rel_map r (a :: lsa) (b :: lsb).

(* Specifications: *)
Theorem rel_map_map2 : forall (A B C D : Type)(ls_c : list C)(ls_d: list D)(P : A -> B -> Prop)(f1 : C -> A)(f2 : D -> B), rel_map (fun a b => P (f1 a) (f2 b)) ls_c ls_d -> rel_map P (map f1 ls_c) (map f2 ls_d).
Lemma rel_map_length : forall (A B : Type)(lsa : list A)(P : A -> B -> Prop)(lsb : list B), rel_map P lsa lsb -> length lsa = length lsb.
Lemma rel_map_unary_pred : forall (A B : Type)(P : A -> B -> Prop)(lsa : list A)(lsb : list B)(P' : B -> Prop), rel_map P lsa lsb -> (forall a b, P a b -> P' b) -> forall b, In b lsb -> P' b.
Lemma rel_map_eq_inv : forall (A B : Type)(ls1 ls2 : list A)(rel1 rel2 : A -> B -> Prop) ls1' ls2', ls1 = ls2 -> (forall a b1 b2, rel1 a b1 -> rel2 a b2 -> b1 = b2) -> rel_map rel1 ls1 ls1' -> rel_map rel2 ls2 ls2' -> ls1' = ls2'.
Lemma rel_map_eq : forall (A B : Type)(ls1 : list A)(rel1 : A -> B -> Prop) ls', rel_map rel1 ls1 ls' -> forall ls2 (rel2 : A -> B -> Prop), ls1 = ls2 -> (forall a b, In a ls1 -> In b ls' -> rel1 a b -> rel2 a b) -> rel_map rel2 ls2 ls'.
Theorem pred_count_eq_0 : forall (A B : Set)(ls : list B)(ls' : list A)(f : B -> A -> Prop)(P : A -> Prop) v, (forall a b, In b ls -> f b a -> ~ P a) -> rel_map f ls ls' -> pred_count P ls' v -> v = O.
Lemma rel_map_app_inv : forall (A B : Type)(rel : A -> B -> Prop)(lsa1 lsa2 : list A)(lsb : list B), rel_map rel (lsa1 ++ lsa2) lsb -> (rel_map rel lsa1 (firstn (length lsa1) lsb) /\ rel_map rel lsa2 (skipn (length lsa1) lsb)).
Lemma rel_map_map_inv : forall (A B C : Type)(rel : B -> C -> Prop)(f : A -> B)(lsa : list A)(lsc : list C), rel_map rel (map f lsa) lsc -> rel_map (fun a c => rel (f a) c) lsa lsc.
Lemma rel_map_listRepeat : forall (A B : Set)(lsa : list A)(rel : A -> B -> Prop) b, (forall a, In a lsa -> rel a b) -> rel_map rel lsa (listRepeat b (length lsa)).
Lemma rel_map_app : forall (A B : Type)(rel : A -> B -> Prop)(lsa1 lsa2 : list A)(lsb1 lsb2 : list B), rel_map rel lsa1 lsb1 -> rel_map rel lsa2 lsb2 -> rel_map rel (lsa1 ++ lsa2) (lsb1 ++ lsb2).
Lemma rel_map_map : forall (A B C : Type)(f : A -> B)(rel : B -> C -> Prop) lsa lsc, rel_map (fun a c => rel (f a) c) lsa lsc -> rel_map rel (map f lsa) lsc.
Lemma rel_map_inverse : forall (A B : Type)(lsa : list A)(lsb : list B) rel, rel_map rel lsa lsb -> forall b, In b lsb -> exists a, In a lsa /\ rel a b.
Lemma ne_all_not_in : forall (A : Type)(ls : list A) a, (forall a', In a' ls -> a <> a') -> ~In a ls.
Lemma rel_map_NoDup : forall (A B : Type)(lsa : list A)(lsb : list B) rel, rel_map rel lsa lsb -> NoDup lsa -> (forall a1 a2 b1 b2, In a1 lsa -> In a2 lsa -> a1 <> a2 -> rel a1 b1 -> rel a2 b2 -> b1 <> b2) -> NoDup lsb.
Lemma rel_map_in : forall (A B : Type)(lsa : list A)(lsb : list B) rel, rel_map rel lsa lsb -> (forall a b1 b2, In a lsa -> rel a b1 -> rel a b2 -> b1 = b2) -> forall b a, In a lsa -> rel a b -> In b lsb.
Lemma rel_map_left_total : forall (A B : Type)(rel : A -> B -> Prop)(lsa : list A), (forall a, exists b, rel a b) -> exists lsb, rel_map rel lsa lsb.
Lemma rel_map_func : forall (A B : Type) (rel : A -> B -> Prop) lsa lsb1, rel_map rel lsa lsb1 -> forall lsb2, rel_map rel lsa lsb2 -> (forall a b1 b2, In a lsa -> rel a b1 -> rel a b2 -> b1 = b2) -> lsb1 = lsb2.
Lemma rel_map_permutation : forall (A B : Type) lsa1 lsa2, Permutation lsa1 lsa2 -> forall (rel : A -> B -> Prop), (forall a b1 b2, rel a b1 -> rel a b2 -> b1 = b2) -> (forall a, exists b, rel a b) -> forall lsb1 lsb2, rel_map rel lsa1 lsb1 -> rel_map rel lsa2 lsb2 -> Permutation lsb1 lsb2.
Lemma rel_map_impl : forall (A B : Type)(rel1 rel2 : A -> B -> Prop) lsa lsb, rel_map rel1 lsa lsb -> (forall a b, In a lsa -> rel1 a b -> rel2 a b) -> rel_map rel2 lsa lsb.
Lemma rel_map_in_inv : forall (A B : Type)(rel : A -> B -> Prop) lsa lsb, rel_map rel lsa lsb -> forall a, In a lsa -> exists b, In b lsb /\ rel a b.
Lemma sumList_rel_distance : forall (A : Set)(ls : list A)(f1 f2 : A -> Rat -> Prop) r r1 r2, (forall a r1 r2, In a ls -> f1 a r1 -> f2 a r2 -> (ratDistance r1 r2) <= r) -> sumList_rel f1 ls r1 -> sumList_rel f2 ls r2 -> ratDistance r1 r2 <= (r * (length ls / 1)).
Lemma sumList_rel_left_total : forall (A : Type)(rel : A -> Rat -> Prop)(ls : list A), (forall a, In a ls -> exists r, rel a r) -> exists r, sumList_rel rel ls r.
Lemma sumList_rel_factor_constant : forall (p1 p2 : posnat) (A : Type)(rel : A -> Rat -> Prop)(ls : list A) r, sumList_rel (fun a r' => rel a (r' * (RatIntro p1 p2))) ls (r * (RatIntro p2 p1)) -> sumList_rel rel ls r.
Lemma sumList_rel_permutation : forall (A : Type)(rel : A -> Rat -> Prop)(ls1 ls2 : list A), Permutation ls1 ls2 -> forall r, sumList_rel rel ls1 r -> sumList_rel rel ls2 r.
Lemma sumList_rel_all_0 : forall (A : Type)(rel : A -> Rat -> Prop)(ls : list A), (forall a, In a ls -> rel a 0) -> sumList_rel rel ls 0.
Lemma sumList_rel_sumList : forall (A : Set)(ls : list A)(f : A -> Rat), sumList_rel (fun a r => f a = r) ls (sumList ls f).
Lemma rel_map_left_total_strong' : forall (A B : Type)(lsa : list A)(P : A -> Prop)(rel : A -> B -> Prop), (forall a, P a -> exists b, rel a b) -> (forall a, In a lsa -> P a) -> exists lsb, rel_map rel lsa lsb.
Lemma firstn_eq_all_gen : forall (A : Type)(ls : list A) n, n = length ls -> firstn n ls = ls.