Ltac do_map_arg :=
match goal with |- ?a = ?b =>
match a with context [map ?x _] =>
match b with context [map ?y _] => replace y with x; auto end end end.

(* Specifications: *)
Lemma preds_fmap_fmap:
forall f g pp, preds_fmap f (preds_fmap g pp) = preds_fmap (f oo g) pp.
Lemma resource_fmap_fmap:  forall f g r, resource_fmap f (resource_fmap g r) =
resource_fmap (f oo g) r.
Lemma resource_at_approx:
forall phi l,
phi @ l = resource_fmap (approx (level phi)) (phi @ l).
Lemma necR_resource_at:
forall phi phi' loc r,
necR phi phi' ->
phi @ loc = resource_fmap (approx (level phi)) r ->
phi' @ loc = resource_fmap (approx (level phi')) r.
Lemma necR_YES:
forall phi phi' loc sh k pp,
necR phi phi' ->
phi @ loc = YES sh k pp ->
phi' @ loc = YES sh k (preds_fmap (approx (level phi')) pp).
Lemma necR_PURE:
forall phi phi' loc k pp,
necR phi phi' ->
phi @ loc = PURE k pp ->
phi' @ loc = PURE k (preds_fmap (approx (level phi')) pp).
Lemma necR_NO:
forall phi phi' l, necR phi phi' ->
(phi@l = NO <-> phi'@l = NO).
Lemma resource_at_empty: forall phi, identity phi -> forall l, (phi @ l = NO \/ exists k, exists pds, phi @ l = PURE k pds).
Implicit Arguments resource_at_empty.
Lemma rmap_valid: forall r, AV.valid (res_option oo resource_at r).
Ltac inj_pair_tac :=
match goal with H: (@existT ?U ?P ?p ?x = @existT _ _ _ ?y) |- _ =>
generalize (@inj_pair2 U P p x y H); clear H; intro; try (subst x || subst y)
end.
Lemma preds_fmap_NoneP:
forall f, preds_fmap f NoneP = NoneP.
Lemma necR_YES':
forall phi phi' loc sh k,
necR phi phi' -> (phi@loc = YES sh k NoneP <-> phi'@loc = YES sh k NoneP).
Lemma necR_YES'':
forall phi phi' loc sh k,
necR phi phi' ->
((exists pp, phi@loc = YES sh k pp) <->
(exists pp, phi'@loc = YES sh k pp)).
Lemma resource_at_join_sub:
forall phi1 phi2 l,
join_sub phi1 phi2 -> join_sub (phi1@l) (phi2@l).
Lemma age1_res_option: forall phi phi' loc,
age1 phi = Some phi' -> res_option (phi @ loc) = res_option (phi' @ loc).
Lemma necR_res_option:
forall (phi phi' : rmap) (loc : AV.address),
necR phi phi' -> res_option (phi @ loc) = res_option (phi' @ loc).
Lemma age1_resource_at:
forall phi phi',
age1 phi = Some phi' ->
forall loc r,
phi @ loc = resource_fmap (approx (level phi)) r ->
phi' @ loc = resource_fmap (approx (level phi')) r.
Lemma age1_YES: forall phi phi' l sh k ,
age1 phi = Some phi' -> (phi @ l = YES sh k NoneP <-> phi' @ l = YES sh k NoneP).
Lemma empty_NO: forall r, identity r -> r = NO \/ exists k, exists pds, r = PURE k pds.
Lemma YES_join_full':
forall loc k P m1 m2 m3, join m1 m2 m3 -> m1@loc = YES pfullshare k P ->
m3 @ loc = YES pfullshare k P.
Lemma level_age_fash:
forall m m': rmap, level m = S (level m') -> exists m1, age m m1. (* /\ comparable m1 m'. *)
Lemma level_later_fash:
forall m m': rmap, (level m > level m')%nat  -> exists m1, laterR m m1 /\ level m1 = level m'.
Lemma resource_at_constructive_joins2:
forall phi1 phi2,
level phi1 = level phi2 ->
(forall loc, constructive_joins (phi1 @ loc) (phi2 @ loc)) ->
constructive_joins phi1 phi2.
Lemma resource_at_joins2:
forall phi1 phi2,
level phi1 = level phi2 ->
(forall loc, constructive_joins (phi1 @ loc) (phi2 @ loc)) ->
joins phi1 phi2.
Lemma resource_at_approx:
forall phi l,
resource_fmap (approx (level phi)) (approx (level phi)) (phi @ l) = phi @ l.
Lemma necR_resource_at:
forall phi phi' loc r,
necR phi phi' ->
phi @ loc = resource_fmap (approx (level phi)) (approx (level phi)) r ->
phi' @ loc = resource_fmap (approx (level phi')) (approx (level phi')) r.
Lemma necR_YES:
forall phi phi' loc rsh sh k pp,
necR phi phi' ->
phi @ loc = YES rsh sh k pp ->
phi' @ loc = YES rsh sh k (preds_fmap (approx (level phi')) (approx (level phi')) pp).
Lemma necR_PURE:
forall phi phi' loc k pp,
necR phi phi' ->
phi @ loc = PURE k pp ->
phi' @ loc = PURE k (preds_fmap (approx (level phi')) (approx (level phi')) pp).
Lemma necR_NO:
forall phi phi' l sh nsh, necR phi phi' ->
(phi@l = NO sh nsh <-> phi'@l = NO sh nsh).
Lemma resource_at_empty: forall phi,
identity phi ->
forall l, phi @ l = NO Share.bot bot_unreadable \/ exists k, exists pds, phi @ l = PURE k pds.