Section IDENTIFY.
Variable uf: t.
Variables a b: elt.
Hypothesis a_canon: M.get a uf.(m) = None.
Hypothesis not_same_class: repr uf b <> a.
Remark identify_Acc_b:
forall x,
Acc (order uf.(m)) x -> repr uf x <> a -> Acc (order (M.set a b uf.(m))) x.
Remark identify_Acc:
forall x,
Acc (order uf.(m)) x -> Acc (order (M.set a b uf.(m))) x.
Definition identify := mk (M.set a b uf.(m)) identify_wf.
End IDENTIFY.
(* Union *)
Remark union_not_same_class:
forall uf a b, repr uf a <> repr uf b -> repr uf (repr uf b) <> repr uf a.
Definition union (uf: t) (a b: elt) : t :=
let a' := repr uf a in
let b' := repr uf b in
match M.elt_eq a' b' with
| left EQ => uf
| right NEQ => identify uf a' b' (repr_res_none uf a) (union_not_same_class uf a b NEQ)
end.
(* Merge *)
Definition merge (uf: t) (a b: elt) : t :=
let a' := repr uf a in
let b' := repr uf b in
match M.elt_eq a' b' with
| left EQ => uf
| right NEQ => identify uf a' b (repr_res_none uf a) (not_eq_sym NEQ)
end.
(* Path order and merge *)
Definition path_ord (uf: t) : elt -> elt -> Prop := order uf.(m).

Lemma path_ord_canonical:
forall uf x y, repr uf x = x -> ~path_ord uf y x.