Section VotesWithLogTermSanity.
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}.
Ltac start :=
red; unfold votesWithLog_term_sanity; simpl; intros.
Ltac start_update :=
start;
repeat find_higher_order_rewrite;
update_destruct; subst; rewrite_update; [|eauto].
Proof using.
unfold votesWithLog_term_sanity. intros.
find_higher_order_rewrite. update_destruct; subst; rewrite_update; [|eauto].
simpl in *. find_apply_hyp_hyp. break_or_hyp.
- find_apply_hyp_hyp. lia.
- break_and. subst. auto.
Qed.
Ltac start_cases :=
red; intros; eapply votesWithLog_term_sanity_cases; eauto.
Ltac solve_votesWithLog lem :=
intros; subst; first [
left; solve [eapply lem; eauto] |  (* votesWithLog doesn't change *)
solve [eapply lem; eauto]  (* has both cases *)
].
Ltac solve_currentTerm lem :=
find_apply_lem_hyp lem; solve [intuition].

Lemma votesWithLog_term_sanity_invariant :
forall net,
refined_raft_intermediate_reachable net ->
votesWithLog_term_sanity net.