Module mathcomp.classical.cardinality
From HB Require Import structures.From mathcomp Require Import boot order finmap ssralg ssrnum ssrint rat.
From mathcomp Require Import mathcomp_extra boolp classical_sets functions.
Unset SsrOldRewriteGoalsOrder.
Set Implicit Arguments.
Unset Strict Implicit.
Unset Printing Implicit Defensive.
Reserved Notation "A '#<=' B" (at level 79, format "A '#<=' B").
Reserved Notation "A '#>=' B" (at level 79, format "A '#>=' B").
Reserved Notation "A '#=' B" (at level 79, format "A '#=' B").
Reserved Notation "A '#!=' B" (at level 79, format "A '#!=' B").
Import Order.Theory GRing.Theory.
Local Open Scope classical_set_scope.
Local Open Scope ring_scope.
Local Open Scope function_scope.
Declare Scope card_scope.
Delimit Scope card_scope with card.
Local Open Scope card_scope.
Definition
Source code
`[< $|{injfun [set: A] >-> [set: B]}| >].
Notation
Source code
Notation
Source code
Definition
card_le : forall [T U : Type], set T -> set U -> bool card_le is not universe polymorphic Arguments card_le [T U]%_type_scope (A B)%_classical_set_scope card_le is transparent Expands to: Constant mathcomp.classical.cardinality.card_le Declared in library mathcomp.classical.cardinality, line 61, characters 11-18
Source code
`[< $|{bij [set: A] >-> [set: B]}| >].
Notation
Source code
Notation
Source code
Definition
card_eq : forall [T U : Type], set T -> set U -> bool card_eq is not universe polymorphic Arguments card_eq [T U]%_type_scope (A B)%_classical_set_scope card_eq is transparent Expands to: Constant mathcomp.classical.cardinality.card_eq Declared in library mathcomp.classical.cardinality, line 66, characters 11-18
Source code
Notation
Source code
Notation
Source code
Lemma
Source code
$|{inj A >-> U}| <-> exists : T -> U, set_inj A f.
Proof.
Lemma
Source code
$|{surj A >-> B}| <-> exists , set_surj A B f.
Proof.
Lemma
Source code
$|{bij A >-> B}| <-> exists , set_bij A B f.
Proof.
Lemma
Source code
$|{surjfun A >-> B}| <-> exists , B = f @` A.
Proof.
Lemma
Source code
$|{injfun A >-> B}| <-> exists2 : T -> U, set_fun A B f & set_inj A f.
Lemma
Source code
reflect $|{injfun [set: A] >-> [set: B]}| (A #<= B).
Proof.
Lemma
Source code
Lemma
Source code
reflect $|{injfun A >-> B}| (A #<= B).
Lemma
Source code
reflect $|{inj A >-> U}| (A #<= [set: U]).
Proof.
Lemma
Source code
reflect (exists : T -> U, {in A &, injective f}) (A #<= [set: U]).
Proof.
Lemma
Source code
reflect $|{splitinjfun A >-> B}| (A #<= B).
Lemma
Source code
#[global] Hint Resolve card_ge0 : core.
Lemma
Source code
Proof.
Lemma
Source code
Lemma
Source code
reflect $|{bij [set: A] >-> [set: B]}| (A #= B).
Proof.
Lemma
Source code
Lemma
Source code
reflect $| {bij A >-> B} | (A #= B).
Lemma
Source code
reflect (exists : A -> B, bijective f) (A #= B).
Lemma
Source code
reflect $|{splitbij [set: A] >-> [set: B]}| (A #= B).
Lemma
Source code
reflect (exists , set_bij A B f) (A #= B).
Lemma
Source code
reflect $| {splitbij A >-> B} | (A #= B).
Lemma
Source code
#[global] Hint Resolve card_eqxx : core.
Lemma
Source code
Proof.
Section empty1.
Implicit Types (T : emptyType).
Lemma
Source code
Lemma
Source code
Proof.
Source code
Definition
finite_set : forall {T : Type}, set T -> Prop finite_set is not universe polymorphic Arguments finite_set {T}%_type_scope A%_classical_set_scope finite_set is transparent Expands to: Constant mathcomp.classical.cardinality.finite_set Declared in library mathcomp.classical.cardinality, line 71, characters 11-21
Source code
End empty1.
Theorem
Source code
A #<= B -> B #<= A -> A #= B.
Proof.
elim/Ppointed: U => U in B *; first by rewrite !emptyE_subdef => ->.
suff {A B} card_eq ( : set U) : B `<=` A -> A #<= B -> A #= B.
move=> /ppcard_leP[f] /ppcard_leP[g].
have /(_ _)/ppcard_eqP[|h] := card_eq _ _ (fun_image_sub f).
by apply/pcard_leP; squash ([fun f in A] \o g).
by apply/pcard_eqP; squash ((split h)^-1 \o [fun f in A]).
move=> BA /ppcard_leP[u]; have uAB := 'funS_u.
pose C_ := fix C := if n is n.+1 then u @` C n else A `\` B.
pose C := \bigcup_ C_ n; have CA : C `<=` A.
by move=> + [] => /[swap]; elim=> [|i IH] y _ []// x /IH/uAB/BA + <-; apply.
have uC: {homo u : / x \in C}.
by move=> x; rewrite !inE => -[i _ Cix]; exists i.+1 => //; exists x.
apply/card_set_bijP; exists (fun => if x \in C then u x else x); split.
- move=> x Ax; case: ifPn; first by move=> _; apply: uAB.
by move/negP; apply: contra_notP => NBx; rewrite inE; exists 0%N.
- move=> x y xA yA; have := 'inj_u xA yA.
have [xC|] := boolP (x \in C); have [yC|] := boolP (y \in C) => // + _.
by move=> /[swap]<-; rewrite uC// xC.
by move=> /[swap]->; rewrite uC// yC.
- move=> y /[dup] By /BA Ay/=.
case: (boolP (y \in C)); last by exists y; rewrite // ifN.
rewrite inE => -[[|i]/= _ []// x Cix <-]; have Cx : C x by exists i.
by exists x; [exact: CA|rewrite ifT// inE].
Qed.
Lemma
Source code
Lemma
Source code
(A #= B) = (A #<= B) && (B #<= A).
Proof.
Lemma
Source code
(A #= B) <-> (A #<= B) /\ (B #<= A).
Proof.
Lemma
Source code
#[global] Hint Resolve card_lexx : core.
Lemma
Source code
Lemma
Source code
Lemma
Source code
Proof.
by apply/pcard_leP; squash (pinv A f).
Qed.
Lemma
Source code
Arguments inj_card_eq {T U A f}.
Lemma
Source code
Proof.
Lemma
Source code
Proof.
Lemma
Source code
Lemma
Source code
A #<= B -> B #<= C -> A #<= C.
Lemma
Source code
Proof.
Lemma
Source code
A #= B -> B #= C -> A #= C.
Lemma
Source code
Source code
A #= B -> (A #<= C) = (B #<= C).
Proof.
Lemma
Source code
Source code
A #= B -> (C #<= A) = (C #<= B).
Proof.
Lemma
Source code
Source code
A #= B -> (A #= C) = (B #= C).
Proof.
Lemma
Source code
Source code
A #= B -> (C #= A) = (C #= B).
Proof.
Lemma
Source code
X `<=` A -> (f @` X #<= Y) = (X #<= Y).
Proof.
Lemma
Source code
X `<=` A -> (Y #<= f @` X) = (Y #<= X).
Proof.
Lemma
Source code
X `<=` A -> Y `<=` A ->
(f @` X #<= f @` Y) = (X #<= Y).
Proof.
Lemma
Source code
X `<=` A -> (f @` X #= Y) = (X #= Y).
Proof.
Lemma
Source code
X `<=` A -> (Y #= f @` X) = (Y #= X).
Proof.
Lemma
Source code
X `<=` A -> Y `<=` A ->
(f @` X #= f @` Y) = (X #= Y).
Proof.
Lemma
Source code
(some @` A #<= B) = (A #<= B).
Proof.
Lemma
Source code
(A #<= some @` B) = (A #<= B).
Proof.
Lemma
Source code
(some @` A #<= some @` B) = (A #<= B).
Proof.
Lemma
Source code
(some @` A #= B) = (A #= B).
Lemma
Source code
(A #= some @` B) = (A #= B).
Lemma
Source code
(some @` A #= some @` B) = (A #= B).
Proof.
Lemma
Source code
Proof.
Lemma
Source code
Proof.
Lemma
Source code
Lemma
Source code
(B #= A) = (B == set0).
Lemma
Source code
(A #= B) = (B == set0).
Proof.
Definition
emptyE_subdef : (forall T : emptyType, all_equal_to (set0 : set T)) * (forall (T : emptyType) (U : Type) (A : set T) (B : set U), (A #<= B)%card) * (forall (T : emptyType) (U : Type) (A : set T) (B : set U), (B #<= A)%card = (B == set0)) * (forall (T : eqType) (x y : T), (x == y : Prop) = (x = y)) emptyE_subdef is not universe polymorphic emptyE_subdef is transparent Expands to: Constant mathcomp.classical.cardinality.emptyE_subdef Declared in library mathcomp.classical.cardinality, line 191, characters 11-24
Source code
Lemma
Source code
#[global] Hint Resolve card_setT : core.
Lemma
Source code
#[global] Hint Resolve card_setT : core.
Lemma
Source code
Proof.
Lemma
Source code
reflect (exists , set_surj B A g) (A #<= B).
Proof.
Lemma
Source code
reflect $|{surj B >-> A}| (A #<= B).
Proof.
Lemma
Source code
reflect $|{surj B >-> some @` A}| (A #<= B).
Proof.
Lemma
Source code
reflect (A = set0 \/ $|{surjfun B >-> A}|) (A #<= B).
Proof.
elim/Ppointed: T => T in A *; first by rewrite !emptyE; left.
elim/Ppointed: U => U in B *; first by rewrite !emptyE => ->; right; squash any.
move=> /pcard_geP[f]; case: (eqVneq A set0); first by left.
move=> /set0P[x Ax]; right; apply/surjfunPex.
exists (fun => if f y \in A then f y else x).
apply/seteqP; split.
by move=> x' /[dup] /= /'surj_f [y By <-] Afy; exists y; rewrite ?ifT// inE.
by apply/image_subP => y By; case: ifPn; rewrite (inE, notin_setE).
Qed.
Lemma
Source code
Proof.
Lemma
Source code
reflect $|{bij A >-> some @` B}| (A #= B).
Lemma
Source code
reflect $|{splitbij some @` A >-> some @` B}| (A #= B).
Proof.
Lemma
Source code
Proof.
Lemma
Source code
Proof.
Arguments image_subset {aT rT} f [A B].
Lemma
Source code
reflect (exists2 , C #= A & C `<=` B) (A #<= B).
Proof.
#[deprecated(since="mathcomp-analysis 1.15.0", note="To be removed, use other lemmas instead.")]
Lemma
Source code
f @` `I_m `<=` `I_n -> (m <= n)%N.
Proof.
Definition
emptyE : (forall T : emptyType, all_equal_to (set0 : set T)) * (forall (T : emptyType) (U : Type) (A : set T) (B : set U), (A #<= B)%card) * (forall (T : emptyType) (U : Type) (A : set T) (B : set U), (B #<= A)%card = (B == set0)) * (forall (T : eqType) (x y : T), (x == y : Prop) = (x = y)) * (forall (T : emptyType) (U : Type) (A : set T) (B : set U), (B #= A)%card = (B == set0)) * (forall (T : emptyType) (U : Type) (A : set T) (B : set U), (A #= B)%card = (B == set0)) emptyE is not universe polymorphic emptyE is transparent Expands to: Constant mathcomp.classical.cardinality.emptyE Declared in library mathcomp.classical.cardinality, line 363, characters 11-17
Source code
Lemma
Source code
A #= B -> countable A = countable B.
Proof.
Lemma
Source code
#[global] Hint Resolve countableP : core.
Lemma
Source code
Proof.
Lemma
Source code
reflect (exists : T -> nat, {in A &, injective f}) (countable A).
Proof.
Lemma
Source code
reflect (exists : set nat, (A #= B)%card) (countable A).
Proof.
Lemma
Source code
countable B -> countable A.
Proof.
Lemma
Source code
Proof.
Lemma
Source code
Proof.
Lemma
Source code
Lemma
Source code
finite_set A <-> exists : {fset T}, A = [set` X].
Proof.
exists #|{: X}|; rewrite (card_eqr card_II).
by apply/card_eqP; squash (to_setT \o enum_rank \o val_finset).
rewrite (card_eqr card_II) => /card_esym/card_eqVP[f]; pose g := f \o to_setT.
exists [fset val (g i) | in 'I_n]%fset.
apply/seteqP; split=> [x /mem_set Ax|_ /imfsetP[i _ ->]]; last exact: set_valP.
by apply/imfsetP; exists (g^-1 (SigSub Ax)); rewrite ?[g _]invK//= inE.
Qed.
Lemma
Source code
A `<=` [set` X] -> finite_set A.
Proof.
Lemma
Source code
Proof.
Lemma
Source code
Proof.
Lemma
Source code
Proof.
Lemma
Source code
finite_set A <-> exists : seq T, A = [set` s].
Proof.
Lemma
Source code
Proof.
Lemma
Source code
Proof.
Lemma
Source code
finite_set [set` P].
Proof.
Hint Extern 0 (finite_set [set` _]) => solve [apply: finite_finpred] : core.
Lemma
Source code
#[global] Hint Resolve finite_finset : core.
Lemma
Source code
Proof.
Lemma
Source code
Proof.
by rewrite !emptyE; split=> // /(congr1 (@^~ 0%N))/=; rewrite propeqE => -[].
split=> [Ainfinite| + /finite_setP[n eqAI]]; last first.
rewrite (card_le_eqr eqAI) => le_nat_n.
suff: `I_n.+1 #<= `I_n by rewrite card_le_II ltnn.
exact: card_le_trans (subset_card_le _) le_nat_n.
have /all_sig2[f Af fX] : forall : {fset T}, { | x \in A & x \notin X}.
move=> X; apply/sig2W; apply: contra_notP Ainfinite => nAX; apply/finite_fsetP.
exists [fset in X | x \in A]%fset; rewrite eqEsubset; split; last first.
by move=> x/=; rewrite !inE => /andP[_]; rewrite inE.
move=> x Ax /=; rewrite !inE/=; apply/andP; split; rewrite ?inE//.
by apply: contra_notT nAX => xNX; exists x; rewrite ?inE.
do [under [forall : {fset _}, _]eq_forall do rewrite inE] in Af *.
suff [g gE] : exists : nat -> T,
forall , g n = f [fset g k | in iota 0 n]%fset.
have /Pinj[h hE] : {in setT &, injective g}.
move=> i j _ _; apply: contra_eq; wlog lt_ij : i j / (i < j)%N => [hwlog|_].
by case: ltngtP => // ij _; [|rewrite eq_sym];
apply: hwlog=> //; rewrite lt_eqF//.
rewrite [g j]gE; set X := (X in f X); have := fX X.
by apply: contraNneq => <-; apply/imfsetP; exists i => //=; rewrite mem_iota.
have/injPfun[i _] : {homo h : / setT x >-> A x} by move=> i; rewrite -hE gE.
by apply/pcard_leP; squash i.
pose g := fix g := if n isn't n'.+1 then f fset0
else f [fset g n' i | in iota 0 k]%fset.
exists (fun => g n n) => n.
suff {n} gn n k : (k <= n)%N -> g n k = f [fset g k k | in iota 0 k]%fset.
by rewrite gn//; congr f; apply/fsetP => k.
have [m] := ubnP n; elim: m n k => //= m IHm [|n] k /=.
rewrite leqn0 => _ /eqP->/=.
congr f; apply/fsetP => x; rewrite !inE; symmetry.
by apply/imfsetP => /= -[].
rewrite ltnS => ltmn lekSn /=; congr f; apply/fsetP => i.
by apply/imfsetP/imfsetP => /= -[j]; rewrite mem_iota/= => jk ->;
exists j; rewrite ?mem_iota//= ?add0n ?IHm//;
by [rewrite (leq_trans jk)// (leq_trans lekSn)|rewrite -ltnS (leq_trans jk)].
Qed.
Lemma
Source code
Lemma
Source code
A #<= B -> finite_set B -> finite_set A.
Proof.
Lemma
Source code
finite_set B -> finite_set A.
Proof.
Lemma
Source code
cofinite_set A -> cofinite_set B.
Proof.
Lemma
Source code
infinite_set A -> infinite_set B.
Proof.
Lemma
Source code
Proof.
by apply: card_le_finite leAn _; exists n.
Qed.
Lemma
Source code
{in f @^-1` B &, injective f} -> f @^-1` B #<= B.
Proof.
by apply: subset_card_le; apply: image_preimage_subset.
Qed.
Corollary
Source code
{in f @^-1` B &, injective f} -> finite_set B -> finite_set (f @^-1` B).
Proof.
Lemma
Source code
A #= B -> finite_set A = finite_set B.
Proof.
Lemma
Source code
Proof.
Lemma
Source code
Proof.
Lemma
Source code
finite_set (A `*` B) -> finite_set A \/ finite_set B.
Proof.
Lemma
Source code
infinite_set A -> infinite_set B -> infinite_set (A `*` B).
Proof.
Lemma
Source code
Proof.
Lemma
Source code
Proof.
Lemma
Source code
Proof.
Lemma
Source code
Proof.
Lemma
Source code
cofinite_set A \/ cofinite_set B -> cofinite_set (A `|` B).
Proof.
Lemma
Source code
finite_set (A `|` B) = (finite_set A /\ finite_set B).
Proof.
by move=> finAUB; split; apply: sub_finite_set finAUB.
by case=> /fP[X->]/fP[Y->]; apply/fP; exists (X `|` Y)%fset; rewrite set_fsetU.
Qed.
Lemma
Source code
cofinite_set (A `&` B) = (cofinite_set A /\ cofinite_set B).
Proof.
Lemma
Source code
Proof.
Lemma
Source code
Proof.
Lemma
Source code
Proof.
Lemma
Source code
Proof.
Lemma
Source code
Proof.
Lemma
Source code
Proof.
Lemma
Source code
(finite_set A \/ finite_set B) -> finite_set (A `&` B).
Proof.
Lemma
Source code
Proof.
Lemma
Source code
Proof.
Lemma
Source code
finite_set A -> finite_set B -> finite_set (A `*` B).
Proof.
move=> /finite_fsetP[{}A ->] /finite_fsetP[{}B ->].
apply/finite_fsetP; exists (A `*` B)%fset; apply/predeqP => x.
by split; rewrite /= inE => /andP.
Qed.
Lemma
Source code
( : aT -> bT -> rT) :
finite_set A -> finite_set B -> finite_set [set f x y | in A & in B].
Proof.
Lemma
Source code
( : aT -> bT -> rT) ( : xT -> aT) ( : xT -> bT) :
finite_set (fa @` X) -> finite_set (fb @` X) ->
finite_set [set g (fa x) (fb x) | in X].
Proof.
by move=> r/= [x Xx <-]; exists (fa x, fb x) => //; split; exists x.
Qed.
Definition
countable : forall [T : Type], set T -> bool countable is not universe polymorphic Arguments countable [T]%_type_scope A%_classical_set_scope countable is transparent Expands to: Constant mathcomp.classical.cardinality.countable Declared in library mathcomp.classical.cardinality, line 459, characters 11-20
Source code
if pselect (finite_set A) is left Afin
then projT1 (cid (finite_fsetP.1 Afin)) else fset0.
Lemma
Source code
[set` fset_set A] = A.
Lemma
Source code
fset_set A =i A.
Lemma
Source code
finite_set A -> finite_set B -> A `<=` B = (fset_set A `<=` fset_set B)%fset.
Proof.
by apply/fsubsetP => t; rewrite in_fset_set// in_fset_set// 2!inE => /AB.
by have := AB t; rewrite !in_fset_set// !inE.
Qed.
Lemma
Source code
fset_set A = fset0 -> A = set0.
Proof.
Lemma
Source code
Proof.
Lemma
Source code
Lemma
Source code
finite_set A -> finite_set B ->
fset_set (A `|` B) = (fset_set A `|` fset_set B)%fset.
Proof.
rewrite ?(inE, in_fset_set)//; first by rewrite finite_setU.
by apply/idP/orP; rewrite ?inE.
Qed.
Lemma
Source code
finite_set A -> finite_set B ->
fset_set (A `&` B) = (fset_set A `&` fset_set B)%fset.
Proof.
rewrite ?(inE, in_fset_set)//; first by apply: finite_setI; left.
by apply/idP/andP; rewrite ?inE.
Qed.
Lemma
Source code
finite_set A -> fset_set (x |` A) = (x |` fset_set A)%fset.
Lemma
Source code
finite_set A -> finite_set B ->
fset_set (A `\` B) = (fset_set A `\` fset_set B)%fset.
Proof.
rewrite ?(inE, in_fset_set)//; first exact: finite_setD.
by apply/idP/andP; rewrite ?inE => -[]; rewrite ?notin_setE.
Qed.
Lemma
Source code
finite_set A -> fset_set (A `\ x) = (fset_set A `\ x)%fset.
Lemma
Source code
finite_set A -> finite_set B ->
fset_set (A `*` B) = (fset_set A `*` fset_set B)%fset.
Proof.
apply/fsetP => i; apply/idP/idP; rewrite !(inE, in_fset_set)//=.
by move=> [/mem_set-> /mem_set->].
by move=> /andP[]; rewrite !inE.
Qed.
Definition
fset_set : forall [T : choiceType], set T -> {fset T} fset_set is not universe polymorphic Arguments fset_set [T] A%_classical_set_scope fset_set is transparent Expands to: Constant mathcomp.classical.cardinality.fset_set Declared in library mathcomp.classical.cardinality, line 761, characters 11-19
Source code
[fset x.1 | in A]%fset.
Definition
fst_fset : forall [T1 T2 : choiceType], {fset T1 * T2} -> {fset T1} fst_fset is not universe polymorphic Arguments fst_fset [T1 T2] A fst_fset is transparent Expands to: Constant mathcomp.classical.cardinality.fst_fset Declared in library mathcomp.classical.cardinality, line 846, characters 11-19
Source code
[fset x.2 | in A]%fset.
Notation
Source code
Notation
Source code
Lemma
Source code
finite_set A -> finite_set A.`1.
Proof.
by apply/seteqP; split=> [x/= [y]|_/= /imfsetP[[x1 x2]/= +] ->]; rewrite A_B;
[move=> xyB; apply/imfsetP; exists (x, y)|move=> ?; exists x2].
Qed.
Lemma
Source code
finite_set A -> finite_set A.`2.
Proof.
apply/seteqP; split=> [y/= [x]|_/= /imfsetP[[x1 x2]/= +] ->]; rewrite A_B;
by [move=> xyB; apply/imfsetP; exists (x, y)|move=> ?; exists x1].
Qed.
Lemma
Source code
finite_set D -> (forall , D i -> finite_set (F i)) ->
finite_set (\bigcup_( in D) F i).
Proof.
elim/Ppointed: T => T in F *; first by rewrite emptyE.
move=> Dfin Ffin; pose G ( : fset_set D) := fset_set (F (val i)).
suff: (\bigcup_( in D) F i #<= [set: { & G i}])%card.
by move=> /card_le_finite; apply; apply: finite_finset.
apply/pcard_geP/surjPex.
exists (fun ( : { : fset_set D & G i}) => val (projT2 k)).
move=> y [i Di Fky]/=.
have Dk : i \in fset_set D by rewrite in_fset_set// inE.
pose k : fset_set D := [` Dk]%fset.
have Gy : y \in G k by rewrite in_fset_set ?inE//; apply: Ffin.
by exists (Tagged G [` Gy]%fset).
Qed.
Lemma
Source code
cofinite_set A -> infinite_set A.
Proof.
Lemma
Source code
(forall , finite_set (F n)) -> trivIset [set: nat] F ->
(\sum_( < n) #|` fset_set (F i)| =
#|` fset_set (\big[setU/set0]_( < n) F k)|)%N.
Proof.
rewrite big_ord_recr//= ih big_ord_recr/= fset_setU//.
by rewrite -bigcup_mkord; exact: bigcup_finite.
rewrite cardfsU [X in (_ - X)%N](_ : _ = O) ?subn0// ?EFinD ?natrD//.
apply/eqP; rewrite cardfs_eq0 -fset_setI//.
by rewrite -bigcup_mkord; exact: bigcup_finite.
rewrite (@trivIset_bigsetUI _ xpredT)// ?fset_set0//.
by rewrite [X in trivIset X F](_ : _ = [set: nat])//; exact/seteqP.
Qed.
Lemma
Source code
finite_set A -> (forall , A x -> finite_set (B x)) -> finite_set (A `*`` B).
Proof.
by apply: bigcup_finite => // i Ai; exact/finite_setX/Bfin.
Qed.
Lemma
Source code
(forall , B x -> finite_set (A x)) -> finite_set B -> finite_set (A ``*` B).
Proof.
by apply: bigcup_finite => // i Ai; apply/finite_setX => //; exact: Afin.
Qed.
Lemma
Source code
Proof.
Lemma
Source code
Proof.
Lemma
Source code
finite_set A -> fset_set (f @` A) = (f @` fset_set A)%fset.
Proof.
rewrite !in_fset_set; first exact: finite_image.
apply/idP/imfsetP; rewrite !inE/=.
by move=> [x Ax <-]; exists x; rewrite ?in_fset_set ?inE.
by move=> [x + ->]; rewrite in_fset_set// inE; exists x.
Qed.
Lemma
Source code
finite_set A -> finite_set B -> fset_set A = fset_set B -> A = B.
Lemma
Source code
finite_set A -> \big[setU/set0]_( <- fset_set A) F i =\bigcup_( in A) F i.
Proof.
Lemma
Source code
finite_set A -> \bigcup_( in A) F i = \big[setU/set0]_( <- fset_set A) F i.
Proof.
Notation
Source code
Lemma
Source code
( : pred I) : finite_set A ->
\big[setU/set0]_( <- fset_set A | P i) F i = \bigcup_( in A `&` P) F i.
Proof.
Lemma
Source code
( : pred I) : finite_set A ->
\bigcup_( in A `&` P) F i = \big[setU/set0]_( <- fset_set A | P i) F i.
Proof.
Notation
Source code
Lemma
Source code
finite_set A -> \big[setI/setT]_( <- fset_set A) F i =\bigcap_( in A) F i.
Proof.
Lemma
Source code
finite_set A -> \bigcap_( in A) F i = \big[setI/setT]_( <- fset_set A) F i.
Proof.
Notation
Source code
Lemma
Source code
( : pred I) : finite_set A ->
\big[setI/setT]_( <- fset_set A | P i) F i = \bigcap_( in A `&` P) F i.
Proof.
Lemma
Source code
X `<=` A -> Y `<=` B -> A `\` X #= B `\` Y ->
exists : {bij A >-> B}, {in X, g =1 f}.
Proof.
rewrite !emptyE in f * => XA _; rewrite setD_eq0 => AX.
by suff /seteqP->// : A `<=>` X by exists f.
move=> XA YB /pcard_eqP[g].
rewrite -(joinIB X A) -(joinIB Y B) !meetEset.
have /disj_set2P AX : (A `&` X) `&` (A `\` X) = set0 by apply: meetIB.
have /disj_set2P BY : (B `&` Y) `&` (B `\` Y) = set0 by apply: meetIB.
rewrite !(setIidr XA) !(setIidr YB) in AX BY *.
by exists [bij of glue AX BY f g] => x /= xX; rewrite glue1.
Qed.
Lemma
Source code
reflect (#|` A| = n) ([set` A] #= `I_n).
Proof.
rewrite -{1}[A]set_fsetK !emptyE fset_set0 cardfs0.
by apply: (iffP eqP) => [/IIn_eq0->//|<-]; rewrite II0.
rewrite (card_eqr card_II) card_eq_sym.
apply: (iffP pcard_eqP) => [[f]|]; last first.
rewrite cardfE => eqAn.
by squash (set_val \o finset_val \o enum_val \o cast_ord (esym eqAn)).
suff -> : A = [fset f i | in 'I_n]%fset by rewrite card_imfset ?size_enum_ord.
apply/fsetP => x; apply/idP/imfsetP => /= [xA|[i _ ->]].
by have [i _ <-] := 'surj_f xA; exists i.
by have /(_ i I) := 'funS_f.
Qed.
Lemma
Source code
A #= `I_n -> #|`fset_set A| = n.
Proof.
Lemma
Source code
A #<= `I_n -> (#|`fset_set A| <= n)%N.
Proof.
by apply/finite_set_leP; exists n.
by rewrite (card_fset_set Am) -card_le_II -(card_le_eql Am).
Qed.
Lemma
Source code
finite_set A -> A #>= `I_n -> (#|`fset_set A| >= n)%N.
Proof.
Lemma
Source code
infinite_set A -> finite_set B -> infinite_set (A `\` B).
Proof.
have : finite_set ((A `&` ~` B) `|` B) by rewrite finite_setU.
by rewrite setUIl setUCl setIT finite_setU => -[].
Qed.
Lemma
Source code
infinite_set A -> cofinite_set B -> infinite_set (A `&` B).
Proof.
Lemma
Source code
cofinite_set A -> infinite_set B -> infinite_set (A `&` B).
Proof.
Lemma
Source code
infinite_set A ->
exists2 : {fset T}, [set` B] `<=` A & (#|` B| >= n)%N.
Proof.
move=> /infiniteP/ppcard_leP[f]; exists (fset_set [set f i | in `I_n]).
rewrite fset_setK//; first exact: finite_image.
by apply: subset_trans (fun_image_sub f); apply: image_subset.
rewrite fset_set_image// card_imfset//= fset_set_II/=.
by rewrite card_imfset//= ?size_enum_ord//; apply: val_inj.
Qed.
Lemma
Source code
infinite_set A <->
forall , exists2 : {fset T}, [set` B] `<=` A & (#|` B| >= n)%N.
Proof.
elim/choicePpointed: T => T in A *.
move=> /(_ 1%N)[B _]; rewrite cardfs_gt0 => /fset0Pn[x xB].
by have: [set` B] x by []; rewrite emptyE.
move=> Bge /finite_setP[n An]; have [B BA] := Bge n.+1.
apply/negP; rewrite -leqNgt -(card_fset_set An) fsubset_leq_card//.
apply/fsubsetP => x /BA; rewrite in_fset_set ?inE//.
by apply/finite_setP; exists n.
Qed.
Lemma
Source code
finite_set A -> finite_set B ->
reflect (#|`fset_set A| = #|`fset_set B|) (A #= B).
Proof.
rewrite (card_fset_set An) (card_fset_set Bm).
by rewrite (card_eql An) (card_eqr Bm); apply: card_eq_II.
Qed.
Lemma
Source code
Proof.
rewrite fset_setD//= cardfsD/= -fset_setI// setI_II.
rewrite !fset_set_II !card_imfset// /= !size_enum_ord.
by case: leqP; rewrite // subnn => /eqP->.
Qed.
Lemma
Source code
A #= `I_n -> S `<=` A ->
exists ( : {bij `I_n >-> A}) , (k <= n)%N /\ `I_n `&` (f @^-1` S) = `I_k.
Proof.
move=> AN0 An SA; have [k kn Sk] : exists2 , (k <= n)%N & S #= `I_k.
have /finite_setP[k Sk]: finite_set S by apply: sub_finite_set SA _; exists n.
exists k => //; rewrite -card_le_II.
by rewrite -(card_le_eqr An) -(card_le_eql Sk); apply: subset_card_le.
have /card_esym/ppcard_eqP[f] := Sk.
have eqAS : A `\` S #= `I_n `\` `I_k.
have An' := An; have Sk' := Sk.
do [have /finite_fsetP[{An'}A ->] : finite_set A by exists n] in An AN0 SA *.
do [have /finite_fsetP[{Sk'}S ->] : finite_set S by exists k] in Sk f SA *.
have [/card_eq_fsetP {}An /card_eq_fsetP {}Sk] := (An, Sk).
rewrite -set_fsetD (card_eqr card_IID); apply/card_eq_fsetP.
by rewrite cardfsD (fsetIidPr _) ?An ?Sk //; apply/fsubsetP.
case: (super_bij [bij of f^-1] SA _ eqAS) => [x /= /leq_trans->// | g].
have [{}g ->] := pPbij 'bij_g => /= gE.
exists [bij of g^-1], k; split=> //=; rewrite -inv_sub_image //= invV.
by under eq_imagel do rewrite /= gE ?inE//; rewrite image_eq.
Qed.
#[deprecated(note="use countable0 instead")]
Notation
Source code
Lemma
Source code
Proof.
Lemma
Source code
Proof.
Lemma
Source code
Proof.
Lemma
Source code
countable A -> ~ finite_set A -> A #= [set: nat].
Proof.
Lemma
Source code
Lemma
Source code
Proof.
Lemma
Source code
Proof.
Lemma
Source code
Proof.
apply: infinite_setN0; apply: cofinite_set_infinite; first exact: infinite_nat.
by rewrite setCK; apply: finite_preimage; first by move=> ? ? ? ?; apply: fI.
Qed.
.
Source code
Source code
Source code
Lemma
Source code
Proof.
Lemma
Source code
Proof.
Lemma
Source code
Proof.
Lemma
Source code
Proof.
Lemma
Source code
{ : countType | T = T' :> Type}.
Proof.
Lemma
Source code
{ : countType | T = T' :> Type}.
Proof.
Lemma
Source code
{ : countType | T = T' :> Type}.
Proof.
Lemma
Source code
countable D -> (forall , D i -> countable (F i)) ->
countable (\bigcup_( in D) F i).
Proof.
rewrite -(eq_countable (card_setT _)) => cD cF; rewrite bigcup_set_type.
set G := (fun : D => F (val i)).
have {cF}cG i : countable (G i) by apply: cF; apply: set_valP.
move: (D : Type) cD G cG => {F I}_ /Pcountable[{}D ->] G cG.
suff: (\bigcup_ G i #<= [set: { & G i}])%card.
have cGT i : countable [set: G i] by rewrite (eq_countable (card_setT _)).
have /all_sig[H GE] := fun => Pcountable (cGT i).
by move=> /sub_countable->//; rewrite (eq_fun GE).
apply/pcard_geP/surjPex; exists (fun ( : { & G i}) => val (projT2 k)).
by move=> x [i _] Gix/=; exists (Tagged G (SigSub (mem_set Gix))).
Qed.
Lemma
Source code
countable A -> (forall , A i -> countable (B i)) -> countable (A `*`` B).
Proof.
elim/Ppointed: T' => T' in B *.
by rewrite -bigcupX1l bigcup0// => i; rewrite emptyE setX0.
move=> Ac Bc; rewrite -bigcupX1l bigcup_countable// => i Ai.
have /ppcard_leP[f] := Bc i Ai; apply/pcard_geP/surjPex.
exists (fun => (i, f^-1%FUN k)) => -[_ j]/= [-> dj].
by exists (f j) => //=; rewrite funK ?inE.
Qed.
Lemma
Source code
countable D1 -> countable D2 -> countable (D1 `*` D2).
Proof.
Lemma
Source code
countable B -> (forall , B i -> countable (A i)) -> countable (A ``*` B).
Proof.
by apply: countableX => //; exact: Ac.
Qed.
Lemma
Source code
infinite_set A -> (forall , B i !=set0) -> infinite_set (A `*`` B).
Proof.
Lemma
Source code
(A #= [set: nat] -> (forall , countable (B i) /\ B i !=set0) ->
A `*`` B #= [set: nat])%card.
Proof.
by rewrite [(_ #<= _)%card]countableXR//=; exact/infiniteP/infiniteXRl.
Qed.
Lemma
Source code
reflect (exists2 , A x & A `\ x #= `I_n) (A #= `I_n.+1).
Proof.
rewrite !emptyE; apply: (iffP eqP) => [|[]//].
by move=> /(congr1 (@^~ 0%N))/=; rewrite -falseE ltnS leq0n => /is_true_inj.
apply: (iffP idP) => [|[x Ax]].
move=> /ppcard_eqP[f]; exists (f^-1 n); first by apply: funS => /=.
by apply/card_esym/card_set_bijP; exists f^-1; apply: bij_II_D1.
move=> /pcard_eqP[f]; have [//|||g _] := @super_bij _ _ _ A _ `I_n.+1 f.
- by move=> k /=; apply: leq_trans.
- by rewrite setDD (card_eqr card_IID) subSnn// setIidr ?card_set1// => ? ->.
- by apply/pcard_eqP; squash g.
Qed.
Lemma
Source code
countable D -> countable [set | A `<=` D /\ A #= `I_n].
Proof.
rewrite [X in countable X]( _ : _ = [set set0])// eqEsubset II0.
by split=> A /=; [rewrite card_eq0; case=> _ /eqP | move->; split].
move=> /(countableX Dcnt); apply: sub_countable.
apply: card_le_trans (card_image_le (fun => u.1 |` u.2) _).
apply: subset_card_le => B [BD] /eq_cardSP [x Bx BDx].
exists (x, B `\ x) => /=; last by apply: setDUK => ? ->.
by do !split=> //; [exact: BD | apply: subset_trans _ BD; apply: subDsetl].
Qed.
Lemma
Source code
countable D -> countable [set | A `<=` D /\ finite_set A ].
Proof.
\bigcup_ [set | A `<=` D /\ A #= `I_n ].
by apply: bigcup_countable => // ? _; exact: countable_n_subset.
rewrite eqEsubset; split=> [A [AD /finite_setP[n An]]|A]; first by exists n.
by move=> [n _ [AD An]]; split=> //; apply/finite_setP; exists n.
Qed.
Lemma
Source code
[set | A `<=` D /\ finite_set A ] #= [set : {fset T} | {subset A <= D}] .
Proof.
- by move=> A [AD fsetA] /= x; rewrite in_fset_set // ?inE; exact: AD.
- by move=> ? ? /set_mem [_ +] /set_mem [_ +]; exact: fset_set_inj.
- move=> B /= BD; exists [set` B]; rewrite ?set_fsetK //.
by split; [by move => x /= /BD /set_mem | exact: finite_fset].
Qed.
Lemma
Source code
countable D -> countable [set : {fset T} | {subset A <= D}].
Proof.
.
Source code
Source code
Source code
fimfunP : finite_set (range f)
}.
.
Source code
Source code
Source code
Arguments fimfunP {aT rT} _.
#[global] Hint Extern 0 (finite_set _) => solve [apply: fimfunP] : core.
Reserved Notation "{ 'fimfun' aT >-> T }"
(at level 0, format "{ 'fimfun' aT >-> T }").
Reserved Notation "[ 'fimfun' 'of' f ]"
(at level 0, format "[ 'fimfun' 'of' f ]").
Notation
Source code
Notation
Source code
Lemma
Source code
finite_set (f @` D).
Proof.
#[global] Hint Resolve fimfun_inP : core.
Lemma
Source code
( : {fimfun T1 >-> T2}) ( : T2 -> T3) :
fset_set [set (g \o f) x | in D] =
[fset g x | in fset_set [set f x | in D]]%fset.
Proof.
Section fimfun_pred.
Context { : Type}.
Definition
snd_fset : forall [T1 T2 : choiceType], {fset T1 * T2} -> {fset T2} snd_fset is not universe polymorphic Arguments snd_fset [T1 T2] A snd_fset is transparent Expands to: Constant mathcomp.classical.cardinality.snd_fset Declared in library mathcomp.classical.cardinality, line 848, characters 11-19
Source code
Definition
fimfun : forall {aT rT : Type}, {pred aT -> rT} fimfun is not universe polymorphic Arguments fimfun {aT rT}%_type_scope _ fimfun is transparent Expands to: Constant mathcomp.classical.cardinality.fimfun Declared in library mathcomp.classical.cardinality, line 1340, characters 11-17
Source code
Proof.
fimfun_key : forall {aT rT : Type}, pred_key (T:=aT -> rT) fimfun fimfun_key is not universe polymorphic Arguments fimfun_key {aT rT}%_type_scope fimfun_key is opaque Expands to: Constant mathcomp.classical.cardinality.fimfun_key Declared in library mathcomp.classical.cardinality, line 1341, characters 11-21
Source code
End fimfun_pred.
Section fimfun.
Context { : Type}.
Notation := {fimfun aT >-> rT}.
Notation
Source code
Section Sub.
Context ( : aT -> rT) ( : f \in fimfun).
Definition
fimfun_keyed : forall {aT rT : Type}, keyed_pred fimfun_key fimfun_keyed is not universe polymorphic Arguments fimfun_keyed {aT rT}%_type_scope fimfun_keyed is transparent Expands to: Constant mathcomp.classical.cardinality.fimfun_keyed Declared in library mathcomp.classical.cardinality, line 1343, characters 10-22
Source code
Source code
Source code
Source code
Source code
Definition
fimfun_Sub_subproof : forall {aT rT : Type} [f : aT -> rT], f \in fimfun -> FiniteImage.axioms_ aT rT f fimfun_Sub_subproof is not universe polymorphic Arguments fimfun_Sub_subproof {aT rT}%_type_scope [f]%_function_scope fP fimfun_Sub_subproof is transparent Expands to: Constant mathcomp.classical.cardinality.fimfun_Sub_subproof Declared in library mathcomp.classical.cardinality, line 1352, characters 11-30
Source code
End Sub.
Lemma
Source code
(forall ( : f \in fimfun), K (fimfun_Sub Pf)) -> forall : T, K u.
Proof.
Lemma
Source code
Proof.
.
Source code
Source code
Source code
End fimfun.
Lemma
Source code
f = g <-> f =1 g.
.
Source code
Source code
Source code
[Equality of {fimfun aT >-> rT} by <:].
.
Source code
Source code
Source code
[Choice of {fimfun aT >-> rT} by <:].
Lemma
Source code
finite_set (range (cst x : aT -> _)).
Proof.
.
Source code
Source code
FiniteImage.Build aT rT (cst x) (@finite_image_cst aT rT x).
Definition
fimfun_Sub : forall {aT rT : Type} [f : aT -> rT], f \in fimfun -> {fimfun aT >-> rT} fimfun_Sub is not universe polymorphic Arguments fimfun_Sub {aT rT}%_type_scope [f]%_function_scope fP fimfun_Sub is transparent Expands to: Constant mathcomp.classical.cardinality.fimfun_Sub Declared in library mathcomp.classical.cardinality, line 1354, characters 11-21
Source code
Lemma
Source code
Proof.
Lemma
Source code
( : {fimfun aT >-> rT}) ( : rT -> sT) : @FiniteImage aT sT (g \o f).
Proof.
Source code
Source code
Source code
Section zmod.
Context ( : Type) ( : zmodType).
Lemma
Source code
Proof.
by move=> fA gA; apply: (finite_image11 (fun => x - y)).
Qed.
Source code
Source code
GRing.isZmodClosed.Build (aT -> rT) fimfun fimfun_zmod_closed.
.
Source code
Source code
[SubChoice_isSubZmodule of {fimfun aT >-> rT} by <:].
Implicit Types (f g : {fimfun aT >-> rT}).
Lemma
Source code
Proof.
Source code
Proof.
Source code
Proof.
Source code
Proof.
Source code
(\sum_( <- r | P i) f i) x = \sum_( <- r | P i) f i x.
Proof.
.
Source code
Source code
Source code
.
Source code
Source code
Source code
.
Source code
Source code
Source code
End zmod.