Section RaftMsgRefinement.
Context {orig_base_params : BaseParams}.
Context {one_node_params : OneNodeParams orig_base_params}.
Context {raft_params : RaftParams orig_base_params}.

(* Specifications: *)
Lemma msg_refined_raft_invariant_handle_message P :
forall xs p ys net st' ps' gd d l,
msg_refined_raft_net_invariant_append_entries P ->
msg_refined_raft_net_invariant_append_entries_reply P ->
msg_refined_raft_net_invariant_request_vote P ->
msg_refined_raft_net_invariant_request_vote_reply P ->
handleMessage (pSrc p) (pDst p) (snd (pBody p)) (snd (nwState net (pDst p))) = (d, l) ->
update_elections_data_net (pDst p) (pSrc p) (snd (pBody p)) (nwState net (pDst p)) = gd ->
P net ->
msg_refined_raft_intermediate_reachable 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) \/
In p' (send_packets (pDst p) (@add_ghost_msg _ _ ghost_log_params (pDst p) (gd, d) l))) ->
P (mkNetwork ps' st').