(* Lemma match_env_alloc_variables: forall e1 m1 vars e2 m2, Clight.alloc_variables e1 m1 vars e2 m2 -> forall te1, match_env e1 te1 -> exists te2, Csharpminor.alloc_variables te1 m1 (map transl_var vars) te2 m2 /\ match_env e2 te2.  Definition match_tempenv (j:meminj) (le: temp_env) (tle: Csharpminor.temp_env) := forall id v, le!id = Some v -> exists tv, val_inject j v tv /\ tle!id = Some tv.  Lemma match_tempenv_inject_incr: forall j e te (TENV : match_tempenv j e te) j' (INC: inject_incr j j'), match_tempenv j' e te.  Lemma match_tempenv_set: forall j le tle (TENV : match_tempenv j le tle) v tv (Inj : val_inject j v tv) x, match_tempenv j (PTree.set x v le) (PTree.set x tv tle).  Lemma create_undef_temps_match: forall temps, create_undef_temps (map fst temps) = Clight.create_undef_temps temps. Lemma create_undef_temps_match_inject: forall temps j, match_tempenv j (Clight.create_undef_temps temps) (create_undef_temps (map fst temps)).  Lemma bind_parameter_temps_match_inject: forall vars vals le1 le2 (BP: Clight.bind_parameter_temps vars vals le1 = Some le2) j tle1 (TENV: match_tempenv j le1 tle1) tvals (Inj: val_list_inject j vals tvals), exists tle2, bind_parameters (map fst vars) tvals tle1 = Some tle2 /\ match_tempenv j le2 tle2. (* Lemma bind_parameter_temps_match: forall vars vals le1 le2, Clight.bind_parameter_temps vars vals le1 = Some le2 -> bind_parameters (map fst vars) vals le1 = Some le2. *)
(** * 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. *)

Lemma unary_op_inject': forall op v ty u
(SUO:sem_unary_operation op v ty = Some u)
j tv (V: val_inject j v tv),
exists tu, val_inject j u tu /\
sem_unary_operation op tv ty = Some tu.