(******* FUNASSERT, MAKE_WORLD ********************)
Definition funspec := (list var * assert)%type.
Definition funspecs := table adr funspec.
Definition unpack (P: list adr -> pred rmap) (vl: listprod (@cons Type (list adr) nil)):  pred rmap := P (fst vl).
Definition call (P: list var * assert) (vl: list adr) : pred rmap :=
(!! (length vl = length (fst P)) && snd P (arguments (fst P) vl)).
Program Definition cont (nP: funspec)  (v: adr) : pred rmap :=
fun w => w @ v = PURE (FUN (fst nP)) (preds_fmap (approx (level w)) (SomeP (list adr::nil)
(unpack (call nP)))).
Next Obligation.
intros; intro; intros.
apply (age1_resource_at a a' H v (PURE (FUN (fst nP)) _));   simpl; auto.
Qed.
Definition funassert (G: funspecs) : pred rmap :=
(ALL  i:_, ALL P:_,  !! (table_get G i = Some P) --> cont P i)  &&
(ALL  i:_, ALL P:_,  cont P i --> !! exists P', table_get G i = Some P').
Definition make_world_aux (G: funspecs) (h: heap) (n: nat) (a: adr) : resource :=
match table_get G a with
| Some P => PURE (FUN (fst P))
(preds_fmap (approx n)
(SomeP (@cons Type (list adr) nil) (unpack (call P))))
| None => match heap_get h a with
| Some v => YES pfullshare (VAL v) NoneP
| None => NO
end
end.

(* Specifications: *)
Lemma make_world_aux_OK:
forall G h n,
resource_fmap (approx n) oo make_world_aux G h n =  make_world_aux G h n.