(** The main operation over environments is update: it assigns
  a value [v] to a register [r] and preserves the values of other
  registers. *)

Definition update (r: reg) (v: val) (e: env) : env :=
  fun r' => if reg_eq r' r then v else e r'.

Lemma update_commut: forall r1 v1 r2 v2 e, r1 <> r2 -> update r1 v1 (update r2 v2 e) = update r2 v2 (update r1 v1 e).