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.
Proof using.
unfold update_elections_data_timeout.
intros. repeat break_match; simpl in *; intuition; repeat tuple_inversion; intuition.
Qed.
Proof using.
intros. unfold update_elections_data_client_request.
repeat break_match; auto.
Qed.
Proof using.
intros. unfold update_elections_data_client_request.
repeat break_match; auto.
Qed.
Proof using.
unfold update_elections_data_client_request.
intros. repeat break_match; repeat tuple_inversion; intuition.
Qed.
Proof using.
unfold update_elections_data_timeout.
intros. repeat break_match; simpl in *; intuition; repeat tuple_inversion; intuition.
Qed.
Proof using.
intros. unfold update_elections_data_appendEntries.
repeat break_match; auto.
Qed.
Proof using.
unfold update_elections_data_appendEntries.
intros. repeat break_match; repeat tuple_inversion; intuition.
Qed.
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_requestVoteReply.
break_match; simpl in *; auto.
Qed.
Proof using.
unfold update_elections_data_client_request in *.
intros. repeat break_match; repeat find_inversion; auto.
Qed.
Proof using.
unfold update_elections_data_timeout.
intros.
repeat break_match; auto.
Qed.
Proof using.
unfold update_elections_data_appendEntries.
intros. repeat break_match; auto.
Qed.
Proof using.
unfold update_elections_data_requestVote.
intros.
repeat break_match; repeat find_inversion; auto.
Qed.
Proof using.
unfold update_elections_data_requestVoteReply.
intros.
repeat break_match; repeat find_inversion; intuition.
simpl in *. intuition.
find_inversion. intuition.
Qed.
Proof using.
unfold update_elections_data_requestVoteReply.
intros.
repeat break_match; repeat find_inversion; intuition.
simpl in *. intuition.
Qed.
Proof using.
intros.
unfold update_elections_data_client_request.
repeat break_match; repeat find_inversion; auto.
simpl.
find_copy_apply_lem_hyp handleClientRequest_log.
intuition.
- repeat find_rewrite. do_bool. lia.
- right.  break_exists_exists. intuition.
congruence.
Qed.

Lemma update_elections_data_client_request_log_allEntries :
forall h st client id c out st' ms,
handleClientRequest h (snd st) client id c = (out, st', ms) ->
(allEntries (update_elections_data_client_request h st client id c) =
allEntries (fst st) /\
log st' = log (snd st)) \/
(type (snd st) = Leader /\
exists e : entry,
eIndex e = S (maxIndex (log (snd st))) /\
eTerm e = currentTerm (snd st) /\
eClient e = client /\ eInput e = c /\ eId e = id /\ type (snd st) = Leader /\
allEntries (update_elections_data_client_request h st client id c) =
(currentTerm st', e) :: allEntries (fst st) /\
log st' = e :: log (snd st)).