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

Lemma refined_raft_invariant_handle_message P :
forall xs p ys net st' ps' gd d l,
refined_raft_net_invariant_append_entries P ->
refined_raft_net_invariant_append_entries_reply P ->
refined_raft_net_invariant_request_vote P ->
refined_raft_net_invariant_request_vote_reply P ->
handleMessage (pSrc p) (pDst p) (pBody p) (snd (nwState net (pDst p))) = (d, l) ->
update_elections_data_net (pDst p) (pSrc p) (pBody p) (nwState net (pDst p)) = gd ->
P net ->
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) l)) ->
P (mkNetwork ps' st').