Proof using.
intros. unfold handleAppendEntries in *.
repeat (break_match; try find_inversion; intuition;
simpl in *; do_bool; subst; intuition;
break_exists; try congruence; eauto using advanceCurrentTerm_log).
right. right. intuition. eexists; eauto.
Qed.

Lemma handleAppendEntries_log_matching_middle_of_time_entries_match :
forall net p t n pli plt es ci h ple,
log_matching_hosts net ->
log_matching_nw net ->
logs_sorted_host net ->
logs_sorted_nw net ->
uniqueIndices_host_invariant net ->
In p (nwPackets net) ->
pBody p = AppendEntries t n pli plt es ci ->
findAtIndex (log (nwState net (pDst p))) pli = Some ple ->
eTerm ple = plt ->
pli <> 0 ->
entries_match (es ++ (removeAfterIndex (log (nwState net (pDst p))) pli))
(log (nwState net h)).