Opaque Mem.storebytes.

(* Specifications: *)
Lemma mem_obs_eq_storeF:
forall f mc mf mf' chunk b ofs v pmap pmap2
(Hlt: permMapLt pmap (getMaxPerm mf))
(Hlt': permMapLt pmap (getMaxPerm mf'))
(Hlt2: permMapLt pmap2 (getMaxPerm mf))
(Hstore: Mem.store chunk (restrPermMap Hlt2) b ofs v = Some mf')
(Hdisjoint: permMapCoherence pmap pmap2 \/ permMapsDisjoint pmap pmap2)
(Hobs_eq: mem_obs_eq f mc (restrPermMap Hlt)),
mem_obs_eq f mc (restrPermMap Hlt').
Lemma mem_obs_eq_disjoint_lock:
forall f  mc mf mc' mf' pmap pmapF bl1 bl2 ofsl sz
(Hf: f bl1 = Some bl2)
(Hlt: permMapLt pmap (getMaxPerm mc))
(HltF: permMapLt pmapF (getMaxPerm mf))
(Hlt': permMapLt pmap (getMaxPerm mc'))
(HltF': permMapLt pmapF (getMaxPerm mf'))
(Hvb : forall b : block, Mem.valid_block mc b <-> Mem.valid_block mc' b)
(HvbF : forall b : block, Mem.valid_block mf b <-> Mem.valid_block mf' b)
(Hobs_eq: mem_obs_eq f (restrPermMap Hlt) (restrPermMap HltF))
(Hlock: forall ofs, Intv.In ofs (ofsl, ofsl + sz)%Z ->
memval_obs_eq f (ZMap.get ofs (Mem.mem_contents mc') # bl1)
(ZMap.get ofs (Mem.mem_contents mf') # bl2))
(Hstable: forall b ofs,
(b <> bl1 \/ (b = bl1 /\ ~ Intv.In ofs (ofsl, ofsl + sz)%Z)) ->
Mem.perm (restrPermMap Hlt) b ofs Cur Readable ->
ZMap.get ofs (Mem.mem_contents mc) # b = ZMap.get ofs (Mem.mem_contents mc') # b)
(HstableF: forall b ofs,
(b <> bl2 \/ (b = bl2 /\  ~ Intv.In ofs (ofsl, ofsl + sz)%Z)) ->
Mem.perm (restrPermMap HltF) b ofs Cur Readable ->
ZMap.get ofs (Mem.mem_contents mf) # b = ZMap.get ofs (Mem.mem_contents mf') # b),
mem_obs_eq f (restrPermMap Hlt') (restrPermMap HltF').
Lemma mem_obs_eq_changePerm:
forall mc mf rmap rmapF rmap' rmapF' f
(Hlt: permMapLt rmap (getMaxPerm mc))
(HltF: permMapLt rmapF (getMaxPerm mf))
(Hlt': permMapLt rmap' (getMaxPerm mc))
(HltF': permMapLt rmapF' (getMaxPerm mf))
(Hrmap: forall b1 b2 ofs,
f b1 = Some b2 ->
rmap' # b1 ofs = rmapF' # b2 ofs)
(Hobs_eq: mem_obs_eq f (restrPermMap Hlt) (restrPermMap HltF))
(Hnew: forall b ofs, Mem.perm_order' (rmap' # b ofs) Readable ->
Mem.perm_order' (rmap # b ofs) Readable),
mem_obs_eq f (restrPermMap Hlt') (restrPermMap HltF').
Lemma weak_mem_obs_eq_store:
forall mc mf mc' mf' rmap rmapF bl1 bl2 f
(Hlt: permMapLt rmap (getMaxPerm mc))
(HltF: permMapLt rmapF (getMaxPerm mf))
(Hlt2: permMapLt rmap (getMaxPerm mc'))
(Hlt2F: permMapLt rmapF (getMaxPerm mf'))
(Hf: f bl1 = Some bl2)
(Hinjective: forall b1 b1' b2 : block, f b1 = Some b2 -> f b1' = Some b2 -> b1 = b1')
(Hobs_eq: weak_mem_obs_eq f (restrPermMap Hlt) (restrPermMap HltF))
(Hvb: forall b, Mem.valid_block mc b <-> Mem.valid_block mc' b)
(HvbF: forall b, Mem.valid_block mf b <-> Mem.valid_block mf' b),
weak_mem_obs_eq f (restrPermMap Hlt2) (restrPermMap Hlt2F).
(*TODO: Generalize what is stored, chunk, value, etc.*)
Lemma strong_mem_obs_eq_store:
forall mc mf mc' mf' rmap rmapF bl1 bl2 ofsl f v
(Hlt: permMapLt rmap (getMaxPerm mc))
(HltF: permMapLt rmapF (getMaxPerm mf))
(Hlt2: permMapLt rmap (getMaxPerm mc'))
(Hlt2F: permMapLt rmapF (getMaxPerm mf'))
(Hf: f bl1 = Some bl2)
(Hinjective: forall b1 b1' b2 : block, f b1 = Some b2 -> f b1' = Some b2 -> b1 = b1')
(Hobs_eq: strong_mem_obs_eq f (restrPermMap Hlt) (restrPermMap HltF))
(Hstore: Mem.mem_contents mc' = PMap.set bl1 (Mem.setN (encode_val Mint32 (Vint v)) ofsl (Mem.mem_contents mc) # bl1)
(Mem.mem_contents mc))
(HstoreF: Mem.mem_contents mf' = PMap.set bl2 (Mem.setN (encode_val Mint32 (Vint v)) ofsl (Mem.mem_contents mf) # bl2)
(Mem.mem_contents mf))
(Hvb: forall b, Mem.valid_block mc b <-> Mem.valid_block mc' b)
(HvbF: forall b, Mem.valid_block mf b <-> Mem.valid_block mf' b),
strong_mem_obs_eq f (restrPermMap Hlt2) (restrPermMap Hlt2F).
Corollary mem_obs_eq_store :
forall (mc mf mc' mf' : mem) (rmap rmapF : access_map) (bl1 bl2 : block) (ofsl : Z) f v
(Hlt : permMapLt rmap (getMaxPerm mc)) (HltF : permMapLt rmapF (getMaxPerm mf))
(Hlt2 : permMapLt rmap (getMaxPerm mc'))
(Hlt2F : permMapLt rmapF (getMaxPerm mf'))
(Hfl: f bl1 = Some bl2)
(Hinjective: forall b1 b1' b2 : block,
f b1 = Some b2 -> f b1' = Some b2 -> b1 = b1')
(Hmem_obs_eq: mem_obs_eq f (restrPermMap Hlt) (restrPermMap HltF))
(Hcontents: Mem.mem_contents mc' =
PMap.set bl1 (Mem.setN (encode_val Mint32 (Vint v)) ofsl
(Mem.mem_contents mc) # bl1) (Mem.mem_contents mc))
(HcontentsF: Mem.mem_contents mf' =
PMap.set bl2 (Mem.setN (encode_val Mint32 (Vint v)) ofsl
(Mem.mem_contents mf) # bl2) (Mem.mem_contents mf))
(Hvb: forall b : block, Mem.valid_block mc b <-> Mem.valid_block mc' b)
(HvbF: forall b : block, Mem.valid_block mf b <-> Mem.valid_block mf' b),
mem_obs_eq f (restrPermMap Hlt2) (restrPermMap Hlt2F).
Lemma alloc_perm_eq:
forall f m m' lo hi m2 m2' b b'
(Hobs_eq: mem_obs_eq f m m')
(Halloc: Mem.alloc m lo hi = (m2, b))
(Halloc': Mem.alloc m' lo hi = (m2', b'))
b1 b2 ofs
(Hf: (if proj_sumbool (valid_block_dec m b1)
then f b1
else if proj_sumbool (valid_block_dec m2 b1)
then Some b' else None) = Some b2),
permission_at m2 b1 ofs Cur =
permission_at m2' b2 ofs Cur.
Lemma setPermBlock_var_eq:
forall f bl1 bl2 ofsl b1 b2 ofs pmap pmap' p
(Hf: f b1 = Some b2)
(Hfl: f bl1 = Some bl2)
(Hinjective: forall b1 b1' b2 : block,
f b1 = Some b2 -> f b1' = Some b2 -> b1 = b1')
(Hperm: pmap # b1 ofs = pmap' # b2 ofs),
(setPermBlock_var p bl1 ofsl pmap
lksize.LKSIZE_nat) # b1 ofs =
(setPermBlock_var p bl2 ofsl pmap'
lksize.LKSIZE_nat) # b2 ofs.
Lemma setPermBlock_var_weak_obs_eq:
forall (f : block -> option block) (bl1 bl2 : block) (ofsl : Z)
(pmap pmapF : access_map) (mc mf : mem) p (Hlt : permMapLt pmap (getMaxPerm mc))
(HltF : permMapLt pmapF (getMaxPerm mf))
(Hfl: f bl1 = Some bl2)
(Hweak_obs_eq: weak_mem_obs_eq f (restrPermMap Hlt) (restrPermMap HltF))
(Hlt' : permMapLt (setPermBlock_var p bl1 ofsl pmap lksize.LKSIZE_nat) (getMaxPerm mc))
(HltF' : permMapLt (setPermBlock_var p bl2 ofsl pmapF lksize.LKSIZE_nat) (getMaxPerm mf)),
weak_mem_obs_eq f (restrPermMap Hlt') (restrPermMap HltF').
Lemma setPermBlock_var_obs_eq:
forall f bl1 bl2 ofsl pmap pmapF mc mf p
(Hlt: permMapLt pmap (getMaxPerm mc))
(HltF: permMapLt pmapF (getMaxPerm mf))
(Hfl: f bl1 = Some bl2)
(Hval_obs_eq: forall ofs0, (ofsl <= ofs0 < ofsl + Z.of_nat (lksize.LKSIZE_nat))%Z ->
memval_obs_eq f (ZMap.get ofs0 (Mem.mem_contents mc) # bl1)
(ZMap.get ofs0 (Mem.mem_contents mf) # bl2))
(Hobs_eq: mem_obs_eq f (restrPermMap Hlt) (restrPermMap HltF))
(Hlt': permMapLt (setPermBlock_var p bl1 ofsl pmap lksize.LKSIZE_nat) (getMaxPerm mc))
(HltF': permMapLt (setPermBlock_var p bl2 ofsl pmapF lksize.LKSIZE_nat) (getMaxPerm mf)),
mem_obs_eq f (restrPermMap Hlt') (restrPermMap HltF').
Lemma setPermBlock_weak_obs_eq:
forall (f : block -> option block) (bl1 bl2 : block) (ofsl : Z)
(pmap pmapF : access_map) (mc mf : mem) (p : option permission) (Hlt : permMapLt pmap (getMaxPerm mc))
(HltF : permMapLt pmapF (getMaxPerm mf))
(Hfl: f bl1 = Some bl2)
(Hweak_obs_eq: weak_mem_obs_eq f (restrPermMap Hlt) (restrPermMap HltF))
(Hlt' : permMapLt (setPermBlock p bl1 ofsl pmap lksize.LKSIZE_nat) (getMaxPerm mc))
(HltF' : permMapLt (setPermBlock p bl2 ofsl pmapF lksize.LKSIZE_nat) (getMaxPerm mf)),
weak_mem_obs_eq f (restrPermMap Hlt') (restrPermMap HltF').
Lemma setPermBlock_obs_eq:
forall f bl1 bl2 ofsl pmap pmapF mc mf p
(Hlt: permMapLt pmap (getMaxPerm mc))
(HltF: permMapLt pmapF (getMaxPerm mf))
(Hfl: f bl1 = Some bl2)
(Hval_obs_eq: forall ofs0, (ofsl <= ofs0 < ofsl + Z.of_nat (lksize.LKSIZE_nat))%Z ->
memval_obs_eq f (ZMap.get ofs0 (Mem.mem_contents mc) # bl1)
(ZMap.get ofs0 (Mem.mem_contents mf) # bl2))
(Hobs_eq: mem_obs_eq f (restrPermMap Hlt) (restrPermMap HltF))
(Hlt': permMapLt (setPermBlock p bl1 ofsl pmap lksize.LKSIZE_nat) (getMaxPerm mc))
(HltF': permMapLt (setPermBlock p bl2 ofsl pmapF lksize.LKSIZE_nat) (getMaxPerm mf)),
mem_obs_eq f (restrPermMap Hlt') (restrPermMap HltF').
Lemma mem_free_obs_perm:
forall f m m' m2 m2' lo hi b1 b2
(Hmem_obs_eq: mem_obs_eq f m m')
(Hf: f b1 = Some b2)
(Hfree: Mem.free m b1 lo hi = Some m2)
(Hfree': Mem.free m' b2 lo hi = Some m2') b0 b3 ofs
(Hf0: f b0 = Some b3),
permissions.permission_at m2 b0 ofs Cur =
permissions.permission_at m2' b3 ofs Cur.