mapsto and memory_block -maybe move the lemmas using them elsewhere?*)
Definition size_compatible {C: compspecs} t p :=
match p with
| Vptr b i_ofs => Ptrofs.unsigned i_ofs + sizeof t < Ptrofs.modulus
| _ => True
end.

(* Specifications: *)
Lemma nonlock_permission_bytes_valid_pointer: forall sh b ofs n i,
0 <= ofs /\ ofs + n <= Ptrofs.modulus ->
0 <= i < n ->
nonidentity sh ->
nonlock_permission_bytes sh (b, ofs) n |-- valid_pointer (Vptr b (Ptrofs.repr (ofs + i))).
Lemma VALspec_range_valid_pointer: forall sh b ofs n i,
0 <= ofs /\ ofs + n <= Ptrofs.modulus ->
0 <= i < n ->
VALspec_range n sh (b, ofs) |-- valid_pointer (Vptr b (Ptrofs.repr (ofs + i))).
Lemma address_mapsto_valid_pointer: forall ch v sh b ofs i,
0 <= ofs /\ ofs + size_chunk ch <= Ptrofs.modulus ->
0 <= i < size_chunk ch ->
address_mapsto ch v sh (b, ofs) |-- valid_pointer (Vptr b (Ptrofs.repr (ofs + i))).
Lemma mapsto_valid_pointer: forall {cs: compspecs} sh t p v i,
size_compatible t p ->
0 <= i < sizeof t ->
nonidentity sh ->
mapsto sh t p v |-- valid_pointer (offset_val i p).
Lemma memory_block_valid_pointer: forall {cs: compspecs} sh n p i,
0 <= i < n ->
nonidentity sh ->
memory_block sh n p |-- valid_pointer (offset_val i p).
Lemma VALspec_range_weak_valid_pointer: forall sh b ofs n i,
0 <= ofs /\ ofs + n < Ptrofs.modulus -> 0 <= i <= n -> 0 < n ->
VALspec_range n sh (b, ofs) |-- weak_valid_pointer (Vptr b (Ptrofs.repr (ofs + i))).
Lemma nonlock_permission_bytes_weak_valid_pointer: forall sh b ofs n i,
0 <= ofs /\ ofs + n < Ptrofs.modulus -> 0 <= i <= n -> 0 < n -> nonidentity sh ->
nonlock_permission_bytes sh (b, ofs) n |--
weak_valid_pointer (Vptr b (Ptrofs.repr (ofs + i))).
Lemma memory_block_weak_valid_pointer: forall {cs: compspecs} sh n p i,
0 <= i <= n -> 0 < n -> nonidentity sh ->
memory_block sh n p |-- weak_valid_pointer (offset_val i p).