Definition NoneP := SomeP ((Void:Type)::nil) (fun _ => FF).
Definition hair := preds.
Inductive resource : Type :=
| NO
| YES: pshare -> kind -> preds -> resource
| PURE: kind -> preds -> resource.
Definition res_option (r:resource) :=
match r with
| NO => None
| YES sh k _ => Some (sh,k)
| PURE k _ => None
end.
Inductive res_join : resource -> resource -> resource -> Prop :=
| res_join_NO1 : res_join NO NO NO
| res_join_NO2 : forall sh k p, res_join (YES sh k p) NO (YES sh k p)
| res_join_NO3 : forall sh k p, res_join NO (YES sh k p) (YES sh k p)
| res_join_YES : forall (sh1 sh2 sh3:pshare) k p,
join sh1 sh2 sh3 ->
res_join (YES sh1 k p) (YES sh2 k p) (YES sh3 k p)
| res_join_PURE : forall k p, res_join (PURE k p) (PURE k p) (PURE k p).
Instance Join_resource: Join resource := res_join.

(* Specifications: *)
Axiom Perm_resource: Perm_alg resource. Existing Instance Perm_resource.
Axiom Sep_resource: Sep_alg resource. Existing Instance Sep_resource.
Axiom Canc_resource: Canc_alg resource. Existing Instance Canc_resource.
Axiom Disj_resource: Disj_alg resource. Existing Instance Disj_resource.
Definition preds_fmap (f:pred rmap -> pred rmap) (x:preds) : preds :=
match x with SomeP A Q => SomeP A (f oo Q)
end.
Axiom preds_fmap_id : preds_fmap (id _) = id preds.
Axiom preds_fmap_comp : forall f g, preds_fmap g oo preds_fmap f = preds_fmap (g oo f).
Definition resource_fmap (f:pred rmap -> pred rmap) (x:resource) : resource :=
match x with
| NO => NO
| YES sh k p => YES sh k (preds_fmap f p)
| PURE k p => PURE k (preds_fmap f p)
end.
Axiom resource_fmap_id : resource_fmap (id _) = id resource.
Axiom resource_fmap_comp : forall f g, resource_fmap g oo resource_fmap f = resource_fmap (g oo f).
Definition valid (m: address -> resource) : Prop :=
AV.valid  (res_option oo m).
Axiom valid_res_map : forall f m, valid m -> valid (resource_fmap f oo m).
Axiom rmapj_valid_join : forall (x y z : address -> resource),
join x y z -> valid x -> valid y -> valid z.
Axiom rmapj_valid_core: forall x: address -> resource, valid x -> valid (core x).
Definition rmap' := sig valid.