Section MatchIndexLeader.
Context {orig_base_params : BaseParams}.
Context {one_node_params : OneNodeParams orig_base_params}.
Context {raft_params : RaftParams orig_base_params}.
Context {naertsi : no_append_entries_replies_to_self_interface}.
Proof using naertsi.
red. unfold match_index_leader in *. simpl in *. intros.
repeat find_higher_order_rewrite.
destruct_update; simpl in *; eauto.
find_eapply_lem_hyp handleAppendEntriesReply_matchIndex_leader_preserved; eauto.
erewrite handleAppendEntriesReply_log; eauto.
intuition.
find_apply_hyp_hyp.
find_higher_order_rewrite; auto.
find_apply_lem_hyp no_append_entries_replies_to_self_invariant.
unfold no_append_entries_replies_to_self in *.
intuition.
match goal with
| H : context [_ = _ -> False] |- _ => eapply H
end; eauto.
Qed.
Proof using.
red. unfold match_index_leader in *. simpl in *. intros.
repeat find_higher_order_rewrite.
destruct_update; simpl in *; eauto.
find_copy_apply_lem_hyp handleClientRequest_type.
find_eapply_lem_hyp handleClientRequest_matchIndex_maxIndex.
intuition; repeat find_rewrite; eauto.
Qed.
Proof using.
red. unfold match_index_leader in *. simpl in *. intros.
repeat find_higher_order_rewrite.
destruct_update; simpl in *; eauto.
find_copy_apply_lem_hyp handleRequestVoteReply_matchIndex.
intuition; repeat find_rewrite; eauto.
erewrite handleRequestVoteReply_log; eauto.
Qed.
Proof using.
red. unfold match_index_leader in *. simpl in *. intros.
repeat find_higher_order_rewrite.
destruct_update; simpl in *; eauto.
find_copy_apply_lem_hyp handleAppendEntries_matchIndex_preserved.
unfold matchIndex_preserved in *.
intuition; repeat find_rewrite; eauto.
Qed.
Proof using.
red. unfold match_index_leader in *. simpl in *. intros.
repeat find_higher_order_rewrite.
destruct_update; simpl in *; eauto.
find_copy_apply_lem_hyp handleRequestVote_matchIndex_preserved.
unfold matchIndex_preserved in *.
intuition; repeat find_rewrite; eauto.
Qed.
Proof using.
red. unfold match_index_leader in *. simpl in *. intros.
repeat find_higher_order_rewrite.
destruct_update; simpl in *; eauto.
find_copy_apply_lem_hyp handleTimeout_matchIndex_preserved.
unfold matchIndex_preserved in *.
intuition; repeat find_rewrite; eauto.
Qed.
Proof using.
red. unfold match_index_leader in *. simpl in *. intros.
repeat find_higher_order_rewrite.
destruct_update; simpl in *; eauto.
find_copy_apply_lem_hyp doLeader_matchIndex_preserved.
unfold matchIndex_preserved in *.
intuition; repeat find_rewrite; eauto.
Qed.
Proof using.
red. unfold match_index_leader in *. simpl in *. intros.
repeat find_higher_order_rewrite.
destruct_update; simpl in *; eauto.
find_copy_apply_lem_hyp doGenericServer_matchIndex_preserved.
unfold matchIndex_preserved in *.
intuition; repeat find_rewrite; eauto.
Qed.

Lemma match_index_leader_reboot :
raft_net_invariant_reboot match_index_leader.