Definition update {A B : Type} (A_eq_dec : forall x y : A, {x = y} + {x <> y}) st h (v : B) := 
  fun nm => if A_eq_dec nm h then v else st nm.

Lemma update_fun_comm : forall A B C A_eq_dec (f : B -> C) (st : A -> B) y v x, f (update A_eq_dec st y v x) = update A_eq_dec (fun x => f (st x)) y (f v) x.