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.

Lemma res2resource2res: forall x, resource2res (res2resource x) = x.