Proof using.
intros. unfold doLeader in *.
repeat break_match; find_inversion; subst; auto.
Qed.

Lemma doLeader_messages :
forall h st os st' ms m t n pli plt entries c,
doLeader st h = (os, st', ms) ->
sorted (log st) ->
In m ms ->
snd m = AppendEntries t n pli plt entries c ->
subseq entries (log st) /\
(forall e, In e entries -> eIndex e > pli) /\
(forall e, In e entries -> eTerm e >= plt).