Proof using one_node_params.
intros new current prev e Hsorted Huniq Hinv. intros. red. intros.
intuition.
- destruct (le_lt_dec i prev).
+ unfold contiguous_range_exact_lo in *. intuition.
match goal with
| H: forall _, _ < _ <= _ current -> _, H' : In _ current |- _ =>
specialize (H i); apply maxIndex_is_max in H'; auto; forward H; intuition
end.
break_exists. exists x. intuition.
apply in_or_app. right. subst.
eapply removeAfterIndex_le_In; eauto.
+ pose proof maxIndex_app new (removeAfterIndex current prev). intuition.
* find_rewrite.
unfold contiguous_range_exact_lo in *. intuition.
match goal with
| H: forall _, _ < _ <= _ new -> _ |- _ =>
specialize (H i); auto; forward H; intuition
end. break_exists. exists x. intuition.
* subst. simpl in *. clean.
exfalso.
pose proof maxIndex_removeAfterIndex current (eIndex e) e.
intuition.
- unfold contiguous_range_exact_lo in *.
do_in_app. intuition.
+ firstorder.
+ firstorder using removeAfterIndex_in.
Qed.

Lemma incoming_entries_in_log :
forall es log x i,
In x es ->
uniqueIndices log ->
exists y,
eIndex x = eIndex y /\
eTerm x = eTerm y /\
In y (es ++ (removeAfterIndex log i)).