Section AllEntriesVotesWithLog.
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 {aeli : allEntries_log_interface}.
Context {vwltsi : votesWithLog_term_sanity_interface}.
Context {vvwlci : votes_votesWithLog_correspond_interface}.
Context {vci : votes_correct_interface}.
Proof using.
intros. unfold update_elections_data_appendEntries in *.
repeat break_match; auto. simpl in *.
do_in_app. intuition. do_in_map. find_inversion.
right.
unfold handleAppendEntries in *.
repeat break_match; find_inversion; simpl in *; do_bool; auto.
Qed.
Proof using vwltsi.
red. unfold allEntries_votesWithLog. intros. simpl in *.
repeat find_higher_order_rewrite.
destruct_update; simpl in *.
- find_eapply_lem_hyp votesWithLog_update_elections_data_append_entries; eauto.
find_copy_apply_lem_hyp votesWithLog_term_sanity_invariant; eauto.
find_eapply_lem_hyp update_elections_data_appendEntries_allEntries'; eauto.
intuition; do 2 (unfold raft_data, ghost_data in *; simpl in *); try lia.
eapply_prop_hyp votesWithLog votesWithLog; eauto. intuition.
right. break_exists_exists. intuition.
find_higher_order_rewrite. destruct_update; simpl in *; auto.
rewrite update_elections_data_appendEntries_leaderLogs. auto.
- eapply_prop_hyp votesWithLog votesWithLog; eauto. intuition.
right. break_exists_exists. intuition.
find_higher_order_rewrite. destruct_update; simpl in *; auto.
rewrite update_elections_data_appendEntries_leaderLogs. auto.
Qed.
Proof using.
red. unfold allEntries_votesWithLog. intros. simpl in *.
repeat find_higher_order_rewrite.
destruct_update; simpl in *;
eapply_prop_hyp votesWithLog votesWithLog; eauto; intuition;
right; break_exists_exists; intuition;
find_higher_order_rewrite; destruct_update; simpl in *; auto.
Qed.
Definition currentTerm_votedFor_votesWithLog net :=
forall h t n,
(currentTerm (snd (nwState net h)) = t /\
votedFor (snd (nwState net h)) = Some n) ->
exists l,
In (t, n, l) (votesWithLog (fst (nwState net h))).
Proof using vci vvwlci.
unfold currentTerm_votedFor_votesWithLog. intros.
eapply votes_votesWithLog_correspond_invariant; eauto.
break_and.
eapply votes_correct_invariant; eauto.
Qed.
Proof using.
intros. unfold handleRequestVote, advanceCurrentTerm in *.
repeat (break_match; try find_inversion; simpl in *; auto);
do_bool; auto; congruence.
Qed.
Proof using.
intros.
unfold handleRequestVote, advanceCurrentTerm in *.
repeat break_match; find_inversion; simpl in *; do_bool; auto.
Qed.
Proof using.
unfold update_elections_data_requestVote.
intros.
repeat break_match; repeat tuple_inversion; intuition;
simpl in *; intuition;
tuple_inversion; intuition; repeat (do_bool; intuition);
try congruence;
unfold raft_data, ghost_data in *; simpl in *;
repeat find_rewrite; repeat find_inversion;
find_copy_apply_lem_hyp handleRequestVote_currentTerm_leaderId;
intuition;
find_apply_lem_hyp handleRequestVote_currentTerm_leaderId'; repeat find_rewrite; try congruence; intuition.
Qed.

Lemma allEntries_votesWithLog_request_vote :
refined_raft_net_invariant_request_vote allEntries_votesWithLog.