Section CroniesCorrectProof.
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 {vci : votes_correct_interface}.
Context {cvfsi : candidates_vote_for_selves_interface}.
Proof using cvfsi rri.
intros.
eapply lift_prop; [exact candidates_vote_for_selves_invariant|eauto].
Qed.
Proof using.
intros.
unfold handleClientRequest in *; repeat break_match;
repeat find_inversion; subst; simpl in *; find_apply_hyp_hyp; intuition.
Qed.
Proof using.
intros.
unfold handleTimeout, tryToBecomeLeader in *; repeat break_match;
repeat find_inversion; subst; simpl in *; find_apply_hyp_hyp;
in_crush; congruence.
Qed.
Proof using.
intros.
unfold handleAppendEntries, advanceCurrentTerm in *; repeat break_match;
repeat find_inversion; subst; simpl in *; find_apply_hyp_hyp;
in_crush; congruence.
Qed.
Proof using.
intros.
unfold handleAppendEntriesReply, advanceCurrentTerm in *; repeat break_match;
repeat find_inversion; subst; simpl in *; find_apply_hyp_hyp;
in_crush; congruence.
Qed.
Proof using.
unfold refined_raft_net_invariant_client_request. intros.
unfold cronies_correct in *; intuition.
- unfold votes_received_cronies, handleClientRequest in *. intros.
simpl in *. repeat find_higher_order_rewrite.
unfold update_elections_data_client_request in *.
repeat break_match; find_inversion; subst; simpl in *; eauto; try congruence.
- unfold cronies_votes in *. intros.
simpl in *. repeat find_higher_order_rewrite.
unfold update_elections_data_client_request in *.
repeat break_match; subst; simpl in *; eauto.
- unfold votes_nw in *. intros. simpl in *.
assert (In p (nwPackets net)) by eauto using handleClientRequest_rvr.
repeat find_apply_hyp_hyp.
repeat find_higher_order_rewrite.
unfold update_elections_data_client_request in *.
repeat break_match; subst; repeat find_rewrite; simpl in *; intuition.
- unfold votes_received_leaders in *. intros. simpl in *. repeat find_higher_order_rewrite.
unfold handleClientRequest in *.
unfold update_elections_data_client_request in *.
repeat break_match; find_inversion; subst; simpl in *; eauto.
Qed.
Proof using.
unfold refined_raft_net_invariant_timeout. intros.
unfold cronies_correct, update_elections_data_timeout in *; intuition.
- unfold votes_received_cronies, handleTimeout, tryToBecomeLeader in *.
intros. simpl in *.
repeat break_match; repeat find_inversion; subst; simpl in *; eauto;
repeat find_higher_order_rewrite; repeat (break_if; simpl in *); auto; congruence.
- unfold cronies_votes, handleTimeout, tryToBecomeLeader in *. intros.
simpl in *.
repeat break_match; repeat find_inversion; subst; simpl in *; eauto;
repeat find_higher_order_rewrite; repeat (break_if; simpl in *); auto;
repeat find_inversion; subst; intuition;
congruence.
- unfold votes_nw in *. intros. simpl in *.
assert (In p (nwPackets net)) by eauto using handleTimeout_rvr.
repeat find_apply_hyp_hyp.
repeat find_higher_order_rewrite.
repeat break_match; subst; repeat find_rewrite; simpl in *; intuition.
- unfold votes_received_leaders in *. intros. simpl in *. repeat find_higher_order_rewrite.
unfold handleTimeout, tryToBecomeLeader in *. simpl in *.
repeat (break_match; subst; simpl in *; repeat find_inversion; try discriminate);
intuition eauto.
Qed.
Proof using.
unfold refined_raft_net_invariant_append_entries. intros.
unfold cronies_correct in *; intuition.
- unfold votes_received_cronies, handleAppendEntries in *.
intros. simpl in *.
repeat find_higher_order_rewrite.
unfold update_elections_data_appendEntries.
repeat break_match; repeat find_inversion; subst; simpl in *; eauto;
repeat find_higher_order_rewrite; repeat (break_if; simpl in *); intuition; try congruence.
- unfold cronies_votes in *. intros.
simpl in *. repeat find_higher_order_rewrite.
unfold update_elections_data_appendEntries in *.
repeat break_match; repeat find_inversion; subst; simpl in *; eauto.
- unfold votes_nw in *. intros. simpl in *.
assert (In p0 (xs ++ ys)) by eauto using handleAppendEntries_rvr.
assert (In p0 (nwPackets net)) by (repeat find_rewrite; in_crush).
repeat find_apply_hyp_hyp.
repeat find_higher_order_rewrite.
unfold update_elections_data_appendEntries in *.
repeat break_match; subst; repeat find_rewrite; simpl in *; intuition.
- unfold votes_received_leaders in *. intros. simpl in *.
repeat find_higher_order_rewrite. repeat break_if; eauto.
subst. simpl in *. unfold handleAppendEntries in *.
repeat break_match; find_inversion; subst; simpl in *;
try discriminate; eauto.
Qed.
Proof using.
unfold refined_raft_net_invariant_append_entries_reply. intros.
unfold cronies_correct in *; intuition.
- unfold votes_received_cronies, handleAppendEntriesReply, advanceCurrentTerm in *.
intros. simpl in *.
repeat break_match; repeat find_inversion; subst; simpl in *; eauto;
repeat find_higher_order_rewrite; repeat (break_if; simpl in *); intuition; try congruence.
- unfold cronies_votes in *. intros.
simpl in *. repeat find_higher_order_rewrite.
repeat break_match; subst; simpl in *; eauto.
- unfold votes_nw in *. intros. simpl in *.
assert (In p0 (xs ++ ys)) by eauto using handleAppendEntriesReply_rvr.
assert (In p0 (nwPackets net)) by (repeat find_rewrite; in_crush).
repeat find_apply_hyp_hyp.
repeat find_higher_order_rewrite.
repeat break_match; subst; repeat find_rewrite; simpl in *; intuition.
- unfold votes_received_leaders in *. intros. simpl in *.
repeat find_higher_order_rewrite. repeat break_if; eauto.
subst. simpl in *. unfold handleAppendEntriesReply, advanceCurrentTerm in *.
repeat break_match; find_inversion; subst; simpl in *;
try discriminate; eauto.
Qed.

Lemma handleRequestVote_true_votedFor :
forall h st t src lli llt d t',
handleRequestVote h st t src lli llt = (d, RequestVoteReply t' true) ->
currentTerm d = t' /\ votedFor d = Some src.