Skip to content

Commit

Permalink
[B] Change order of Cardinals, Finite, Countable …
Browse files Browse the repository at this point in the history
Moves the definition of `eq_cardinal` to Cardinals, where it belongs.
But to allow this, the statements `countable_img_inj` and
`FiniteT_cardinality` had to be moved to Countable and FiniteTypes
respectively. In addition, `CountableT_cardinality` was removed, because
`CountableT` could be redefined in terms of `le_cardinal`, making the
lemma even more trivial.

Also, removes the file InfiniteTypes, because it has become empty.
  • Loading branch information
Columbus240 committed Oct 8, 2023
1 parent 3f1b769 commit ce98c01
Show file tree
Hide file tree
Showing 8 changed files with 163 additions and 182 deletions.
1 change: 0 additions & 1 deletion _CoqProject
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ theories/ZornsLemma/FunctionPropertiesEns.v
theories/ZornsLemma/Image.v
theories/ZornsLemma/ImageImplicit.v
theories/ZornsLemma/IndexedFamilies.v
theories/ZornsLemma/InfiniteTypes.v
theories/ZornsLemma/InverseImage.v
theories/ZornsLemma/Ordinals.v
theories/ZornsLemma/Powerset_facts.v
Expand Down
3 changes: 1 addition & 2 deletions theories/Topology/CountabilityAxioms.v
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@ From ZornsLemma Require Export
From ZornsLemma Require Import
Classical_Wf
DecidableDec
FiniteIntersections
InfiniteTypes.
FiniteIntersections.
From Coq Require Import
RelationClasses.

Expand Down
48 changes: 14 additions & 34 deletions theories/ZornsLemma/Cardinals.v
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,16 @@ From Coq Require Import Description.
From ZornsLemma Require Export FunctionProperties.
From ZornsLemma Require Import FunctionPropertiesEns.
From ZornsLemma Require Import Relation_Definitions_Implicit.
From ZornsLemma Require Import CSB.
From ZornsLemma Require Import EnsemblesSpec.
From ZornsLemma Require Import ZornsLemma.
From ZornsLemma Require Import EnsemblesImplicit.
From ZornsLemma Require Import CountableTypes.
From ZornsLemma Require Import FiniteTypes.
From ZornsLemma Require Import InfiniteTypes.
From ZornsLemma Require Import CSB.
From Coq Require Import RelationClasses.

Definition le_cardinal (A B : Type) : Prop :=
exists f : A -> B, injective f.
Definition eq_cardinal (X Y : Type) : Prop :=
exists (f : X -> Y) (g : Y -> X), inverse_map f g.

Definition lt_cardinal (kappa lambda:Type) : Prop :=
le_cardinal kappa lambda /\ ~ eq_cardinal kappa lambda.
Expand All @@ -34,6 +33,17 @@ split.
apply injective_compose; auto.
Qed.

Instance eq_cardinal_equiv : Equivalence eq_cardinal.
Proof.
split.
- red; intro. exists id, id. apply id_inverse_map.
- red; intros ? ? [f [g Hfg]].
exists g, f. apply inverse_map_sym. assumption.
- intros ? ? ? [f Hf] [g Hg].
exists (compose g f).
apply invertible_compose; assumption.
Qed.

Instance le_cardinal_PartialOrder :
PartialOrder eq_cardinal le_cardinal.
Proof.
Expand Down Expand Up @@ -86,12 +96,6 @@ Proof.
reflexivity.
Qed.

Definition countable_img_inj {X Y : Type} (f : X -> Y) (U : Ensemble X) :
injective_ens f U ->
CountableT X ->
Countable (Im U f) :=
@le_cardinal_img_inj_ens X Y nat f U.

Lemma cantor_diag: forall (X:Type) (f:X->(X->bool)),
~ surjective f.
Proof.
Expand Down Expand Up @@ -535,30 +539,6 @@ destruct (types_comparable T0 T1) as [[f]|[f]];
exists f; assumption.
Qed.

Lemma CountableT_cardinality {X : Type} :
CountableT X <-> le_cardinal X nat.
Proof.
reflexivity.
Qed.

Lemma FiniteT_cardinality {X : Type} :
FiniteT X <-> lt_cardinal X nat.
Proof.
split; intros.
- split.
+ destruct (FiniteT_nat_embeds H) as [f].
exists f. assumption.
+ intros H0.
apply nat_infinite.
apply bij_finite with X; assumption.
- destruct H as [[f Hf] H].
apply NNPP. intro.
destruct (infinite_nat_inj _ H0) as [g].
contradict H.
apply CSB_inverse_map with (f := f) (g := g);
auto.
Qed.

