(* (** [filter] **)
Definition filter {A : Type} (f : key -> A -> bool) {dom} (m : t A dom) :=
fold (fun x v acc => if f x v then add x acc else acc) m empty.

(* Specifications: *)
Lemma filter_spec : forall A f dom (m : t A dom) x v,
find x (filter f m) = Some v <-> find x m = Some v ∧ f x v = true.