Proof using.
induction l; intros; simpl in *; auto.
repeat break_match; simpl in *; auto; do_bool;
try solve [f_equal; eauto using assoc_set_a_equiv];
match goal with
| _ : assoc ?dec ?ks ?c = _, _ : assoc ?dec ?ks' ?c = _ |- _ =>
assert (assoc dec ks c = assoc dec ks' c) by (eauto using assoc_a_equiv)
end; repeat find_rewrite; try find_inversion; try congruence; omega.
Qed.

Lemma cacheApplyEntry_getLastId :
forall st e l st' client id out,
cacheApplyEntry st e = (l, st') ->
getLastId st' client = Some (id, out) ->
getLastId st client = Some (id, out) \/
eClient e = client /\
l = [out] /\
eId e = id /\
out = fst (handler (eInput e) (stateMachine st)) /\
(forall id' out', getLastId st client = Some (id', out') ->
id' < id).