Section PrevLogCandidateEntriesTerm.
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 {cei : candidate_entries_interface}.
Context {cti : cronies_term_interface}.
Context {cci : cronies_correct_interface}.
Proof using.
unfold refined_raft_net_invariant_init, prevLog_candidateEntriesTerm.
simpl. intuition.
Qed.
Proof using.
unfold candidateEntriesTerm.
intros. break_exists_exists.
repeat find_higher_order_rewrite. intuition.
Qed.
Proof using.
unfold candidateEntriesTerm.
intros. break_exists_exists.
repeat find_higher_order_rewrite.
intuition.
Qed.
Proof using.
unfold refined_raft_net_invariant_client_request, prevLog_candidateEntriesTerm.
simpl. intros.
find_apply_hyp_hyp. break_or_hyp.
- eapply candidateEntriesTerm_ext; eauto.
eapply candidateEntriesTerm_same; eauto; intros;
update_destruct_simplify; auto.
+ now erewrite update_elections_data_client_request_cronies by eauto.
+ find_apply_lem_hyp handleClientRequest_type. intuition.
+ find_apply_lem_hyp handleClientRequest_type. intuition.
- find_apply_lem_hyp in_map_iff. break_exists. break_and. subst. simpl in *.
exfalso. eapply handleClientRequest_no_append_entries; eauto.
find_rewrite. eauto 10.
Qed.
Proof using.
unfold update_elections_data_timeout.
intros.
repeat break_match; repeat find_inversion; simpl; auto.
break_match; auto.
Qed.
Proof using cti.
unfold candidateEntriesTerm.
intros.
break_exists_exists. break_and.
match goal with
| [ H : handleTimeout _ _ = _ |- _ ] =>
pose proof H;
eapply update_elections_data_timeout_cronies with (t := t) in H
end. break_or_hyp.
- update_destruct_simplify; auto.
find_copy_apply_lem_hyp handleTimeout_type_strong.
intuition; repeat find_rewrite; auto.
find_apply_lem_hyp wonElection_exists_voter.
break_exists.
find_apply_lem_hyp in_dedup_was_in.
find_copy_apply_lem_hyp cronies_term_invariant; auto.
simpl in *.
lia.
- update_destruct_simplify; auto.
find_copy_apply_lem_hyp handleTimeout_type_strong.
find_apply_lem_hyp wonElection_exists_voter.
break_exists.
find_apply_lem_hyp in_dedup_was_in.
find_copy_apply_lem_hyp cronies_term_invariant; auto.
intuition; subst; repeat find_rewrite; auto;
simpl in *; lia.
Qed.
Proof using cti.
unfold refined_raft_net_invariant_timeout, prevLog_candidateEntriesTerm.
simpl. intros.
find_apply_hyp_hyp. break_or_hyp.
- eapply candidateEntriesTerm_ext; eauto.
eapply handleClientRequest_preserves_candidateEntriesTerm; eauto.
- find_apply_lem_hyp in_map_iff. break_exists. break_and.
subst. simpl in *.
exfalso. eapply handleTimeout_not_is_append_entries; eauto.
find_rewrite. eauto 10.
Qed.
Proof using.
unfold candidateEntriesTerm.
intros.
break_exists_exists. break_and.
update_destruct_simplify.
- rewrite update_elections_data_appendEntries_cronies.
find_apply_lem_hyp handleAppendEntries_type.
intuition; subst; repeat find_rewrite; auto.
discriminate.
- intuition.
Qed.
Proof using.
unfold refined_raft_net_invariant_append_entries, prevLog_candidateEntriesTerm.
simpl. intros.
find_apply_hyp_hyp. break_or_hyp.
- find_eapply_lem_hyp app_cons_in_rest; [|solve[eauto]].
eapply candidateEntriesTerm_ext; eauto.
eapply handleAppendEntries_preserves_candidateEntriesTerm; eauto.
- exfalso. eapply handleAppendEntries_not_append_entries; eauto.
simpl in *. subst. eauto 10.
Qed.
Proof using.
unfold candidateEntriesTerm.
intros. break_exists_exists.
find_apply_lem_hyp handleAppendEntriesReply_type.
update_destruct_simplify.
- intuition; repeat find_rewrite; auto. discriminate.
- auto.
Qed.
Proof using.
unfold refined_raft_net_invariant_append_entries_reply, prevLog_candidateEntriesTerm.
simpl. intros.
find_apply_hyp_hyp. break_or_hyp.
- find_eapply_lem_hyp app_cons_in_rest; [|solve[eauto]].
eapply candidateEntriesTerm_ext; eauto.
eauto using handleAppendEntriesReply_preserves_candidateEntriesTerm.
- find_apply_lem_hyp in_map_iff. break_exists. break_and.
find_apply_lem_hyp handleAppendEntriesReply_packets.
subst. simpl in *. intuition.
Qed.

Lemma update_elections_data_requestVote_cronies_same :
forall h h' t lli llt st,
cronies (update_elections_data_requestVote h h' t h' lli llt st) =
cronies (fst st).