Section PrevLogCandidateEntriesTerm.
Context {orig_base_params : BaseParams}.
Context {one_node_params : OneNodeParams orig_base_params}.
Context {raft_params : RaftParams orig_base_params}.
Context {rri : raft_refinement_interface}.
Context {cei : candidate_entries_interface}.
Context {cti : cronies_term_interface}.
Context {cci : cronies_correct_interface}.
Proof using.
unfold refined_raft_net_invariant_init, prevLog_candidateEntriesTerm.
simpl. intuition.
Qed.
Proof using.
unfold candidateEntriesTerm.
intros. break_exists_exists.
repeat find_higher_order_rewrite. intuition.
Qed.
Proof using.
unfold candidateEntriesTerm.
intros. break_exists_exists.
repeat find_higher_order_rewrite.
intuition.
Qed.
Proof using.
unfold refined_raft_net_invariant_client_request, prevLog_candidateEntriesTerm.
simpl. intros.
find_apply_hyp_hyp. break_or_hyp.
- eapply candidateEntriesTerm_ext; eauto.
eapply candidateEntriesTerm_same; eauto; intros;
update_destruct_simplify; auto.
+ now erewrite update_elections_data_client_request_cronies by eauto.
+ find_apply_lem_hyp handleClientRequest_type. intuition.
+ find_apply_lem_hyp handleClientRequest_type. intuition.
- find_apply_lem_hyp in_map_iff. break_exists. break_and. subst. simpl in *.
exfalso. eapply handleClientRequest_no_append_entries; eauto.
find_rewrite. eauto 10.
Qed.

Lemma update_elections_data_timeout_cronies :
forall h d out d' l t,
handleTimeout h (snd d) = (out, d', l) ->
cronies (update_elections_data_timeout h d) t = cronies (fst d) t \/
(t = currentTerm d' /\ type d' = Candidate /\
cronies (update_elections_data_timeout h d) t = votesReceived d').