(** An RTL register environment matches a CminorSel local environment and let-environment if the value of every local or let-bound variable in the CminorSel environments is identical to the value of the corresponding pseudo-register in the RTL register environment. *)
(*LENB: replaced extension by injection. In particular, added paranmeter j:meminj and replaced lessdefs by val_injects*)
Record match_env (j:meminj)
(map: mapping) (e: env) (le: letenv) (rs: regset) : Prop :=
mk_match_env {
me_vars:
(forall id v,
e!id = Some v -> exists r, map.(map_vars)!id = Some r
/\ val_inject j v rs#r);
me_letvars:
val_list_inject j le rs##(map.(map_letvars))
}.

(* Specifications: *)
Lemma match_env_find_var:
forall j map e le rs id v r,
match_env j map e le rs ->
e!id = Some v ->
map.(map_vars)!id = Some r ->
val_inject j v rs#r.
Lemma match_env_inject_incr: forall j map e le rs
(MENV: match_env j map e le rs) j'
(INC: inject_incr j j'),
match_env j' map e le rs.
Lemma match_env_restrictD: forall j X map e le rs
(MENV: match_env (restrict j X) map e le rs),
match_env j map e le rs.
Lemma match_env_find_letvar:
forall j map e le rs idx v r,
match_env j map e le rs ->
List.nth_error le idx = Some v ->
List.nth_error map.(map_letvars) idx = Some r ->
val_inject j v rs#r.
Lemma match_env_invariant:
forall j map e le rs rs',
match_env j map e le rs ->
(forall r, (reg_in_map map r) -> rs'#r = rs#r) ->
match_env j map e le rs'.