Definition from_elements A (l : list (key * A))
: t A (List.fold_left (fun acc xv => Dom.add (fst xv) acc) l Dom.empty) :=
exist (OK (List.fold_left (fun acc xv => Dom.add (fst xv) acc) l Dom.empty))
(List.fold_left (fun acc xv => S.add (fst xv) (snd xv) acc) l (@S.empty A))
(from_elements_OK l).
(** ***  Specifications  **)

Lemma combine_spec : forall A B C (f : A -> B -> C) g₁ g₂ dom₁ dom₂ (m₁ : t A dom₁) (m₂ : t B dom₂) x v,
find x (combine f g₁ g₂ m₁ m₂) = Some v <->
(exists v₁ v₂, find x m₁ = Some v₁ ∧ find x m₂ = Some v₂ ∧ v = f v₁ v₂)
∨ (exists v₁, find x m₁ = Some v₁ ∧ find x m₂ = None ∧ v = g₁ v₁)
∨ (exists v₂, find x m₁ = None ∧ find x m₂ = Some v₂ ∧ v = g₂ v₂).