Proof using.
intros.
unfold handleAppendEntries, advanceCurrentTerm in *.
repeat break_match; find_inversion; simpl in *;
do_bool; auto.
Qed.

Theorem handleAppendEntries_log_detailed :
forall h st t n pli plt es ci st' ps,
handleAppendEntries h st t n pli plt es ci = (st', ps) ->
(commitIndex st' = commitIndex st /\ log st' = log st) \/
(leaderId st' <> None /\
currentTerm st' = t /\
commitIndex st' = max (commitIndex st) (min ci (maxIndex es)) /\
es <> nil /\
pli = 0 /\ t >= currentTerm st /\ log st' = es /\
haveNewEntries st es = true ) \/
(leaderId st' <> None /\
currentTerm st' = t /\
commitIndex st' = max (commitIndex st)
(min ci (maxIndex (es ++ (removeAfterIndex (log st) pli)))) /\
es <> nil /\
exists e,
In e (log st) /\
eIndex e = pli /\
eTerm e = plt) /\
t >= currentTerm st /\
log st' = es ++ (removeAfterIndex (log st) pli) /\
haveNewEntries st es = true.