End ENVSEC.
End ENV.
Module Env: ENV.
Section ENVSEC.
Context {key: Type}{A: Type}.
Instance JA: Join A := Join_equiv A.
Definition env := fpm key (pshare * A).
Definition env_get (rho: env) (id: key) : option (pshare * A) := lookup_fpm rho id.
Definition env_set_sh {KE: EqDec key} (id: key) (v: option (pshare * A)) (rho: env) : env :=
insert'_fpm _ id v rho.
Definition env_set {KE: EqDec key} (id: key) (v: A) (rho: env) : env :=
insert_fpm _ id (pfullshare,v) rho.

(* Specifications: *)
Lemma env_gss {KE: EqDec key} : forall i a rho, env_get (env_set i a rho) i = Some (pfullshare, a).
Lemma env_gso {KE: EqDec key}: forall i j a rho, i <> j -> env_get (env_set j a rho) i = env_get rho i.
Lemma env_gss_sh {KE: EqDec key}: forall i v rho, env_get (env_set_sh i v rho) i = v.
Lemma env_gso_sh {KE: EqDec key} : forall i j v rho, i <> j -> env_get (env_set_sh j v rho) i = env_get rho i.
Definition finite_idfun (f: key -> option (pshare * A)) :=
(exists l, forall a, ~In a l -> f a = None).