Proof using.
unfold raft_net_invariant_append_entries, no_entries_past_current_term.
intros. find_apply_lem_hyp handleAppendEntries_spec.
intuition.
- unfold no_entries_past_current_term_host in *.
intros. simpl in *. find_higher_order_rewrite.
break_if; eauto. subst.
find_apply_hyp_hyp. intuition.
+ eapply le_trans; [|eauto]; eauto.
+ subst.
eapply_prop no_entries_past_current_term_nw; eauto.
- match goal with
| _ : context [{| pSrc := ?ps; pDst := ?pd; pBody := ?pb |}] |- _ =>
eapply no_entries_past_current_term_nw_not_append_entries
with (p' := {| pSrc := ps; pDst := pd; pBody := pb |})
end; eauto.
intros. find_apply_hyp_hyp. find_rewrite. in_crush.
Qed.

(* Specifications: *)
Lemma no_entries_past_current_term_unaffected :
forall net st' ps' xs p ys d ms,
nwPackets net = xs ++ p :: ys ->
no_entries_past_current_term net ->
(forall h : Net.name, st' h = update name_eq_dec (nwState net) (pDst p) d h) ->
(forall p' : packet,
In p' ps' ->
In p' (xs ++ ys) \/ In p' (send_packets (pDst p) ms)) ->
currentTerm (nwState net (pDst p)) <= currentTerm d ->
log d = log (nwState net (pDst p)) ->
(forall m, In m ms -> ~ is_append_entries (snd m)) ->
no_entries_past_current_term {| nwPackets := ps'; nwState := st' |}.