(** * Proof of semantic preservation *)
(** ** Semantic preservation for expressions *)
(** The proof of semantic preservation for the translation of expressions relies on simulation diagrams of the following form: << e, le, m, a ------------------- te, le, m, ta |                                | |                                | |                                | v                                v e, le, m, v ------------------- te, le, m, v >> Left: evaluation of r-value expression [a] in Clight. Right: evaluation of its translation [ta] in Csharpminor. Top (precondition): matching between environments [e], [te], plus well-typedness of expression [a]. Bottom (postcondition): the result values [v] are identical in both evaluations.  We state these diagrams as the following properties, parameterized by the Clight evaluation. *)
Section EXPR.
Variable cunit: Clight.program.
Hypothesis LINK: linkorder cunit prog.
Variable e: Clight.env.
Variable le: temp_env.
Variable m: mem.
Variable te: Csharpminor.env.
Hypothesis MENV: match_env e te.

Lemma transl_expr_lvalue_correct:
(forall a v,
Clight.eval_expr ge e le m a v ->
forall ta (TR: transl_expr cunit.(prog_comp_env) a = OK ta) ,
Csharpminor.eval_expr tge te le m ta v)
/\(forall a b ofs,
Clight.eval_lvalue ge e le m a b ofs ->
forall ta (TR: transl_lvalue cunit.(prog_comp_env) a = OK ta),
Csharpminor.eval_expr tge te le m ta (Vptr b ofs)).