Local Open Scope pred.
Definition cleave (sh: share) :=
(Share.lub (fst (Share.split (Share.glb Share.Lsh sh))) (fst (Share.split (Share.glb Share.Rsh sh))),
Share.lub (snd (Share.split (Share.glb Share.Lsh sh))) (snd (Share.split (Share.glb Share.Rsh sh)))).
Definition split_resource r :=
match r with YES sh rsh k pp =>
(YES (fst (cleave sh)) (cleave_readable1 _ rsh) k pp ,
YES (snd (cleave sh)) (cleave_readable2 _ rsh) k pp)
| PURE k pp => (PURE k pp, PURE k pp)
| NO sh nsh => (NO (fst (cleave sh)) (cleave_nonreadable1 _ nsh),
NO (snd (cleave sh)) (cleave_nonreadable2 _ nsh))
end.
(* Definition split_rmap (m: rmap) : rmap * rmap := (proj1_sig (make_rmap _ (split_rmap_valid1 m) (level m) (split_rmap_ok1 m)), proj1_sig (make_rmap _ (split_rmap_valid2 m) (level m) (split_rmap_ok2 m))). *)

Lemma nonlock_permission_bytes_VALspec_range_join:
forall sh1 sh2 (rsh2: readable_share sh2) sh p n,
join sh1 sh2 sh ->
nonlock_permission_bytes sh1 p n *
VALspec_range n sh2 p =
VALspec_range n sh p.