Lemma cardinal_no_inj_equiv_lt_cardinal (A B : Type) :
(forall f : A -> B, ~ injective f) <->
lt_cardinal B A.
Expand Down
18 changes: 8 additions & 10 deletions theories/ZornsLemma/CardinalsEns.v
Original file line number Diff line number Diff line change
Expand Up @@ -776,7 +776,7 @@ Proof.
{ exact (H 0 ltac:(constructor)). }
destruct H as [f [Hf0 Hf1]].
red in Hf0.
apply InfiniteTypes.nat_infinite.
apply nat_infinite.
apply Finite_ens_type in HU.
pose (f0 := fun n : nat => exist U (f n) (Hf0 n ltac:(constructor))).
assert (invertible f0).
Expand All @@ -792,9 +792,9 @@ Proof.
apply subset_eq. reflexivity.
}
destruct H as [g Hg0].
eapply bij_finite with _.
2: exists g, f0; split; apply Hg0.
assumption.
apply bij_finite with (sig U).
{ assumption. }
exists g, f0. apply inverse_map_sym, Hg0.
- (* <- *)
intros [[[H0 H1]|[f [Hf0 Hf1]]] H2].
{ specialize (H0 0). contradiction. }
Expand All @@ -818,14 +818,12 @@ Proof.
}
destruct H as [n Hn].
(* [n] is an upper bound of the image of [U] under [f] *)
assert (Finite (Im U f)).
{ apply nat_Finite_bounded_char.
exists n. intros m Hm.
destruct Hm as [x Hx m Hm]; subst.
apply Hn; auto.
}
apply Finite_injective_image with f;
auto.
apply nat_Finite_bounded_char.
exists n. intros m Hm.
destruct Hm as [x Hx m Hm]; subst.
apply Hn; auto.
Qed.

Lemma Countable_as_le_cardinal_ens {X : Type} (U : Ensemble X) :
Expand Down
12 changes: 9 additions & 3 deletions theories/ZornsLemma/CountableTypes.v
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ From Coq Require Import
QArith
ZArith.
From ZornsLemma Require Import
Cardinals
CSB
DecidableDec
DependentTypeChoice
Finite_sets
FunctionPropertiesEns
InfiniteTypes.
FunctionPropertiesEns.
From ZornsLemma Require Export
FiniteTypes
IndexedFamilies.
Expand All @@ -29,7 +29,7 @@ Local Close Scope Q_scope.
Set Asymmetric Patterns.

Definition CountableT (X : Type) : Prop :=
exists f : X -> nat, injective f.
le_cardinal X nat.

Lemma CountableT_is_FiniteT_or_countably_infinite (X : Type) :
CountableT X -> {FiniteT X} + {exists f : X -> nat, bijective f}.
Expand Down Expand Up @@ -390,3 +390,9 @@ all: inversion Hx; subst; clear Hx;
destruct (proof_irrelevance _ Hx0 Hx1);
reflexivity.
Qed.

Definition countable_img_inj {X Y : Type} (f : X -> Y) (U : Ensemble X) :
injective_ens f U ->
CountableT X ->
Countable (Im U f) :=
@le_cardinal_img_inj_ens X Y nat f U.
140 changes: 122 additions & 18 deletions theories/ZornsLemma/FiniteTypes.v
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
From Coq Require Import
Arith
ClassicalChoice
Description
FunctionalExtensionality
Lia.
From ZornsLemma Require Import
Cardinals
CSB
DecidableDec
FiniteImplicit
Finite_sets
Expand All @@ -19,20 +22,6 @@ From Coq Require Import

Set Asymmetric Patterns.

Definition eq_cardinal (X Y : Type) : Prop :=
exists (f : X -> Y) (g : Y -> X), inverse_map f g.

Instance eq_cardinal_equiv : Equivalence eq_cardinal.
Proof.
split.
- red; intro. exists id, id. apply id_inverse_map.
- red; intros ? ? [f [g Hfg]].
exists g, f. apply inverse_map_sym. assumption.
- intros ? ? ? [f Hf] [g Hg].
exists (compose g f).
apply invertible_compose; assumption.
Qed.

Inductive FiniteT : Type -> Prop :=
| empty_finite: FiniteT False
| add_finite: forall T:Type, FiniteT T -> FiniteT (option T)
Expand Down Expand Up @@ -1230,6 +1219,122 @@ apply Extensionality_Ensembles; split; intros m Hm;
cbv in *; lia.
Qed.

Lemma infinite_nat_inj: forall X:Type, ~ FiniteT X ->
exists f:nat->X, injective f.
Proof.
intros.
assert (inhabited (forall S:Ensemble X, Finite S ->
{ x:X | ~ In S x})).
{ pose proof (choice (fun (x:{S:Ensemble X | Finite S}) (y:X) =>
~ In (proj1_sig x) y)).
simpl in H0.
match type of H0 with | ?A -> ?B => assert B end.
{ apply H0.
intros.
apply NNPP.
red; intro.
pose proof (not_ex_not_all _ _ H1); clear H1.
destruct x.
assert (x = Full_set).
{ apply Extensionality_Ensembles; red; split; auto with sets. }
subst.
contradict H.
apply Finite_full_impl_FiniteT.
assumption.
}
clear H0.
destruct H1.
exists.
intros.
exists (x (exist _ S H1)).
exact (H0 (exist _ S H1)).
}
destruct H0.

