Module Rmaps (AV':ADR_VAL): RMAPS with Module AV:=AV'.
Module AV:=AV'.
Module SM := StratModel(AV).
Module TyF. (* <: TY_FUNCTOR_PROP. *)
Definition F := f_pre_rmap.
End TyF.
Module TyFSA <: KNOT_FULL_SA_INPUT with Module KI:=TyF.
Module KI := TyF.
Instance Join_F: forall A, Join (F A) := _.
Definition Perm_F : forall A, Perm_alg (F A) := Perm_pre_rmap.
Definition Sep_F := Sep_pre_rmap.
Definition paf_F := paf_pre_rmap.
End TyFSA.
Module K := Knot_MixVariantHeredProp(TyF).
Module KL := KnotLemmas_MixVariantHeredProp(K).
Module KSa := KnotFullSa(TyFSA)(K)(KL).
Definition rmap := K.knot.
Instance Join_rmap: Join rmap := KSa.Join_knot.
Instance Perm_rmap : Perm_alg rmap:= KSa.Perm_knot.
Instance Sep_rmap : Sep_alg rmap:= KSa.Sep_knot.
Instance ag_rmap : ageable rmap := K.ageable_knot.
Instance Age_rmap: Age_alg rmap := KSa.asa_knot.
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 resource2res (r: resource): res (pred rmap) :=
match r with
| NO sh nsh => NO' (pred rmap) sh nsh
| YES sh rsh k (SomeP A l) => YES' (pred rmap) sh rsh k (existT _ A l)
| PURE k (SomeP A l) => PURE' (pred rmap) k (existT _ A l)
end.
Definition res2resource (r: res (pred rmap)) : resource :=
match r with
| NO' sh nsh => NO sh nsh
| YES' sh rsh k (existT A l) => YES sh rsh k (SomeP A l)
| PURE' k (existT A l) => PURE k (SomeP A l)
end.

(* Specifications: *)
Lemma res2resource2res: forall x, resource2res (res2resource x) = x.
Definition ghost : Type := list (option ({g: Ghost & {a: @G g | ghost.valid a}} * preds)%type).