Section CORRECTNESS.
Variable prog: Clight.program.
Variable tprog: Csharpminor.program.
Hypothesis TRANSL: transl_program prog = OK tprog.
Let ge : Clight.genv := Genv.globalenv prog.
Let tge : Csharpminor.genv := Genv.globalenv tprog.
Proof (Genv.find_symbol_transf_partial2 transl_fundef transl_globvar _ TRANSL).
Proof (Genv.find_funct_transf_partial2 transl_fundef transl_globvar _ TRANSL).
Proof (Genv.find_funct_ptr_transf_partial2 transl_fundef transl_globvar _ TRANSL).
Proof (Genv.find_var_info_transf_partial2 transl_fundef transl_globvar _ TRANSL).
Proof (Genv.find_var_info_rev_transf_partial2 transl_fundef transl_globvar _ TRANSL).
(*NEW: globalfunction_ptr_inject - just as in SelctionproofEFF.v*)
Definition globalfunction_ptr_inject (j:meminj):=
forall b f, Genv.find_funct_ptr ge b = Some f ->
j b = Some(b,0) /\ isGlobalBlock ge b = true.
(*From Cminorgenproof*)
Remark val_inject_function_pointer:
forall v fd j tv,
Genv.find_funct ge v = Some fd ->
globalfunction_ptr_inject j ->
val_inject j v tv ->
tv = v.
(** * Matching between environments *)
(** In this section, we define a matching relation between a Clight local environment and a Csharpminor local environment. *)
(*LENB: added parameter j - first, let's try an attempt where all offsets are 0*)
Record match_env (j:meminj) (e: Clight.env) (te: Csharpminor.env) : Prop :=
mk_match_env {
me_local:
forall id b ty,
e!id = Some (b, ty) -> exists b',
j b = Some(b',0) /\ te!id = Some(b', sizeof ty);
me_local_inv:
forall id b sz,
te!id = Some (b, sz) -> exists b' ty,
j b' = Some(b,0) /\e!id = Some(b', ty)
}.

Lemma match_env_restrictD: forall j X e te
(MENV : match_env (restrict j X) e te),
match_env j e te.