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_same_blocks: forall j e te, match_env j e te -> blocks_of_env te = Clight.blocks_of_env e. *)

Lemma FreelistEffect_PropagateLeft: forall
m e m'
(FL : Mem.free_list m (Clight.blocks_of_env e) = Some m')
mu m2 (SMV : sm_valid mu m m2) (WD: SM_wd mu)
te (MENV: match_env (restrict (as_inj mu) (vis mu)) e te)
b2 ofs
(EFF : FreelistEffect m2 (blocks_of_env te) b2 ofs = true)
(LB: locBlocksTgt mu b2 = false),
exists b1 delta,
foreign_of mu b1 = Some (b2, delta) /\
FreelistEffect m (Clight.blocks_of_env e) b1 (ofs - delta) = true /\
Mem.perm m b1 (ofs - delta) Max Nonempty.