Section CandidateEntriesInterface.
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 {cci : cronies_correct_interface}.
Context {cti : cronies_term_interface}.
Context {cei : candidate_entries_interface}.
Context {lltsi : leaderLogs_term_sanity_interface}.
Ltac start :=
red; unfold leaderLogs_candidateEntries; simpl; intros.
Proof using.
start. contradiction.
Qed.
Proof using.
start.
eapply candidateEntries_ext; eauto.
repeat find_higher_order_rewrite.
assert (candidateEntries e (nwState net)).
{ update_destruct; rewrite_update; simpl in *.
- find_rewrite_lem update_elections_data_client_request_leaderLogs. eauto.
- eauto. }
eapply candidateEntries_same.
- eauto.
- intros. update_destruct; rewrite_update; [|auto].
simpl. subst. eauto using update_elections_data_client_request_cronies.
- intros. update_destruct; rewrite_update; [|auto].
simpl. subst. find_apply_lem_hyp handleClientRequest_type. intuition.
- intros. update_destruct; rewrite_update; [|auto].
simpl. subst. find_apply_lem_hyp handleClientRequest_type. intuition.
Qed.
Proof using cti.
start.
eapply candidateEntries_ext; eauto.
repeat find_higher_order_rewrite.
assert (candidateEntries e (nwState net)).
{ update_destruct; rewrite_update; simpl in *.
- find_rewrite_lem update_elections_data_timeout_leaderLogs. eauto.
- eauto. }
unfold candidateEntries in *.
break_exists; break_and.
exists x.
update_destruct; rewrite_update; simpl in *; [|auto].
subst. split.
- assert (H100 := update_elections_data_timeout_cronies x (nwState net x) (eTerm e)).
intuition.
+ find_rewrite. auto.
+ exfalso.
find_apply_lem_hyp wonElection_exists_voter.
break_exists.
find_apply_lem_hyp in_dedup_was_in.
intro_refined_invariant cronies_term_invariant.
eapply_prop_hyp cronies_term In.
simpl in *.
lia.
- find_apply_lem_hyp handleTimeout_type_strong.
break_or_hyp; break_and.
+ repeat find_rewrite. auto.
+ intros. find_rewrite.
exfalso.
find_apply_lem_hyp wonElection_exists_voter.
break_exists.
find_apply_lem_hyp in_dedup_was_in.
intro_refined_invariant cronies_term_invariant.
eapply_prop_hyp cronies_term In.
simpl in *.
lia.
Qed.
Proof using.
start.
eapply candidateEntries_ext; eauto.
repeat find_higher_order_rewrite.
update_destruct; rewrite_update.
- simpl in *.
find_rewrite_lem update_elections_data_appendEntries_leaderLogs.
assert (candidateEntries e (nwState net)) by eauto.
unfold candidateEntries in *.
break_exists. break_and.
exists x.
update_destruct; rewrite_update; [|auto].
simpl. subst. rewrite update_elections_data_appendEntries_cronies.
split; [auto|].
find_apply_lem_hyp handleAppendEntries_type_term.
break_or_hyp; break_and.
* repeat find_rewrite. auto.
* unfold not. intros. find_rewrite. discriminate.
- assert (candidateEntries e (nwState net)) by eauto.
unfold candidateEntries in *.
break_exists. break_and.
exists x.
update_destruct; rewrite_update; [|auto].
simpl. subst. rewrite update_elections_data_appendEntries_cronies.
split; [auto|].
find_apply_lem_hyp handleAppendEntries_type_term.
break_or_hyp; break_and.
* repeat find_rewrite. auto.
* unfold not. intros. find_rewrite. discriminate.
Qed.
Proof using.
start.
eapply candidateEntries_ext; eauto.
repeat find_higher_order_rewrite.
assert (candidateEntries e (nwState net)).
{ update_destruct; rewrite_update; eauto. }
unfold candidateEntries in *.
break_exists. break_and.
exists x.
update_destruct; rewrite_update; simpl; [|auto].
subst. split; [auto|].
find_apply_lem_hyp handleAppendEntriesReply_type_term.
break_or_hyp; break_and.
- repeat find_rewrite. auto.
- unfold not. intros. find_rewrite. discriminate.
Qed.
Proof using.
start.
eapply candidateEntries_ext; eauto.
repeat find_higher_order_rewrite.
assert (candidateEntries e (nwState net)).
{ update_destruct; rewrite_update; simpl in *.
- find_rewrite_lem leaderLogs_update_elections_data_requestVote. eauto.
- eauto. }
unfold candidateEntries in *.
break_exists. break_and.
exists x.
update_destruct; rewrite_update; simpl; [|auto].
subst. split.
- rewrite update_elections_data_requestVote_cronies. auto.
- find_apply_lem_hyp handleRequestVote_type_term.
break_or_hyp; break_and.
+ repeat find_rewrite. auto.
+ unfold not. intros. find_rewrite. discriminate.
Qed.
Proof using cei cci.
start.
intro_refined_invariant candidate_entries_invariant.
eapply candidateEntries_ext; eauto.
subst.
repeat find_higher_order_rewrite.
find_rewrite_lem update_fun_comm. simpl in *.
update_destruct; rewrite_update.
- find_eapply_lem_hyp leaderLogs_update_elections_data_RVR; eauto.
intuition.
+ eapply handleRequestVoteReply_preserves_candidate_entries; eauto.
+ subst. find_erewrite_lem handleRequestVoteReply_log.
eapply handleRequestVoteReply_preserves_candidate_entries; eauto.
- eapply handleRequestVoteReply_preserves_candidate_entries; eauto.
Qed.

Lemma leaderLogs_candidateEntries_do_leader :
refined_raft_net_invariant_do_leader leaderLogs_candidateEntries.