assert (forall (n:nat) (g:forall m:nat, m<n -> X),
{ x:X | forall (m:nat) (Hlt:m<n), g m Hlt <> x }).
{ intros.
assert (Finite (fun x:X => exists m:nat, exists Hlt:m<n,
g m Hlt = x)).
{ pose (h := fun x:{m:nat | m<n} =>
g (proj1_sig x) (proj2_sig x)).

match goal with |- @Finite X ?S => assert (S =
Im Full_set h) end.
- apply Extensionality_Ensembles; red; split; red; intros; destruct H0.
+ destruct H0.
now exists (exist (fun m:nat => m < n) x0 x1).
+ destruct x.
now exists x, l.
- rewrite H0; apply FiniteT_img.
+ apply finite_nat_initial_segment.
+ intros.
apply classic.
}
destruct (X0 _ H0).
unfold In in n0.
exists x.
intros; red; intro.
contradiction n0; exists m; exists Hlt; exact H1.
}
pose (f := Fix Wf_nat.lt_wf (fun n:nat => X)
(fun (n:nat) (g:forall m:nat, m<n->X) => proj1_sig (X1 n g))).
simpl in f.
assert (forall n m:nat, m<n -> f m <> f n).
{ pose proof (Fix_eq Wf_nat.lt_wf (fun n:nat => X)
(fun (n:nat) (g:forall m:nat, m<n->X) => proj1_sig (X1 n g))).
fold f in H0.
simpl in H0.
match type of H0 with | ?A -> ?B => assert (B) end.
- apply H0.
intros.
replace f0 with g.
{ reflexivity. }
extensionality y; extensionality p; symmetry; apply H1.
- intros.
specialize (H1 n).
destruct X1 in H1.
simpl in H1.
destruct H1.
auto.
}
exists f.
red; intros m n ?.
destruct (Compare_dec.lt_eq_lt_dec m n) as [[Hlt|Heq]|Hlt]; trivial.
- contradiction (H0 n m).
- now contradiction (H0 m n).
Qed.

Lemma nat_infinite: ~ FiniteT nat.
Proof.
red; intro.
assert (surjective S).
{ apply finite_inj_surj; trivial.
red; intros.
injection H0; trivial.
}
destruct (H0 0).
discriminate H1.
Qed.

Lemma FiniteT_cardinality {X : Type} :
FiniteT X <-> lt_cardinal X nat.
Proof.
split; intros.
- split.
+ destruct (FiniteT_nat_embeds H) as [f].
exists f. assumption.
+ intros H0.
apply nat_infinite.
apply bij_finite with X; assumption.
- destruct H as [[f Hf] H].
apply NNPP. intro.
destruct (infinite_nat_inj _ H0) as [g].
contradict H.
apply CSB_inverse_map with (f := f) (g := g);
auto.
Qed.

Lemma finite_indexed_union {A T : Type} {F : IndexedFamily A T} :
FiniteT A ->
(forall a, Finite (F a)) ->
Expand Down Expand Up @@ -1266,8 +1371,7 @@ induction H;
+ extensionality_ensembles.
* econstructor.
eassumption.
* destruct Hf as [g [Hgf Hfg]].
rewrite <- (Hfg a) in H0.
econstructor.
eassumption.
* destruct Hf as [g Hfg].
exists (g a). rewrite (proj2 Hfg).
assumption.
Qed.
15 changes: 9 additions & 6 deletions theories/ZornsLemma/IndexedFamilies.v
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
From ZornsLemma Require Export Families.
From ZornsLemma Require Import
EnsemblesImplicit
FunctionProperties.
FunctionProperties
ImageImplicit.

Set Implicit Arguments.

Expand Down Expand Up @@ -124,11 +125,13 @@ Lemma IndexedIntersection_surj_fn
surjective f ->
IndexedIntersection V = IndexedIntersection (fun x => V (f x)).
Proof.
intros.
apply Extensionality_Ensembles; split; red; intros.
- destruct H0. constructor. intros. apply H0.
- destruct H0. constructor. intros. destruct (H a).
subst. apply H0.
intros Hf.
apply Extensionality_Ensembles; split.
- intros x Hx. destruct Hx as [x Hx].
constructor. intros b. apply Hx.
- intros x Hx. destruct Hx as [x Hx].
constructor. intros a.
specialize (Hf a) as [b Hb]. subst. apply Hx.
Qed.

Lemma image_indexed_union (X Y I : Type) (F : IndexedFamily I X) (f : X -> Y) :
Expand Down
Loading

0 comments on commit ce98c01

Please sign in to comment.