Set Implicit Arguments.
Definition Tsh : share := Share.top.
Definition nonempty_share (sh: share) :=
sepalg.nonidentity sh.
Definition readable_share (sh: share) :=
nonempty_share (Share.glb Share.Rsh sh).
Definition writable_share (sh: share) :=
nonempty_share (Share.glb Share.Lsh sh) /\ join_sub Share.Rsh sh.
Hint Resolve writable_readable : core.
Arguments glb_Rsh_not_top sh _ : clear implicits.
Hint Resolve writable_share_top : core.
Hint Resolve writable_readable_share : core.
Definition extern_retainer := fst (Share.split Share.Lsh).
Definition Ews (* extern_write_share *) :=
Share.lub extern_retainer Share.Rsh.
Hint Resolve readable_nonidentity : core.
Definition pure_readable_share (sh: Share.t) :=
Share.glb Share.Lsh sh = Share.bot /\ readable_share sh.
Definition rshare := sig pure_readable_share.
Definition readable_part: forall (sh: Share.t) (rsh: readable_share sh), rshare.
intros.
exists (Share.glb Share.Rsh sh).
split.
rewrite <- Share.glb_assoc. rewrite glb_Lsh_Rsh.
rewrite Share.glb_commute. apply Share.glb_bot.
unfold readable_share.
rewrite <- Share.glb_assoc.
rewrite Share.glb_idem.
apply rsh.
Defined.
Arguments readable_not_identity sh P _ _ : clear implicits.
Instance Join_rshare: Join rshare :=
fun a b c => join (proj1_sig a) (proj1_sig b) (proj1_sig c).
Instance Perm_rshare: Perm_alg rshare. (* move me! *)
Definition retainer_part (sh: Share.t) := Share.glb Share.Lsh sh.
Arguments retainer_part_nonreadable: clear implicits.

Lemma retainer_part_join: forall sh1 sh2 sh3,
join sh1 sh2 sh3 -> join (retainer_part sh1) (retainer_part sh2) (retainer_part sh3).