Section CandidateTermGtLog.
Context {orig_base_params : BaseParams}.
Context {one_node_params : OneNodeParams orig_base_params}.
Context {raft_params : RaftParams orig_base_params}.
Context {tsi : term_sanity_interface}.
Proof using.
red. unfold candidate_term_gt_log. simpl. discriminate.
Qed.
Proof using.
red. unfold candidate_term_gt_log. simpl. intros.
find_higher_order_rewrite. update_destruct; subst; rewrite_update; auto.
find_copy_apply_lem_hyp handleClientRequest_type.
find_apply_lem_hyp handleClientRequest_log. intuition.
+ repeat find_rewrite. eauto.
+ break_exists. intuition. repeat find_rewrite. discriminate.
Qed.
Proof using tsi.
red. unfold candidate_term_gt_log. simpl. intros.
find_higher_order_rewrite. update_destruct; subst; rewrite_update; auto.
find_copy_apply_lem_hyp handleTimeout_log_same.
find_apply_lem_hyp handleTimeout_type_strong. intuition.
+ repeat find_rewrite. eauto.
+ find_apply_lem_hyp no_entries_past_current_term_invariant.
unfold no_entries_past_current_term in *. intuition.
unfold no_entries_past_current_term_host in *. repeat find_rewrite.
find_apply_hyp_hyp. lia.
Qed.
Proof using.
red. unfold candidate_term_gt_log. simpl. intros.
find_higher_order_rewrite. update_destruct; subst; rewrite_update; auto.
unfold handleAppendEntries in *. repeat break_match; tuple_inversion; eauto; discriminate.
Qed.
Ltac start := red; unfold candidate_term_gt_log; simpl; intros;
find_higher_order_rewrite; update_destruct; subst; rewrite_update; [|auto].
Proof using.
start.
find_copy_apply_lem_hyp handleAppendEntriesReply_type.
find_copy_apply_lem_hyp handleAppendEntriesReply_log.
intuition; repeat find_rewrite; [eauto|discriminate].
Qed.
Proof using.
start.
find_copy_apply_lem_hyp handleRequestVote_type.
find_copy_apply_lem_hyp handleRequestVote_log.
intuition; repeat find_rewrite; [eauto|discriminate].
Qed.
Proof using.
red; unfold candidate_term_gt_log; simpl; intros;
find_higher_order_rewrite; update_destruct; rewrite_update; auto.
find_copy_apply_lem_hyp handleRequestVoteReply_type.
find_copy_apply_lem_hyp handleRequestVoteReply_log.
intuition; repeat find_rewrite; [eauto|discriminate|discriminate].
Qed.
Proof using.
start.
find_copy_apply_lem_hyp doLeader_type.
find_copy_apply_lem_hyp doLeader_log.
intuition. repeat find_rewrite. eauto.
Qed.
Proof using.
start.
find_copy_apply_lem_hyp doGenericServer_type.
find_copy_apply_lem_hyp doGenericServer_log.
intuition. repeat find_rewrite. eauto.
Qed.
Proof using.
red. unfold candidate_term_gt_log. simpl. intros.
repeat find_reverse_higher_order_rewrite. auto.
Qed.

Lemma candidate_term_gt_log_reboot :
raft_net_invariant_reboot candidate_term_gt_log.