Proof using.
intros. induction l; simpl in *; intuition.
conclude IHl intuition.
conclude IHl intuition. intuition.
- find_rewrite. break_match; intuition.
repeat break_if; intuition.
+ do_bool. right.
find_apply_lem_hyp argmin_in; intuition.
destruct (A_eq_dec a a1); destruct (A_eq_dec a a0); repeat subst; intuition;
specialize (H0 a1); specialize (H a0); intuition; repeat find_rewrite; omega.
+ do_bool. right.
find_apply_lem_hyp argmin_in; intuition.
destruct (A_eq_dec a a1); destruct (A_eq_dec a a0); repeat subst; intuition.
* specialize (H a1); specialize (H0 a0); intuition. repeat find_rewrite. omega.
* specialize (H a1); specialize (H0 a0); intuition. repeat find_rewrite. omega.
- find_rewrite. repeat break_match; subst; intuition.
do_bool.
repeat find_apply_lem_hyp argmin_elim; intuition.
destruct (A_eq_dec a a1); destruct (A_eq_dec a a0); repeat subst; intuition.
+ specialize (H a0); specialize (H0 a1); intuition. repeat find_rewrite. omega.
+ pose proof H a0; pose proof H a1; intuition. repeat find_rewrite.
specialize (H3 a1). intuition. omega.
Qed.

Lemma applied_entries_update :
forall sigma h st,
lastApplied st >= lastApplied (sigma h) ->
(applied_entries (update name_eq_dec sigma h st) = applied_entries sigma /\
(exists h',
argmax (fun h => lastApplied (sigma h)) (all_fin N) = Some h' /\
lastApplied (sigma h') >= lastApplied st))
\/
(argmax (fun h' => lastApplied (update name_eq_dec sigma h st h')) (all_fin N) = Some h /\
applied_entries (update name_eq_dec sigma h st) = (rev (removeAfterIndex (log st) (lastApplied st)))).