Proof using.
intros.
unfold log_matching_nw in *. use_nw_invariant_keep.
eapply entries_match_scratch; eauto; intuition.
unfold log_matching_hosts in *.
match goal with
| [ H : _ |- _ ] => solve [eapply H; eauto]
end.
Qed.

(* Specifications: *)
Lemma handleAppendEntries_spec :
forall h d t from pli plt entries lci d' m,
handleAppendEntries h d t from pli plt entries lci = (d', m) ->
~ is_append_entries m /\
(log d' = log d \/
(pli = 0 /\ log d' = entries) \/
(pli <> 0 /\
(exists e, findAtIndex (log d) pli = Some e /\
eTerm e = plt)
/\ log d' = entries ++ (removeAfterIndex (log d) pli))).