(** Useful tactic for simplifying expressions like [In y (add x e (remove z m))] *)

Ltac map_iff :=
 repeat (progress (
  rewrite add_mapsto_iff || rewrite add_in_iff ||
  rewrite remove_mapsto_iff || rewrite remove_in_iff ||
  rewrite empty_mapsto_iff || rewrite empty_in_iff ||
  rewrite map_mapsto_iff || rewrite map_in_iff ||
  rewrite mapi_in_iff)).

(* Specifications: *)
Lemma mem_find_b : forall (elt:Type)(m:t elt)(x:key), mem x m = if find x m then true else false.
Lemma mem_b : forall m x y, E.eq x y -> mem x m = mem y m.
Lemma find_o : forall m x y, E.eq x y -> find x m = find y m.
Lemma empty_o : forall x, find x (empty elt) = None.
Lemma empty_a : forall x, mem x (empty elt) = false.
Lemma add_eq_o : forall m x y e, E.eq x y -> find y (add x e m) = Some e.
Lemma add_neq_o : forall m x y e, ~ E.eq x y -> find y (add x e m) = find y m.
Lemma add_o : forall m x y e, find y (add x e m) = if eq_dec x y then Some e else find y m.
Lemma add_eq_b : forall m x y e, E.eq x y -> mem y (add x e m) = true.
Lemma add_neq_b : forall m x y e, ~E.eq x y -> mem y (add x e m) = mem y m.
Lemma add_b : forall m x y e, mem y (add x e m) = eqb x y || mem y m.
Lemma remove_eq_o : forall m x y, E.eq x y -> find y (remove x m) = None.
Lemma remove_neq_o : forall m x y, ~ E.eq x y -> find y (remove x m) = find y m.
Lemma remove_o : forall m x y, find y (remove x m) = if eq_dec x y then None else find y m.
Lemma remove_eq_b : forall m x y, E.eq x y -> mem y (remove x m) = false.
Lemma remove_neq_b : forall m x y, ~ E.eq x y -> mem y (remove x m) = mem y m.
Lemma remove_b : forall m x y, mem y (remove x m) = negb (eqb x y) && mem y m.
Lemma map_o : forall m x (f:elt->elt'), find x (map f m) = Datatypes.option_map f (find x m).
Lemma map_b : forall m x (f:elt->elt'), mem x (map f m) = mem x m.
Lemma mapi_b : forall m x (f:key->elt->elt'), mem x (mapi f m) = mem x m.
Lemma mapi_o : forall m x (f:key->elt->elt'), (forall x y e, E.eq x y -> f x e = f y e) -> find x (mapi f m) = Datatypes.option_map (f x) (find x m).
Lemma map2_1bis : forall (m: t elt)(m': t elt') x (f:option elt->option elt'->option elt''), f None None = None -> find x (map2 f m m') = f (find x m) (find x m').
Lemma elements_o : forall m x, find x m = findA (eqb x) (elements m).
Lemma elements_b : forall m x, mem x m = existsb (fun p => eqb x (fst p)) (elements m).
Lemma Equal_mapsto_iff : forall m1 m2 : t elt, Equal m1 m2 <-> (forall k e, MapsTo k e m1 <-> MapsTo k e m2).
Lemma Equal_Equiv : forall (m m' : t elt), Equal m m' <-> Equiv Logic.eq m m'.