Skip to content

Commit 81f92b3

Browse files
Bolzano weierstrass (#1787)
* bolzano-weierstrass --------- Co-authored-by: Cyril Cohen <cohen@crans.org>
1 parent 848a02e commit 81f92b3

File tree

5 files changed

+140
-1
lines changed

5 files changed

+140
-1
lines changed

CHANGELOG_UNRELEASED.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,23 @@
104104
- in `lebesgue_integrable.v`:
105105
+ lemma `integrable_set0`
106106

107+
- in `classical_sets.v`:
108+
+ lemmas `setUDl`, `setUDr`
109+
110+
- in `cardinality.v`:
111+
+ notation `cofinite_set`
112+
+ lemmas `cofinite_setT`, `infinite_setN0`, `sub_cofinite_set`,
113+
`sub_infinite_set`, `cofinite_setUl`, `cofinite_setUr`, `cofinite_setU`,
114+
`cofinite_setI`, `cofinite_set_infinite`, `infinite_setIl`,
115+
`infinite_setIr`
116+
+ lemma `injective_gtn`
117+
118+
- in `sequences.v`:
119+
+ lemma `finite_range_cst_subsequence`
120+
+ lemmas `infinite_increasing_seq`, `infinite_increasing_seq_wf`
121+
+ lemma `finite_range_cvg_subsequence`
122+
+ theorem `bolzano_weierstrass`
123+
107124
- in `lebesgue_integrable.v`:
108125
+ lemma `integrable_norm`
109126
- in `order_topology.v`:

classical/cardinality.v

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ From mathcomp Require Import mathcomp_extra boolp classical_sets functions.
2626
(* <-> exists X : {fset T}, A = [set` X] *)
2727
(* <-> ~ ([set: nat] #<= A) *)
2828
(* infinite_set A := ~ finite_set A *)
29+
(* cofinite_set A := finite_set (~` A) *)
2930
(* countable A <-> A is countable *)
3031
(* := A #<= [set: nat] *)
3132
(* fset_set A == the finite set corresponding if A : set T is finite, *)
@@ -68,6 +69,7 @@ Notation "A '#!=' B" := (~~ (card_eq A B)) : card_scope.
6869

6970
Definition finite_set {T} (A : set T) := exists n, A #= `I_n.
7071
Notation infinite_set A := (~ finite_set A).
72+
Notation cofinite_set A := (finite_set (~` A)).
7173

7274
Lemma injPex {T U} {A : set T} :
7375
$|{inj A >-> U}| <-> exists f : T -> U, set_inj A f.
@@ -412,6 +414,7 @@ apply/idP/idP=> [/card_leP[f]|?];
412414
by have /leq_card := in2TT 'inj_(IIord \o f \o IIord^-1); rewrite !card_ord.
413415
Qed.
414416

417+
415418
Lemma ocard_eqP {T U} {A : set T} {B : set U} :
416419
reflect $|{bij A >-> some @` B}| (A #= B).
417420
Proof.
@@ -515,6 +518,13 @@ Lemma finite_set0 T : finite_set (set0 : set T).
515518
Proof. by apply/finite_setP; exists 0%N; rewrite II0. Qed.
516519
#[global] Hint Resolve finite_set0 : core.
517520

521+
Lemma cofinite_setT T : cofinite_set [set: T].
522+
Proof. by rewrite setCT. Qed.
523+
#[global] Hint Resolve cofinite_setT : core.
524+
525+
Lemma infinite_setN0 {T} (A : set T) : infinite_set A -> A !=set0.
526+
Proof. by rewrite -set0P; apply: contra_not_neq => ->. Qed.
527+
518528
Lemma finite_seqP {T : eqType} A :
519529
finite_set A <-> exists s : seq T, A = [set` s].
520530
Proof.
@@ -602,6 +612,14 @@ Lemma sub_finite_set T (A B : set T) : A `<=` B ->
602612
finite_set B -> finite_set A.
603613
Proof. by move=> ?; apply/card_le_finite/subset_card_le. Qed.
604614

615+
Lemma sub_cofinite_set T (A B : set T) : A `<=` B ->
616+
cofinite_set A -> cofinite_set B.
617+
Proof. by move=> /subsetC/sub_finite_set. Qed.
618+
619+
Lemma sub_infinite_set T (A B : set T) : A `<=` B ->
620+
infinite_set A -> infinite_set B.
621+
Proof. by move=> AB; apply/contra_not/sub_finite_set. Qed.
622+
605623
Lemma finite_set_leP T (A : set T) : finite_set A <-> exists n, A #<= `I_n.
606624
Proof.
607625
split=> [[n /card_eqPle[]]|[n leAn]]; first by exists n.
@@ -657,6 +675,16 @@ Qed.
657675
Lemma finite_setD T (A B : set T) : finite_set A -> finite_set (A `\` B).
658676
Proof. exact/card_le_finite/card_le_setD. Qed.
659677

678+
Lemma cofinite_setUl T (A B : set T) : cofinite_set A -> cofinite_set (A `|` B).
679+
Proof. by rewrite setCU -setDE; apply: finite_setD. Qed.
680+
681+
Lemma cofinite_setUr T (A B : set T) : cofinite_set B -> cofinite_set (A `|` B).
682+
Proof. by rewrite setUC; apply: cofinite_setUl. Qed.
683+
684+
Lemma cofinite_setU T (A B : set T) :
685+
cofinite_set A \/ cofinite_set B -> cofinite_set (A `|` B).
686+
Proof. by move=> [/cofinite_setUl|/cofinite_setUr]. Qed.
687+
660688
Lemma finite_setU T (A B : set T) :
661689
finite_set (A `|` B) = (finite_set A /\ finite_set B).
662690
Proof.
@@ -665,6 +693,10 @@ pose fP := @finite_fsetP {classic T}; rewrite propeqE; split.
665693
by case=> /fP[X->]/fP[Y->]; apply/fP; exists (X `|` Y)%fset; rewrite set_fsetU.
666694
Qed.
667695

696+
Lemma cofinite_setI T (A B : set T) :
697+
cofinite_set (A `&` B) = (cofinite_set A /\ cofinite_set B).
698+
Proof. by rewrite setCI finite_setU. Qed.
699+
668700
Lemma finite_set2 T (x y : T) : finite_set [set x; y].
669701
Proof. by rewrite !finite_setU; split; apply: finite_set1. Qed.
670702
#[global] Hint Resolve finite_set2 : core.
@@ -855,6 +887,10 @@ have Gy : y \in G k by rewrite in_fset_set ?inE//; apply: Ffin.
855887
by exists (Tagged G [` Gy]%fset).
856888
Qed.
857889

890+
Lemma cofinite_set_infinite {T} (A : set T) : infinite_set [set: T] ->
891+
cofinite_set A -> infinite_set A.
892+
Proof. by move=> + ACfin Afin; apply; rewrite -(setvU A) finite_setU. Qed.
893+
858894
Lemma trivIset_sum_card (T : choiceType) (F : nat -> set T) n :
859895
(forall n, finite_set (F n)) -> trivIset [set: nat] F ->
860896
(\sum_(i < n) #|` fset_set (F i)| =
@@ -1025,6 +1061,14 @@ have : finite_set ((A `&` ~` B) `|` B) by rewrite finite_setU.
10251061
by rewrite setUIl setUCl setIT finite_setU => -[].
10261062
Qed.
10271063

1064+
Lemma infinite_setIl {T} (A B : set T) :
1065+
infinite_set A -> cofinite_set B -> infinite_set (A `&` B).
1066+
Proof. by move=> /infinite_setD/[apply]; rewrite setDE setCK. Qed.
1067+
1068+
Lemma infinite_setIr {T} (A B : set T) :
1069+
cofinite_set A -> infinite_set B -> infinite_set (A `&` B).
1070+
Proof. by rewrite setIC => *; apply: infinite_setIl. Qed.
1071+
10281072
Lemma infinite_set_fset {T : choiceType} (A : set T) n :
10291073
infinite_set A ->
10301074
exists2 B : {fset T}, [set` B] `<=` A & (#|` B| >= n)%N.
@@ -1119,6 +1163,13 @@ Proof. by rewrite -setXTT; apply: infinite_setX; exact: infinite_nat. Qed.
11191163
Lemma card_nat2 : [set: nat * nat] #= [set: nat].
11201164
Proof. exact/eq_card_nat/infinite_prod_nat/countableP. Qed.
11211165

1166+
Lemma injective_gtn (f : nat -> nat) : injective f -> forall (n : nat), exists m, (n < f m)%N.
1167+
Proof.
1168+
move=> fI n; suff [m /negP] : ~` (f @^-1` `I_n.+1) !=set0 by rewrite -ltnNge; exists m.
1169+
apply: infinite_setN0; apply: cofinite_set_infinite; first exact: infinite_nat.
1170+
by rewrite setCK; apply: finite_preimage; first by move=> ? ? ? ?; apply: fI.
1171+
Qed.
1172+
11221173
HB.instance Definition _ := isPointed.Build rat 0.
11231174

11241175
Lemma infinite_rat : infinite_set [set: rat].

classical/classical_sets.v

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -710,6 +710,15 @@ Qed.
710710

711711
Lemma setDE A B : A `\` B = A `&` ~` B. Proof. by []. Qed.
712712

713+
Lemma setUDl A B C : (A `\` B) `|` C = (A `|` C) `\` (B `\` C).
714+
Proof.
715+
apply/seteqP; split => x /=; first tauto.
716+
by move=> [[a|c]]; rewrite not_andE notE; tauto.
717+
Qed.
718+
719+
Lemma setUDr A B C : A `|` (B `\` C) = (A `|` B) `\` (C `\` A).
720+
Proof. by rewrite setUC setUDl setUC. Qed.
721+
713722
Lemma setDUK A B : A `<=` B -> A `|` (B `\` A) = B.
714723
Proof.
715724
move=> AB; apply/seteqP; split=> [x [/AB//|[//]]|x Bx].

classical/functions.v

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
(* mathcomp analysis (c) 2017 Inria and AIST. License: CeCILL-C. *)
1+
(* mathcomp analysis (c) 2025 Inria and AIST. License: CeCILL-C. *)
22
From mathcomp Require Import all_ssreflect finmap ssralg ssrnum ssrint rat.
33
From HB Require Import structures.
44
From mathcomp Require Import mathcomp_extra unstable boolp classical_sets.

theories/sequences.v

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2972,6 +2972,68 @@ Qed.
29722972

29732973
End adjacent_cut.
29742974

2975+
Section finite_range_sequence_constant.
2976+
2977+
Lemma finite_range_cst_subsequence {T} (u_ : T^nat) : finite_set (range u_) ->
2978+
exists x, exists2 A, infinite_set A & (forall k, A k <-> u_ k = x).
2979+
Proof.
2980+
move=> range_u_finite; pose A x := u_ @^-1` [set x].
2981+
suff [x Aoo] : exists x, infinite_set (A x) by exists x, (A x) => // k.
2982+
apply/existsNP => Afin.
2983+
have: finite_set (\bigcup_(x in range u_) A x) by exact: bigcup_finite.
2984+
rewrite -preimage_bigcup bigcup_imset1 image_id preimage_range.
2985+
exact: infinite_nat.
2986+
Qed.
2987+
2988+
Lemma infinite_increasing_seq {d} {T : porderType d} (A : set T) :
2989+
(forall x, infinite_set [set y | A y /\ (x < y)%O]) ->
2990+
forall x0 : T, exists f : nat -> T,
2991+
[/\ increasing_seq f, forall n : nat, (x0 < f n)%O & forall n, A (f n)].
2992+
Proof.
2993+
pose R (x y : T) := A y /\ (x < y)%O => Roo x0.
2994+
have [x|f [f0 /all_and2[fA fS]]] := @dependent_choice T R _ x0.
2995+
by have /infinite_setN0/cid := Roo x.
2996+
exists (f \o S); split => //=; first by apply/increasing_seqP => n; apply: fS.
2997+
by elim=> /= [|n IHn]; rewrite (le_lt_trans _ (fS _)) ?f0//= ltW.
2998+
Qed.
2999+
3000+
Lemma infinite_increasing_seq_wf {d} {T : orderType d} (A : set T) :
3001+
(forall x : T, finite_set [set y | (y <= x)%O]) -> infinite_set A ->
3002+
forall x0 : T, exists f : nat -> T,
3003+
[/\ increasing_seq f, forall n, (x0 < f n)%O & forall n, A (f n)].
3004+
Proof.
3005+
move=> Dfin Aoo; apply: infinite_increasing_seq => x.
3006+
apply: infinite_setIl => //.
3007+
by apply: sub_finite_set (Dfin x) => y /=; case: leP.
3008+
Qed.
3009+
3010+
Lemma finite_range_cvg_subsequence {T : ptopologicalType} (x_ : T ^nat) :
3011+
finite_set (range x_) ->
3012+
exists2 f : nat -> nat, increasing_seq f & cvgn (x_ \o f).
3013+
Proof.
3014+
move=> /finite_range_cst_subsequence[x [A Aoo Ax_]].
3015+
have /= [|f [fincr _ Af]] := infinite_increasing_seq_wf _ Aoo 0.
3016+
by move=> n; apply: sub_finite_set (finite_II n.+1) => m /=.
3017+
exists f => //=; suff -> : x_ \o f = fun=> x by apply: is_cvg_cst.
3018+
by apply/funext => k /=; rewrite (Ax_ _).1.
3019+
Qed.
3020+
3021+
End finite_range_sequence_constant.
3022+
3023+
Theorem bolzano_weierstrass {R : realType} (u_ : R^nat):
3024+
bounded_fun u_ -> exists2 f : nat -> nat, increasing_seq f & cvgn (u_ \o f).
3025+
Proof.
3026+
move=> bnd_u; set U := range u_.
3027+
have bndU : bounded_set U.
3028+
case: bnd_u => N [Nreal Nu_].
3029+
by exists N; split => // x /Nu_ {}Nu_ /= y [x0 _ <-]; exact: Nu_.
3030+
have [/finite_range_cvg_subsequence//|infU] := pselect (finite_set U).
3031+
have [/= l Ul] := infinite_bounded_limit_point_nonempty infU bndU.
3032+
have x_l := limit_point_cluster_eventually Ul.
3033+
have [+ _] := cluster_eventually_cvg u_ l.
3034+
by move=> /(_ x_l)[f fi fl]; exists f => //; apply/cvg_ex; exists l.
3035+
Qed.
3036+
29753037
Section banach_contraction.
29763038

29773039
Context {R : realType} {X : completeNormedModType R} (U : set X).

0 commit comments

Comments
 (0)