Definition access_cohere (m: mem)  (phi: rmap) :=
forall loc,  access_at m loc Cur = perm_of_res (phi @ loc).
Definition max_access_at m loc := access_at m loc Max.
Definition max_access_cohere (m: mem) (phi: rmap)  :=
forall loc,
perm_order'' (max_access_at m loc) (perm_of_res' (phi @ loc)).
(* Definition max_access_cohere (m: mem) (phi: rmap)  := forall loc, match phi @ loc with | YES rsh sh _ _ => perm_order'' (max_access_at m loc) (perm_of_sh rsh (pshare_sh sh)) | NO rsh => perm_order'' (max_access_at m loc) (perm_of_sh rsh Share.bot ) | PURE _ _ => (fst loc < nextblock m)%positive end. *)
Definition alloc_cohere (m: mem) (phi: rmap) :=
forall loc,  (fst loc >= nextblock m)%positive -> phi @ loc = NO Share.bot bot_unreadable.
Inductive juicy_mem: Type :=
mkJuicyMem: forall (m: mem) (phi: rmap)
(JMcontents: contents_cohere m phi)
(JMaccess: access_cohere m phi)
(JMmax_access: max_access_cohere m phi)
(JMalloc: alloc_cohere m phi),
juicy_mem.
Section selectors.
Variable (j: juicy_mem).
Definition m_dry := match j with mkJuicyMem m _ _ _ _ _ => m end.
Definition m_phi := match j with mkJuicyMem _ phi _ _ _ _ => phi end.

Lemma constructive_age1_join  {A}  {JA: Join A}{PA: Perm_alg A}{agA: ageable A}{AgeA: Age_alg A} : forall x y z x' : A,
join x y z ->
age x x' ->
{ yz' : A*A | join x' (fst yz') (snd yz') /\ age y (fst yz') /\ age z (snd yz')}.