Section SpecLemmas.
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.
unfold update_elections_data_requestVote.
intros.
repeat break_match; repeat tuple_inversion; intuition;
simpl in *; intuition;
tuple_inversion; intuition.
Qed.
Proof using.
unfold update_elections_data_requestVoteReply.
intros. repeat break_match; repeat tuple_inversion; intuition.
Qed.
Proof using.
intros. unfold update_elections_data_appendEntries.
repeat break_match; auto.
Qed.
Proof using.
unfold update_elections_data_timeout, handleTimeout, tryToBecomeLeader.
intros.
repeat break_match; simpl in *; intuition; repeat tuple_inversion; intuition.
Qed.
Proof using.
unfold handleTimeout, tryToBecomeLeader.
intros. repeat break_match; repeat tuple_inversion; simpl in *; auto; lia.
Qed.
Proof using.
unfold update_elections_data_requestVoteReply.
intros. repeat break_match; repeat tuple_inversion; intuition.
Qed.
Proof using.
unfold update_elections_data_requestVote.
intros.
repeat break_match; repeat tuple_inversion; do_bool; intuition;
simpl in *; intuition; do_bool; try discriminate; intuition try congruence.
lia.
Qed.
Proof using.
unfold update_elections_data_requestVote.
intros.
repeat break_match; repeat tuple_inversion; simpl; auto.
Qed.
Proof using.
unfold update_elections_data_timeout, handleTimeout, tryToBecomeLeader.
intros.
repeat break_match; simpl in *; intuition; repeat tuple_inversion;
intuition (auto; congruence).
Qed.

Lemma votes_update_elections_data_timeout :
forall h st out st' ps t' h',
handleTimeout h (snd st) = (out, st', ps) ->
In (t', h') (votes (update_elections_data_timeout h st)) ->
In (t', h') (votes (fst st)) \/ t' = currentTerm st'.