Proof using.
unfold deghost.
simpl.
intros.
eexists; intuition eauto.
apply in_map_iff. eexists; eauto.
Qed.
Definition lift_leader_sublog_nw :
forall net leader p t leaderId prevLogIndex prevLogTerm entries leaderCommit e,
refined_raft_intermediate_reachable net ->
type (snd (nwState net leader)) = Leader ->
In p (nwPackets net) ->
pBody p = AppendEntries t leaderId prevLogIndex prevLogTerm
entries leaderCommit ->
In e entries ->
eTerm e = currentTerm (snd (nwState net leader)) ->
In e (log (snd (nwState net leader))).
Proof using lsli rri.
intros.
pose proof lift_prop leader_sublog_nw_invariant.
conclude_using ltac:(apply leader_sublog_invariant_invariant).
find_apply_hyp_hyp.
find_apply_lem_hyp exists_deghosted_packet.
match goal with
| H : exists _, _ |- _ => destruct H as [q]
end. break_and.
match goal with
| H : leader_sublog_nw_invariant _ |- _ =>
specialize (H leader q t leaderId prevLogIndex prevLogTerm entries leaderCommit e)
end.
repeat find_rewrite_lem deghost_spec. subst. simpl in *.
intuition.
Qed.
Definition append_entries_append_entries_prefix_within_term_nw net :=
forall p t n pli plt es ci p' t' n' pli' plt' es' ci' e e',
In p (nwPackets net) ->
pBody p = AppendEntries t n pli plt es ci ->
In p' (nwPackets net) ->
pBody p' = AppendEntries t' n' pli' plt' es' ci' ->
eTerm e = eTerm e' ->
eIndex e <= eIndex e' ->
In e es ->
In e' es' ->
(In e es' \/ (eIndex e = pli' /\ eTerm e = plt') \/ (eIndex e < pli' /\ eTerm e <= plt')).

(* Specifications: *)
Theorem log_log_prefix_within_term_invariant :
forall net,
refined_raft_intermediate_reachable net ->
log_log_prefix_within_term net.