(*Require Import VST.concurrency.permjoin.*)
Set Bullet Behavior "Strict Subproofs".
Local Open Scope Z_scope.
Ltac app_pred_unfold :=
match goal with
H : context[app_pred (exist ?F ?f ?p) ?phi] |- _ =>
change (app_pred (exist F f p) phi) with (f phi) in H; cbv beta in H
| |- context[app_pred (exist ?F ?f ?p) ?phi] =>
change (app_pred (exist F f p) phi) with (f phi); cbv beta
end.

Lemma mapsto_unfold sh z b ofs phi loc :
readable_share sh ->
app_pred (mapsto sh (Tpointer Tvoid noattr) (offset_val (size_chunk Mptr * z) (Vptr b ofs)) Vundef) phi ->
if adr_range_dec (b, Ptrofs.unsigned (Ptrofs.add ofs (Ptrofs.repr (size_chunk Mptr * z)))) (size_chunk Mptr) loc then
exists p v,
phi @ loc =
YES sh p (VAL v) NoneP
else
identity (phi @ loc).