Section LastAppliedLeCommitIndex.
Context {orig_base_params : BaseParams}.
Context {one_node_params : OneNodeParams orig_base_params}.
Context {raft_params : RaftParams orig_base_params}.
Proof using.
red. unfold lastApplied_le_commitIndex. intros.
simpl in *. repeat find_higher_order_rewrite.
destruct_update; simpl in *; eauto.
find_copy_apply_lem_hyp handleAppendEntries_same_lastApplied.
repeat find_rewrite.
find_apply_lem_hyp handleAppendEntries_log_detailed.
intuition; repeat find_rewrite; eauto;
eapply le_trans; eauto; eauto using Max.le_max_l.
Qed.
Proof using.
red. unfold lastApplied_le_commitIndex. intros.
simpl in *. repeat find_higher_order_rewrite.
destruct_update; simpl in *; eauto.
find_copy_apply_lem_hyp handleAppendEntriesReply_same_lastApplied.
repeat find_rewrite.
find_copy_apply_lem_hyp handleAppendEntriesReply_same_commitIndex.
repeat find_rewrite. eauto.
Qed.
Proof using.
red. unfold lastApplied_le_commitIndex. intros.
simpl in *. repeat find_higher_order_rewrite.
destruct_update; simpl in *; eauto.
find_copy_apply_lem_hyp handleRequestVote_same_lastApplied.
repeat find_rewrite.
find_copy_apply_lem_hyp handleRequestVote_same_commitIndex.
repeat find_rewrite. eauto.
Qed.
Proof using.
red. unfold lastApplied_le_commitIndex. intros.
simpl in *. repeat find_higher_order_rewrite.
destruct_update; simpl in *; eauto.
rewrite handleRequestVoteReply_same_lastApplied.
rewrite handleRequestVoteReply_same_commitIndex. eauto.
Qed.

Lemma doLeader_same_lastApplied:
forall st (os : list raft_output) (d' : raft_data)
(ms : list (name * msg)) (h0 : name),
doLeader st h0 = (os, d', ms) ->
lastApplied d' = lastApplied st.