(** * Semantic preservation for the translation *)
(** The proof of semantic preservation uses simulation diagrams of the following form: << e, m1, s ----------------- sp, te1, tm1, ts |                                | t|                                |t v                                v e, m2, out --------------- sp, te2, tm2, tout >> where [ts] is the Cminor statement obtained by translating the C#minor statement [s].  The left vertical arrow is an execution of a C#minor statement.  The right vertical arrow is an execution of a Cminor statement.  The precondition (top vertical bar) includes a [mem_inject] relation between the memory states [m1] and [tm1], and a [match_callstack] relation for any callstack having [e], [te1], [sp] as top frame.  The postcondition (bottom vertical bar) is the existence of a memory injection [f2] that extends the injection [f1] we started with, preserves the [match_callstack] relation for the transformed callstack at the final state, and validates a [outcome_inject] relation between the outcomes [out] and [tout]. *)
(** ** Semantic preservation for expressions *)
Remark bool_of_val_inject:
forall f v tv b,
Val.bool_of_val v b -> Val.inject f v tv -> Val.bool_of_val tv b.

Lemma transl_constant_correct:
forall f sp cst v,
Csharpminor.eval_constant cst = Some v ->
exists tv,
eval_constant tge sp (transl_constant cst) = Some tv
/\ Val.inject f v tv.