Definition cast {A : Type} dom₁ dom₂ (Heq : Dom.eq dom₁ dom₂) (m : t A dom₁) : t A dom₂ :=
  exist (OK dom₂) (proj1_sig m) (cast_OK Heq (proj2_sig m)).(** [elements] **)
Definition elements A dom (m : t A dom) := S.elements (proj1_sig m).

(* Specifications: *)
Lemma pre_from_elements_OK : forall A l dom (m : t A dom), OK (fold_left (fun acc xv => Dom.add (fst xv) acc) l (domain m)) (fold_left (fun acc xv => S.add (fst xv) (snd xv) acc) l (proj1_sig m)).