Section NoAppendEntriesToLeader.
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 {naetsi : no_append_entries_to_self_interface}.
Context {ollpti : one_leaderLog_per_term_interface}.
Context {aercfli : append_entries_came_from_leaders_interface}.
Context {lhlli : leaders_have_leaderLogs_interface}.
Definition no_append_entries_to_leader' (net : network) : Prop :=
forall p t n pli plt es ci,
In p (nwPackets net) ->
pBody p = AppendEntries t n pli plt es ci ->
type (snd (nwState net (pDst p))) = Leader ->
currentTerm (snd (nwState net (pDst p))) = t ->
False.
Definition no_append_entries_to_self' (net : network) : Prop :=
forall p t n pli plt es ci,
In p (nwPackets net) ->
pBody p = AppendEntries t n pli plt es ci ->
pDst p = pSrc p ->
False.
Proof using naetsi rri.
intros.
eapply lift_prop; eauto using no_append_entries_to_self_invariant.
Qed.
Proof using.
unfold deghost.
simpl. intuition.
apply in_map_iff.
eexists; eauto.
Qed.

Theorem no_append_entries_to_self'_invariant :
forall net,
refined_raft_intermediate_reachable net ->
no_append_entries_to_self' net.