(* 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
(* Module Test. Definition T1 := Tstruct 1%positive (Fcons 101%positive tint (Fcons 102%positive tint Fnil)) noattr. Definition T2 := Tstruct 2%positive (Fcons 201%positive T1 (Fcons 202%positive T1 Fnil)) noattr. Definition T3 := Tstruct 3%positive (Fcons 301%positive T2 (Fcons 302%positive T2 Fnil)) noattr.  Definition v : reptype T3 := (((Vint (Int.repr 1), Vint (Int.repr 2)), (Vint (Int.repr 3), Vint (Int.repr 4))), ((Vint (Int.repr 5), Vint (Int.repr 6)), (Vint (Int.repr 7), Vint (Int.repr 8)))).  Arguments eq_rect_r / {A} {x} P H {y} H0. Arguments proj_except_reptype / t gf gfs v.  Lemma Test1: JMeq (proj_reptype T3 (StructField 201%positive :: StructField 302%positive :: nil) v) (Vint (Int.repr 5), Vint (Int.repr 6)).  Lemma Test2: JMeq (upd_reptype T3 (StructField 201%positive :: StructField 302%positive :: nil) v (Vint (Int.repr 15), Vint (Int.repr 16))) (((Vint (Int.repr 1), Vint (Int.repr 2)), (Vint (Int.repr 3), Vint (Int.repr 4))), ((Vint (Int.repr 15), Vint (Int.repr 16)), (Vint (Int.repr 7), Vint (Int.repr 8)))).  Lemma Test3: JMeq (proj_except_reptype T3 (StructField 201%positive) (StructField 302%positive :: nil) v) (((Vint (Int.repr 1), Vint (Int.repr 2)), (Vint (Int.repr 3), Vint (Int.repr 4))), ((Vint (Int.repr 7), Vint (Int.repr 8)))). End Test. *)
Definition gupd_reptype_array_is_pair: forall t n a i t0,
0 <= i < n ->
sigT (fun F => sigT (fun G =>
forall v v0,
F (gupd_reptype_array t n a i t0 v v0) =
(proj_except_reptype_array t n a i v, v0) /\
gupd_reptype_array t n a i t0 v v0 =
G (proj_except_reptype_array t n a i v, v0)
)).

Lemma proj_except_reptype_is_proj_except_reptye1_gupd_reptype: forall t gf gfs v,
legal_nested_field t (gf :: gfs) ->
JMeq (proj_except_reptype t gf gfs v)
(gupd_reptype t gfs _ v
(proj_except_reptype _ gf nil (proj_reptype t gfs v))).