Module SimpleAdrVal (AV0: ADR_VAL0) <:
ADR_VAL with Definition address := AV0.address
with Definition kind := AV0.kind.
Definition address := address.
Definition some_address := some_address.
Definition kind := kind.
Definition valid (_: address -> option (pshare * kind)) := True.
Definition f_res : functor res := Functor ff_res.
Existing Instance f_res.
Inductive res_join (PRED : Type) : res PRED -> res PRED -> res PRED -> Prop :=
| res_join_NO1 : res_join PRED (NO' PRED) (NO' PRED) (NO' PRED)
| res_join_NO2 : forall sh k p, res_join PRED (NO' PRED) (YES' PRED sh k p) (YES' PRED sh k p)
| res_join_NO3 : forall sh k p, res_join PRED (YES' PRED sh k p) (NO' PRED) (YES' PRED sh k p)
| res_join_YES : forall (sh1 sh2 sh3:pshare) k p,
join sh1 sh2 sh3 ->
res_join PRED (YES' PRED sh1 k p) (YES' PRED sh2 k p) (YES' PRED sh3 k p)
| res_join_PURE : forall k p, res_join PRED (PURE' PRED k p) (PURE' PRED k p) (PURE' PRED k p).
Instance Join_res (PRED: Type) : Join (res PRED) := res_join PRED.
Instance pa_rj : forall PRED, @Perm_alg _ (res_join PRED).
Instance sa_rj : forall PRED, @Sep_alg _ (res_join PRED).
Instance da_rj : forall PRED, @Disj_alg _ (res_join PRED).
Instance paf_res : @pafunctor res f_res res_join.
Definition res_option (PRED : Type) (r: res PRED) :=
match r with
| NO' => None
| YES' sh k _ => Some (sh,k)
| PURE' _ _ => None
end.
Definition valid' A (w: address -> res A) : Prop :=
AV.valid (fun l => res_option A (w l)).
Definition pre_rmap (A:Type) := { m:address -> res A | valid' A m }.
Definition f_pre_rmap : functor pre_rmap :=
f_subset (f_fun _ f_res) _ valid'_res_map.
Existing Instance f_pre_rmap.
Instance Join_pre_rmap (A: Type) : Join (pre_rmap A) :=
Join_prop _ (Join_fun address (res A) (res_join A)) (valid' A).
Instance paf_pre_rmap : pafunctor f_pre_rmap :=
saf_subset  (paf_fun address paf_res) valid' valid'_res_map valid'_res_map2.

Lemma pre_rmap_sa_valid_core (A: Type):
forall x : address -> res A,
valid' A x ->
valid' A  (@core (address -> res A) (Join_fun address (res A) (res_join A))
(Sep_fun address (res A) (res_join A) (sa_rj A)) x).