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

Theorem write_and_read_correct (k : K) (v : V) (s : St) : well_formed s -> fst (write_and_read k v s) = Some v.