Module Rmaps (AV':ADR_VAL) : RMAPS with Module AV:=AV'.
Module AV:=AV'.
Module SM := StratModel(AV).
Module TyF. (* <: TY_FUNCTOR_PROP. *)
Definition F := pre_rmap.
Definition f_F := f_pre_rmap.
Definition other := unit.
End TyF.
Module TyFSA. (* <: TY_FUNCTOR_SA_PROP with Module TF:=TyF. *)
Module TF := TyF.
Instance Join_F: forall A, Join (F A) := _.
Definition Perm_F : Perm_paf f_F Join_F := fun A _ _ => Perm_pre_rmap A.
Definition Sep_F : Sep_paf f_F Join_F := fun (A : Type) (JA : Join A) _ _ => Sep_pre_rmap A.
Definition Canc_F : Canc_paf f_F Join_F := fun (A : Type) (JA : Join A) _ _ => Canc_pre_rmap A.
Definition Disj_F : Disj_paf f_F Join_F := fun (A : Type) (JA : Join A) _ _ => Disj_pre_rmap A.
Definition paf_F := paf_pre_rmap.
End TyFSA.
Module K := KnotHered(TyF).
Module KL := KnotHered_Lemmas(K).
Module KSa := KnotHeredSa(TyFSA)(K).
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 Sep_pre_rmap.
Instance Canc_rmap : Canc_alg rmap:= KSa.Canc_knot Canc_pre_rmap.
Instance Disj_rmap : Disj_alg rmap:= KSa.Disj_knot Disj_pre_rmap.
Instance ag_rmap : ageable rmap := KSa.K.ag_knot.
Instance Age_rmap: Age_alg rmap := KSa.asa_knot.
Inductive preds : Type :=
SomeP : forall A : list Type, (listprod A -> pred rmap) -> preds.
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 resource2res (r: resource): res (pred rmap) :=
match r with
| NO => NO' (pred rmap)
| YES p k (SomeP A l) => YES' (pred rmap) p 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' => NO
| YES' p k (existT A l) => YES p k (SomeP A l)
| PURE' k (existT A l) => PURE k (SomeP A l)
end.

Lemma res2resource2res: forall x, resource2res (res2resource x) = x.
Instance Sep_resource: Sep_alg resource.