Proof using.
intros. unfold doLeader in *.
repeat break_match; find_inversion; subst; simpl in *; intuition.
- unfold replicaMessage in *. do_in_map. simpl in *.
subst. simpl in *. find_inversion.
apply subseq_findGtIndex.
- unfold replicaMessage in *. do_in_map. simpl in *.
subst. simpl in *. find_inversion.
find_apply_lem_hyp findGtIndex_necessary; intuition.
- unfold replicaMessage in *. do_in_map. simpl in *.
subst. simpl in *. find_inversion. break_match; intuition.
find_apply_lem_hyp findGtIndex_necessary; intuition.
find_apply_lem_hyp findAtIndex_elim. simpl in *.
intuition. repeat find_rewrite.
eapply sorted_index_term; eauto.
omega.
Qed.

Theorem logs_sorted_do_leader :
raft_net_invariant_do_leader logs_sorted.