Proof using rlmli.
intros.
unfold haveNewEntries in *. do_bool. intuition;
[unfold not_empty in *; break_match; subst; simpl in *; intuition; congruence|].
break_match; try congruence.
do_bool. find_apply_lem_hyp findAtIndex_elim. intuition.
assert (es <> nil) by (destruct es; subst; simpl in *; intuition; congruence).
find_eapply_lem_hyp maxIndex_non_empty.
break_exists. intuition.
find_copy_eapply_lem_hyp entries_sorted_nw_invariant; eauto.
match goal with
| H : In e es |- _ => copy_eapply maxIndex_is_max H; eauto
end.
repeat find_rewrite.
find_eapply_lem_hyp entries_match_nw_host_invariant; eauto.
Qed.

(* Specifications: *)
Lemma packets_entries_eq:
forall net p p0 entries es e e'
(d : raft_data) (n : name) (pli : logIndex) (plt : term)
(ci : logIndex)
(t0 : term) (leaderId : name) (prevLogIndex : logIndex)
(prevLogTerm : term) (leaderCommit : logIndex),
refined_raft_intermediate_reachable net ->
In p (nwPackets net) ->
In p0 (nwPackets net) ->
pBody p0 =
AppendEntries t0 leaderId prevLogIndex prevLogTerm entries leaderCommit ->
pBody p = AppendEntries (currentTerm d) n pli plt es ci ->
eTerm e = eTerm e' ->
eIndex e = eIndex e' -> In e entries -> In e' es -> e = e'.
Lemma maxIndex_le :
forall l1 l2,
sorted l1 ->
contiguous_range_exact_lo l1 0 ->
findAtIndex l1 (maxIndex l2) = None ->
l2 = nil
\/ (exists e, In e l2 /\ eIndex e = 0)
\/ maxIndex l1 <= maxIndex l2.