Proof using.
intros. unfold logs_sorted in *. intuition.
find_apply_lem_hyp handleAppendEntries_log. intuition.
- find_rewrite; eauto.
- subst. unfold logs_sorted_nw in *. simpl in *.
find_eapply_hyp_goal; eauto.
- find_rewrite. apply sorted_append; eauto using removeAfterIndex_sorted.
+ intros. find_apply_lem_hyp removeAfterIndex_In_le; eauto.
unfold packets_gt_prevIndex in *.
eapply gt_le_trans; [|eauto].
find_eapply_hyp_goal; [in_crush|eauto|eauto].
simpl in *. eauto.
+ intros. find_copy_apply_lem_hyp removeAfterIndex_In_le; eauto.
find_apply_lem_hyp removeAfterIndex_in.
break_exists. intuition. subst.
match goal with
| H : eIndex ?x <= eIndex ?x', _ : In ?x ?ll |- _ =>
apply sorted_index_term with (l := ll) (e := x) (e' := x') in H
end; eauto.
match goal with |- ?a >= ?b => cut (b <= a); [omega|] end.
eapply le_trans; eauto.
unfold packets_ge_prevTerm in *.
find_eapply_hyp_goal; [in_crush|eauto|eauto];
simpl in *; eauto.
Qed.

(* Specifications: *)
Theorem logs_sorted_append_entries :
raft_net_invariant_append_entries logs_sorted.