(** ** Erased X86 machine is safe*)
From mathcomp.ssreflect Require Import ssreflect ssrbool ssrnat ssrfun eqtype seq fintype finfun.
Set Implicit Arguments.
(*NOTE: because of redefinition of [val], these imports must appear after Ssreflect eqtype.*)
Module InitialMemWD.

(* Specifications: *)
Lemma valid_genv_alloc: forall ge (m m1:mem) lo hi b
(ALLOC: Mem.alloc m lo hi = (m1,b))
(G: X86WD.ge_wd (id_ren m) ge),
X86WD.ge_wd (id_ren m1) ge.
Lemma valid_genv_store: forall ge m m1 b ofs v chunk
(STORE: Mem.store chunk m b ofs v = Some m1)
(G: X86WD.ge_wd (id_ren m) ge), X86WD.ge_wd (id_ren m1) ge.
Lemma valid_genv_store_zeros: forall ge m m1 b y z
(STORE_ZERO: store_zeros m b y z = Some m1)
(G: X86WD.ge_wd (id_ren m) ge), X86WD.ge_wd (id_ren m1) ge.
Lemma mem_wd_store_zeros: forall m b p n m1
(STORE_ZERO: store_zeros m b p n = Some m1)
(WD: MemoryWD.valid_mem m),
MemoryWD.valid_mem m1.
Lemma validblock_id_ren : forall (m : mem) (b : block),
id_ren m b ->  Mem.valid_block m b.
Lemma valid_genv_drop: forall ge (m m1:mem) b lo hi p
(DROP: Mem.drop_perm m b lo hi p = Some m1) (G: X86WD.ge_wd (id_ren m) ge),
X86WD.ge_wd (id_ren m1) ge.
Lemma mem_wd_store_init_data: forall ge a (b:block) (z:Z)
m1 m2 (SID:Genv.store_init_data ge m1 b z a = Some m2),
X86WD.ge_wd (id_ren m1) ge -> MemoryWD.valid_mem m1 -> MemoryWD.valid_mem m2.
Lemma valid_genv_store_init_data:
forall ge a (b:block) (z:Z) m1 m2
(SID: Genv.store_init_data ge m1 b z a = Some m2),
X86WD.ge_wd (id_ren m1) ge -> X86WD.ge_wd (id_ren m2) ge.
Lemma mem_wd_store_init_datalist: forall ge l (b:block)
(z:Z) m1 m2 (SID: Genv.store_init_data_list ge m1 b z l = Some m2),
X86WD.ge_wd (id_ren m1) ge -> MemoryWD.valid_mem m1 -> MemoryWD.valid_mem m2.
Lemma valid_genv_store_init_datalist: forall ge l (b:block)
(z:Z) m1 m2 (SID: Genv.store_init_data_list ge m1 b z l = Some m2),
X86WD.ge_wd (id_ren m1) ge -> X86WD.ge_wd (id_ren m2) ge.
Lemma mem_valid_drop :
forall (m : mem) (b : block) (lo hi : Z) (p : permission) (m' : mem),
Mem.drop_perm m b lo hi p = Some m' ->
MemoryWD.valid_mem m -> MemoryWD.valid_mem m'.
Lemma mem_wd_alloc_global: forall ge a m0 m1
(GA: Genv.alloc_global ge m0 a = Some m1),
MemoryWD.valid_mem m0 -> X86WD.ge_wd (id_ren m0) ge -> MemoryWD.valid_mem m1.
Lemma valid_genv_alloc_global: forall ge a m0 m1
(GA: Genv.alloc_global ge m0 a = Some m1),
X86WD.ge_wd (id_ren m0) ge -> X86WD.ge_wd (id_ren m1) ge.
Lemma valid_genv_alloc_globals:
forall ge init_list m0 m
(GA: Genv.alloc_globals ge m0 init_list = Some m),
X86WD.ge_wd (id_ren m0) ge -> X86WD.ge_wd (id_ren m) ge.
Lemma mem_wd_alloc_globals:
forall ge init_list m0 m
(GA: Genv.alloc_globals ge m0 init_list = Some m),
MemoryWD.valid_mem m0 -> X86WD.ge_wd (id_ren m0) ge -> MemoryWD.valid_mem m.