Module UF (M: MAP) : UNIONFIND with Definition elt := M.elt.
Definition elt := M.elt.
Definition elt_eq := M.elt_eq.
(* A set of equivalence classes over elt is represented by a map m. M.get a m = Some a' means that a is in the same class as a'. M.get a m = None means that a is the canonical representative for its equivalence class. *)
(* The ordering over elt induced by such a map. repr_order m a a' iff M.get a' m = Some a. This ordering must be well founded. *)
Definition order (m: M.t elt) (a a': elt) : Prop :=
M.get a' m = Some a.
Record unionfind : Type := mk { m: M.t elt; mwf: well_founded (order m) }.
Definition t := unionfind.
Definition getlink (m: M.t elt) (a: elt) : {a' | M.get a m = Some a'} + {M.get a m = None}.

Lemma repr_canonical:
forall (a: elt), repr (repr a) = repr a.