(* Lemma make_simple_rmap: forall n (f: AV.address -> resource) , AV.valid (fun l => res_option (f l)) -> (forall l, match f l with YES _ _ (SomeP _ _) => False | _ => True end) -> exists phi:rmap, level phi = n /\ resource_at phi = f. *)

(* Specifications: *)
Lemma approx_oo_approx':
forall n n', (n' >= n)%nat -> approx n oo approx n' = approx n.
Lemma approx_oo_approx: forall n, approx n oo approx n = approx n.
Lemma approx_approx' n n' x :
(n' >= n)%nat -> approx n (approx n' x) = approx n x.
Lemma resources_same_level:
forall f phi,
(forall l : AV.address, join_sub (f l) (phi @ l)) ->
resource_fmap (approx (level phi)) oo f = f.
Lemma deallocate:
forall (phi: rmap) (f g : AV.address -> resource),
AV.valid (res_option oo f) -> AV.valid (res_option oo g) ->
(forall l, join  (f l) (g l) (phi@l)) ->
exists phi1, exists phi2,
join phi1 phi2 phi /\ resource_at phi1 = f.
Lemma allocate:
forall (phi : rmap) (f : AV.address -> resource),
AV.valid (res_option oo f) ->
resource_fmap (approx (level phi)) oo f = f ->
(forall l, {r' | join (phi@l) (f l) r'}) ->
exists phi1 : rmap,
exists phi2 : rmap,
join phi phi1 phi2 /\ resource_at phi1 = f.
Lemma unsquash_inj : forall x y,
unsquash x = unsquash y -> x = y.
Lemma rmap_ext: forall phi1 phi2,
level phi1 = level phi2 ->
(forall l, phi1@l = phi2@l) ->
phi1=phi2.
Lemma resource_at_join:
forall phi1 phi2 phi3 loc,
join phi1 phi2 phi3 ->
join (phi1@loc) (phi2@loc) (phi3@loc).
Lemma resource_at_join2:
forall phi1 phi2 phi3,
level phi1 = level phi3 -> level phi2 = level phi3 ->
(forall loc, join (phi1@loc) (phi2@loc) (phi3@loc)) ->
join phi1 phi2 phi3.
Lemma all_resource_at_identity:
forall w, (forall l, identity (w@l)) ->
identity w.
Lemma ageN_squash : forall d n rm, le d n ->
ageN d (squash (n, rm)) = Some (squash ((n - d)%nat, rm)).
Lemma unageN: forall n (phi': rmap),   exists phi, ageN n phi = Some phi'.
Lemma YES_join_full:
forall n P r2 r3,
join (R.YES pfullshare n P) r2 r3 ->
r2 = NO.
Lemma YES_not_identity:
forall sh k Q, ~ identity (YES sh k Q).
Lemma YES_overlap:
forall (phi0 phi1: rmap) loc (sh : pshare) k k' p p',
joins phi0 phi1 -> phi1@loc = R.YES pfullshare k p ->
phi0@loc = R.YES sh k' p' -> False.
Lemma necR_NOx:
forall phi phi' l, necR phi phi' -> phi@l = NO -> phi'@l = NO.