Proof using.
red. unfold logs_leaderLogs_inductive. intros.
match goal with
| H : nwState ?net ?h = (?gd, ?d) |- _ =>
replace gd with (fst (nwState net h)) in * by (rewrite H; reflexivity);
replace d with (snd (nwState net h)) in * by (rewrite H; reflexivity);
clear H
end.
intuition.
- find_apply_lem_hyp doGenericServer_log.
unfold logs_leaderLogs in *. intros.
simpl in *.
find_higher_order_rewrite; update_destruct; subst; rewrite_update; simpl in *;
repeat find_rewrite;
find_apply_hyp_hyp; break_exists_exists; intuition;
find_higher_order_rewrite; update_destruct; subst; rewrite_update; eauto.
- find_apply_lem_hyp doGenericServer_packets. subst.
unfold logs_leaderLogs_nw in *. intros. simpl in *.
find_apply_hyp_hyp. intuition.
eapply_prop_hyp In In; eauto.
break_exists_exists; intuition;
repeat find_higher_order_rewrite;
update_destruct; subst; rewrite_update; eauto.
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).