(* TODO: remove this file. Not useful at all. *)
(* Require Import VST.floyd.mapsto_memory_block. Require Import VST.floyd.data_at_rec_lemmas. Require Import VST.floyd.entailer. Require Import VST.floyd.closed_lemmas. *)
Local Open Scope logic.
(**********************************************  nf_sub2: substraction in type proj_except_reptype: big reptype value proj_reptype: small reptype value pair_reptype: reversion of proj/PROJ upd_reptype data_at_with_exception data_at_with_exception * field_at = data_at  Comment: for now, ident_eq will be used throughout all these definition because it is used in field_type and field_offset in compcert. However, it should be replaced by Pos.eqb here and in compcert.  Further plan: multi substraction, which is useful for definion tree structure  mnf_sub: substraction in type mproj_except_reptype: big reptype value mproj_reptype: small reptype value mnf_pair_reptype: reversion of proj/PROJ mupd_reptype data_at_with_mexception data_at_with_mexception * [field_at] = data_at  **********************************************)
(*** reptype level ***)
(* Fixpoint proj_reptype_structlist id f ofs (v: reptype_structlist f) : reptype (match field_offset_rec id f ofs, field_type id f with | Errors.OK _, Errors.OK t0 => t0 | _, _ => Tvoid end) := match f as f' return reptype_structlist f' -> reptype (match field_offset_rec id f' ofs, field_type id f' with | Errors.OK _, Errors.OK t0 => t0 | _, _ => Tvoid end) with | Fnil => fun _ => default_val _ | Fcons i0 t0 flds0 => if is_Fnil flds0 as b return ((if b then reptype t0 else reptype t0 * reptype_structlist flds0) -> reptype (match (if ident_eq id i0 then Errors.OK (align ofs (alignof t0)) else field_offset_rec id flds0 (align ofs (alignof t0) + sizeof t0)), (if ident_eq id i0 then Errors.OK t0 else field_type id flds0) with | Errors.OK _, Errors.OK t0 => t0 | _, _ => Tvoid end)) then fun v => if ident_eq id i0 as b0 return reptype (match (if b0 then Errors.OK (align ofs (alignof t0)) else field_offset_rec id flds0 (align ofs (alignof t0) + sizeof t0)), (if b0 then Errors.OK t0 else field_type id flds0) with | Errors.OK _, Errors.OK t0 => t0 | _, _ => Tvoid end) then v else default_val _ else fun v => if ident_eq id i0 as b0 return reptype (match (if b0 then Errors.OK (align ofs (alignof t0)) else field_offset_rec id flds0 (align ofs (alignof t0) + sizeof t0)), (if b0 then Errors.OK t0 else field_type id flds0) with | Errors.OK _, Errors.OK t0 => t0 | _, _ => Tvoid end) then fst v else proj_reptype_structlist id flds0 (align ofs (alignof t0) + sizeof t0) (snd v) end v.  Fixpoint proj_reptype_unionlist id f (v: reptype_unionlist f) : reptype (match field_type id f with | Errors.OK t0 => t0 | _ => Tvoid end) := match f as f' return reptype_unionlist f' -> reptype (match field_type id f' with | Errors.OK t0 => t0 | _ => Tvoid end) with | Fnil => fun _ => default_val _ | Fcons i0 t0 flds0 => if is_Fnil flds0 as b return ((if b then reptype t0 else reptype t0 + reptype_unionlist flds0) -> reptype (match (if ident_eq id i0 then Errors.OK t0 else field_type id flds0) with | Errors.OK t0 => t0 | _ => Tvoid end)) then fun v => if ident_eq id i0 as b0 return reptype (match (if b0 then Errors.OK t0 else field_type id flds0) with | Errors.OK t0 => t0 | _ => Tvoid end) then v else default_val _ else fun v => if ident_eq id i0 as b0 return reptype (match (if b0 then Errors.OK t0 else field_type id flds0) with | Errors.OK t0 => t0 | _ => Tvoid end) then match v with | inl v0 => v0 | _ => default_val _ end else match v with | inr v0 => proj_reptype_unionlist id flds0 v0 | _ => default_val _ end end v. *)
Definition proj_except_reptype (t: type) (g

(* Specifications: *)
Lemma gupd_reptype_structlist_aux: forall f i0 t0,
all_fields_replace_one2 f i0 t0 = match f with
| Fnil => Fnil
| Fcons i1 t1 flds0 =>
if ident_eq i0 i1
then Fcons i1 t0 flds0
else Fcons i1 t1 (all_fields_replace_one2 flds0 i0 t0)
end.
Lemma proj_reptype_cons_Tstruct: forall t id gfs i f a v v0,
nested_legal_fieldlist t = true ->
nested_field_type2 t gfs = Tstruct i f a ->
JMeq (proj_reptype t gfs v) v0 ->
JMeq (proj_reptype t (StructField id :: gfs) v) (proj_reptype_structlist id f 0 v0).