Definition exclusive_mpred (R : mpred) :=
(R * R |-- FF)%logic.
Program Definition weak_exclusive_mpred (P: mpred): mpred :=
fun w => exclusive_mpred (approx (S (level w)) P).
Next Obligation.
intros; hnf; intros.
unfold exclusive_mpred in *.
apply age_level in H.
eapply derives_trans, H0.
apply sepcon_derives; apply approx_derives_ge; omega.
Defined.
Definition lock_inv : share -> val -> mpred -> mpred :=
fun sh v R =>
(EX b : block, EX ofs : _,
!!(v = Vptr b ofs) &&
LKspec LKSIZE
R sh (b, Ptrofs.unsigned ofs))%logic.
Definition rec_inv sh v (Q R: mpred): Prop :=
(R = Q * |>lock_inv sh v R)%logic.
Definition weak_rec_inv sh v (Q R: mpred): mpred :=
(! (R <=> Q * |>lock_inv sh v R))%pred.

Lemma sepcon_equiv: forall P1 Q1 P2 Q2: mpred,
((P1 <=> Q1) && (P2 <=> Q2) |-- (P1 * P2) <=> (Q1 * Q2))%pred.