(** Injections on registers *)

  Definition reg_ren f (r:PregEq.t) (rs rs' : regset) : Prop :=
    val_obs f (Pregmap.get r rs) (Pregmap.get r rs').Definition regset_ren f rs rs' : Prop :=
    forall r, reg_ren f r rs rs'.Definition core_inj f c c' :=
    match c, c' with State rs _, State rs' _ => regset_ren f rs rs' end.

Lemma corestep_obs_eq: forall the_ge (Hsafe : safe_genv the_ge) (cc cf cc' : state) (mc mf mc' : mem) f fg, mem_obs_eq f mc mf -> core_inj f cc cf -> (forall b1 b2, fg b1 = Some b2 -> b1 = b2) -> ge_wd fg the_ge -> ren_incr fg f -> corestep (Asm_core_sem the_ge) cc mc cc' mc' -> exists (cf' : state) (mf' : mem) (f' : Renamings.memren), corestep (Asm_core_sem the_ge) cf mf cf' mf' /\ core_inj f' cc' cf' /\ mem_obs_eq f' mc' mf' /\ ren_incr f f' /\ ren_separated f f' mc mf /\ ((exists p : positive, Mem.nextblock mc' = (Mem.nextblock mc + p)%positive /\ Mem.nextblock mf' = (Mem.nextblock mf + p)%positive) \/ Mem.nextblock mc' = Mem.nextblock mc /\ Mem.nextblock mf' = Mem.nextblock mf) /\ (forall b : block, Mem.valid_block mf' b -> ~ Mem.valid_block mf b -> let bz := (Z.pos b - (Z.pos (Mem.nextblock mf) - Z.pos (Mem.nextblock mc)))%Z in f' (Z.to_pos bz) = Some b /\ f (Z.to_pos bz) = None) /\ (Mem.nextblock mc = Mem.nextblock mf -> (forall b1 b2 : block, f b1 = Some b2 -> b1 = b2) -> forall b1 b2 : block, f' b1 = Some b2 -> b1 = b2) /\ (forall b2 : block, ~ (exists b1 : block, f' b1 = Some b2) -> forall ofs : Z, permissions.permission_at mf b2 ofs Cur = permissions.permission_at mf' b2 ofs Cur).