Section GhostLogLogMatching.
Context {orig_base_params : BaseParams}.
Context {one_node_params : OneNodeParams orig_base_params}.
Context {raft_params : RaftParams orig_base_params}.
Context {rmri : raft_msg_refinement_interface}.
Context {rlmli : refined_log_matching_lemmas_interface}.
Context {glci : ghost_log_correct_interface}.
Context {lphogli : log_properties_hold_on_ghost_logs_interface}.
Context {tsi : term_sanity_interface}.
Context {aelsi : allEntries_leader_sublog_interface}.
Context {glaei : ghost_log_allEntries_interface}.
Definition ghost_log_entries_match_nw (net : network) : Prop :=
forall p p',
In p (nwPackets net) ->
In p' (nwPackets net) ->
entries_match (fst (pBody p)) (fst (pBody p')).
Definition ghost_log_entries_match (net : network) : Prop :=
ghost_log_entries_match_host net /\
ghost_log_entries_match_nw net.
Definition lifted_entries_contiguous net :=
forall h,
contiguous_range_exact_lo (log (snd (nwState net h))) 0.
Definition lifted_entries_sorted net :=
forall h,
sorted (log (snd (nwState net h))).
Proof using rlmli rmri.
intros.
enough (entries_contiguous (mgv_deghost net)) by
(unfold entries_contiguous, lifted_entries_contiguous, mgv_deghost in *;
simpl in *;
repeat break_match; simpl in *; auto).
apply msg_lift_prop; eauto using entries_contiguous_invariant.
Qed.

Lemma lifted_entries_sorted_invariant :
forall (net : @network _ raft_msg_refined_multi_params),
msg_refined_raft_intermediate_reachable net ->
lifted_entries_sorted net.