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))).

Lemma currentTerm_votedFor_votesWithLog_invariant :
forall net,
refined_raft_intermediate_reachable net ->
currentTerm_votedFor_votesWithLog net.