Proof using.
unfold refined_raft_net_invariant_request_vote, appendEntries_leader.
simpl.
intros.
find_apply_hyp_hyp.
intuition.
- repeat find_higher_order_rewrite.
update_destruct_simplify.
+ eapply appendEntries_leader_predicate_TTLM_preserved; eauto using handleRequestVote_TTLM.
eauto.
+ eauto.
- find_apply_lem_hyp handleRequestVote_no_append_entries.
subst. exfalso. eauto 10.
Qed.
(* p0 is AE. by AE_came_from_leaders, there is a ll in pre state at (pSrc p0) for p0's term. claim I am (pSrc p0). I am ascending, so I have ll in post state. pSrc p0 ll still is preserved into post state. finish with one ll per term. thus I had a leaderLog in the pre state. this contradicts leaderLogs_currentTerm_sanity_candidate. *)

Lemma handleRequestVoteReply_spec' :
forall h st h' t r st',
handleRequestVoteReply h st h' t r = st' ->
type st' = Follower \/
st' = st \/
type st' = Candidate \/
(type st' = Leader /\
type st = Candidate /\
log st' = log st /\
r = true /\
t = currentTerm st /\
wonElection (dedup name_eq_dec (h' :: votesReceived st)) = true /\
currentTerm st' = currentTerm st).