Skip to content

Commit

Permalink
Merge pull request #56 from Nemeras/master
Browse files Browse the repository at this point in the history
Fset of a fintype is now a fintype : fixes issue #55.
  • Loading branch information
CohenCyril authored Jul 31, 2019
2 parents a673387 + ad08154 commit 6d2b83d
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions finmap.v
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,9 @@ Definition fset_sub_eqMixin := Eval hnf in [eqMixin of fset_sub_type by <:].
Canonical fset_sub_eqType := Eval hnf in EqType fset_sub_type fset_sub_eqMixin.
Definition fset_sub_choiceMixin := Eval hnf in [choiceMixin of fset_sub_type by <:].
Canonical fset_sub_choiceType := Eval hnf in ChoiceType fset_sub_type fset_sub_choiceMixin.
Definition fset_countMixin (T : countType) := Eval hnf in [countMixin of {fset T} by <:].
Canonical fset_countType (T : countType) := Eval hnf in CountType {fset T} (fset_countMixin T).


Definition fset_sub_enum : seq fset_sub_type :=
undup (pmap insub (enum_fset A)).
Expand Down Expand Up @@ -2093,6 +2096,33 @@ Qed.

End PowerSetTheory.

Section FinTypeFset.
Variables (T : finType).

Definition pickle (s : {fset T}) :=
[set x in s].

Definition unpickle (s : {set T}) :=
[fset x | x in s]%fset.

Lemma pickleK : cancel pickle unpickle.
Proof. by move=> s; apply/fsetP=> x; rewrite !inE. Qed.

Lemma unpickleK : cancel unpickle pickle.
Proof. by move=> s; apply/setP=> x; rewrite !inE. Qed.

Definition fset_finMixin := CanFinMixin pickleK.
Canonical fset_finType := Eval hnf in FinType {fset T} fset_finMixin.

Lemma card_fsets : #|{:{fset T}}| = 2^#|T|.
Proof.
rewrite -(card_image (can_inj pickleK)) /=.
rewrite -cardsT -card_powerset powersetT; apply: eq_card.
move=> x; rewrite !inE; apply/mapP; exists (unpickle x).
by rewrite mem_enum. by rewrite unpickleK.
Qed.
End FinTypeFset.

Section BigFSet.
Variable (R : Type) (idx : R) (op : Monoid.law idx).
Variable (I : choiceType).
Expand Down

0 comments on commit 6d2b83d

Please sign in to comment.