Definition Complete (cenv: composite_env) (env: PTree.t A): Prop :=
  forall i,
    (exists co, PTree.get i cenv = Some co) <->
    (exists a, PTree.get i env = Some a).Definition Consistent (cenv: composite_env) (env: PTree.t A): Prop :=
  forall i co a,
    PTree.get i cenv = Some co ->
    PTree.get i env = Some a ->
    a = f_member (co_su co) (map
                              (fun it0: positive * type =>
                                 let (i0, t0) := it0 in
                                 (i0, t0, F env t0))
                              (co_members co)).Definition env_rec (i: positive) (co: composite) (env: PTree.t A): PTree.t A :=
  PTree.set i
    (f_member (co_su co) (map
                              (fun it0: positive * type =>
                                 let (i0, t0) := it0 in (i0, t0, F env t0))
                              (co_members co)))
    env.Definition Env (l: list (positive * composite)): PTree.t A :=
  fold_right
    (fun (ic: positive * composite) =>
       let (i, co) := ic in env_rec i co)
    (PTree.empty A)
    l.

(* Specifications: *)
Lemma F_PTree_set: forall t env i a, ~ In i (map fst (PTree.elements env)) -> relative_defined_type (PTree.elements env) t -> F env t = F (PTree.set i a env) t.
Lemma relative_defined_type_PTree_set: forall t (env: PTree.t A) i a, relative_defined_type (PTree.elements env) t -> relative_defined_type (PTree.elements (PTree.set i a env)) t.
Lemma NOT_IN: ~ In i0 (map fst (PTree.elements env)).
Lemma RDT_PTree: Forall (relative_defined_type (PTree.elements env)) (map snd (co_members co0)).
Lemma establish_In_equiv: forall i, In i (map fst ((i0, co0) :: l)) <-> In i (map fst (PTree.elements (env_rec i0 co0 env))).
Lemma establish_RDT: forall i co a, PTree.get i cenv = Some co -> PTree.get i (env_rec i0 co0 env) = Some a -> Forall (relative_defined_type (PTree.elements (env_rec i0 co0 env))) (map snd (co_members co)).
Lemma establish_main: Consistent cenv (env_rec i0 co0 env).
Lemma Consistency: forall cenv l, Permutation l (PTree.elements cenv) -> ordered_composite l -> Consistent cenv (Env l).
Lemma Completeness: forall cenv l, Permutation l (PTree.elements cenv) -> Complete cenv (Env l).