Section free.
Variables (jm :juicy_mem) (m': mem)
(b: block) (lo hi: Z)
(FREE: free (m_dry jm) b lo hi = Some m')
(PERM: forall ofs, lo <= ofs < hi ->
perm_of_res (m_phi jm @ (b,ofs)) = Some Freeable).
Definition inflate_free: rmap. refine (
proj1_sig (make_rmap (fun loc =>
if adr_range_dec (b,lo) (hi-lo) loc then NO Share.bot bot_unreadable else m_phi jm @ loc)
(ghost_of (m_phi jm))
(level (m_phi jm)) _ (ghost_of_approx (m_phi jm)))).
(* The empty juicy memory *)
Definition after_alloc'
(lo hi: Z) (b: block) (phi: rmap)(H: forall ofs, phi @ (b,ofs) = NO Share.bot bot_unreadable)
: address -> resource := fun loc =>
if adr_range_dec (b,lo) (hi-lo) loc
then YES Share.top readable_share_top (VAL Undef) NoneP
else phi @ loc.
Definition after_alloc
(lo hi: Z) (b: block) (phi: rmap)(H: forall ofs, phi @ (b,ofs) = NO Share.bot bot_unreadable) : rmap :=
proj1_sig (make_rmap (after_alloc' lo hi b phi H) (ghost_of phi)
(level phi)
(after_alloc'_ok lo hi b phi H) (ghost_of_approx phi)).
Definition mod_after_alloc' (phi: rmap) (lo hi: Z) (b: block)
: address -> resource := fun loc =>
if adr_range_dec (b,lo) (hi-lo) loc
then YES Share.top readable_share_top (VAL Undef) NoneP
else core phi @ loc.
Definition mod_after_alloc (phi: rmap) (lo hi: Z) (b: block) :=
proj1_sig (make_rmap (mod_after_alloc' phi lo hi b) (ghost_of phi)
_
(mod_after_alloc'_ok phi lo hi b) (ghost_of_approx phi)).
Transparent alloc.
Definition resource_decay (nextb: block) (phi1 phi2: rmap) :=
(level phi1 >= level phi2)%nat /\
forall l: address,
((fst l >= nextb)%positive -> phi1 @ l = NO Share.bot bot_unreadable) /\
(resource_fmap (approx (level phi2)) (approx (level phi2)) (phi1 @ l) = (phi2 @ l) \/
(exists sh, exists (wsh: writable0_share sh), exists v, exists v',
resource_fmap (approx (level phi2)) (approx (level phi2)) (phi1 @ l) =
YES sh (writable0_readable wsh) (VAL v) NoneP /\
phi2 @ l = YES sh (writable0_readable wsh) (VAL v') NoneP)
\/ ((fst l >= nextb)%positive /\ exists v, phi2 @ l = YES Share.top readable_share_top (VAL v) NoneP)
\/ (exists v, exists pp, phi1 @ l = YES Share.top readable_share_top (VAL v) pp
/\ phi2 @ l = NO Share.bot bot_unreadable)).
Definition resource_nodecay (nextb: block) (phi1 phi2: rmap) :=
(level phi1 >= level phi2)%nat /\
forall l: address,
((fst l >= nextb)%positive -> phi1 @ l = NO Share.bot bot_unreadable) /\
(resource_fmap (approx (level phi2)) (approx (level phi2)) (phi1 @ l) = (phi2 @ l) \/
(exists sh, exists (wsh: writable0_share sh), exists v, exists v',
resource_fmap (approx (level phi2)) (approx (level phi2)) (phi1 @ l) = YES sh (writable0_readable wsh) (VAL v) NoneP
/\ phi2 @ l = YES sh (writable0_readable wsh) (VAL v') NoneP)).
(** * Results about aging in juicy memory coherence properties *)

Lemma age1_YES'_1 {phi phi' l rsh sh k P} :
age1 phi = Some phi' ->
phi @ l = YES rsh sh k P ->
(exists P, phi' @ l = YES rsh sh k P).