Definition AccessMap_EI_Property (j:meminj) (m1 m1' m2 : mem)
(AM:ZMap.t (Z -> perm_kind -> option permission)):Prop :=
forall b2,
(Mem.valid_block m2 b2 -> forall k ofs2,
match j b2 with
None => PMap.get b2 AM ofs2 k  =
PMap.get b2 m2.(Mem.mem_access) ofs2 k
| Some (b3,d3) =>
(Mem.perm m1 b2 ofs2 Max Nonempty ->
PMap.get b2 AM ofs2 k = PMap.get b2 m1'.(Mem.mem_access) ofs2 k)
/\ (~Mem.perm m1 b2 ofs2 Max Nonempty ->
PMap.get b2 AM ofs2 k  = PMap.get b2 m2.(Mem.mem_access) ofs2 k)
end)
/\ (~ Mem.valid_block m2 b2 -> forall k ofs2,
(Mem.perm m1' b2 ofs2 Max Nonempty ->
PMap.get b2 AM ofs2 k = PMap.get b2 m1'.(Mem.mem_access) ofs2 k)
/\ (~Mem.perm m1' b2 ofs2 Max Nonempty -> PMap.get b2 AM ofs2 k = None)).
Definition Content_EI_Property (j:meminj) (m1 m1' m2:Mem.mem)
(CM:ZMap.t (ZMap.t memval)):=
forall b2,
(Mem.valid_block m2 b2 -> forall ofs2,
match j b2 with
None =>  ZMap.get ofs2 (PMap.get b2 CM) =
ZMap.get ofs2 (PMap.get b2 m2.(Mem.mem_contents))
| Some (b3,delta3) =>
(Mem.perm m1 b2 ofs2 Max Nonempty ->
ZMap.get ofs2 (PMap.get b2 CM) =
ZMap.get ofs2 (PMap.get b2 m1'.(Mem.mem_contents)))
/\ (~Mem.perm m1 b2 ofs2 Max Nonempty ->
ZMap.get ofs2 (PMap.get b2 CM) =
ZMap.get ofs2 (PMap.get b2 m2.(Mem.mem_contents)))
end)
/\ (~ Mem.valid_block m2 b2 -> forall (HM1': Mem.valid_block m1' b2) ofs2,
(Mem.perm m1' b2 ofs2 Cur Readable ->
ZMap.get ofs2 (PMap.get b2 CM) =
ZMap.get ofs2 (PMap.get b2 m1'.(Mem.mem_contents)))
/\ (~Mem.perm m1' b2 ofs2 Cur Readable ->
ZMap.get ofs2 (PMap.get b2 CM) =Undef))
/\ fst CM !! b2 = Undef.
Definition AccessMap_EI_FUN (j:meminj) (m1 m1' m2 : mem) (b2:block):
Z -> perm_kind -> option permission :=
if plt b2 (Mem.nextblock m2)
then (fun ofs2 k =>
match j b2 with
None => PMap.get b2 m2.(Mem.mem_access) ofs2 k
| Some (b3,d3) =>
if Mem.perm_dec m1 b2 ofs2 Max Nonempty
then PMap.get b2 m1'.(Mem.mem_access) ofs2 k
else PMap.get b2 m2.(Mem.mem_access) ofs2 k
end)
else (fun ofs2 k =>
if Mem.perm_dec m1' b2 ofs2 Max Nonempty
then PMap.get b2 m1'.(Mem.mem_access) ofs2 k
else None).

Lemma mkAccessMap_EI_existsT: forall j (m1 m1' m2:Mem.mem)
(VB : (Mem.nextblock m2 <= Mem.nextblock m1')%positive),
{ M : PMap.t (Z -> perm_kind -> option permission) |
fst M = (fun k ofs => None) /\
forall b, PMap.get b M = AccessMap_EI_FUN j m1 m1' m2 b}.