Definition lifted_entries_sorted_nw' (net : ghost_log_network) :=
    forall p t n pli plt es ci,
      In p (nwPackets net) ->
      snd (pBody p) = AppendEntries t n pli plt es ci ->
      sorted es.

(* Specifications: *)
Lemma lifted_entries_sorted_nw'_invariant : forall net, msg_refined_raft_intermediate_reachable net -> lifted_entries_sorted_nw' net.
Lemma commit_invariant_append_entries : forall xs p ys (net : ghost_log_network) st' ps' gd d m t n pli plt es ci, handleAppendEntries (pDst p) (snd (nwState net (pDst p))) t n pli plt es ci = (d, m) -> gd = update_elections_data_appendEntries (pDst p) (nwState net (pDst p)) t n pli plt es ci -> snd (pBody p) = AppendEntries t n pli plt es ci -> commit_invariant net -> msg_refined_raft_intermediate_reachable net -> lifted_maxIndex_sanity net -> nwPackets net = xs ++ p :: ys -> (forall h, st' h = update name_eq_dec (nwState net) (pDst p) (gd, d) h) -> (forall p', In p' ps' -> In p' (xs ++ ys) \/ p' = mkPacket (pDst p) (pSrc p) (write_ghost_log (pDst p) (gd, d), m)) -> commit_invariant (mkNetwork ps' st').
Lemma handleAppendEntriesReply_preserves_commit : forall (net net' : ghost_log_network) h src t es b st' l e t', handleAppendEntriesReply h (snd (nwState net h)) src t es b = (st', l) -> (forall h', nwState net' h' = update name_eq_dec (nwState net) h (fst (nwState net h), st') h') -> lifted_committed net e t' -> lifted_committed net' e t'.
Lemma commit_invariant_append_entries_reply : msg_refined_raft_net_invariant_append_entries_reply commit_invariant.
Lemma handleRequestVote_preserves_committed : forall (net net' : ghost_log_network) h t c li lt st' ms e t', handleRequestVote h (snd (nwState net h)) t c li lt = (st', ms) -> (forall h', nwState net' h' = update name_eq_dec (nwState net) h (update_elections_data_requestVote h c t c li lt (nwState net h), st') h') -> lifted_committed net e t' -> lifted_committed net' e t'.
Lemma commit_invariant_request_vote : msg_refined_raft_net_invariant_request_vote commit_invariant.
Lemma handleRequestVoteReply_preserves_committed : forall (net net' : ghost_log_network) h src t v st' e t', handleRequestVoteReply h (snd (nwState net h)) src t v = st' -> (forall h', nwState net' h' = update name_eq_dec (nwState net) h (update_elections_data_requestVoteReply h src t v (nwState net h), st') h') -> lifted_committed net e t' -> lifted_committed net' e t'.
Lemma commit_invariant_request_vote_reply : msg_refined_raft_net_invariant_request_vote_reply commit_invariant.
Lemma committed_ext' : forall ps ps' st st' t e, (forall h, st' h = st h) -> committed (mkNetwork ps st) e t -> committed (mkNetwork ps' st') e t.
Lemma lifted_committed_ext' : forall ps ps' st st' t e, (forall h, st' h = st h) -> lifted_committed (mkNetwork ps st) e t -> lifted_committed (mkNetwork ps' st') e t.
Lemma haveQuorum_directly_committed : forall net h e, refined_raft_intermediate_reachable net -> type (snd (nwState net h)) = Leader -> In e (log (snd (nwState net h))) -> haveQuorum (snd (nwState net h)) h (eIndex e) = true -> eTerm e = currentTerm (snd (nwState net h)) -> directly_committed net e.
Lemma advanceCommitIndex_committed : forall h net, refined_raft_intermediate_reachable net -> type (snd (nwState net h)) = Leader -> (forall e, In e (log (snd (nwState net h))) -> eIndex e <= commitIndex (snd (nwState net h)) -> committed net e (currentTerm (snd (nwState net h)))) -> (forall e, In e (log (snd (nwState net h))) -> eIndex e <= commitIndex (advanceCommitIndex (snd (nwState net h)) h) -> committed net e (currentTerm (snd (nwState net h)))).
Lemma lifted_advanceCommitIndex_lifted_committed : forall h net, msg_refined_raft_intermediate_reachable net -> type (snd (nwState net h)) = Leader -> (forall e, In e (log (snd (nwState net h))) -> eIndex e <= commitIndex (snd (nwState net h)) -> lifted_committed net e (currentTerm (snd (nwState net h)))) -> (forall e, In e (log (snd (nwState net h))) -> eIndex e <= commitIndex (advanceCommitIndex (snd (nwState net h)) h) -> lifted_committed net e (currentTerm (snd (nwState net h)))).
Lemma and_imp_2 : forall P Q : Prop, P /\ (P -> Q) -> P /\ Q.