Section NESTED_PRED.
Context {cs: compspecs}.
Definition nested_pred (atom_pred: type -> bool): type -> bool :=
type_func
(fun _ => bool)
(fun t => atom_pred t)
(fun t n a b => (atom_pred (Tarray t n a) && b)%bool)
(fun id a bl => (atom_pred (Tstruct id a) && fold_right andb true (decay bl))%bool)
(fun id a bl => (atom_pred (Tunion id a) && fold_right andb true (decay bl))%bool).
Definition nested_fields_pred (atom_pred: type -> bool) (m: members) : bool :=
fold_right (fun it b => (nested_pred atom_pred (field_type (fst it) m) && b)%bool) true m.

(* Specifications: *)
Lemma nested_pred_eq: forall atom_pred t,
nested_pred atom_pred t =
match t with
| Tarray t0 _ _ => (atom_pred t && nested_pred atom_pred t0)%bool
| Tstruct id _
| Tunion id _ => (atom_pred t && nested_fields_pred atom_pred (co_members (get_co id)))%bool
| _ => atom_pred t
end.
Lemma nested_pred_Tunion: forall (atom_pred: type -> bool) id a,
nested_pred atom_pred (Tunion id a) = true -> nested_fields_pred atom_pred (co_members (get_co id)) = true.
Lemma complete_legal_cosu_type_Tstruct: forall id a,
complete_legal_cosu_type (Tstruct id a) = true ->
co_su (get_co id) = Struct.
Lemma complete_legal_cosu_type_Tunion: forall id a,
complete_legal_cosu_type (Tunion id a) = true ->
co_su (get_co id) = Union.
Lemma Tarray_sizeof_0: forall t n a,
sizeof (Tarray t n a) = 0 ->
sizeof t = 0 \/ n <= 0.
Lemma Tstruct_sizeof_0: forall id a,
complete_legal_cosu_type (Tstruct id a) = true ->
sizeof (Tstruct id a) = 0 ->
forall i, in_members i (co_members (get_co id)) ->
sizeof (field_type i (co_members (get_co id))) = 0 /\
field_offset_next cenv_cs i (co_members (get_co id)) (co_sizeof (get_co id)) -
(field_offset cenv_cs i (co_members (get_co id)) +
sizeof (field_type i (co_members (get_co id)))) = 0.
Lemma Tunion_sizeof_0: forall id a,
complete_legal_cosu_type (Tunion id a) = true ->
sizeof (Tunion id a) = 0 ->
forall i, in_members i (co_members (get_co id)) ->
sizeof (field_type i (co_members (get_co id))) = 0.