(* 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. *)

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.