Ltac use_nw_invariant_keep :=
    match goal with
      | [ H : forall _ _ _ _ _ _ _, In _ _ -> Net.pBody _ = _ -> _,
            H' : Net.pBody ?p = AppendEntries _ _ _ _ ?xs _ |- _ ] =>
        copy_apply H H'; clear H; intuition
    end.Ltac use_leader_sublog :=
    match goal with
      | [ H : forall _ _ _ _ _ _  _ _ _, type _ = _ -> In _ _ -> Net.pBody _ = _ -> _,
            H' : Net.pBody ?p = AppendEntries _ _ _ _ ?xs _ |- _ ] =>
        eapply H in H'; clear H; eauto; intuition
    end.Ltac pbody_massage :=
    match goal with
      | H : In ?p _ |- _ =>
        match type of H with
          | context [ nwPackets _ ] => fail 1
          | context [AppendEntries ?t ?lid ?pli ?plt ?e ?lc] =>
            assert (Net.pBody p = AppendEntries t lid pli plt e lc) by reflexivity
        end
    end.

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)).