Proof using.
intros. unfold handleAppendEntries in *.
break_if; [find_inversion; subst; eauto|].
break_if;
[do_bool; break_if; find_inversion; subst;
try find_apply_lem_hyp haveNewEntries_not_empty; intuition; simpl in *;
eauto using advanceCurrentTerm_log|].
break_if.
- break_match; [|find_inversion; subst; eauto].
break_if; [find_inversion; subst; eauto|].
find_inversion; subst; simpl in *.
right. right.
find_apply_lem_hyp findAtIndex_elim. intuition; do_bool; eauto.
find_apply_lem_hyp haveNewEntries_not_empty. congruence.
- repeat break_match; find_inversion; subst; eauto.
simpl in *. eauto using advanceCurrentTerm_log.
Qed.

(* Specifications: *)
Theorem handleAppendEntries_log_ind :
forall {h st t n pli plt es ci st' ps},
handleAppendEntries h st t n pli plt es ci = (st', ps) ->
forall (P : list entry -> Prop),
P (log st) ->
(pli = 0 -> P es) ->
(forall e,
pli <> 0 ->
In e (log st) ->
eIndex e = pli ->
eTerm e = plt ->
P (es ++ (removeAfterIndex (log st) pli))) ->
P (log st').