Definition contiguous_range_exact_lo xs lo :=
    (forall i,
       lo < i <= maxIndex xs ->
       exists e,
         eIndex e = i /\
         In e xs) /\
    (forall e,
       In e xs ->
       lo < eIndex e).

(* Specifications: *)
Lemma removeAfterIndex_uniqueIndices : forall l i, uniqueIndices l -> uniqueIndices (removeAfterIndex l i).
Lemma maxIndex_subset : forall xs ys, sorted xs -> sorted ys -> (forall x, In x xs -> In x ys) -> maxIndex xs <= maxIndex (orig_base_params:=orig_base_params) ys.
Lemma maxIndex_exists_in : forall xs, maxIndex xs >= 1 -> exists x, eIndex x = maxIndex xs /\ In x xs.
Lemma maxIndex_removeAfterIndex_le : forall l i, sorted l -> maxIndex (removeAfterIndex l i) <= maxIndex l.
Lemma maxIndex_removeAfterIndex : forall l i e, sorted l -> In e l -> eIndex e = i -> maxIndex (removeAfterIndex l i) = i.
Lemma maxIndex_gt_0_nonempty : forall es, 0 < maxIndex es -> es <> nil.
Lemma removeIncorrect_new_contiguous : forall new current prev e, sorted current -> uniqueIndices current -> (forall e e', eIndex e = eIndex e' -> eTerm e = eTerm e' -> In e new -> In e' current -> e = e') -> contiguous_range_exact_lo current 0 -> contiguous_range_exact_lo new prev -> In e current -> eIndex e = prev -> contiguous_range_exact_lo (new ++ removeAfterIndex current prev) 0.
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)).
Lemma findGtIndex_necessary : forall entries e x, In e (findGtIndex entries x) -> In e entries /\ eIndex e > x.
Lemma findGtIndex_contiguous : forall entries x, sorted entries -> (forall i, 0 < i <= maxIndex entries -> (exists e, In e entries /\ eIndex e = i)) -> forall i, x < i <= maxIndex entries -> exists e, In e (findGtIndex entries x) /\ eIndex e = i.
Lemma findGtIndex_max : forall entries x, maxIndex (findGtIndex entries x) <= maxIndex entries.
Lemma findAtIndex_uniq_equal : forall e e' es, findAtIndex es (eIndex e) = Some e' -> In e es -> uniqueIndices es -> e = e'.