Proof using.
induction l; simpl; intuition.
- subst. break_if; do_bool.
+ apply in_ks_log_to_ks'_le.  rewrite get_set_same. auto.
+ unfold assoc_default in *.
break_match; try omega.
find_eapply_lem_hyp in_ks_log_to_ks'_le.
break_exists_exists. intuition eauto. omega.
- break_if; do_bool; auto.
Qed.

(* Specifications: *)
Lemma handleAppendEntries_preserves_lastApplied_entries':
forall (p : packet) (net : network) (d : raft_data)
(m : msg) (t : term) (n : name) (pli : logIndex)
(plt : term) (es : list entry) (ci : logIndex) xs ys ps' st' e,
raft_intermediate_reachable net ->
raft_intermediate_reachable {| nwPackets := ps'; nwState := st' |} ->
(forall h : name, st' h = update name_eq_dec (nwState net) (pDst p) d h) ->
(forall p' : packet,
In p' ps' ->
In p' (xs ++ ys) \/
p' = {| pSrc := pDst p; pDst := pSrc p; pBody := m |}) ->
handleAppendEntries (pDst p) (nwState net (pDst p)) t n pli plt es ci = (d, m) ->
nwPackets net = xs ++ p :: ys ->
pBody p = AppendEntries t n pli plt es ci ->
eIndex e <= lastApplied (nwState net (pDst p)) ->
In e (log (nwState net (pDst p))) ->
In e (log d).