Proof using.
red. unfold append_entries_leaderLogs. intros.
subst. simpl in *.
find_apply_hyp_hyp. intuition eauto.
- eapply_prop_hyp In In; break_exists. intuition; eauto.
+ repeat eexists; intuition eauto.
repeat find_higher_order_rewrite.
update_destruct; subst_max; rewrite_update; simpl in *; eauto.
subst. replace gd with (fst (nwState net x)); eauto; repeat find_rewrite; reflexivity.
+ repeat eexists; intuition eauto.
repeat find_higher_order_rewrite.
update_destruct; subst_max; rewrite_update; simpl in *; eauto.
subst. replace gd with (fst (nwState net x)); eauto; repeat find_rewrite; reflexivity.
+ repeat eexists; intuition eauto.
repeat find_higher_order_rewrite.
update_destruct; subst_max; rewrite_update; simpl in *; eauto.
subst. replace gd with (fst (nwState net x)); eauto; repeat find_rewrite; reflexivity.
+ eauto.
- unfold doGenericServer in *;
repeat break_match; find_inversion; do_in_map; simpl in *; intuition;
subst; simpl in *; do_in_map; subst; simpl in *; congruence.
Qed.

Lemma doLeader_spec :
forall st h os st' ms m t n pli plt es ci,
doLeader st h = (os, st', ms) ->
In m ms ->
snd m = AppendEntries t n pli plt es ci ->
t = currentTerm st /\
log st' = log st /\
type st = Leader /\
((pli = 0 /\ plt = 0 /\ es = findGtIndex (log st) 0) \/
((exists e, findAtIndex (log st) pli = Some e /\
eTerm e = plt) /\
es = findGtIndex (log st) pli) \/
exists h', pred (getNextIndex st h') <> 0 /\ findAtIndex (log st) (pred (getNextIndex st h')) = None).