Canonical fset_sub_countType := Eval hnf in CountType fset_sub_type fset_sub_countMixin.
Definition fset_sub_finMixin :=
Eval hnf in UniqFinMixin (undup_uniq _) mem_fset_sub_enum.
Canonical fset_sub_finType := Eval hnf in FinType fset_sub_type fset_sub_finMixin.
Canonical fset_sub_subfinType := [subFinType of fset_sub_type].

(* Specifications: *)
Lemma enum_fsetE : enum_fset A = [seq val i | i <- enum fset_sub_type].
Lemma in_imfset (T : choiceType) (f : T -> K) (p : finmempred T) (x : T) :
in_mem x p -> f x \in imfset key f p.
Lemma mem_imfset (T : choiceType) (f : T -> K) (p : finmempred T) :
injective f -> forall (x : T), (f x \in imfset key f p) = (in_mem x p).
Lemma in_imfset2  (T1 : choiceType) (T2 : T1 -> choiceType)
(f : forall x, T2 x -> K) (p1 : finmempred T1)
(p2 : forall x, finmempred (T2 x)) (x : T1) (y : T2 x) :
in_mem x p1 -> in_mem y (p2 x) -> f x y \in imfset2 key f p1 p2.
Lemma enum_imfset (T : choiceType) (f : T -> K) (p : finmempred T) :
{in p &, injective f} ->
perm_eq (imfset key f p) [seq f x | x <- enum_finmem p].
Lemma enum_imfset2  (T1 : choiceType) (T2 : T1 -> choiceType)
(f : forall x, T2 x -> K) (p1 : finmempred T1)
(p2 : forall x, finmempred (T2 x)) :
{in  [pred t | p1 (tag t) & p2 _ (tagged t)] &,
injective (fun t : sigT T2 => f (tag t) (tagged t))} ->
perm_eq (imfset2 key f p1 p2)
(allsigs f (enum_finmem p1) (fun x => enum_finmem (p2 x))).