Definition eq_var_dec := VarType.eq_dec.(** Asserts the binding of a variable in an environment. *)
Definition binds (x : TVar) (v : A) (E : gen_env A) := get x E = Some v.(** Asserts the inclusion of an environment in another. *)
Definition all_binds (E F : gen_env A) :=
  forall x v, binds x v E -> binds x v F.(** Equivalence between environments *)
Definition eq (E F : gen_env A) := all_binds E F ∧ all_binds F E.(** [x '∹' v '⋲' E] to be read x is bound to v in E. *)

Notation "x '∹' v '⋲' E" := (binds x v E) 
  (at level 65) : gen_env_scope.(** [E '⊏' F] to be read F all_binds E, i.e. E is included in F. *)

Notation "E '⊏' F" := (all_binds E F) 
  (at level 65) : gen_env_scope.(** [E '≍' F] to be read F is equivalent to E, i.e. E binds as F. *)

Notation "E '≍' F" := (eq E F) 
  (at level 68) : gen_env_scope.Implicit Types x y : TVar.Implicit Types xs ys : list TVar.

(* Specifications: *)
Theorem ok_dom : forall A (E : gen_env A), List.NoDup (dom E) -> ok E.
Theorem ok_dom_inv : forall A (E : gen_env A), ok E -> List.NoDup (dom E).
Theorem ok_NoDup_dom_eq : forall A (E : gen_env A), ok E <-> List.NoDup (dom E).
Lemma list_length_S : forall A (l : list A) n, length l = S n -> exists x:A, exists l', l = x :: l'.
Theorem eq_refl : forall A (E F : gen_env A), E = F -> E ≍ F.
Theorem eq_sym : forall A (E F : gen_env A), E ≍ F -> F ≍ E.
Theorem eq_trans : forall A (E F G : gen_env A), E ≍ F -> F ≍ G -> E ≍ G.
Theorem eq_binds : forall A x (v : A) (E F : gen_env A), E ≍ F -> binds x v E -> binds x v F.
Theorem eq_get : forall A (E F : gen_env A), E ≍ F -> forall x, get x E = get x F.
Theorem eq_get_inv : forall A (E F : gen_env A), (forall x, get x E = get x F) -> E ≍ F.
Theorem eq_map : forall A B (f : A -> B) (E F : gen_env A), E ≍ F -> map f E ≍ map f F.
Theorem eq_map_inv : forall A B (f : A -> B) (E F : gen_env A), Image.injective A B f -> map f E ≍ map f F -> E ≍ F.
Theorem eq_dec : forall A (E F : gen_env A), (forall w w' : A, { w = w' } + { ¬ w = w' }) -> ok E -> ok F -> { E ≍ F } + { ¬ E ≍ F }.