let apply (m, s, d_opt) k =
    try
      Some(M.find k m)
    with
      | Not_found -> if S.mem k s then None else d_opt