Proof using.
intros.
unfold handleRequestVoteReply, advanceCurrentTerm in *.
repeat break_match; try find_inversion; subst; simpl in *; intuition;
do_bool; intuition; try right; congruence.
Qed.

(* Specifications: *)
Lemma contradict_leaderLogs_term_sanity :
forall net h t ll e,
refined_raft_intermediate_reachable net ->
In (t, ll) (leaderLogs (fst (nwState net h))) ->
In e ll ->
eTerm e = currentTerm (snd (nwState net h)) ->
False.
Lemma allEntries_leader_sublog_request_vote_reply :
refined_raft_net_invariant_request_vote_reply allEntries_leader_sublog.
Lemma handleRequestVoteReply_spec' :
forall h st h' t r st',
st' = handleRequestVoteReply h st h' t r ->
log st' = log st /\
(forall v, In v (votesReceived st) -> In v (votesReceived st')) /\
(type st <> Leader /\ type st' = Leader ->
(type st = Candidate /\ wonElection (dedup name_eq_dec
(votesReceived st')) = true) /\
r = true /\
currentTerm st' = currentTerm st /\
currentTerm st = t /\
votesReceived st' = (h' :: (votesReceived st))).
Theorem handleTimeout_not_is_append_entries :
forall h st st' ms m,
handleTimeout h st = (st', ms) ->
In m ms -> ~ is_append_entries (snd m).