Proof using.
unfold applyEntry.
intros.
repeat break_match; repeat find_inversion. intuition.
Qed.

(* Specifications: *)
Lemma cacheApplyEntry_clientCache :
forall st e l st',
cacheApplyEntry st e = (l, st') ->
(clientCache st' = clientCache st /\
(exists i o, getLastId st (eClient e) = Some (i, o) /\
eId e <= i) ) \/
((let (out, _) := handler (eInput e) (stateMachine st)
in (clientCache st' = assoc_set clientId_eq_dec (clientCache st) (eClient e) (eId e, out) /\
In out l)) /\ (getLastId st (eClient e) = None \/
(exists i o, getLastId st (eClient e) = Some (i, o) /\
i < eId e))).