Definition map {A B : Type} (f : A -> B) dom (m : t A dom) : t B dom :=
  exist (OK dom) (S.map f (proj1_sig m)) (map_OK f m).(** [combine] **)
Definition Scombine {A B C : Type} (f : A -> B -> C) (g : A -> C) (h : B -> C) (m₁ : S.t A) (m₂ : S.t B) : S.t C :=
  Dom.fold (fun x acc => match S.find x m₁, S.find x m₂ with
                           | Some v₁, Some v₂ => S.add x (f v₁ v₂) acc
                           | Some v, None => S.add x (g v) acc
                           | None, Some v => S.add x (h v) acc
                           | None, None => acc
                         end)
           (Dom.union (S.fold (fun x _ acc => Dom.add x acc) m₁ Dom.empty)
                      (S.fold (fun x _ acc => Dom.add x acc) m₂ Dom.empty)) (S.empty C).

(* Specifications: *)
Lemma Sdom_aux : forall A x (m : S.t A) s, Dom.In x (S.fold (fun x _ acc => Dom.add x acc) m s) <-> S.In x m ∨ Dom.In x s.