Proof using.
unfold refined_raft_net_invariant_append_entries, prevLog_candidateEntriesTerm.
simpl. intros.
find_apply_hyp_hyp. break_or_hyp.
- find_eapply_lem_hyp app_cons_in_rest; [|solve[eauto]].
eapply candidateEntriesTerm_ext; eauto.
eapply handleAppendEntries_preserves_candidateEntriesTerm; eauto.
- exfalso. eapply handleAppendEntries_not_append_entries; eauto.
simpl in *. subst. eauto 10.
Qed.

Lemma handleAppendEntriesReply_preserves_candidateEntriesTerm :
forall net h h' t es r st' ms t',
handleAppendEntriesReply h (snd (nwState net h)) h' t es r = (st', ms) ->
refined_raft_intermediate_reachable net ->
candidateEntriesTerm t' (nwState net) ->
candidateEntriesTerm t' (update name_eq_dec (nwState net) h (fst (nwState net h), st')).