Proof using rlmli llsi ollpti aerlli.
unfold appendEntriesRequest_leaderLog_not_in.
intros.
find_copy_apply_lem_hyp append_entries_leaderLogs_invariant.
unfold append_entries_leaderLogs in *.
pose proof entries_sorted_nw_invariant net ltac:(auto) p _ _ _ _ _ _ ltac:(auto) ltac:(eauto).
match goal with
| [ H : In _ (nwPackets _), H' : forall _, _ |- _ ] =>
copy_eapply H' H
end; eauto.
break_exists. break_and.
pose proof one_leaderLog_per_term_invariant _ ltac:(eauto) (pSrc p) x _ _  _ ltac:(eauto) ltac:(eauto).
break_and. subst.
intro.
match goal with
| [ H : ~ In _ _ |- _ ] => apply H
end.
apply in_or_app. right.
find_copy_apply_lem_hyp leaderLogs_sorted_invariant; auto.
find_copy_eapply_lem_hyp maxIndex_is_max; eauto.
intuition.
- break_and. subst. omega.
- break_exists. intuition. subst.
unfold Prefix_sane in *. intuition.
+ eapply prefix_contiguous; eauto.
pose proof entries_contiguous_nw_invariant _ ltac:(eauto) p _ _ _ _ _ _ ltac:(auto) ltac:(eauto).
eapply contiguous_app ; eauto.
+ omega.
- subst. auto.
Qed.

(* Specifications: *)
Lemma leaderLogs_leader_invariant :
forall net,
refined_raft_intermediate_reachable net ->
leaderLogs_leader net.