(** * Correspondence between C#minor's and Cminor's environments and memory states *)
(** In C#minor, every variable is stored in a separate memory block. In the corresponding Cminor code, these variables become sub-blocks of the stack data block.  We capture these changes in memory via a memory injection [f]: [f b = Some(b', ofs)] means that C#minor block [b] corresponds to a sub-block of Cminor block [b] at offset [ofs].  A memory injection [f] defines a relation [val_inject f] between values and a relation [Mem.inject f] between memory states.  These relations will be used intensively in our proof of simulation between C#minor and Cminor executions. *)
(** ** Matching between Cshaprminor's temporaries and Cminor's variables *)
Definition match_temps (f: meminj) (le: Csharpminor.temp_env) (te: env) : Prop :=
forall id v, le!id = Some v -> exists v', te!(id) = Some v' /\ val_inject f v v'.

(* Specifications: *)
Lemma match_temps_invariant:
forall f f' le te,
match_temps f le te ->
inject_incr f f' ->
match_temps f' le te.
Lemma match_temps_assign:
forall f le te id v tv,
match_temps f le te ->
val_inject f v tv ->
match_temps f (PTree.set id v le) (PTree.set id tv te).
Lemma match_temps_invariant:
forall f f' le te,
match_temps f le te ->
inject_incr f f' ->
match_temps f' le te.
Lemma match_temps_assign:
forall f le te id v tv,
match_temps f le te ->
val_inject f v tv ->
match_temps f (PTree.set id v le) (PTree.set id tv te).