Section GhostLogsLogProperties.
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}.
Proof using.
red. unfold log_properties_hold_on_ghost_logs.
intros. simpl in *. intuition.
Qed.
Proof using.
red. unfold log_properties_hold_on_ghost_logs. intros.
simpl in *.
subst.
find_apply_hyp_hyp; intuition; repeat find_rewrite;
try solve [eapply_prop_hyp msg_log_property msg_log_property; eauto].
Qed.
Proof using.
red. unfold log_properties_hold_on_ghost_logs. intros.
simpl in *.
subst.
find_apply_hyp_hyp; intuition; repeat find_rewrite;
try solve [eapply_prop_hyp msg_log_property msg_log_property; eauto].
subst. simpl in *.
unfold write_ghost_log. simpl in *.
replace d with (snd (nwState {| nwPackets := ps'; nwState := st' |} (pDst p)))
by (simpl; repeat find_higher_order_rewrite; rewrite_update; reflexivity).
eauto.
Qed.
Proof using.
red. unfold log_properties_hold_on_ghost_logs. intros.
simpl in *.
subst.
find_apply_hyp_hyp; intuition; repeat find_rewrite;
try solve [eapply_prop_hyp msg_log_property msg_log_property; eauto].
subst. simpl in *.
unfold write_ghost_log. simpl in *.
replace d with (snd (nwState {| nwPackets := ps'; nwState := st' |} (pDst p))) by
(simpl; find_higher_order_rewrite; rewrite_update; reflexivity).
eauto.
Qed.
Proof using.
red. unfold log_properties_hold_on_ghost_logs. intros.
simpl in *.
subst.
find_apply_hyp_hyp; intuition; repeat find_rewrite;
try solve [eapply_prop_hyp msg_log_property msg_log_property; eauto].
do_in_map. subst.
simpl in *.
unfold add_ghost_msg, write_ghost_msg in *.
do_in_map.
subst. simpl in *.
unfold write_ghost_log. simpl in *.
replace d with (snd (nwState {| nwPackets := ps'; nwState := st' |} (pDst p))) by
(simpl; find_higher_order_rewrite; rewrite_update; reflexivity).
eauto.
Qed.
Proof using.
red. unfold log_properties_hold_on_ghost_logs. intros.
simpl in *.
subst.
find_apply_hyp_hyp; intuition; repeat find_rewrite;
try solve [eapply_prop_hyp msg_log_property msg_log_property; eauto].
do_in_map. subst.
simpl in *.
unfold add_ghost_msg, write_ghost_msg in *.
do_in_map.
subst. simpl in *.
unfold write_ghost_log. simpl in *.
replace d with (snd (nwState {| nwPackets := ps'; nwState := st' |} h)) by
(simpl; find_higher_order_rewrite; rewrite_update; reflexivity).
eauto.
Qed.
Proof using.
red. unfold log_properties_hold_on_ghost_logs. intros.
simpl in *.
subst.
find_apply_hyp_hyp; intuition; repeat find_rewrite;
try solve [eapply_prop_hyp msg_log_property msg_log_property; eauto].
do_in_map. subst.
simpl in *.
unfold add_ghost_msg, write_ghost_msg in *.
do_in_map.
subst. simpl in *.
unfold write_ghost_log. simpl in *.
replace d with (snd (nwState {| nwPackets := ps'; nwState := st' |} h)) by
(simpl; find_higher_order_rewrite; rewrite_update; reflexivity).
eauto.
Qed.
Proof using.
red. unfold log_properties_hold_on_ghost_logs. intros.
simpl in *.
subst.
find_apply_hyp_hyp; intuition; repeat find_rewrite;
try solve [eapply_prop_hyp msg_log_property msg_log_property; eauto].
do_in_map. subst.
simpl in *.
unfold add_ghost_msg, write_ghost_msg in *.
do_in_map.
subst. simpl in *.
unfold write_ghost_log. simpl in *.
replace d' with (snd (nwState {| nwPackets := ps'; nwState := st' |} h)) by
(simpl; find_higher_order_rewrite; rewrite_update; reflexivity).
eauto.
Qed.
Proof using.
red. unfold log_properties_hold_on_ghost_logs. intros.
simpl in *.
subst.
find_apply_hyp_hyp; intuition; repeat find_rewrite;
try solve [eapply_prop_hyp msg_log_property msg_log_property; eauto].
do_in_map. subst.
simpl in *.
unfold add_ghost_msg, write_ghost_msg in *.
do_in_map.
subst. simpl in *.
unfold write_ghost_log. simpl in *.
replace d' with (snd (nwState {| nwPackets := ps'; nwState := st' |} h)) by
(simpl; find_higher_order_rewrite; rewrite_update; reflexivity).
eauto.
Qed.
Proof using.
red. unfold log_properties_hold_on_ghost_logs. intros.
simpl in *.
subst. repeat find_reverse_rewrite.
eapply_prop_hyp msg_log_property msg_log_property; eauto.
Qed.
Proof using.
red. unfold log_properties_hold_on_ghost_logs. intros.
simpl in *.
subst. repeat find_reverse_rewrite.
eapply_prop_hyp msg_log_property msg_log_property; eauto.
Qed.

Theorem log_properties_hold_on_ghost_logs_invariant :
forall net,
msg_refined_raft_intermediate_reachable net ->
log_properties_hold_on_ghost_logs net.