Section Logs.
(* A log is a map from nat, and a finite log has a latest element. *)
Context {B : Type}.
Local Close Scope Z.
Definition log_latest s (v1 : nat) (v2 : B) := s v1 = Some v2 /\ forall v', v1 < v' -> s v' = None.

Lemma log_latest_add : forall m1 m2 k1 k2 (v1 v2 : B)
(Hlatest1 : log_latest m1 k1 v1) (Hlatest2 : log_latest m2 k2 v2),
log_latest (map_add m1 m2) (max k1 k2) (if lt_dec k1 k2 then v2 else v1).