Module Type RMAPS.
Declare Module AV:ADR_VAL.
Parameter rmap : Type.
Inductive preds : Type :=
SomeP : forall A : TypeTree,
(forall ts: list Type, dependent_type_functor_rec ts A (pred rmap)) -> preds.
Definition NoneP := SomeP (ConstType unit) (fun _ => tt).
Inductive resource : Type :=
| NO: forall sh: Share.t, ~(readable_share sh) -> resource
| YES: forall sh: Share.t, readable_share sh -> kind -> preds -> resource
| PURE: kind -> preds -> resource.
Definition res_option (r:resource) : option (rshare * kind) :=
match r with
| NO _ _ => None
| YES sh rsh k _ => Some (readable_part rsh,k)
| PURE k _ => None
end.
Inductive res_join : resource -> resource -> resource -> Prop :=
| res_join_NO1 : forall sh1 nsh1 sh2 nsh2 sh3 nsh3
(RJ: join sh1 sh2 sh3),
res_join (NO sh1 nsh1) (NO sh2 nsh2) (NO sh3 nsh3)
| res_join_NO2 : forall sh1 rsh1 sh2 nsh2 sh3 rsh3 k p
(RJ: join sh1 sh2 sh3),
res_join (YES sh1 rsh1 k p) (NO sh2 nsh2) (YES sh3 rsh3 k p)
| res_join_NO3 : forall sh1 nsh1 sh2 rsh2 sh3 rsh3 k p
(RJ: join sh1 sh2 sh3),
res_join (NO sh1 nsh1) (YES sh2 rsh2 k p) (YES sh3 rsh3 k p)
| res_join_YES : forall sh1 rsh1 sh2 rsh2 sh3 rsh3 k p
(RJ: join sh1 sh2 sh3),
res_join (YES sh1 rsh1 k p) (YES sh2 rsh2 k p) (YES sh3 rsh3 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.
Definition preds_fmap (f g: pred rmap -> pred rmap) (x:preds) : preds :=
match x with SomeP A Q => SomeP A (fmap (fpi _) f g Q)
end.

(* Check whether the following two can be erased. *)
Axiom preds_fmap_id : preds_fmap (id _) (id _) = id preds.
Axiom preds_fmap_comp : forall f1 f2 g1 g2,
preds_fmap g1 g2 oo preds_fmap f1 f2 = preds_fmap (g1 oo f1) (f2 oo g2).