Proof using.
unfold doLeader.
intros.
repeat break_match; repeat find_inversion; simpl in *; intuition.
do_in_map.
subst.
unfold replicaMessage in *. simpl in *.
find_inversion.
auto.
Qed.

Lemma commit_invariant_do_leader :
forall net st' ps' gd d h os d' ms,
doLeader d h = (os, d', ms) ->
commit_invariant net ->
msg_refined_raft_intermediate_reachable net ->
lifted_maxIndex_sanity net ->
nwState net h = (gd, d) ->
(forall h', st' h' = update name_eq_dec (nwState net) h (gd, d') h') ->
(forall p,
In p ps' -> In p (nwPackets net) \/ In p (send_packets h (add_ghost_msg (msg_ghost_params := ghost_log_params) h (gd, d') ms))) ->
commit_invariant {| nwPackets := ps'; nwState := st' |}.