Section RefinedLogMatchingLemmas.
Context {orig_base_params : BaseParams}.
Context {one_node_params : OneNodeParams orig_base_params}.
Context {raft_params : RaftParams orig_base_params}.
Context {rri : raft_refinement_interface}.
Context {lmi : log_matching_interface}.
Context {si : sorted_interface}.
Context {aeigt0 : allEntries_indices_gt_0_interface}.
Proof using.
unfold deghost.
simpl. intuition.
apply in_map_iff.
eexists; eauto.
Qed.
Ltac forward_invariant :=
match goal with
| [ H : refined_raft_intermediate_reachable _, H' : _ |- _ ] =>
apply H' in H; clear H'
end.
Ltac forward_nw_invariant :=
match goal with
| [ H : forall _ _ _ _ _ _ _, In _ _ -> pBody _ = _ -> _,
H' : In _ _,
H'' : pBody _ = _ |- _ ] =>
specialize (H _ _ _ _ _ _ _ H' H'')
end.
Proof using lmi rri.
intros.
pose proof (lift_prop _ log_matching_invariant).
forward_invariant.
unfold log_matching, log_matching_nw, entries_contiguous_nw in *. intuition.
find_apply_lem_hyp ghost_packet.
forward_nw_invariant. red. intuition.
Qed.
Proof using lmi rri.
intros.
pose proof (lift_prop _ log_matching_invariant).
forward_invariant.
unfold log_matching, log_matching_nw, entries_gt_0_nw in *. intuition.
find_apply_lem_hyp ghost_packet.
forward_nw_invariant. break_and.
find_apply_hyp_hyp. lia.
Qed.

Lemma entries_sorted_nw_invariant :
forall net,
refined_raft_intermediate_reachable net ->
entries_sorted_nw net.