Proof using.
red. unfold CandidateEntries.
intros. subst.
intuition; simpl in *.
- unfold candidateEntries_host_invariant in *.
intros.
eapply candidateEntries_ext; eauto.
repeat find_higher_order_rewrite.
find_rewrite_lem update_fun_comm. simpl in *.
update_destruct; subst; rewrite_update;
eapply handleAppendEntries_preserves_candidate_entries; eauto.
find_copy_apply_lem_hyp handleAppendEntries_spec. break_and.
find_apply_hyp_hyp. intuition eauto.
- unfold candidateEntries_nw_invariant in *.
intros. simpl in *.
eapply candidateEntries_ext; eauto.
find_apply_hyp_hyp.
intuition.
+ eapply handleAppendEntries_preserves_candidate_entries; eauto.
+ subst. simpl in *. find_apply_lem_hyp handleAppendEntries_spec.
break_and.
subst.
exfalso.
eauto using is_append_entries_intro.
Qed.

(* Specifications: *)
Lemma handleAppendEntriesReply_spec :
forall h st h' t es r st' ms,
handleAppendEntriesReply h st h' t es r = (st', ms) ->
log st' = log st /\
((currentTerm st' = currentTerm st /\ type st' = type st)
\/ type st' = Follower) /\
(forall m, In m ms -> ~ is_append_entries (snd m)).