Proof using one_node_params.
induction l; try congruence; intros.
destruct l'; simpl.
- contradiction.
- simpl Prefix in *. intuition. subst a. f_equal. break_if.
+ do_bool. unfold contiguous_range_exact_lo in *.
intuition.
simpl maxIndex in *.
specialize (H6 e).
specialize (H4 e).
assert (H_in': In e (e :: l')).
left. reflexivity.
concludes.
assert (H_in: In e (e :: l)).
left. reflexivity.
concludes.
omega.
+ destruct l.
{ do_bool. simpl in *. find_apply_lem_hyp contiguous_index_singleton. destruct l'.
- reflexivity.
- simpl. intuition. specialize (H0 e0).
assert (H_in: In e0 (e0 :: l')).
left.
reflexivity.
concludes. intuition. find_rewrite. break_if.
+ reflexivity.
+ do_bool. omega. }
{ apply IHl; try discriminate; auto.
- find_apply_lem_hyp cons_contiguous_sorted.
+ firstorder.
+ eauto using Prefix_cons, prefix_sorted.
- find_apply_lem_hyp cons_contiguous_sorted.
+ unfold contiguous_range_exact_lo in *.
inversion H1.
split; intros.
* do_bool.
simpl maxIndex in *.
destruct H2.
destruct H3.
destruct l'; simpl in *; intuition.
subst_max.
specialize (H2 i0).
specialize (H0 e1).
conclude_using eauto.
break_and.
assert (i < i0 <= eIndex e) by omega.
concludes.
break_exists.
break_and.
subst.
exists x.
split; auto.
break_or_hyp; auto.
omega.
* apply H2.
right; auto.
+ eauto using Prefix_cons, prefix_sorted.
- apply cons_contiguous_sorted in H3; auto.
}
Qed.

Lemma thing :
forall es l l' e e',
sorted l ->
sorted l' ->
contiguous_range_exact_lo l' 0 ->
entries_match l l' ->
es <> [] ->
Prefix es l' ->
contiguous_range_exact_lo es (eIndex e) ->
In e l ->
In e' l' ->
eIndex e = eIndex e' ->
eTerm e = eTerm e' ->
es ++ (removeAfterIndex l (eIndex e)) = l'.