Section EXPR.
Variable e: Clight.env.
Variable le: temp_env.
Variable m: mem.
Variable tm: mem. (*Lenb: NEW*)
Variable te: Csharpminor.env.
Variable tle: Csharpminor.temp_env. (*Lenb: NEW*)
Variable j: meminj. (*Lenb: NEW*)
Hypothesis MENV: match_env j e te.
Hypothesis LENV: match_tempenv j le tle. (*Lenb: NEW*)
Hypothesis MINJ: Mem.inject j m tm. (*Lenb: NEW*)
Hypothesis PG: meminj_preserves_globals ge j. (*Lenb: NEW*)
(* Lemma transl_expr_lvalue_correct: (forall a v, Clight.eval_expr ge e le m a v -> forall ta (TR: transl_expr a = OK ta) tv (TV: val_inject j v tv), Csharpminor.eval_expr tge te tle tm ta tv) /\(forall a b ofs, Clight.eval_lvalue ge e le m a b ofs -> forall ta (TR: transl_lvalue a = OK ta) tv (TV: val_inject j (Vptr b ofs) tv), Csharpminor.eval_expr tge te le m ta tv). *)
Proof (proj1 transl_expr_lvalue_correct).
(* Lemma transl_expr_correct: forall a v, Clight.eval_expr ge e le m a v -> forall ta, transl_expr a = OK ta -> Csharpminor.eval_expr tge te le m ta v. Proof (proj1 transl_expr_lvalue_correct). *)
Proof (proj2 transl_expr_lvalue_correct).
(* Lemma transl_arglist_correct: forall al tyl vl, Clight.eval_exprlist ge e le m al tyl vl -> forall tal, transl_arglist al tyl = OK tal -> Csharpminor.eval_exprlist tge te le m tal vl. *)
End EXPR.
(** ** Semantic preservation for statements *)
(** The simulation diagram for the translation of statements and functions is a "plus" diagram of the form << I S1 ------- R1 |          | t |        + | t v          v S2 ------- R2 I                         I >>  The invariant [I] is the [match_states] predicate that we now define. *)
Inductive match_transl: stmt -> cont -> stmt -> cont -> Prop :=
| match_transl_0: forall ts tk,
match_transl ts tk ts tk
| match_transl_1: forall ts tk,
match_transl (Sblock ts) tk ts (Kblock tk).
(* Lemma match_transl_step: forall ts tk ts' tk' f te le m, match_transl (Sblock ts) tk ts' tk' -> star (clight_corestep tge (CL_core f ts' tk' te le) m E0 (State f ts (Kblock tk) te le m). *)
Inductive match_cont (j:meminj): type -> nat -> nat -> Clight.cont -> Csharpminor.cont -> Prop :=
| match_Kstop: forall tyret nbrk ncnt,
match_cont j tyret nbrk ncnt Clight.Kstop Kstop
| match_Kseq: forall tyret nbrk ncnt s k ts tk,
transl_statement tyret nbrk ncnt s = OK ts ->
match_cont j tyret nbrk ncnt k tk ->
match_cont j tyret nbrk ncnt
(Clight.Kseq s k)
(Kseq ts tk)
| match_Kloop1: forall tyret s1 s2 k ts1 ts2 nbrk ncnt tk,
transl_statement tyret 1%nat 0%nat s1 = OK ts1 ->
transl_statement tyret 0%nat (S ncnt) s2 = OK ts2 ->
match_cont j tyret nbrk ncnt k tk ->
match_cont j tyret 1%nat 0%nat
(Clight.Kloop1 s1 s2 k)
(Kblock (Kseq ts2 (Kseq (Sloop (Sseq (Sblock ts1) ts2)) (Kblock tk))))
| match_Kloop2: forall tyret s1 s2 k ts1 ts2 nbrk ncnt tk,
transl_statement tyret 1%nat 0%nat s1 = OK ts1 ->
transl_statement tyret 0%nat (S ncnt) s2 = OK ts2 ->
match_cont j tyret nbrk ncnt k tk ->
match_cont j tyret 0%nat (S ncnt)
(Clight.Kloop2 s1 s2 k)
(Kseq (Sloop (Sseq (Sblock ts1) ts2)) (Kblock tk))
| match_Kswitch: forall tyret nbrk ncnt k tk,
match_cont j tyret nbrk ncnt k tk ->
match_cont j tyret 0%nat (S ncnt)
(Clight.Kswitch k)
(Kblock tk)
| match_Kcall_some: forall tyret nbrk ncnt nbrk' ncnt' f e k id tf te le tle tk,
transl_function f = OK tf ->
match_env j e te ->
match_tempenv j le tle ->
match_cont j (Clight.fn_return f) nbrk' ncnt' k tk ->
match_cont j tyret nbrk ncnt
(Clight.Kcall id f e le k)
(Kcall id tf te tle tk).

Lemma match_cont_inject_incr: forall j j' (I: inject_incr j j') tp n m k k'
(MC: match_cont j tp n m k k'), match_cont j' tp n m k k'.