End BOOLEAN_EQUALITY.
(** Extensional equality between trees *)
Section EXTENSIONAL_EQUALITY.
Variable A: Type.
Variable eqA: A -> A -> Prop.
Hypothesis eqAeq: Equivalence eqA.
Definition Equal (m1 m2: T.t A) : Prop :=
forall x, match T.get x m1, T.get x m2 with
| None, None => True
| Some a1, Some a2 => a1 === a2
| _, _ => False
end.

(* Specifications: *)
Lemma Equal_refl: forall m, Equal m m.
Lemma Equal_sym: forall m1 m2, Equal m1 m2 -> Equal m2 m1.
Lemma Equal_trans: forall m1 m2 m3, Equal m1 m2 -> Equal m2 m3 -> Equal m1 m3.
Instance Equal_Equivalence : Equivalence Equal := {
Equivalence_Reflexive := Equal_refl;
Equivalence_Symmetric := Equal_sym;
Equivalence_Transitive := Equal_trans
}.
Lemma Equal_refl: forall m, Equal m m.
Lemma Equal_sym: forall m1 m2, Equal m1 m2 -> Equal m2 m1.
Lemma Equal_trans: forall m1 m2 m3, Equal m1 m2 -> Equal m2 m3 -> Equal m1 m3.
Instance Equal_Equivalence : Equivalence Equal := {
Equivalence_Reflexive := Equal_refl;
Equivalence_Symmetric := Equal_sym;
Equivalence_Transitive := Equal_trans
}.