(** * Semantic preservation for instruction selection. *)
(** Relationship between the local environments. *)
(* Definition env_lessdef (e1 e2: env) : Prop := forall id v1, e1!id = Some v1 -> exists v2, e2!id = Some v2 /\ Val.lessdef v1 v2. *)
Definition env_inject j (e1 e2: env) : Prop :=
forall id v1, e1!id = Some v1 -> exists v2, e2!id = Some v2 /\ val_inject j v1 v2.

(* Specifications: *)
(* Lemma set_var_lessdef: forall e1 e2 id v1 v2, env_lessdef e1 e2 -> Val.lessdef v1 v2 -> env_lessdef (PTree.set id v1 e1) (PTree.set id v2 e2). *)
Lemma set_var_inject:
forall j e1 e2 id v1 v2,
env_inject j e1 e2 -> val_inject j v1 v2 ->
env_inject j (PTree.set id v1 e1) (PTree.set id v2 e2).
(* Lemma set_params_lessdef: forall il vl1 vl2, Val.lessdef_list vl1 vl2 -> env_lessdef (set_params vl1 il) (set_params vl2 il). *)
Lemma set_params_inject:
forall j il vl1 vl2,
val_list_inject j vl1 vl2 ->
env_inject j (set_params vl1 il) (set_params vl2 il).