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.
Definition finite_idfun (f: key -> option (pshare * A)) :=
(exists l, forall a, ~In a l -> f a = None).
Definition mk_env_aux: forall f, finite_idfun f -> finMap f.
Definition mk_env (f: key -> option (pshare * A))  (FIN: finite_idfun f):  env :=
exist _ _ (mk_env_aux _ FIN).

Lemma env_finite: forall rho, finite_idfun (env_get rho).