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).

Lemma write_and_read_lemma (k : K) (v : V) : state_lift well_formed well_formed (eq (Some v)) (write_and_read k v).