Section CORRECTNESS.
Variable prog: Clight.program.
Variable tprog: Csharpminor.program.
Hypothesis TRANSL: match_prog prog tprog.
Let ge := globalenv prog.
Let tge := Genv.globalenv tprog.
Proof (Genv.find_symbol_match TRANSL).
Proof (Genv.senv_match TRANSL).
Proof (Genv.find_funct_ptr_match TRANSL).
Proof (Genv.find_funct_match TRANSL).
(** * Matching between environments *)
(** In this section, we define a matching relation between a Clight local environment and a Csharpminor local environment. *)
Record match_env (e: Clight.env) (te: Csharpminor.env) : Prop :=
mk_match_env {
me_local:
forall id b ty,
e!id = Some (b, ty) -> te!id = Some(b, Ctypes.sizeof ge ty);
me_local_inv:
forall id b sz,
te!id = Some (b, sz) -> exists ty, e!id = Some(b, ty)
}.
(** The following lemmas establish the [match_env] invariant at the beginning of a function invocation, after allocation of local variables and initialization of the parameters. *)

Lemma match_env_alloc_variables:
forall cunit, linkorder cunit prog ->
forall e1 m1 vars e2 m2, Clight.alloc_variables ge e1 m1 vars e2 m2 ->
forall tvars te1,
mmap (transl_var cunit.(prog_comp_env)) vars = OK tvars ->
match_env e1 te1 ->
exists te2,
Csharpminor.alloc_variables te1 m1 tvars te2 m2
/\ match_env e2 te2.