Hint Resolve length_empty length_insert length_map : length.
Hint Resolve length_insert length_map : construction_closed.
(* ---------------------------------------------------------------------------- *)
(* The definitions and properties that follow should be independent of the details of the definitions of [empty], [lookup], [insert], and [map]. *)
Opaque empty lookup raw_insert map.
(* ---------------------------------------------------------------------------- *)
(* A definition of when two environments agree up to length [k]. *)
Definition agree A (e1 e2 : env A) (k : nat) :=
forall x,
x < k ->
lookup x e1 = lookup x e2.
(* A simple consequence of the definition. *)

(* Specifications: *)
Lemma agree_below:
forall A (e1 e2 : env A) x a k,
lookup x e1 = Some a ->
x < k ->
agree e1 e2 k ->
lookup x e2 = Some a.