Definition nextIndex_preserved st st' :=
    (type st' = Leader ->
     type st = Leader /\
     maxIndex (log st) <= maxIndex (log st') /\
     nextIndex st' = nextIndex st).

(* Specifications: *)
Lemma nextIndex_safety_preserved : forall st st', (forall h', type st = Leader -> Nat.pred (getNextIndex st h') <= maxIndex (log st)) -> nextIndex_preserved st st' -> (forall h', type st' = Leader -> Nat.pred (getNextIndex st' h') <= maxIndex (log st')).
Theorem handleClientRequest_nextIndex_preserved : forall h st client id c out st' ps, handleClientRequest h st client id c = (out, st', ps) -> nextIndex_preserved st st'.
Lemma nextIndex_safety_client_request : raft_net_invariant_client_request nextIndex_safety.
Lemma handleTimeout_nextIndex_preserved : forall h d out d' l, handleTimeout h d = (out, d', l) -> nextIndex_preserved d d'.
Lemma nextIndex_safety_timeout : raft_net_invariant_timeout nextIndex_safety.
Lemma handleAppendEntries_nextIndex_preserved : forall h st t n pli plt es ci st' ps, handleAppendEntries h st t n pli plt es ci = (st', ps) -> nextIndex_preserved st st'.
Lemma nextIndex_safety_append_entries : raft_net_invariant_append_entries nextIndex_safety.
Lemma handleAppendEntriesReply_nextIndex : forall h st st' m t es res h', handleAppendEntriesReply h st h' t es res = (st', m) -> type st' = Leader -> type st = Leader /\ ((nextIndex st' = nextIndex st \/ (res = true /\ currentTerm st = t /\ nextIndex st' = (assoc_set name_eq_dec (nextIndex st) h' (Nat.max (getNextIndex st h') (S (maxIndex es)))))) \/ (res = false /\ currentTerm st = t /\ nextIndex st' = (assoc_set name_eq_dec (nextIndex st) h' (pred (getNextIndex st h'))))).
Lemma nextIndex_safety_append_entries_reply : raft_net_invariant_append_entries_reply nextIndex_safety.
Lemma handleRequestVote_nextIndex_preserved : forall st h h' t lli llt st' m, handleRequestVote h st t h' lli llt = (st', m) -> nextIndex_preserved st st'.
Lemma nextIndex_safety_request_vote : raft_net_invariant_request_vote nextIndex_safety.
Lemma nextIndex_safety_request_vote_reply : raft_net_invariant_request_vote_reply nextIndex_safety.
Lemma doLeader_nextIndex_preserved : forall st h os st' ms, doLeader st h = (os, st', ms) -> nextIndex_preserved st st'.
Lemma nextIndex_safety_do_leader : raft_net_invariant_do_leader nextIndex_safety.
Lemma doGenericServer_nextIndex_preserved : forall h st os st' ms, doGenericServer h st = (os, st', ms) -> nextIndex_preserved st st'.
Lemma nextIndex_safety_do_generic_server : raft_net_invariant_do_generic_server nextIndex_safety.
Lemma nextIndex_safety_state_same_packet_subset : raft_net_invariant_state_same_packet_subset nextIndex_safety.
Lemma nextIndex_safety_reboot : raft_net_invariant_reboot nextIndex_safety.
Lemma nextIndex_safety_invariant : forall net, raft_intermediate_reachable net -> nextIndex_safety net.