Proof (@extensionality reg val).
(** 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'.

(* Specifications: *)
Lemma update_s:
forall r v e, update r v e r = v.
Lemma update_o:
forall r v e r', r' <> r -> update r v e r' =  e r'.
Lemma update_ident:
forall r e, update r (e r) e = e.
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).
Lemma update_twice:
forall r v e,
update r v (update r v e) = update r v e.