Hint Resolve mymax_l mymax_r : mymax.
(* Extending an environment increments its length by one, in the usual case. It can be extended by more than one if [x] is far away. *)

(* Specifications: *)
Lemma length_insert_general:
forall A x k o (e : env A),
length e = k ->
length (raw_insert x o e) = mymax (1 + k) (1 + x).