Section AllEntriesTermSanity.
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}.
Proof using.
intros.
unfold handleAppendEntries in *.
repeat break_match; simpl in *; do_bool; repeat find_inversion; auto; try lia;
simpl in *;
unfold advanceCurrentTerm in *; repeat break_match; do_bool; auto.
Qed.
Proof using.
red. unfold allEntries_term_sanity. intros. simpl in *.
subst. repeat find_higher_order_rewrite.
destruct_update; simpl in *; eauto.
find_copy_eapply_lem_hyp update_elections_data_appendEntries_allEntries_term'; eauto.
intuition.
find_apply_lem_hyp handleAppendEntries_currentTerm_monotonic;
find_apply_hyp_hyp; lia.
Qed.
Proof using.
red. unfold allEntries_term_sanity. intros.
subst. repeat find_higher_order_rewrite.
destruct_update; simpl in *; eauto.
find_apply_lem_hyp handleAppendEntriesReply_type_term. intuition; repeat find_rewrite; eauto.
find_apply_hyp_hyp. lia.
Qed.
Proof using.
red. unfold allEntries_term_sanity. intros.
subst. repeat find_higher_order_rewrite.
destruct_update; simpl in *; eauto.
find_rewrite_lem update_elections_data_requestVote_allEntries.
find_apply_lem_hyp handleRequestVote_type_term. intuition; repeat find_rewrite; eauto.
find_apply_hyp_hyp. lia.
Qed.

Lemma allEntries_term_sanity_request_vote_reply :
refined_raft_net_invariant_request_vote_reply allEntries_term_sanity.