Ltac type_induction t :=
  pattern t;
  match goal with
  | |- ?P t =>
    apply type_ind; clear t;
    let t := fresh "t" in
    intros t IH;
    let id := fresh "id" in
    destruct t as [ | id]
  end.Definition FT_aux id :=
    let m := co_members (get_co id) in
    ListType (map (fun it => A (field_type (fst it) m)) m).Fixpoint type_func_rec (n: nat) (t: type): A t :=
  match n with
  | 0 =>
    match t as t0 return A t0 with
    | Tstruct id =>
       match (Maps.PTree.get id cenv_cs)with
       | None => let m := co_members (get_co id) in
                       F_Tstruct id (ListTypeGen (fun it => A (field_type (fst it) m)) (fun it => F_Tint (field_type (fst it) m)) m)
       | _ => F_Tint (Tstruct id)
       end
    | t' => F_Tint t'
    end
  | S n' =>
    match t as t0 return A t0 with
    | Tstruct id =>  let m := co_members (get_co id) in
                            F_Tstruct id (ListTypeGen (fun it => A (field_type (fst it) m)) (fun it => type_func_rec n' (field_type (fst it) m)) m)
    | t' => F_Tint t'
    end
  end.Definition type_func t := type_func_rec (rank_type cenv_cs t) t.

Lemma rank_type_Tstruct: forall id co, (Maps.PTree.get id cenv_cs) = Some co -> rank_type cenv_cs (Tstruct id) = S (co_rank (get_co id)).