Proof using.
intros. unfold update_elections_data_appendEntries, handleAppendEntries in *.
repeat break_match; repeat find_inversion; auto; simpl in *.
- right. intuition. right. left. do_bool. intuition; eauto using advanceCurrentTerm_term.
find_apply_lem_hyp haveNewEntries_not_empty. congruence.
- rewrite advanceCurrentTerm_log.
right. intuition. left. intuition.
do_bool.
eauto using advanceCurrentTerm_term.
- right. intuition. right. right. do_bool. intuition.
+ eauto using advanceCurrentTerm_term.
+ find_apply_lem_hyp haveNewEntries_not_empty. congruence.
+ find_apply_lem_hyp findAtIndex_elim. intuition; do_bool; eauto.
- rewrite advanceCurrentTerm_log. do_bool. rewrite advanceCurrentTerm_term; auto.
intuition.
Qed.

(* Specifications: *)
Lemma update_elections_data_appendEntries_allEntries_detailed :
forall h st t h' pli plt es ci st' m te e,
handleAppendEntries h (snd st) t h' pli plt es ci = (st', m) ->
In (te, e) (allEntries (update_elections_data_appendEntries h st t h' pli plt es ci)) ->
In (te, e) (allEntries (fst st)) \/ In e (log st') \/ (In e es /\ haveNewEntries (snd st) es = false /\ log st' = log (snd st)).