Definition St : Type := Map K V.Definition read (k : K) : State St (option V) :=
  bind get (fun st =>
  ret (lookup k st)).Definition write (k : K) (v : V) : State St unit :=
  bind get (fun st =>
  put (insert k v st)).Definition write_and_read (k : K) (v : V) : State St (option V) :=
  bind (write k v) (fun _ =>
  read k).

(* Specifications: *)
Lemma write_and_read_lemma (k : K) (v : V) : state_lift well_formed well_formed (eq (Some v)) (write_and_read k v).
Theorem write_and_read_correct (k : K) (v : V) (s : St) : well_formed s -> fst (write_and_read k v s) = Some v.
Lemma write_and_read_lemma (k : K) (v : V) : state_lift well_formed well_formed (eq (Some v)) (write_and_read k v).
Theorem write_and_read_correct (k : K) (v : V) (s : St) : well_formed s -> fst (write_and_read k v s) = Some v.