Proof using.
intros.
unfold applied_entries in *.
repeat break_match; intuition;
try solve [find_apply_lem_hyp argmax_None;
exfalso;
pose proof (all_fin_all _ h); find_rewrite; intuition].
match goal with
| _ : argmax ?f ?l = _, _ : argmax ?g ?l = _ |- _ =>
pose proof argmax_one_different name name_eq_dec g f l h as Hproof
end.
forward Hproof; [intros; rewrite_update; intuition|]; concludes.
forward Hproof; [intros; update_destruct; subst; rewrite_update; intuition|]; concludes.
intuition.
- repeat find_rewrite. find_inversion.
update_destruct; subst; rewrite_update; intuition. left.
intuition. eexists; intuition eauto. repeat find_apply_lem_hyp argmax_elim; intuition eauto.
match goal with
H : _ |- _ =>
solve [specialize (H h); rewrite_update; eauto using all_fin_all]
end.
- repeat find_rewrite. find_inversion. rewrite_update. intuition.
Qed.

(* Specifications: *)
Lemma applied_entries_safe_update :
forall sigma h st,
lastApplied st = lastApplied (sigma h) ->
removeAfterIndex (log st) (lastApplied (sigma h))
= removeAfterIndex (log (sigma h)) (lastApplied (sigma h)) ->
applied_entries (update name_eq_dec sigma h st) = applied_entries sigma.