(* TODO those definitions are also in sync_preds_defs, see if we can
include without changing the dep DAG too badly *)

(* The TT branch of the jam below might seem too weak, but we already
keep enough control over joining with other rmaps that it should be
enough *)

Definition LKspec_ext (R: pred rmap) lksize : spec :=
   fun (sh: Share.t) (l: AV.address)  =>
    allp (jam (adr_range_dec l lksize)
              (fun l' => yesat (SomeP rmaps.Mpred (fun _ => R)) (LK lksize (snd l' - snd l)) sh l')
              (fun _ => TT)).Definition LK_at R lksize sh :=
  LKspec_ext R lksize sh.

(* Specifications: *)
Lemma data_at_rmap_makelock CS sh b ofs R phi length : 0 < length -> writable0_share sh -> app_pred (@data_at_ CS sh (Tarray (Tpointer Tvoid noattr) length noattr) (Vptr b ofs)) phi -> exists phi', rmap_makelock phi phi' (b, Ptrofs.unsigned ofs) R (size_chunk Mptr * length) /\ LK_at R (size_chunk Mptr * length) sh (b, Ptrofs.unsigned ofs) phi'.
Lemma nat_of_Z_nonzero z n: n <> O -> nat_of_Z z = n -> z = Z.of_nat n.
Lemma rmap_makelock_unique phi phi1 phi2 loc R len : rmap_makelock phi phi1 loc R len -> rmap_makelock phi phi2 loc R len -> phi1 = phi2.
Lemma rmap_freelock_unique phi phi1 phi2 m loc R len : rmap_freelock phi phi1 m loc R len -> rmap_freelock phi phi2 m loc R len -> phi1 = phi2.
Lemma rmap_freelock_pures_same phi phi' m loc R length : rmap_freelock phi phi' m loc R length -> pures_same phi phi'.
Lemma rmap_makelock_pures_same phi phi' loc R length : rmap_makelock phi phi' loc R length -> pures_same phi phi'.
Lemma glb_Lsh_unreadable: forall sh, ~ readable_share (Share.glb Share.Lsh sh).
Lemma readable_part_glb: forall (sh sh0 : Share.t) (r : readable_share sh) (r0 : readable_share sh0), Share.glb Share.Rsh sh0 = Share.glb Share.Rsh sh -> readable_part (readable_glb r0) = readable_part (readable_glb r).