Program Definition p2p (p:(pred rmap)) : K.predicate :=
fun phi_e => p (fst phi_e).
Next Obligation.
destruct a as [a b]; destruct a' as [a' b'].
unfold age, age1 in H. simpl in H. invSome. simpl in *.
eapply pred_hereditary; eauto.
Qed.
Program Definition p2p' (p:K.predicate) : (pred rmap) :=
fun (v:rmap) => p (v, tt).
Next Obligation.
unfold age in H; simpl in H.
unfold rmap in *.
eapply pred_hereditary; eauto.
unfold age, age1; simpl.
unfold ag_rmap in H. rewrite H. auto.
Qed.
Definition squash (n_rm:nat * rmap') : rmap :=
match n_rm with (n,rm) => K.squash (n, fmap p2p (rmap'2pre_rmap rm)) end.
Definition unsquash (phi:rmap) : (nat * rmap') :=
match K.unsquash phi with (n,rm) => (n, pre_rmap2rmap' (fmap p2p' rm)) end.
Definition rmap_level (phi:rmap) : nat := fst (unsquash phi).
Definition resource_at (phi:rmap) : address -> resource := proj1_sig (snd (unsquash phi)).
Infix "@" := resource_at (at level 50, no associativity).

Lemma pred_ext': forall {A} `{agA: ageable A} P Q,
(forall x, app_pred P x <-> app_pred Q x) -> P = Q.