Proof using ollpti rlmli llli.
red. red. intros.
match goal with
| H : In ?e _,
H' : In ?e' _ |- _ =>
copy_eapply logs_leaderLogs_invariant H; eauto;
copy_eapply logs_leaderLogs_invariant H'; eauto
end.
break_exists; intuition.
repeat find_rewrite.
find_eapply_lem_hyp one_leaderLog_per_term_log_invariant; eauto.
conclude_using eauto. subst.
assert (exists e'', eIndex e'' = eIndex e /\ In e'' (log (snd (nwState net h')))) by
(eapply entries_contiguous_invariant; eauto; intuition;
[eapply entries_gt_0_invariant; eauto|];
eapply le_trans; eauto;
eapply maxIndex_is_max; eauto;
apply entries_sorted_invariant; auto).
break_exists. intuition.
match goal with
| _ : removeAfterIndex ?l ?i = _ _,
_ : In ?x ?l,
_ : eIndex ?x = _ |- _ =>
assert (In x (removeAfterIndex l i)) by (apply removeAfterIndex_le_In; eauto; omega)
end.
repeat find_rewrite. do_in_app. intuition.
- find_apply_hyp_hyp.
eapply entries_match_invariant; eauto; repeat find_rewrite; auto.
- cut (e = x0); intros; subst; intuition.
eapply uniqueIndices_elim_eq; eauto.
+ apply sorted_uniqueIndices.
apply entries_sorted_invariant.
auto.
+ match goal with
| H : context [ removeAfterIndex ?l ?index ] |- In _ ?l =>
apply removeAfterIndex_in with (i := index)
end.
repeat find_rewrite. apply in_app_iff; intuition.
Qed.
Definition locked_or x y :=
x \/ y.

(* Specifications: *)
Theorem append_entries_append_entries_prefix_within_term_invariant :
forall net,
refined_raft_intermediate_reachable net ->
append_entries_append_entries_prefix_within_term_nw net.