(*
Lemma union_default_filter_legal: forall m, m <> nil ->
  legal_compact_sum_filter (union_default_filter m) m = true.
Proof.
  intros.
  destruct m; auto.
  simpl.
  destruct (member_dec p p); [| congruence].
  auto.
Qed.
*)

Definition struct_default_val (m : members) := compact_prod_gen (fun it => default_val (field_type (fst it) m)) m.Definition union_default_val (m : members) := compact_sum_gen (fun it => true) (fun it => default_val (field_type (fst it) m)) m.

(* Specifications: *)
Lemma compact_prod_sigT_compact_prod_gen: forall {A B} {P: A -> Type} (genT: B -> A) (genV: forall b: B, P (genT b)) (gen: B -> sigT P) (l: list B), (forall b, gen b = existT P (genT b) (genV b)) -> JMeq (compact_prod_sigT_value (map gen l)) (compact_prod_gen genV l).
Lemma compact_sum_sigT_compact_sum_gen: forall {A B} {P: A -> Type} (genT: B -> A) (genV: forall b: B, P (genT b)) (filter: B -> bool) (gen: B -> sigT P) (l: list B), (forall b, gen b = existT P (genT b) (genV b)) -> is_default_filter filter l -> JMeq (compact_sum_sigT_value (map gen l)) (compact_sum_gen filter genV l).
Lemma default_val_eq: forall t, default_val t = fold_reptype match t as t' return REPTYPE t' with | Tvoid | Tfunction _ _ _ => tt | Tint _ _ _ | Tlong _ _ | Tfloat _ _ | Tpointer _ _ => Vundef | Tarray t0 n _ => list_repeat (Z.to_nat n) (default_val t0) | Tstruct id _ => struct_default_val (co_members (get_co id)) | Tunion id _ => union_default_val (co_members (get_co id)) end.